kmail
index.hGo to the documentation of this file.00001 #ifndef LPC_INDEX_H1110724080_INCLUDE_GUARD_
00002 #define LPC_INDEX_H1110724080_INCLUDE_GUARD_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include <qobject.h>
00035 #include <qcstring.h>
00036 #include <qvaluelist.h>
00037 #include <qtimer.h>
00038 #include <config.h>
00039 #ifdef HAVE_INDEXLIB
00040 #include <indexlib/index.h>
00041 #include <indexlib/lockfile.h>
00042 #endif
00043 #include <vector>
00044 #include <set>
00045
00046 class KMFolder;
00047
00048 class KMSearch;
00049 class KMSearchRule;
00050 class KMSearchPattern;
00051
00052 class KMMsgIndex : public QObject {
00053 Q_OBJECT
00054 public:
00055 explicit KMMsgIndex( QObject* parent );
00056 ~KMMsgIndex();
00057
00058 public:
00059
00066 bool startQuery( KMSearch* );
00072 bool stopQuery( KMSearch* );
00073
00077 std::vector<Q_UINT32> simpleSearch( QString, bool* ) const;
00078
00086 bool isIndexable( KMFolder* folder ) const;
00087
00094 bool isIndexed( KMFolder* folder ) const;
00095
00099 bool isEnabled() const { return mState != s_disabled; }
00100 public slots:
00110 void setEnabled( bool );
00111
00118 void setIndexingEnabled( KMFolder*, bool );
00119
00120 private slots:
00127 void clear();
00128 void create();
00129 void maintenance();
00130
00131 void act();
00132 void removeSearch( QObject* );
00133
00134 void continueCreation();
00135
00136 void slotAddMessage( Q_UINT32 message );
00137 void slotRemoveMessage( Q_UINT32 message );
00138 private:
00139 static QString defaultPath();
00140
00141 bool canHandleQuery( const KMSearchPattern* ) const;
00142 int addMessage( Q_UINT32 );
00143 void removeMessage( Q_UINT32 );
00144
00145 void scheduleAction();
00146 bool creating() const;
00147
00148 public:
00156 class Search;
00157 private:
00158
00159 std::vector<Q_UINT32> mPendingMsgs;
00160 std::vector<KMFolder*> mPendingFolders;
00161 std::vector<Q_UINT32> mAddedMsgs;
00162 std::vector<Q_UINT32> mRemovedMsgs;
00163 std::vector<Q_UINT32> mExisting;
00164
00165 enum e_state {
00166 s_idle,
00167 s_willcreate,
00168 s_creating,
00169 s_processing,
00170 s_error,
00171 s_disabled
00172 } mState;
00173
00174 unsigned mMaintenanceCount;
00175
00176 #ifdef HAVE_INDEXLIB
00177
00181 indexlib::detail::lockfile mLockFile;
00182
00183
00184
00185 indexlib::index* mIndex;
00186 #endif
00187 std::set<KMFolder*> mOpenedFolders;
00188 std::vector<Search*> mSearches;
00189 QCString mIndexPath;
00190 QTimer* mTimer;
00191 bool mSlowDown;
00192 };
00193
00194
00195 class KMMsgIndex::Search : public QObject {
00196 Q_OBJECT
00197 public:
00198 explicit Search( KMSearch* s );
00199 ~Search();
00200 KMSearch* search() const { return mSearch; }
00201 signals:
00202 void found( Q_UINT32 );
00203 void finished( bool );
00204 private slots:
00205 void act();
00206 private:
00207 KMSearch* mSearch;
00208 QTimer* mTimer;
00213 KMSearchPattern* mResidual;
00214 std::vector<Q_UINT32> mValues;
00215 enum { s_none = 0, s_starting, s_emitting, s_emitstopped, s_done } mState;
00216 };
00217
00218 #endif
|