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 @@ -78,6 +78,7 @@ QString m_filePath; bool m_balooRunning = false; Baloo::IndexerState m_indexerState = Baloo::Unavailable; + QElapsedTimer m_remainingTimeTimer; org::kde::baloo::scheduler* m_scheduler; org::kde::baloo::fileindexer* m_fileindexer; diff --git a/src/qml/experimental/monitor.cpp b/src/qml/experimental/monitor.cpp --- a/src/qml/experimental/monitor.cpp +++ b/src/qml/experimental/monitor.cpp @@ -82,13 +82,12 @@ fetchTotalFiles(); } m_filePath = filePath; - if (++m_filesIndexed == m_totalFiles) { - m_filePath = QStringLiteral("Done"); - } + ++m_filesIndexed; Q_EMIT newFileIndexed(); - if (m_filesIndexed % 100 == 0) { + if (m_remainingTimeTimer.elapsed() > 1000) { updateRemainingTime(); + m_remainingTimeTimer.restart(); } } @@ -99,8 +98,6 @@ void Monitor::toggleSuspendState() { - Q_ASSERT(m_scheduler != nullptr); - if (m_indexerState == Baloo::Suspended) { m_scheduler->resume(); } else { @@ -116,12 +113,6 @@ m_fileindexer->registerMonitor(); slotIndexerStateChanged(m_scheduler->state()); - // qDebug() << "fetched suspend state"; - fetchTotalFiles(); - if (m_indexerState == Baloo::ContentIndexing) { - m_filePath = m_fileindexer->currentFile(); - updateRemainingTime(); - } Q_EMIT balooStateChanged(); } @@ -133,6 +124,7 @@ m_totalFiles = tr.size(); m_filesIndexed = tr.size() - tr.phaseOneSize(); Q_EMIT totalFilesChanged(); + Q_EMIT newFileIndexed(); } } @@ -156,6 +148,11 @@ m_indexerState = newState; Q_EMIT indexerStateChanged(); fetchTotalFiles(); + if (m_indexerState == Baloo::ContentIndexing) { + m_remainingTimeTimer.start(); + } else { + m_filePath = QString(); + } } }