NepomukDaemons
searchfolder.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _NEPOMUK_SEARCH_FOLDER_H_
00020 #define _NEPOMUK_SEARCH_FOLDER_H_
00021
00022 #include <QtCore/QThread>
00023 #include <QtCore/QString>
00024 #include <QtCore/QList>
00025 #include <QtCore/QEventLoop>
00026 #include <QtCore/QQueue>
00027 #include <QtCore/QMutex>
00028
00029 #include "term.h"
00030 #include "result.h"
00031 #include "query.h"
00032
00033 #include <kio/udsentry.h>
00034 #include <kio/slavebase.h>
00035 #include <Nepomuk/Resource>
00036 #include <KUrl>
00037
00038
00039 uint qHash( const QUrl& );
00040
00041 namespace Nepomuk {
00042 namespace Search {
00043 class QueryServiceClient;
00044 }
00045
00046 class SearchFolder;
00047
00048 class SearchEntry
00049 {
00050 public:
00051 SearchEntry( const QUrl& uri,
00052 const KIO::UDSEntry& = KIO::UDSEntry() );
00053
00054 QUrl resource() const { return m_resource; }
00055 KIO::UDSEntry entry() const { return m_entry; }
00056
00057 private:
00058 QUrl m_resource;
00059 KIO::UDSEntry m_entry;
00060
00061 friend class SearchFolder;
00062 };
00063
00064
00065 class SearchFolder : public QThread
00066 {
00067 Q_OBJECT
00068
00069 public:
00070 SearchFolder();
00071 SearchFolder( const QString& name, const Search::Query& query, KIO::SlaveBase* slave );
00072 ~SearchFolder();
00073
00074 Search::Query query() const { return m_query; }
00075 QString name() const { return m_name; }
00076 QList<SearchEntry*> entries() const { return m_entries.values(); }
00077
00078 SearchEntry* findEntry( const QString& name ) const;
00079 SearchEntry* findEntry( const KUrl& url ) const;
00080
00081 void list();
00082 void stat( const QString& name );
00083
00084 private Q_SLOTS:
00085 void slotNewEntries( const QList<Nepomuk::Search::Result>& );
00086 void slotEntriesRemoved( const QList<QUrl>& );
00087 void slotFinishedListing();
00088 void slotStatNextResult();
00089
00090 private:
00091
00092
00093
00094
00095 void run();
00096
00100 SearchEntry* statResult( const Search::Result& result );
00101 void wrap();
00102
00103
00104 QString m_name;
00105 Search::Query m_query;
00106
00107
00108 QQueue<Search::Result> m_results;
00109 QHash<QString, SearchEntry*> m_entries;
00110 QHash<QUrl, QString> m_resourceNameMap;
00111
00112
00113
00114 QHash<QString, int> m_nameCntHash;
00115
00116
00117
00118
00119 bool m_initialListingFinished;
00120
00121
00122 KIO::SlaveBase* m_slave;
00123
00124
00125
00126
00127 QString m_nameToStat;
00128
00129
00130 bool m_statEntry;
00131
00132
00133 bool m_listEntries;
00134
00135
00136 bool m_statingStarted;
00137
00138
00139 QEventLoop m_loop;
00140
00141 Search::QueryServiceClient* m_client;
00142
00143
00144 QMutex m_resultMutex;
00145 };
00146 }
00147
00148 #endif