NepomukDaemons
folder.h
Go to the documentation of this file.00001 /* 00002 Copyright (c) 2008 Sebastian Trueg <trueg@kde.org> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License version 2 as published by the Free Software Foundation. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Library General Public License for more details. 00012 00013 You should have received a copy of the GNU Library General Public License 00014 along with this library; see the file COPYING.LIB. If not, write to 00015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00016 Boston, MA 02110-1301, USA. 00017 */ 00018 00019 #ifndef _NEPOMUK_VIRTUAL_FOLDER_H_ 00020 #define _NEPOMUK_VIRTUAL_FOLDER_H_ 00021 00022 #include <QtCore/QObject> 00023 00024 #include "result.h" 00025 #include "query.h" 00026 #include "searchcore.h" 00027 00028 #include <QtCore/QHash> 00029 #include <QtCore/QTimer> 00030 00031 00032 namespace Nepomuk { 00033 namespace Search { 00034 00035 class Query; 00036 class FolderConnection; 00037 00043 class Folder : public QObject 00044 { 00045 Q_OBJECT 00046 00047 public: 00048 Folder( const Query& query, QObject* parent = 0 ); 00049 ~Folder(); 00050 00056 QList<Result> entries() const; 00057 00062 bool initialListingDone() const; 00063 00064 QList<FolderConnection*> openConnections() const; 00065 00066 public Q_SLOTS: 00067 void update(); 00068 00069 Q_SIGNALS: 00070 void newEntries( const QList<Nepomuk::Search::Result>& entries ); 00071 void entriesRemoved( const QList<QUrl>& entries ); 00072 void finishedListing(); 00073 00074 private Q_SLOTS: 00075 void slotSearchNewResult( const Nepomuk::Search::Result& ); 00076 void slotSearchScoreChanged( const Nepomuk::Search::Result& ); 00077 void slotSearchFinished(); 00078 void slotStorageChanged(); 00079 void slotUpdateTimeout(); 00080 00081 private: 00085 void addConnection( FolderConnection* ); 00086 00090 void removeConnection( FolderConnection* ); 00091 00092 Query m_query; 00093 QList<FolderConnection*> m_connections; 00094 00095 bool m_initialListingDone; 00096 QHash<QUrl, Result> m_results; // the actual current results 00097 QHash<QUrl, Result> m_newResults; // the results gathered during an update, needed to find removed items 00098 00099 SearchCore* m_searchCore; 00100 00101 bool m_storageChanged; // did the nepomuk store change after the last update 00102 QTimer m_updateTimer; // used to ensure that we do not update all the time if the storage changes a lot 00103 00104 friend class FolderConnection; // for addConnection and removeConnection 00105 }; 00106 } 00107 } 00108 00109 #endif