diff --git a/libsearch/global-settings.cpp b/libsearch/global-settings.cpp index 431c097..50b5765 100644 --- a/libsearch/global-settings.cpp +++ b/libsearch/global-settings.cpp @@ -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); diff --git a/libsearch/global-settings.h b/libsearch/global-settings.h index c943df7..4a3e3d6 100644 --- a/libsearch/global-settings.h +++ b/libsearch/global-settings.h @@ -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 { diff --git a/libsearch/index/index-generator.cpp b/libsearch/index/index-generator.cpp index e63ed88..f8aa88d 100644 --- a/libsearch/index/index-generator.cpp +++ b/libsearch/index/index-generator.cpp @@ -6,6 +6,7 @@ #include "file-utils.h" #include "index-generator.h" #include "chinesecharacterstopinyin.h" +#include "global-settings.h" #include #include @@ -57,9 +58,12 @@ bool IndexGenerator::creatAllIndex(QList > *messageList) } catch(const Xapian::Error &e) { - qDebug()<<"creatAllIndex fail!"<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 *messageList) } catch(const Xapian::Error &e) { - qDebug()<<"creat content Index fail!"<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() <> *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 *m_index_map; QList *m_doc_list_path; //for path index