ukui-search/libsearch/index/monitor.h

174 lines
5.0 KiB
C
Raw Normal View History

/*
* Copyright (C) 2022, 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>
*
*/
2022-10-26 18:01:40 +08:00
#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(QString indexState READ getIndexState NOTIFY indexStateChanged)
2022-10-26 18:01:40 +08:00
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);
/**
* @brief getCurrentIndexPaths
* @return
*/
2022-10-26 18:01:40 +08:00
QStringList getCurrentIndexPaths();
/**
* @brief getIndexState
* @return
*/
QString getIndexState();
/**
* @brief getBasicIndexSize
* @return
*/
2022-10-26 18:01:40 +08:00
uint getBasicIndexSize();
/**
* @brief getContentIndexSize
* @return
*/
2022-10-26 18:01:40 +08:00
uint getContentIndexSize();
/**
* @brief getOCRIndexSize
* @return OCR索引数量
*/
2022-10-26 18:01:40 +08:00
uint getOCRIndexSize();
/**
* @brief getBasicIndexProgress
* @return
*/
2022-10-26 18:01:40 +08:00
uint getBasicIndexProgress();
/**
* @brief getContentIndexProgress
* @return
*/
2022-10-26 18:01:40 +08:00
uint getContentIndexProgress();
/**
* @brief getOCRIndexProgress
* @return ocr索引进度
*/
2022-10-26 18:01:40 +08:00
uint getOCRIndexProgress();
/**
* @brief getBasicIndexDocNum
* @return
*/
2022-10-26 18:01:40 +08:00
uint getBasicIndexDocNum();
/**
* @brief getContentIndexDocNum
* @return
*/
2022-10-26 18:01:40 +08:00
uint getContentIndexDocNum();
Q_SIGNALS:
/**
* @brief indexStateChanged
*
*/
void indexStateChanged(QString);
/**
* @brief basicIndexSizeChange
*
*/
2022-10-26 18:01:40 +08:00
void basicIndexSizeChange(uint);
/**
* @brief contentIndexSizeChange
* OCR索引
*/
2022-10-26 18:01:40 +08:00
void contentIndexSizeChange(uint);
/**
* @brief ocrIndexSizeChange
* OCR索引总量
*/
2022-10-26 18:01:40 +08:00
void ocrIndexSizeChange(uint);
/**
* @brief basicIndexProgressUpdate
*
*/
2022-10-26 18:01:40 +08:00
void basicIndexProgressUpdate(uint);
/**
* @brief contentIndexProgressUpdate
* OCR索引
*/
2022-10-26 18:01:40 +08:00
void contentIndexProgressUpdate(uint);
/**
* @brief ocrIndexProgressUpdate
* OCR索引进度
*/
2022-10-26 18:01:40 +08:00
void ocrIndexProgressUpdate(uint);
/**
* @brief basicIndexDocNumUpdate
*
*/
2022-10-26 18:01:40 +08:00
void basicIndexDocNumUpdate(uint);
/**
* @brief contentIndexDocNumUpdate
*
*/
2022-10-26 18:01:40 +08:00
void contentIndexDocNumUpdate(uint);
/**
* @brief basicIndexDone
*
*/
void basicIndexDone();
/**
* @brief contentIndexDone
*
*/
void contentIndexDone();
2022-10-26 18:01:40 +08:00
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