diff --git a/src/engine/CMakeLists.txt b/src/engine/CMakeLists.txt --- a/src/engine/CMakeLists.txt +++ b/src/engine/CMakeLists.txt @@ -10,6 +10,7 @@ enginequery.cpp idtreedb.cpp idfilenamedb.cpp + indexerstate.cpp mtimedb.cpp orpostingiterator.cpp phraseanditerator.cpp diff --git a/src/file/indexerstate.h b/src/engine/indexerstate.h rename from src/file/indexerstate.h rename to src/engine/indexerstate.h --- a/src/file/indexerstate.h +++ b/src/engine/indexerstate.h @@ -22,10 +22,15 @@ #ifndef BALOO_INDEXER_STATE_H #define BALOO_INDEXER_STATE_H +#include #include #include +#include "engine_export.h" + namespace Baloo { +Q_NAMESPACE_EXPORT(BALOO_ENGINE_EXPORT) + enum IndexerState { Idle, Suspended, @@ -38,50 +43,12 @@ StaleIndexEntriesClean, LowPowerIdle, }; +Q_ENUM_NS(IndexerState) -inline QString stateString(IndexerState state) -{ - QString status = i18n("Unknown"); - switch (state) { - case Idle: - status = i18n("Idle"); - break; - case Suspended: - status = i18n("Suspended"); - break; - case FirstRun: - status = i18n("Initial Indexing"); - break; - case NewFiles: - status = i18n("Indexing new files"); - break; - case ModifiedFiles: - status = i18n("Indexing modified files"); - break; - case XAttrFiles: - status = i18n("Indexing Extended Attributes"); - break; - case ContentIndexing: - status = i18n("Indexing file content"); - break; - case UnindexedFileCheck: - status = i18n("Checking for unindexed files"); - break; - case StaleIndexEntriesClean: - status = i18n("Checking for stale index entries"); - break; - case LowPowerIdle: - status = i18n("Idle (Powersave)"); - break; - } - return status; -} +BALOO_ENGINE_EXPORT QString stateString(IndexerState state); //TODO: check for implicit conversion -inline QString stateString(int state) -{ - return stateString(static_cast(state)); -} +BALOO_ENGINE_EXPORT QString stateString(int state); } #endif //BALOO_INDEXER_STATE_H diff --git a/src/engine/indexerstate.cpp b/src/engine/indexerstate.cpp new file mode 100644 --- /dev/null +++ b/src/engine/indexerstate.cpp @@ -0,0 +1,44 @@ +#include "indexerstate.h" + +QString Baloo::stateString(IndexerState state) +{ + QString status = i18n("Unknown"); + switch (state) { + case Idle: + status = i18n("Idle"); + break; + case Suspended: + status = i18n("Suspended"); + break; + case FirstRun: + status = i18n("Initial Indexing"); + break; + case NewFiles: + status = i18n("Indexing new files"); + break; + case ModifiedFiles: + status = i18n("Indexing modified files"); + break; + case XAttrFiles: + status = i18n("Indexing Extended Attributes"); + break; + case ContentIndexing: + status = i18n("Indexing file content"); + break; + case UnindexedFileCheck: + status = i18n("Checking for unindexed files"); + break; + case StaleIndexEntriesClean: + status = i18n("Checking for stale index entries"); + break; + case LowPowerIdle: + status = i18n("Idle (Powersave)"); + break; + } + return status; +} + +QString Baloo::stateString(int state) +{ + return stateString(static_cast(state)); +} diff --git a/src/qml/experimental/baloomonitorplugin.cpp b/src/qml/experimental/baloomonitorplugin.cpp --- a/src/qml/experimental/baloomonitorplugin.cpp +++ b/src/qml/experimental/baloomonitorplugin.cpp @@ -19,13 +19,14 @@ #include "baloomonitorplugin.h" #include "monitor.h" +#include "indexerstate.h" #include void BalooMonitorPlugin::registerTypes(const char *uri) { Q_ASSERT(uri == QLatin1String("org.kde.baloo.experimental")); qmlRegisterType(uri, 0, 1, "Monitor"); + qmlRegisterUncreatableMetaObject(Baloo::staticMetaObject, uri, 0, 1, "Baloo", "Error: only enums"); } - diff --git a/src/qml/experimental/monitor.h b/src/qml/experimental/monitor.h --- a/src/qml/experimental/monitor.h +++ b/src/qml/experimental/monitor.h @@ -42,16 +42,16 @@ Q_PROPERTY(uint filesIndexed MEMBER m_filesIndexed NOTIFY newFileIndexed) Q_PROPERTY(QString remainingTime READ remainingTime NOTIFY remainingTimeChanged) Q_PROPERTY(QString stateString READ stateString NOTIFY indexerStateChanged) - Q_PROPERTY(int state READ state NOTIFY indexerStateChanged) + Q_PROPERTY(Baloo::IndexerState state READ state NOTIFY indexerStateChanged) public: explicit Monitor(QObject* parent = nullptr); // Property readers QString filePath() const { return m_filePath; } QString suspendState() const; QString remainingTime() const { return m_remainingTime; } QString stateString() const { return Baloo::stateString(m_indexerState); } - int state() const { return static_cast(m_indexerState); } + Baloo::IndexerState state() const { return m_indexerState; } // Invokable methods Q_INVOKABLE void toggleSuspendState();