Changeset View
Changeset View
Standalone View
Standalone View
src/file/fileindexscheduler.h
Show All 39 Lines | |||||
40 | { | 40 | { | ||
41 | Q_OBJECT | 41 | Q_OBJECT | ||
42 | Q_CLASSINFO("D-Bus Interface", "org.kde.baloo.scheduler") | 42 | Q_CLASSINFO("D-Bus Interface", "org.kde.baloo.scheduler") | ||
43 | 43 | | |||
44 | Q_PROPERTY(int state READ state NOTIFY stateChanged) | 44 | Q_PROPERTY(int state READ state NOTIFY stateChanged) | ||
45 | public: | 45 | public: | ||
46 | FileIndexScheduler(Database* db, FileIndexerConfig* config, QObject* parent = nullptr); | 46 | FileIndexScheduler(Database* db, FileIndexerConfig* config, QObject* parent = nullptr); | ||
47 | ~FileIndexScheduler() override; | 47 | ~FileIndexScheduler() override; | ||
48 | int state() const { return m_indexerState; } | 48 | int state() const { return m_indexerStates.at(0); } | ||
49 | 49 | | |||
50 | Q_SIGNALS: | 50 | Q_SIGNALS: | ||
51 | Q_SCRIPTABLE void stateChanged(int state); | 51 | Q_SCRIPTABLE void stateChanged(int state); | ||
52 | 52 | | |||
53 | public Q_SLOTS: | 53 | public Q_SLOTS: | ||
54 | void indexNewFile(const QString& file) { | 54 | void indexNewFile(const QString& file) { | ||
55 | if (!m_newFiles.contains(file)) { | 55 | if (!m_newFiles.contains(file)) { | ||
56 | m_newFiles << file; | 56 | m_newFiles << file; | ||
Show All 16 Lines | |||||
73 | } | 73 | } | ||
74 | 74 | | |||
75 | void handleFileRemoved(const QString& file); | 75 | void handleFileRemoved(const QString& file); | ||
76 | 76 | | |||
77 | void scheduleIndexing(); | 77 | void scheduleIndexing(); | ||
78 | void scheduleCheckUnindexedFiles(); | 78 | void scheduleCheckUnindexedFiles(); | ||
79 | void scheduleCheckStaleIndexEntries(); | 79 | void scheduleCheckStaleIndexEntries(); | ||
80 | 80 | | |||
81 | Q_SCRIPTABLE void suspend() { setSuspend(true); } | 81 | Q_SCRIPTABLE void suspend() { suspendContentIndexer(true); } | ||
82 | Q_SCRIPTABLE void resume() { setSuspend(false); } | 82 | Q_SCRIPTABLE void resume() { suspendContentIndexer(false); } | ||
83 | Q_SCRIPTABLE uint getRemainingTime(); | 83 | Q_SCRIPTABLE uint getRemainingTime(); | ||
84 | Q_SCRIPTABLE void checkUnindexedFiles(); | 84 | Q_SCRIPTABLE void checkUnindexedFiles(); | ||
85 | Q_SCRIPTABLE void checkStaleIndexEntries(); | 85 | Q_SCRIPTABLE void checkStaleIndexEntries(); | ||
86 | Q_SCRIPTABLE uint getBatchSize(); | 86 | Q_SCRIPTABLE uint getBatchSize(); | ||
87 | 87 | | |||
88 | private Q_SLOTS: | 88 | private Q_SLOTS: | ||
89 | void powerManagementStatusChanged(bool isOnBattery); | 89 | void suspendContentIndexer(bool suspend); | ||
90 | 90 | | |||
91 | private: | 91 | private: | ||
92 | void setSuspend(bool suspend); | | |||
93 | | ||||
94 | Database* m_db; | 92 | Database* m_db; | ||
95 | FileIndexerConfig* m_config; | 93 | FileIndexerConfig* m_config; | ||
96 | 94 | | |||
95 | QList<Baloo::IndexerState> m_indexerStates; | ||||
bruns: Make this a QFlags ... | |||||
There is no cast from int to enum anywhere here. There is a cast fron enum to int, to a negative integer used to set the QRunnable thread priority. smithjd: There is no cast from int to enum anywhere here. There is a cast fron enum to int, to a… | |||||
Sigh ... bruns: Sigh ...
Make each state a bit in the flags. No bits set -> Idle, one or multiple bits set ->… | |||||
96 | | ||||
97 | QStringList m_newFiles; | 97 | QStringList m_newFiles; | ||
98 | QStringList m_modifiedFiles; | 98 | QStringList m_modifiedFiles; | ||
99 | QStringList m_xattrFiles; | 99 | QStringList m_xattrFiles; | ||
100 | 100 | | |||
101 | QThreadPool m_threadPool; | 101 | QThreadPool m_threadPool; | ||
102 | 102 | | |||
103 | FileContentIndexerProvider m_provider; | 103 | FileContentIndexerProvider m_provider; | ||
104 | FileContentIndexer* m_contentIndexer; | 104 | FileContentIndexer* m_contentIndexer; | ||
105 | 105 | | |||
106 | PowerStateMonitor m_powerMonitor; | 106 | PowerStateMonitor m_powerMonitor; | ||
107 | 107 | | |||
108 | IndexerState m_indexerState; | | |||
109 | TimeEstimator m_timeEstimator; | 108 | TimeEstimator m_timeEstimator; | ||
110 | 109 | | |||
111 | bool m_checkUnindexedFiles; | 110 | bool m_checkUnindexedFiles; | ||
112 | bool m_checkStaleIndexEntries; | 111 | bool m_checkStaleIndexEntries; | ||
112 | bool m_schedulerLocked; | ||||
113 | }; | 113 | }; | ||
114 | 114 | | |||
115 | } | 115 | } | ||
116 | 116 | | |||
117 | #endif // BALOO_FILEINDEXSCHEDULER_H | 117 | #endif // BALOO_FILEINDEXSCHEDULER_H |
Make this a QFlags ...