forked from openkylin/ukui-search
commit
e5ceb16a1a
|
@ -15,7 +15,7 @@ GlobalSettings *GlobalSettings::getInstance()
|
|||
|
||||
GlobalSettings::GlobalSettings(QObject *parent) : QObject(parent)
|
||||
{
|
||||
m_settings = new QSettings("org.ukui", "ukui-search-blockdirs", this);
|
||||
m_settings = new QSettings("org.ukui", "ukui-search", this);
|
||||
//the default number of transparency in mainwindow is 0.7
|
||||
//if someone changes the num in mainwindow, here should be modified too
|
||||
m_cache.insert(TRANSPARENCY_KEY, 0.7);
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
|
||||
#define CONTROL_CENTER_PERSONALISE_GSETTINGS_ID "org.ukui.control-center.personalise"
|
||||
#define TRANSPARENCY_KEY "transparency"
|
||||
#define INDEX_DATABASE_STATE "index_database_state"
|
||||
#define CONTENT_INDEX_DATABASE_STATE "content_index_database_state"
|
||||
#define INDEX_GENERATOR_NORMAL_EXIT "index_generator_normal_exit"
|
||||
|
||||
class LIBSEARCH_EXPORT GlobalSettings : public QObject
|
||||
{
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "file-utils.h"
|
||||
#include "index-generator.h"
|
||||
#include "chinesecharacterstopinyin.h"
|
||||
#include "global-settings.h"
|
||||
|
||||
#include <QtConcurrent>
|
||||
#include <QFuture>
|
||||
|
@ -57,9 +58,12 @@ bool IndexGenerator::creatAllIndex(QList<QVector<QString> > *messageList)
|
|||
}
|
||||
catch(const Xapian::Error &e)
|
||||
{
|
||||
qDebug()<<"creatAllIndex fail!"<<QString::fromStdString(e.get_description());
|
||||
qWarning()<<"creatAllIndex fail!"<<QString::fromStdString(e.get_description());
|
||||
//need a record
|
||||
GlobalSettings::getInstance()->setValue(INDEX_DATABASE_STATE,"0");
|
||||
return false;
|
||||
}
|
||||
GlobalSettings::getInstance()->setValue(INDEX_DATABASE_STATE,"1");
|
||||
m_doc_list_path->clear();
|
||||
Q_EMIT this->transactionFinished();
|
||||
|
||||
|
@ -86,9 +90,11 @@ bool IndexGenerator::creatAllIndex(QList<QString> *messageList)
|
|||
}
|
||||
catch(const Xapian::Error &e)
|
||||
{
|
||||
qDebug()<<"creat content Index fail!"<<QString::fromStdString(e.get_description());
|
||||
qWarning()<<"creat content Index fail!"<<QString::fromStdString(e.get_description());
|
||||
GlobalSettings::getInstance()->setValue(CONTENT_INDEX_DATABASE_STATE,"0");
|
||||
return false;
|
||||
}
|
||||
GlobalSettings::getInstance()->setValue(CONTENT_INDEX_DATABASE_STATE,"1");
|
||||
m_doc_list_content->clear();
|
||||
Q_EMIT this->transactionFinished();
|
||||
return true;
|
||||
|
@ -99,10 +105,16 @@ IndexGenerator::IndexGenerator(QObject *parent) : QObject(parent)
|
|||
{
|
||||
m_datebase_path = new Xapian::WritableDatabase(INDEX_PATH, Xapian::DB_CREATE_OR_OPEN);
|
||||
m_database_content = new Xapian::WritableDatabase(CONTENT_INDEX_PATH, Xapian::DB_CREATE_OR_OPEN);
|
||||
GlobalSettings::getInstance()->setValue(CONTENT_INDEX_DATABASE_STATE,"1");
|
||||
}
|
||||
|
||||
IndexGenerator::~IndexGenerator()
|
||||
{
|
||||
if(m_datebase_path)
|
||||
delete m_datebase_path;
|
||||
if(m_database_content)
|
||||
delete m_database_content;
|
||||
GlobalSettings::getInstance()->setValue(INDEX_GENERATOR_NORMAL_EXIT,"1");
|
||||
}
|
||||
|
||||
void IndexGenerator::insertIntoDatabase(Document doc)
|
||||
|
@ -329,7 +341,7 @@ bool IndexGenerator::deleteAllIndex(QStringList *pathlist)
|
|||
}
|
||||
catch(const Xapian::Error &e)
|
||||
{
|
||||
qDebug() <<QString::fromStdString(e.get_description());
|
||||
qWarning() <<QString::fromStdString(e.get_description());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ public Q_SLOTS:
|
|||
|
||||
private:
|
||||
explicit IndexGenerator(QObject *parent = nullptr);
|
||||
~IndexGenerator();
|
||||
//For file name index
|
||||
void HandlePathList(QList<QVector<QString>> *messageList);
|
||||
//For file content index
|
||||
|
@ -37,7 +38,6 @@ private:
|
|||
//add one data in database
|
||||
void insertIntoDatabase(Document doc);
|
||||
void insertIntoContentDatabase(Document doc);
|
||||
~IndexGenerator();
|
||||
|
||||
QMap<QString,QStringList> *m_index_map;
|
||||
QList<Document> *m_doc_list_path; //for path index
|
||||
|
|
Loading…
Reference in New Issue