add more spacing
[personal-kdebase.git] / runtime / nepomuk / services / queryservice / folder.h
blobdfd29952c4dc3e6c0fd7a8d33858949c4230e0c9
1 /*
2 Copyright (c) 2008 Sebastian Trueg <trueg@kde.org>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
19 #ifndef _NEPOMUK_VIRTUAL_FOLDER_H_
20 #define _NEPOMUK_VIRTUAL_FOLDER_H_
22 #include <QtCore/QObject>
24 #include "result.h"
25 #include "query.h"
26 #include "searchcore.h"
28 #include <QtCore/QHash>
29 #include <QtCore/QTimer>
32 namespace Nepomuk {
33 namespace Search {
35 class Query;
36 class FolderConnection;
38 /**
39 * One search folder which automatically updates itself.
40 * Once all connections to the folder have been deleted,
41 * the folder deletes itself.
43 class Folder : public QObject
45 Q_OBJECT
47 public:
48 Folder( const Query& query, QObject* parent = 0 );
49 ~Folder();
51 /**
52 * \return A list of all cached results in the folder.
53 * If initial listing is not finished yet, the results found
54 * so far are returned.
56 QList<Result> entries() const;
58 /**
59 * \return true if the initial listing is done, ie. further
60 * signals only mean a change in the folder.
62 bool initialListingDone() const;
64 QList<FolderConnection*> openConnections() const;
66 public Q_SLOTS:
67 void update();
69 Q_SIGNALS:
70 void newEntries( const QList<Nepomuk::Search::Result>& entries );
71 void entriesRemoved( const QList<QUrl>& entries );
72 void finishedListing();
74 private Q_SLOTS:
75 void slotSearchNewResult( const Nepomuk::Search::Result& );
76 void slotSearchScoreChanged( const Nepomuk::Search::Result& );
77 void slotSearchFinished();
78 void slotStorageChanged();
79 void slotUpdateTimeout();
81 private:
82 /**
83 * Called by the FolderConnection constructor.
85 void addConnection( FolderConnection* );
87 /**
88 * Called by the FolderConnection destructor.
90 void removeConnection( FolderConnection* );
92 Query m_query;
93 QList<FolderConnection*> m_connections;
95 bool m_initialListingDone;
96 QHash<QUrl, Result> m_results; // the actual current results
97 QHash<QUrl, Result> m_newResults; // the results gathered during an update, needed to find removed items
99 SearchCore* m_searchCore;
101 bool m_storageChanged; // did the nepomuk store change after the last update
102 QTimer m_updateTimer; // used to ensure that we do not update all the time if the storage changes a lot
104 friend class FolderConnection; // for addConnection and removeConnection
109 #endif