forked from openkylin/ukui-search
69 lines
2.4 KiB
C++
69 lines
2.4 KiB
C++
#ifndef MONITOR_H
|
|
#define MONITOR_H
|
|
|
|
#include <QObject>
|
|
#include "index-scheduler.h"
|
|
#include "database.h"
|
|
namespace UkuiSearch {
|
|
/**
|
|
* @brief The Monitor class
|
|
* 用于监控索引状态
|
|
* 为qml
|
|
*/
|
|
class Monitor : public QObject
|
|
{
|
|
Q_OBJECT
|
|
Q_PROPERTY(QStringList currentIndexPaths READ getCurrentIndexPaths)
|
|
Q_PROPERTY(IndexScheduler::IndexerState indexState READ getIndexState NOTIFY indexStateChanged)
|
|
Q_PROPERTY(uint basicIndexSize READ getBasicIndexSize NOTIFY basicIndexSizeChange)
|
|
Q_PROPERTY(uint contentIndexSize READ getContentIndexSize NOTIFY contentIndexSizeChange)
|
|
Q_PROPERTY(uint ocrIndexSize READ getOCRIndexSize NOTIFY ocrIndexSizeChange)
|
|
Q_PROPERTY(uint basicIndexProgress READ getBasicIndexProgress NOTIFY basicIndexProgressUpdate)
|
|
Q_PROPERTY(uint contentIndexProgress READ getContentIndexProgress NOTIFY contentIndexProgressUpdate)
|
|
Q_PROPERTY(uint ocrIndexProgress READ getOCRIndexProgress NOTIFY ocrIndexProgressUpdate)
|
|
Q_PROPERTY(uint basicIndexDocNum READ getBasicIndexDocNum NOTIFY basicIndexDocNumUpdate)
|
|
Q_PROPERTY(uint contentIndexDocNum READ getContentIndexDocNum NOTIFY contentIndexDocNumUpdate)
|
|
|
|
public:
|
|
explicit Monitor(IndexScheduler* scheduler, QObject *parent = nullptr);
|
|
QStringList getCurrentIndexPaths();
|
|
IndexScheduler::IndexerState getIndexState();
|
|
uint getBasicIndexSize();
|
|
uint getContentIndexSize();
|
|
uint getOCRIndexSize();
|
|
uint getBasicIndexProgress();
|
|
uint getContentIndexProgress();
|
|
uint getOCRIndexProgress();
|
|
uint getBasicIndexDocNum();
|
|
uint getContentIndexDocNum();
|
|
|
|
Q_SIGNALS:
|
|
void indexStateChanged(IndexScheduler::IndexerState);
|
|
void basicIndexSizeChange(uint);
|
|
void contentIndexSizeChange(uint);
|
|
void ocrIndexSizeChange(uint);
|
|
|
|
void basicIndexProgressUpdate(uint);
|
|
void contentIndexProgressUpdate(uint);
|
|
void ocrIndexProgressUpdate(uint);
|
|
void basicIndexDocNumUpdate(uint);
|
|
void contentIndexDocNumUpdate(uint);
|
|
|
|
private Q_SLOTS:
|
|
void onIndexStateChanged(IndexScheduler::IndexerState);
|
|
void processUpdate(IndexType type, uint all, uint finished);
|
|
|
|
private:
|
|
IndexScheduler *m_scheduler = nullptr;
|
|
Database m_basicDatabase;
|
|
Database m_contentDatabase;
|
|
uint m_basicIndexSize = 0;
|
|
uint m_contentIndexSize = 0;
|
|
uint m_ocrIndexSize = 0;
|
|
uint m_basicIndexProgress = 0;
|
|
uint m_contentIndexProgress = 0;
|
|
uint m_ocrIndexProgress = 0;
|
|
};
|
|
}
|
|
#endif // MONITOR_H
|