feat(index):增加索引进度监控接口
This commit is contained in:
parent
29ec9abc3a
commit
166218115a
|
@ -11,8 +11,8 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
|
||||
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core DBus Widgets Xml Concurrent Sql LinguistTools REQUIRED)
|
||||
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core DBus Widgets Xml Concurrent Sql LinguistTools REQUIRED)
|
||||
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core DBus Widgets Xml Concurrent Sql LinguistTools RemoteObjects REQUIRED)
|
||||
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core DBus Widgets Xml Concurrent Sql LinguistTools RemoteObjects REQUIRED)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
find_package(KF5WindowSystem)
|
||||
find_package(qt5xdg)
|
||||
|
@ -74,6 +74,9 @@ set(LIBUKUI_SEARCH_SRC
|
|||
index/search-manager.cpp index/search-manager.h
|
||||
index/ukui-search-qdbus.cpp index/ukui-search-qdbus.h
|
||||
index/writable-database.cpp index/writable-database.h
|
||||
index/file-extraction-result.cpp
|
||||
index/file-extraction-result.h
|
||||
index/index-monitor.cpp
|
||||
libsearch.cpp libsearch.h
|
||||
libsearch_global.h
|
||||
log-utils.cpp log-utils.h
|
||||
|
@ -104,9 +107,9 @@ set(LIBUKUI_SEARCH_SRC
|
|||
icon-loader.cpp icon-loader.h
|
||||
data-collecter.cpp
|
||||
data-collecter.h
|
||||
index/file-extraction-result.cpp
|
||||
index/file-extraction-result.h
|
||||
|
||||
)
|
||||
qt5_generate_repc(LIBUKUI_SEARCH_SRC index/monitor.rep REPLICA)
|
||||
set(QRC_FILES resource1.qrc)
|
||||
file(GLOB TS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../translations/libukui-search/*.ts)
|
||||
set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION ${CMAKE_BINARY_DIR}/libsearch/.qm)
|
||||
|
@ -136,6 +139,7 @@ set(HEADERS
|
|||
development-files/header-files/UkuiSearchTask
|
||||
development-files/header-files/UkuiSearchPluginIface
|
||||
development-files/header-files/FileSystemWatcher
|
||||
index/index-monitor.h
|
||||
)
|
||||
|
||||
include_directories(
|
||||
|
@ -170,6 +174,7 @@ target_link_libraries(${PROJECT_NAME} PRIVATE
|
|||
Qt${QT_VERSION_MAJOR}::Sql
|
||||
Qt${QT_VERSION_MAJOR}::Widgets
|
||||
Qt${QT_VERSION_MAJOR}::Xml
|
||||
Qt${QT_VERSION_MAJOR}::RemoteObjects
|
||||
chinese-segmentation
|
||||
quazip5
|
||||
uchardet
|
||||
|
@ -219,3 +224,6 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/ukui-search.pc DESTINATION $
|
|||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ukui-search-config.cmake
|
||||
${CMAKE_CURRENT_BINARY_DIR}/ukui-search-config-version.cmake
|
||||
DESTINATION ${CMAKE_CONFIG_INSTALL_DIR})
|
||||
if(BUILD_TEST)
|
||||
add_subdirectory(test)
|
||||
endif ()
|
|
@ -60,14 +60,17 @@ void BatchIndexer::run()
|
|||
fetch();
|
||||
|
||||
if(m_target & Target::Basic) {
|
||||
Q_EMIT basicIndexStart(m_mode);
|
||||
basicIndex();
|
||||
Q_EMIT basicIndexDone(m_mode);
|
||||
}
|
||||
if(m_target & Target::Content) {
|
||||
Q_EMIT contentIndexStart(m_mode);
|
||||
contentIndex();
|
||||
Q_EMIT contentIndexDone(m_mode);
|
||||
}
|
||||
if(m_target & Target::Ocr) {
|
||||
Q_EMIT ocrContentIndexStart(m_mode);
|
||||
ocrIndex();
|
||||
Q_EMIT ocrContentIndexDone(m_mode);
|
||||
}
|
||||
|
|
|
@ -71,6 +71,9 @@ public:
|
|||
|
||||
Q_SIGNALS:
|
||||
void progress(IndexType type, uint all, uint finished);
|
||||
void basicIndexStart(WorkMode);
|
||||
void contentIndexStart(WorkMode);
|
||||
void ocrContentIndexStart(WorkMode);
|
||||
void basicIndexDone(WorkMode);
|
||||
void contentIndexDone(WorkMode);
|
||||
void ocrContentIndexDone(WorkMode);
|
||||
|
|
|
@ -0,0 +1,162 @@
|
|||
/*
|
||||
* Copyright (C) 2024, KylinSoft Co., Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: iaom <zhangpengfei@kylinos.cn>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "index-monitor.h"
|
||||
#include <QRemoteObjectNode>
|
||||
#include "rep_monitor_replica.h"
|
||||
|
||||
static UkuiSearch::IndexMonitor *globalInstance = nullptr;
|
||||
namespace UkuiSearch {
|
||||
class IndexMonitorPrivate {
|
||||
public:
|
||||
~IndexMonitorPrivate();
|
||||
QRemoteObjectNode m_qroNode;
|
||||
MonitorReplica *m_monitorReplica = nullptr;
|
||||
static QUrl nodeUrl();
|
||||
};
|
||||
|
||||
IndexMonitorPrivate::~IndexMonitorPrivate()
|
||||
{
|
||||
if(m_monitorReplica) {
|
||||
m_monitorReplica->disconnect();
|
||||
delete m_monitorReplica;
|
||||
m_monitorReplica = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
QUrl IndexMonitorPrivate::nodeUrl()
|
||||
{
|
||||
QString displayEnv = (qgetenv("XDG_SESSION_TYPE") == "wayland") ? QLatin1String("WAYLAND_DISPLAY") : QLatin1String("DISPLAY");
|
||||
QString display(qgetenv(displayEnv.toUtf8().data()));
|
||||
return QUrl(QStringLiteral("local:ukui-search-service-monitor-") + QString(qgetenv("USER")) + display);
|
||||
}
|
||||
|
||||
IndexMonitor *IndexMonitor::self()
|
||||
{
|
||||
if(!globalInstance)
|
||||
globalInstance = new IndexMonitor;
|
||||
return globalInstance;
|
||||
}
|
||||
|
||||
void IndexMonitor::stopMonitor()
|
||||
{
|
||||
globalInstance->deleteLater();
|
||||
globalInstance = nullptr;
|
||||
}
|
||||
|
||||
void IndexMonitor::startMonitor()
|
||||
{
|
||||
IndexMonitor::self();
|
||||
}
|
||||
|
||||
IndexMonitor::IndexMonitor(QObject *parent) : QObject(parent), d(new IndexMonitorPrivate)
|
||||
{
|
||||
d->m_qroNode.connectToNode(IndexMonitorPrivate::nodeUrl());
|
||||
d->m_monitorReplica = d->m_qroNode.acquire<MonitorReplica>();
|
||||
//转发信号
|
||||
connect(d->m_monitorReplica, &MonitorReplica::currentIndexPathsChanged, this, &IndexMonitor::currentIndexPathsChanged);
|
||||
connect(d->m_monitorReplica, &MonitorReplica::indexStateChanged, this, &IndexMonitor::indexStateChanged);
|
||||
connect(d->m_monitorReplica, &MonitorReplica::basicIndexSizeChanged, this, &IndexMonitor::basicIndexSizeChanged);
|
||||
connect(d->m_monitorReplica, &MonitorReplica::contentIndexSizeChanged, this, &IndexMonitor::contentIndexSizeChanged);
|
||||
connect(d->m_monitorReplica, &MonitorReplica::ocrContentIndexSizeChanged, this, &IndexMonitor::ocrContentIndexSizeChanged);
|
||||
connect(d->m_monitorReplica, &MonitorReplica::basicIndexProgressChanged, this, &IndexMonitor::basicIndexProgressChanged);
|
||||
connect(d->m_monitorReplica, &MonitorReplica::contentIndexProgressChanged, this, &IndexMonitor::contentIndexProgressChanged);
|
||||
connect(d->m_monitorReplica, &MonitorReplica::ocrContentIndexProgressChanged, this, &IndexMonitor::ocrContentIndexProgressChanged);
|
||||
connect(d->m_monitorReplica, &MonitorReplica::basicIndexDocNumChanged, this, &IndexMonitor::basicIndexDocNumChanged);
|
||||
connect(d->m_monitorReplica, &MonitorReplica::contentIndexDocNumChanged, this, &IndexMonitor::contentIndexDocNumChanged);
|
||||
connect(d->m_monitorReplica, &MonitorReplica::ocrContentIndexDocNumChanged, this, &IndexMonitor::ocrContentIndexDocNumChanged);
|
||||
connect(d->m_monitorReplica, &MonitorReplica::basicIndexStart, this, &IndexMonitor::basicIndexStart);
|
||||
connect(d->m_monitorReplica, &MonitorReplica::contentIndexStart, this, &IndexMonitor::contentIndexStart);
|
||||
connect(d->m_monitorReplica, &MonitorReplica::ocrContentIndexStart, this, &IndexMonitor::ocrContentIndexStart);
|
||||
connect(d->m_monitorReplica, &MonitorReplica::basicIndexDone, this, &IndexMonitor::basicIndexDone);
|
||||
connect(d->m_monitorReplica, &MonitorReplica::contentIndexDone, this, &IndexMonitor::contentIndexDone);
|
||||
connect(d->m_monitorReplica, &MonitorReplica::ocrContentIndexDone, this, &IndexMonitor::ocrContentIndexDone);
|
||||
|
||||
connect(d->m_monitorReplica, &QRemoteObjectReplica::initialized, this, &IndexMonitor::serviceReady);
|
||||
connect(d->m_monitorReplica, &QRemoteObjectReplica::stateChanged, this, [&](QRemoteObjectReplica::State state, QRemoteObjectReplica::State oldState){
|
||||
if(state == QRemoteObjectReplica::State::Suspect && oldState == QRemoteObjectReplica::State::Valid) {
|
||||
Q_EMIT serviceOffline();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
IndexMonitor::~IndexMonitor()
|
||||
{
|
||||
if(d) {
|
||||
delete d;
|
||||
d = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
QStringList IndexMonitor::currentIndexPaths() const
|
||||
{
|
||||
return d->m_monitorReplica->currentIndexPaths();
|
||||
}
|
||||
|
||||
QString IndexMonitor::indexState() const
|
||||
{
|
||||
return d->m_monitorReplica->indexState();
|
||||
}
|
||||
|
||||
uint IndexMonitor::basicIndexSize() const
|
||||
{
|
||||
return d->m_monitorReplica->basicIndexSize();
|
||||
}
|
||||
|
||||
uint IndexMonitor::contentIndexSize() const
|
||||
{
|
||||
return d->m_monitorReplica->contentIndexSize();
|
||||
}
|
||||
|
||||
uint IndexMonitor::ocrContentIndexSize() const
|
||||
{
|
||||
return d->m_monitorReplica->ocrContentIndexSize();
|
||||
}
|
||||
|
||||
uint IndexMonitor::basicIndexProgress() const
|
||||
{
|
||||
return d->m_monitorReplica->basicIndexProgress();
|
||||
}
|
||||
|
||||
uint IndexMonitor::contentIndexProgress() const
|
||||
{
|
||||
return d->m_monitorReplica->contentIndexProgress();
|
||||
}
|
||||
|
||||
uint IndexMonitor::basicIndexDocNum() const
|
||||
{
|
||||
return d->m_monitorReplica->basicIndexDocNum();
|
||||
}
|
||||
|
||||
uint IndexMonitor::ocrContentIndexProgress() const
|
||||
{
|
||||
return d->m_monitorReplica->ocrContentIndexProgress();
|
||||
}
|
||||
|
||||
uint IndexMonitor::contentIndexDocNum() const
|
||||
{
|
||||
return d->m_monitorReplica->contentIndexDocNum();
|
||||
}
|
||||
|
||||
uint IndexMonitor::ocrContentIndexDocNum() const
|
||||
{
|
||||
return d->m_monitorReplica->ocrContentIndexDocNum();
|
||||
}
|
||||
} // UkuiSearch
|
|
@ -0,0 +1,135 @@
|
|||
/*
|
||||
* Copyright (C) 2024, KylinSoft Co., Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: iaom <zhangpengfei@kylinos.cn>
|
||||
*
|
||||
*/
|
||||
#ifndef UKUI_SEARCH_INDEX_MONITOR_H
|
||||
#define UKUI_SEARCH_INDEX_MONITOR_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace UkuiSearch {
|
||||
/**
|
||||
* 索引状态和进度信息查询
|
||||
*/
|
||||
class IndexMonitorPrivate;
|
||||
class IndexMonitor : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QStringList currentIndexPaths READ currentIndexPaths NOTIFY currentIndexPathsChanged)
|
||||
Q_PROPERTY(QString indexState READ indexState NOTIFY indexStateChanged)
|
||||
Q_PROPERTY(uint basicIndexSize READ basicIndexSize NOTIFY basicIndexSizeChanged)
|
||||
Q_PROPERTY(uint contentIndexSize READ contentIndexSize NOTIFY contentIndexSizeChanged)
|
||||
Q_PROPERTY(uint ocrContentIndexSize READ ocrContentIndexSize NOTIFY ocrContentIndexSizeChanged)
|
||||
Q_PROPERTY(uint basicIndexProgress READ basicIndexProgress NOTIFY basicIndexProgressChanged)
|
||||
Q_PROPERTY(uint contentIndexProgress READ contentIndexProgress NOTIFY contentIndexProgressChanged)
|
||||
Q_PROPERTY(uint ocrContentIndexProgress READ ocrContentIndexProgress NOTIFY ocrContentIndexProgressChanged)
|
||||
Q_PROPERTY(uint basicIndexDocNum READ basicIndexDocNum NOTIFY basicIndexDocNumChanged)
|
||||
Q_PROPERTY(uint contentIndexDocNum READ contentIndexDocNum NOTIFY contentIndexDocNumChanged)
|
||||
Q_PROPERTY(uint ocrContentIndexDocNum READ ocrContentIndexDocNum NOTIFY ocrContentIndexDocNumChanged)
|
||||
|
||||
public:
|
||||
static IndexMonitor *self();
|
||||
static void stopMonitor();
|
||||
static void startMonitor();
|
||||
/**
|
||||
* @brief currentIndexPaths
|
||||
* @return 当前索引的所有目录
|
||||
*/
|
||||
QStringList currentIndexPaths() const;
|
||||
/**
|
||||
* @brief indexState
|
||||
* @return 当前索引调度器的状态
|
||||
*/
|
||||
QString indexState() const;
|
||||
/**
|
||||
* @brief basicIndexSize
|
||||
* @return 当前需要处理的基础索引数量
|
||||
*/
|
||||
uint basicIndexSize() const;
|
||||
/**
|
||||
* @brief contentIndexSize
|
||||
* @return 当前需要处理的内容索引数量
|
||||
*/
|
||||
uint contentIndexSize() const;
|
||||
/**
|
||||
* @brief ocrContentIndexSize
|
||||
* @return 当前需要处理的OCR索引数量
|
||||
*/
|
||||
uint ocrContentIndexSize() const;
|
||||
/**
|
||||
* @brief basicIndexProgress
|
||||
* @return 基础索引进度
|
||||
*/
|
||||
uint basicIndexProgress() const;
|
||||
/**
|
||||
* @brief contentIndexProgress
|
||||
* @return 内容索引进度
|
||||
*/
|
||||
uint contentIndexProgress() const;
|
||||
/**
|
||||
* @brief ocrContentIndexProgress
|
||||
* @return ocr索引进度
|
||||
*/
|
||||
uint ocrContentIndexProgress() const;
|
||||
/**
|
||||
* @brief basicIndexDocNum
|
||||
* @return 基础索引完成的总文档数
|
||||
*/
|
||||
uint basicIndexDocNum() const;
|
||||
/**
|
||||
* @brief contentIndexDocNum
|
||||
* @return 内容索引完成的总文档数
|
||||
*/
|
||||
uint contentIndexDocNum() const;
|
||||
/**
|
||||
* @brief contentIndexDocNum
|
||||
* @return ocr内容索引完成的总文档数
|
||||
*/
|
||||
uint ocrContentIndexDocNum() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void currentIndexPathsChanged(QStringList currentIndexPaths);
|
||||
void indexStateChanged(QString indexState);
|
||||
void basicIndexSizeChanged(uint basicIndexSize);
|
||||
void contentIndexSizeChanged(uint contentIndexSize);
|
||||
void ocrContentIndexSizeChanged(uint ocrIndexSize);
|
||||
void basicIndexProgressChanged(uint basicIndexProgress);
|
||||
void contentIndexProgressChanged(uint contentIndexProgress);
|
||||
void ocrContentIndexProgressChanged(uint ocrIndexProgress);
|
||||
void basicIndexDocNumChanged(uint basicIndexDocNum);
|
||||
void contentIndexDocNumChanged(uint contentIndexDocNum);
|
||||
void ocrContentIndexDocNumChanged(uint ocrContentIndexDocNum);
|
||||
void basicIndexStart();
|
||||
void contentIndexStart();
|
||||
void ocrContentIndexStart();
|
||||
void basicIndexDone(bool success);
|
||||
void contentIndexDone(bool success);
|
||||
void ocrContentIndexDone(bool success);
|
||||
|
||||
void serviceReady();
|
||||
void serviceOffline();
|
||||
|
||||
private:
|
||||
explicit IndexMonitor(QObject *parent = nullptr);
|
||||
~IndexMonitor();
|
||||
IndexMonitorPrivate *d = nullptr;
|
||||
};
|
||||
|
||||
} // UkuiSearch
|
||||
|
||||
#endif //UKUI_SEARCH_INDEX_MONITOR_H
|
|
@ -243,12 +243,15 @@ void IndexScheduler::startIndexJob(const QStringList& folders,const QStringList&
|
|||
m_state = Running;
|
||||
Q_EMIT stateChange(m_state);
|
||||
|
||||
BatchIndexer *indexer = new BatchIndexer(folders, blackList, m_indexStop, m_contentIndexStop, m_ocrContentIndexStop, mode, target);
|
||||
auto *indexer = new BatchIndexer(folders, blackList, m_indexStop, m_contentIndexStop, m_ocrContentIndexStop, mode, target);
|
||||
connect(indexer, &BatchIndexer::done, this, &IndexScheduler::batchIndexerFinished, Qt::QueuedConnection);
|
||||
connect(indexer, &BatchIndexer::progress, this, &IndexScheduler::process, Qt::QueuedConnection);
|
||||
connect(indexer, &BatchIndexer::basicIndexDone, this, &IndexScheduler::onBasicIndexDone, Qt::QueuedConnection);
|
||||
connect(indexer, &BatchIndexer::contentIndexDone, this, &IndexScheduler::onContentIndexDone, Qt::QueuedConnection);
|
||||
connect(indexer, &BatchIndexer::ocrContentIndexDone, this, &IndexScheduler::onOcrContentIndexDone, Qt::QueuedConnection);
|
||||
connect(indexer, &BatchIndexer::basicIndexStart, this, &IndexScheduler::basicIndexStart, Qt::QueuedConnection);
|
||||
connect(indexer, &BatchIndexer::contentIndexStart, this, &IndexScheduler::contentIndexStart, Qt::QueuedConnection);
|
||||
connect(indexer, &BatchIndexer::ocrContentIndexStart, this, &IndexScheduler::ocrContentIndexStart, Qt::QueuedConnection);
|
||||
m_threadPool.start(indexer);
|
||||
}
|
||||
}
|
||||
|
@ -344,6 +347,8 @@ void IndexScheduler::onBasicIndexDone(BatchIndexer::WorkMode mode)
|
|||
m_statusRecorder->getStatus(INDEX_DATABASE_STATE_KEY).toInt() == IndexStatusRecorder::State::Updating) {
|
||||
m_statusRecorder->setStatus(INDEX_DATABASE_STATE_KEY, IndexStatusRecorder::State::Ready);
|
||||
success = true;
|
||||
} else if (m_statusRecorder->getStatus(INDEX_DATABASE_STATE_KEY).toInt() == IndexStatusRecorder::State::RealTimeUpdating ) {
|
||||
success = true;
|
||||
}
|
||||
Q_EMIT basicIndexDone(success);
|
||||
checkIfStartsWaiting();
|
||||
|
@ -359,6 +364,8 @@ void IndexScheduler::onContentIndexDone(BatchIndexer::WorkMode mode)
|
|||
m_statusRecorder->getStatus(CONTENT_INDEX_DATABASE_STATE_KEY).toInt() == IndexStatusRecorder::State::Updating) {
|
||||
m_statusRecorder->setStatus(CONTENT_INDEX_DATABASE_STATE_KEY, IndexStatusRecorder::State::Ready);
|
||||
success = true;
|
||||
} else if (m_statusRecorder->getStatus(CONTENT_INDEX_DATABASE_STATE_KEY).toInt() == IndexStatusRecorder::State::RealTimeUpdating ) {
|
||||
success = true;
|
||||
}
|
||||
Q_EMIT contentIndexDone(success);
|
||||
checkIfStartsWaiting();
|
||||
|
@ -374,8 +381,10 @@ void IndexScheduler::onOcrContentIndexDone(BatchIndexer::WorkMode mode)
|
|||
m_statusRecorder->getStatus(OCR_CONTENT_INDEX_DATABASE_STATE_KEY).toInt() == IndexStatusRecorder::State::Updating) {
|
||||
m_statusRecorder->setStatus(OCR_CONTENT_INDEX_DATABASE_STATE_KEY, IndexStatusRecorder::State::Ready);
|
||||
success = true;
|
||||
} else if (m_statusRecorder->getStatus(OCR_CONTENT_INDEX_DATABASE_STATE_KEY).toInt() == IndexStatusRecorder::State::RealTimeUpdating ) {
|
||||
success = true;
|
||||
}
|
||||
Q_EMIT contentIndexDone(success);
|
||||
Q_EMIT ocrContentIndexDone(success);
|
||||
checkIfStartsWaiting();
|
||||
}
|
||||
|
||||
|
|
|
@ -55,8 +55,12 @@ public:
|
|||
Q_SIGNALS:
|
||||
void stateChange(IndexerState);
|
||||
void process(IndexType type, uint all, uint finished);
|
||||
void basicIndexStart();
|
||||
void contentIndexStart();
|
||||
void ocrContentIndexStart();
|
||||
void basicIndexDone(bool success);
|
||||
void contentIndexDone(bool success);
|
||||
void ocrContentIndexDone(bool success);
|
||||
void done();
|
||||
|
||||
private Q_SLOTS:
|
||||
|
|
|
@ -5,11 +5,17 @@ class Monitor
|
|||
PROP(QString indexState READONLY);
|
||||
PROP(uint basicIndexSize READONLY);
|
||||
PROP(uint contentIndexSize READONLY);
|
||||
PROP(uint ocrIndexSize READONLY);
|
||||
PROP(uint ocrContentIndexSize READONLY);
|
||||
PROP(uint basicIndexProgress READONLY);
|
||||
PROP(uint contentIndexProgress READONLY);
|
||||
PROP(uint ocrIndexProgress READONLY);
|
||||
PROP(uint ocrContentIndexProgress READONLY);
|
||||
PROP(uint basicIndexDocNum READONLY);
|
||||
PROP(uint contentIndexDocNum READONLY);
|
||||
PROP(uint ocrContentIndexDocNum READONLY);
|
||||
SIGNAL(basicIndexStart());
|
||||
SIGNAL(contentIndexStart());
|
||||
SIGNAL(ocrContentIndexStart());
|
||||
SIGNAL(basicIndexDone(bool success));
|
||||
SIGNAL(contentIndexDone(bool success));
|
||||
SIGNAL(ocrContentIndexDone(bool success));
|
||||
};
|
|
@ -0,0 +1,20 @@
|
|||
cmake_minimum_required(VERSION 3.14)
|
||||
project(ukui-search-test)
|
||||
|
||||
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Widgets REQUIRED)
|
||||
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Widgets REQUIRED)
|
||||
|
||||
set(PROJECT_SOURCES
|
||||
main.cpp
|
||||
index-monitor-test.cpp
|
||||
)
|
||||
add_executable(${PROJECT_NAME} ${PROJECT_SOURCES})
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE
|
||||
../index
|
||||
)
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::Widgets
|
||||
ukui-search
|
||||
)
|
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
* Copyright (C) 2024, KylinSoft Co., Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: iaom <zhangpengfei@kylinos.cn>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "index-monitor-test.h"
|
||||
#include <QDebug>
|
||||
|
||||
IndexMonitorTest::IndexMonitorTest(QObject *parent) : QObject(parent)
|
||||
{
|
||||
m_monitor = UkuiSearch::IndexMonitor::self();
|
||||
connect(m_monitor, &UkuiSearch::IndexMonitor::serviceReady, this, [&](){
|
||||
qDebug() << "==serviceReady==";
|
||||
qDebug() << "==currentIndexPaths==" << m_monitor->currentIndexPaths();
|
||||
qDebug() << "==indexState==" << m_monitor->indexState();
|
||||
qDebug() << "==basicIndexSize==" << m_monitor->basicIndexSize();
|
||||
qDebug() << "==contentIndexSize==" << m_monitor->contentIndexSize();
|
||||
qDebug() << "==ocrContentIndexSize==" << m_monitor->ocrContentIndexSize();
|
||||
qDebug() << "==basicIndexProgress==" << m_monitor->basicIndexProgress();
|
||||
qDebug() << "==contentIndexProgress==" << m_monitor->contentIndexProgress();
|
||||
qDebug() << "==ocrContentIndexProgress==" << m_monitor->ocrContentIndexProgress();
|
||||
qDebug() << "==basicIndexDocNum==" << m_monitor->basicIndexDocNum();
|
||||
qDebug() << "==contentIndexDocNum==" << m_monitor->contentIndexDocNum();
|
||||
qDebug() << "==ocrContentIndexDocNum==" << m_monitor->ocrContentIndexDocNum();
|
||||
});
|
||||
connect(m_monitor, &UkuiSearch::IndexMonitor::serviceOffline, this, [&](){
|
||||
qDebug() << "==serviceReady==";
|
||||
});
|
||||
connect(m_monitor, &UkuiSearch::IndexMonitor::currentIndexPathsChanged, this, [&](const QStringList& currentIndexPaths){
|
||||
qDebug() << "==currentIndexPathsChanged==" << currentIndexPaths;
|
||||
});
|
||||
connect(m_monitor, &UkuiSearch::IndexMonitor::indexStateChanged, this, [&](const QString& indexState){
|
||||
qDebug() << "==indexStateChanged==" << indexState;
|
||||
});
|
||||
connect(m_monitor, &UkuiSearch::IndexMonitor::basicIndexSizeChanged, this, [&](uint basicIndexSize){
|
||||
qDebug() << "==basicIndexSizeChanged==" << basicIndexSize;
|
||||
});
|
||||
connect(m_monitor, &UkuiSearch::IndexMonitor::contentIndexSizeChanged, this, [&](uint contentIndexSize){
|
||||
qDebug() << "==contentIndexSizeChanged==" << contentIndexSize;
|
||||
});
|
||||
connect(m_monitor, &UkuiSearch::IndexMonitor::ocrContentIndexSizeChanged, this, [&](uint ocrIndexSize){
|
||||
qDebug() << "==ocrContentIndexSizeChanged==" << ocrIndexSize;
|
||||
});
|
||||
connect(m_monitor, &UkuiSearch::IndexMonitor::basicIndexProgressChanged, this, [&](uint basicIndexProgress){
|
||||
qDebug() << "==basicIndexProgressChanged==" << basicIndexProgress;
|
||||
});
|
||||
connect(m_monitor, &UkuiSearch::IndexMonitor::contentIndexProgressChanged, this, [&](uint contentIndexProgress){
|
||||
qDebug() << "==contentIndexProgressChanged==" << contentIndexProgress;
|
||||
});
|
||||
connect(m_monitor, &UkuiSearch::IndexMonitor::ocrContentIndexProgressChanged, this, [&](uint ocrIndexProgress){
|
||||
qDebug() << "==ocrContentIndexProgressChanged==" << ocrIndexProgress;
|
||||
});
|
||||
connect(m_monitor, &UkuiSearch::IndexMonitor::basicIndexDocNumChanged, this, [&](uint basicIndexDocNum){
|
||||
qDebug() << "==basicIndexDocNumChanged==" << basicIndexDocNum;
|
||||
});
|
||||
connect(m_monitor, &UkuiSearch::IndexMonitor::contentIndexDocNumChanged, this, [&](uint contentIndexDocNum){
|
||||
qDebug() << "==contentIndexDocNumChanged==" << contentIndexDocNum;
|
||||
});
|
||||
connect(m_monitor, &UkuiSearch::IndexMonitor::ocrContentIndexDocNumChanged, this, [&](uint ocrContentIndexDocNum){
|
||||
qDebug() << "==ocrContentIndexDocNumChanged==" << ocrContentIndexDocNum;
|
||||
});
|
||||
connect(m_monitor, &UkuiSearch::IndexMonitor::basicIndexStart, this, [&](){
|
||||
qDebug() << "==basicIndexStart==";
|
||||
});
|
||||
connect(m_monitor, &UkuiSearch::IndexMonitor::contentIndexStart, this, [&](){
|
||||
qDebug() << "==contentIndexStart==";
|
||||
});
|
||||
connect(m_monitor, &UkuiSearch::IndexMonitor::ocrContentIndexStart, this, [&](){
|
||||
qDebug() << "==ocrContentIndexStart==";
|
||||
});
|
||||
connect(m_monitor, &UkuiSearch::IndexMonitor::basicIndexDone, this, [&](bool success){
|
||||
qDebug() << "==basicIndexDone==" << success;
|
||||
});
|
||||
connect(m_monitor, &UkuiSearch::IndexMonitor::contentIndexDone, this, [&](bool success){
|
||||
qDebug() << "==contentIndexDone==" << success;
|
||||
});
|
||||
connect(m_monitor, &UkuiSearch::IndexMonitor::ocrContentIndexDone, this, [&](bool success){
|
||||
qDebug() << "==ocrContentIndexDone==" << success;
|
||||
});
|
||||
}
|
||||
|
||||
IndexMonitorTest::~IndexMonitorTest()
|
||||
{
|
||||
UkuiSearch::IndexMonitor::stopMonitor();
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (C) 2024, KylinSoft Co., Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: iaom <zhangpengfei@kylinos.cn>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef UKUI_SEARCH_INDEX_MONITOR_TEST_H
|
||||
#define UKUI_SEARCH_INDEX_MONITOR_TEST_H
|
||||
|
||||
#include <QObject>
|
||||
#include "index-monitor.h"
|
||||
|
||||
class IndexMonitorTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit IndexMonitorTest(QObject *parent = nullptr);
|
||||
~IndexMonitorTest();
|
||||
|
||||
private:
|
||||
UkuiSearch::IndexMonitor *m_monitor = nullptr;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //UKUI_SEARCH_INDEX_MONITOR_TEST_H
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (C) 2024, KylinSoft Co., Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: iaom <zhangpengfei@kylinos.cn>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QApplication>
|
||||
#include "index-monitor-test.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
IndexMonitorTest test;
|
||||
return QApplication::exec();
|
||||
}
|
|
@ -34,8 +34,7 @@ set(UKUI_SEARCH_SERVICE_SRC
|
|||
monitor.cpp
|
||||
monitor.h
|
||||
)
|
||||
qt5_generate_repc(UKUI_SEARCH_SERVICE_SRC monitor.rep SOURCE)
|
||||
qt5_generate_repc(UKUI_SEARCH_SERVICE_SRC monitor.rep REPLICA)
|
||||
qt5_generate_repc(UKUI_SEARCH_SERVICE_SRC ../libsearch/index/monitor.rep SOURCE)
|
||||
add_executable(ukui-search-service
|
||||
${UKUI_SEARCH_SERVICE_SRC}
|
||||
${QRC_FILES}
|
||||
|
|
|
@ -31,6 +31,10 @@ Monitor::Monitor(IndexScheduler *scheduler, QObject *parent) : MonitorSource(par
|
|||
connect(scheduler, &IndexScheduler::process, this, &Monitor::processUpdate);
|
||||
connect(scheduler, &IndexScheduler::basicIndexDone, this, &Monitor::basicIndexDone);
|
||||
connect(scheduler, &IndexScheduler::contentIndexDone, this, &Monitor::contentIndexDone);
|
||||
connect(scheduler, &IndexScheduler::ocrContentIndexDone, this, &Monitor::ocrContentIndexDone);
|
||||
connect(scheduler, &IndexScheduler::basicIndexStart, this, &Monitor::basicIndexStart);
|
||||
connect(scheduler, &IndexScheduler::contentIndexStart, this, &Monitor::contentIndexStart);
|
||||
connect(scheduler, &IndexScheduler::ocrContentIndexStart, this, &Monitor::ocrContentIndexStart);
|
||||
connect(FileIndexerConfig::getInstance(), &FileIndexerConfig::appendIndexDir, this, [&](){
|
||||
m_currentIndexPaths = FileIndexerConfig::getInstance()->currentIndexableDir();
|
||||
Q_EMIT currentIndexPathsChanged(m_currentIndexPaths);
|
||||
|
@ -62,7 +66,7 @@ uint Monitor::contentIndexSize() const
|
|||
return m_contentIndexSize;
|
||||
}
|
||||
|
||||
uint Monitor::ocrIndexSize() const
|
||||
uint Monitor::ocrContentIndexSize() const
|
||||
{
|
||||
return m_ocrIndexSize;
|
||||
}
|
||||
|
@ -77,7 +81,7 @@ uint Monitor::contentIndexProgress() const
|
|||
return m_contentIndexProgress;
|
||||
}
|
||||
|
||||
uint Monitor::ocrIndexProgress() const
|
||||
uint Monitor::ocrContentIndexProgress() const
|
||||
{
|
||||
return m_ocrIndexProgress;
|
||||
}
|
||||
|
@ -114,30 +118,54 @@ void Monitor::onIndexStateChanged(IndexScheduler::IndexerState state)
|
|||
void Monitor::processUpdate(IndexType type, uint all, uint finished)
|
||||
{
|
||||
switch (type) {
|
||||
case IndexType::Basic:
|
||||
m_basicIndexSize = all;
|
||||
Q_EMIT basicIndexSizeChanged(m_basicIndexSize);
|
||||
m_basicIndexProgress = finished;
|
||||
Q_EMIT basicIndexProgressChanged(m_basicIndexProgress);
|
||||
m_basicIndexDocNum = m_basicDatabase.getIndexDocCount();
|
||||
Q_EMIT basicIndexDocNumChanged(m_basicIndexDocNum);
|
||||
case IndexType::Basic: {
|
||||
if(m_basicIndexSize != all) {
|
||||
m_basicIndexSize = all;
|
||||
Q_EMIT basicIndexSizeChanged(m_basicIndexSize);
|
||||
}
|
||||
if(m_basicIndexProgress != finished) {
|
||||
m_basicIndexProgress = finished;
|
||||
Q_EMIT basicIndexProgressChanged(m_basicIndexProgress);
|
||||
}
|
||||
uint count = m_basicDatabase.getIndexDocCount();
|
||||
if(m_basicIndexDocNum != count) {
|
||||
m_basicIndexDocNum = count;
|
||||
Q_EMIT basicIndexDocNumChanged(m_basicIndexDocNum);
|
||||
}
|
||||
break;
|
||||
case IndexType::Contents:
|
||||
m_contentIndexSize = all;
|
||||
Q_EMIT contentIndexSizeChanged(m_contentIndexSize);
|
||||
m_contentIndexProgress = finished;
|
||||
Q_EMIT contentIndexProgressChanged(m_contentIndexProgress);
|
||||
m_contentIndexDocNum = m_contentDatabase.getIndexDocCount();
|
||||
Q_EMIT contentIndexDocNumChanged(m_contentIndexDocNum);
|
||||
}
|
||||
case IndexType::Contents: {
|
||||
if(m_contentIndexSize != all) {
|
||||
m_contentIndexSize = all;
|
||||
Q_EMIT contentIndexSizeChanged(m_contentIndexSize);
|
||||
}
|
||||
if(m_contentIndexProgress != finished) {
|
||||
m_contentIndexProgress = finished;
|
||||
Q_EMIT contentIndexProgressChanged(m_contentIndexProgress);
|
||||
}
|
||||
uint count = m_contentDatabase.getIndexDocCount();
|
||||
if(m_contentIndexDocNum != count) {
|
||||
m_contentIndexDocNum = count;
|
||||
Q_EMIT contentIndexDocNumChanged(m_contentIndexDocNum);
|
||||
}
|
||||
break;
|
||||
case IndexType::OCR:
|
||||
m_ocrIndexSize = all;
|
||||
Q_EMIT ocrIndexSizeChanged(m_ocrIndexSize);
|
||||
m_ocrIndexProgress = finished;
|
||||
Q_EMIT ocrIndexProgressChanged(m_ocrIndexProgress);
|
||||
m_ocrContentIndexDocNum = m_ocrContentDatabase.getIndexDocCount();
|
||||
Q_EMIT ocrContentIndexDocNumChanged(m_ocrContentDatabase.getIndexDocCount());
|
||||
}
|
||||
case IndexType::OCR: {
|
||||
if(m_ocrIndexSize != all) {
|
||||
m_ocrIndexSize = all;
|
||||
Q_EMIT ocrContentIndexSizeChanged(m_ocrIndexSize);
|
||||
}
|
||||
if(m_ocrIndexProgress != finished) {
|
||||
m_ocrIndexProgress = finished;
|
||||
Q_EMIT ocrContentIndexProgressChanged(m_ocrIndexProgress);
|
||||
}
|
||||
uint count = m_contentDatabase.getIndexDocCount();
|
||||
if(m_ocrContentIndexDocNum != count) {
|
||||
m_ocrContentIndexDocNum = count;
|
||||
Q_EMIT ocrContentIndexDocNumChanged(m_ocrContentDatabase.getIndexDocCount());
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -56,10 +56,10 @@ public:
|
|||
*/
|
||||
uint contentIndexSize() const override;
|
||||
/**
|
||||
* @brief ocrIndexSize
|
||||
* @brief ocrContentIndexSize
|
||||
* @return 当前需要处理的OCR索引数量
|
||||
*/
|
||||
uint ocrIndexSize() const override;
|
||||
uint ocrContentIndexSize() const override;
|
||||
/**
|
||||
* @brief basicIndexProgress
|
||||
* @return 基础索引进度
|
||||
|
@ -71,10 +71,10 @@ public:
|
|||
*/
|
||||
uint contentIndexProgress() const override;
|
||||
/**
|
||||
* @brief ocrIndexProgress
|
||||
* @brief ocrContentIndexProgress
|
||||
* @return ocr索引进度
|
||||
*/
|
||||
uint ocrIndexProgress() const override;
|
||||
uint ocrContentIndexProgress() const override;
|
||||
/**
|
||||
* @brief basicIndexDocNum
|
||||
* @return 基础索引完成的总文档数
|
||||
|
@ -91,22 +91,6 @@ public:
|
|||
*/
|
||||
uint ocrContentIndexDocNum() const override;
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* @brief basicIndexDone
|
||||
* 基础索引数据库建立完成或完成增量更新
|
||||
*/
|
||||
void basicIndexDone();
|
||||
/**
|
||||
* @brief contentIndexDone
|
||||
* 内容索引数据库建立完成或完成增量更新
|
||||
*/
|
||||
void contentIndexDone();
|
||||
|
||||
void basicIndexDocNumChanged(uint);
|
||||
void contentIndexDocNumChanged(uint);
|
||||
void ocrContentIndexDocNumChanged(uint);
|
||||
|
||||
private Q_SLOTS:
|
||||
void onIndexStateChanged(IndexScheduler::IndexerState);
|
||||
void processUpdate(UkuiSearch::IndexType type, uint all, uint finished);
|
||||
|
|
|
@ -30,19 +30,24 @@ Rectangle {
|
|||
StatusKeyValue {
|
||||
id: basicIndexDocumentNum
|
||||
keyText: qsTr("Basic index document number")
|
||||
valueText: "--"
|
||||
valueText: monitor.basicIndexDocNum
|
||||
}
|
||||
|
||||
StatusKeyValue {
|
||||
id: contentIndexDocumentNum
|
||||
keyText: qsTr("Content index document number")
|
||||
valueText: "--"
|
||||
valueText: monitor.contentIndexDocNum
|
||||
}
|
||||
StatusKeyValue {
|
||||
id: ocrContentIndexDocumentNum
|
||||
keyText: qsTr("OCR content index document number")
|
||||
valueText: monitor.ocrContentIndexDocNum
|
||||
}
|
||||
|
||||
StatusKeyValue {
|
||||
id: indexState
|
||||
keyText: qsTr("Index state")
|
||||
valueText: "--"
|
||||
valueText: monitor.indexState
|
||||
}
|
||||
|
||||
IndexProgressBar {
|
||||
|
@ -50,7 +55,9 @@ Rectangle {
|
|||
width: parent.width;
|
||||
name: "Basic index progress"
|
||||
from: 0
|
||||
visible: false
|
||||
to: monitor.basicIndexSize
|
||||
value: monitor.basicIndexProgress
|
||||
visible: true
|
||||
}
|
||||
|
||||
IndexProgressBar {
|
||||
|
@ -58,80 +65,45 @@ Rectangle {
|
|||
width: parent.width;
|
||||
name: "Content index progress"
|
||||
from: 0
|
||||
visible: false
|
||||
to: monitor.contentIndexSize
|
||||
value: monitor.contentIndexProgress
|
||||
visible: true
|
||||
}
|
||||
|
||||
IndexProgressBar {
|
||||
id: ocrIndexProgress
|
||||
id: ocrContentIndexProgress
|
||||
name: "OCR index progress"
|
||||
width: parent.width;
|
||||
from: 0
|
||||
visible: false
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
basicIndexDocumentNum.valueText = monitor.basicIndexDocNum
|
||||
contentIndexDocumentNum.valueText = monitor.contentIndexDocNum
|
||||
indexState.valueText = monitor.indexState
|
||||
monitor.basicIndexDocNumUpdate.connect(onBasicIndexDocNumUpdate);
|
||||
monitor.contentIndexDocNumUpdate.connect(onContentIndexDocumentNum);
|
||||
monitor.indexStateChanged.connect(onIndexStateChanged);
|
||||
monitor.basicIndexSizeChange.connect(onBasicIndexSizeChange);
|
||||
monitor.basicIndexProgressUpdate.connect(onBasicIndexProgressUpdate);
|
||||
monitor.contentIndexSizeChange.connect(onContentIndexSizeChange);
|
||||
monitor.contentIndexProgressUpdate.connect(onContentIndexProgressUpdate);
|
||||
monitor.ocrIndexSizeChange.connect(onOcrIndexSizeChange);
|
||||
monitor.onOcrIndexProgressUpdate.connect(onOcrIndexProgressUpdate);
|
||||
monitor.basicIndexDone.connect(onBasicIndexDone);
|
||||
monitor.contentIndexDone.connect(onContentIndexDone);
|
||||
}
|
||||
function onBasicIndexDocNumUpdate(num) {
|
||||
var numStr = "%1";
|
||||
basicIndexDocumentNum.valueText = numStr.arg(num);
|
||||
}
|
||||
function onContentIndexDocumentNum(num) {
|
||||
var numStr = "%1";
|
||||
contentIndexDocumentNum.valueText = numStr.arg(num);
|
||||
}
|
||||
function onIndexStateChanged(state) {
|
||||
indexState.valueText = state;
|
||||
}
|
||||
function onBasicIndexSizeChange(num) {
|
||||
if(!basicIndexProgress.visible) {
|
||||
basicIndexProgress.visible = true;
|
||||
}
|
||||
basicIndexProgress.to = num;
|
||||
}
|
||||
function onBasicIndexProgressUpdate(num) {
|
||||
basicIndexProgress.value = num;
|
||||
basicIndexProgress.state = "Running"
|
||||
}
|
||||
function onContentIndexSizeChange(num) {
|
||||
if(!contentIndexProgress.visible) {
|
||||
contentIndexProgress.visible = true;
|
||||
}
|
||||
contentIndexProgress.to = num;
|
||||
}
|
||||
function onContentIndexProgressUpdate(num) {
|
||||
contentIndexProgress.value = num;
|
||||
contentIndexProgress.state = "Running"
|
||||
}
|
||||
function onOcrIndexSizeChange(num) {
|
||||
if(!ocrIndexProgress.visible) {
|
||||
ocrIndexProgress.visible = true;
|
||||
}
|
||||
ocrIndexProgress.to = num;
|
||||
}
|
||||
function onOcrIndexProgressUpdate(num) {
|
||||
ocrIndexProgress.value = num;
|
||||
ocrIndexProgress.state = "Running"
|
||||
}
|
||||
function onBasicIndexDone() {
|
||||
basicIndexProgress.state = "Done"
|
||||
}
|
||||
function onContentIndexDone() {
|
||||
contentIndexProgress.state = "Done"
|
||||
ocrIndexProgress.state = "Done"
|
||||
to: monitor.ocrContentIndexSize
|
||||
value: monitor.ocrContentIndexProgress
|
||||
visible: true
|
||||
}
|
||||
}
|
||||
Component.onCompleted: {
|
||||
monitor.basicIndexDone.connect(onBasicIndexDone);
|
||||
monitor.contentIndexDone.connect(onContentIndexDone);
|
||||
monitor.ocrContentIndexDone.connect(onOcrContentIndexDone);
|
||||
monitor.basicIndexStart.connect(onBasicIndexStart);
|
||||
monitor.contentIndexStart.connect(onContentIndexStart);
|
||||
monitor.ocrContentIndexStart.connect(onOcrContentIndexStart);
|
||||
}
|
||||
function onBasicIndexStart() {
|
||||
basicIndexProgress.state = "Running"
|
||||
}
|
||||
function onContentIndexStart() {
|
||||
contentIndexProgress.state = "Running"
|
||||
}
|
||||
function onOcrContentIndexStart() {
|
||||
ocrContentIndexProgress.state = "Running"
|
||||
}
|
||||
function onBasicIndexDone() {
|
||||
basicIndexProgress.state = "Done"
|
||||
}
|
||||
function onContentIndexDone() {
|
||||
contentIndexProgress.state = "Done"
|
||||
}
|
||||
function onOcrContentIndexDone() {
|
||||
ocrContentIndexProgress.state = "Done"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,17 +18,11 @@
|
|||
*
|
||||
*/
|
||||
#include <QDebug>
|
||||
#include <QDBusConnection>
|
||||
#include <QQmlContext>
|
||||
#include <utility>
|
||||
|
||||
#include <cstdio>
|
||||
#include <QVariant>
|
||||
#include "ukui-search-service.h"
|
||||
#include "dir-watcher.h"
|
||||
#include "file-utils.h"
|
||||
#include "file-indexer-config.h"
|
||||
#include "rep_monitor_replica.h"
|
||||
|
||||
using namespace UkuiSearch;
|
||||
UkuiSearchService::UkuiSearchService(int &argc, char *argv[], const QString &applicationName)
|
||||
|
@ -143,26 +137,24 @@ void UkuiSearchService::loadMonitorWindow()
|
|||
|
||||
void UkuiSearchService::showMonitorState()
|
||||
{
|
||||
m_qroNode.connectToNode(nodeUrl());
|
||||
auto *m = m_qroNode.acquire<MonitorReplica>();
|
||||
auto indexMonitor = IndexMonitor::self();
|
||||
|
||||
connect(m, &QRemoteObjectReplica::initialized, [&, m](){
|
||||
connect(indexMonitor, &IndexMonitor::serviceReady, [&, indexMonitor](){
|
||||
qDebug() << "QRemoteObjectReplica initialized";
|
||||
QString state = m->indexState();
|
||||
QString message = "Current index path: " + m->currentIndexPaths().join(",") + "\n"
|
||||
+ "Current index scheduler state: " + m->indexState() + "\n";
|
||||
QString state = indexMonitor->indexState();
|
||||
QString message = "Current index path: " + indexMonitor->currentIndexPaths().join(",") + "\n"
|
||||
+ "Current index scheduler state: " + indexMonitor->indexState() + "\n";
|
||||
if(state == "Idle" || state == "Stop") {
|
||||
message += "Basic index size: " + QString::number(m->basicIndexDocNum()) + " \n"
|
||||
+ "Content index size: " + QString::number(m->contentIndexDocNum()) + " \n"
|
||||
+ "Ocr index size: " + QString::number(m->ocrContentIndexDocNum()) + " \n";
|
||||
message += "Basic index size: " + QString::number(indexMonitor->basicIndexDocNum()) + " \n"
|
||||
+ "Content index size: " + QString::number(indexMonitor->contentIndexDocNum()) + " \n"
|
||||
+ "Ocr index size: " + QString::number(indexMonitor->ocrContentIndexDocNum()) + " \n";
|
||||
|
||||
} else {
|
||||
message += "Basic index progress: " + QString::number(m->basicIndexProgress()) + " of " + QString::number(m->basicIndexSize())+ " finished\n"
|
||||
+ "Content index progress: " + QString::number(m->contentIndexProgress()) + " of " + QString::number(m->contentIndexSize())+ " finished\n"
|
||||
+ "Ocr content index progress: " + QString::number(m->ocrIndexProgress()) + " of " + QString::number(m->ocrIndexSize())+ " finished\n";
|
||||
message += "Basic index progress: " + QString::number(indexMonitor->basicIndexProgress()) + " of " + QString::number(indexMonitor->basicIndexSize())+ " finished\n"
|
||||
+ "Content index progress: " + QString::number(indexMonitor->contentIndexProgress()) + " of " + QString::number(indexMonitor->contentIndexSize())+ " finished\n"
|
||||
+ "Ocr content index progress: " + QString::number(indexMonitor->ocrContentIndexProgress()) + " of " + QString::number(indexMonitor->ocrContentIndexSize())+ " finished\n";
|
||||
}
|
||||
|
||||
delete m;
|
||||
IndexMonitor::stopMonitor();
|
||||
fputs(qPrintable(message), stdout);
|
||||
qApp->quit();
|
||||
});
|
||||
|
|
|
@ -24,11 +24,11 @@
|
|||
#include <QCommandLineParser>
|
||||
#include <QGSettings>
|
||||
#include <QQuickView>
|
||||
#include <QtRemoteObjects/qremoteobjectnode.h>
|
||||
#include "qtsingleapplication.h"
|
||||
#include "common.h"
|
||||
#include "index-scheduler.h"
|
||||
#include "monitor.h"
|
||||
#include "index-monitor.h"
|
||||
|
||||
namespace UkuiSearch {
|
||||
|
||||
|
@ -49,7 +49,6 @@ private:
|
|||
IndexScheduler *m_indexScheduler = nullptr;
|
||||
Monitor *m_monitor = nullptr;
|
||||
QRemoteObjectHost m_qroHost;
|
||||
QRemoteObjectNode m_qroNode;
|
||||
QQuickView *m_quickView = nullptr;
|
||||
QUrl m_qmlPath = QString("qrc:/qml/IndexMonitor.qml");
|
||||
|
||||
|
|
Loading…
Reference in New Issue