2020-12-21 18:50:54 +08:00
|
|
|
#ifndef INDEXGENERATOR_H
|
|
|
|
#define INDEXGENERATOR_H
|
|
|
|
|
|
|
|
#include <xapian.h>
|
|
|
|
#include <QObject>
|
|
|
|
|
|
|
|
#include <QStringList>
|
2020-12-22 21:20:47 +08:00
|
|
|
#include <QMap>
|
2020-12-21 18:50:54 +08:00
|
|
|
#include <QCryptographicHash>
|
|
|
|
|
|
|
|
class IndexGenerator : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
static IndexGenerator *getInstance();
|
2020-12-22 21:20:47 +08:00
|
|
|
bool setIndexdataPath();
|
2020-12-21 18:50:54 +08:00
|
|
|
bool isIndexdataExist();
|
2020-12-22 21:20:47 +08:00
|
|
|
static QStringList IndexSearch(QString indexText);
|
2020-12-21 18:50:54 +08:00
|
|
|
Q_SIGNALS:
|
|
|
|
void transactionFinished();
|
|
|
|
void searchFinish();
|
|
|
|
public Q_SLOTS:
|
|
|
|
bool creatAllIndex(QStringList *pathlist);
|
|
|
|
bool deleteAllIndex(QStringList *pathlist);
|
2020-12-22 21:20:47 +08:00
|
|
|
|
2020-12-21 18:50:54 +08:00
|
|
|
private:
|
|
|
|
explicit IndexGenerator(QObject *parent = nullptr);
|
|
|
|
void HandlePathList(QStringList *pathlist);
|
|
|
|
//add one data in database
|
2020-12-22 21:20:47 +08:00
|
|
|
void insertIntoDatabase(QString *indexText,QString *doc);
|
2020-12-21 18:50:54 +08:00
|
|
|
~IndexGenerator();
|
|
|
|
|
|
|
|
QMap<QString,QString> *m_index_map;
|
|
|
|
QCryptographicHash *m_cryp;
|
|
|
|
QString *m_index_data_path;
|
|
|
|
Xapian::WritableDatabase *m_datebase;
|
|
|
|
std::string m_docstr;
|
|
|
|
std::string m_index_text_str;
|
|
|
|
Xapian::TermGenerator *m_indexer;
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // INDEXGENERATOR_H
|