diff --git a/data/org.ukui.search.data.gschema.xml b/data/org.ukui.search.data.gschema.xml index f4f0158..8186bbc 100644 --- a/data/org.ukui.search.data.gschema.xml +++ b/data/org.ukui.search.data.gschema.xml @@ -1,9 +1,9 @@ - + false - search method - Is current search-method index-search. + file index switch + Enable or disable file index service. "baidu" diff --git a/frontend/mainwindow.cpp b/frontend/mainwindow.cpp index f5f4a5c..4fa5f45 100644 --- a/frontend/mainwindow.cpp +++ b/frontend/mainwindow.cpp @@ -39,7 +39,7 @@ #define MAIN_MARGINS 0, 0, 0, 0 #define TITLE_MARGINS 0,0,0,0 #define UKUI_SEARCH_SCHEMAS "org.ukui.search.settings" -#define SEARCH_METHOD_KEY "indexSearch" +#define SEARCH_METHOD_KEY "file-index-enable" #define WEB_ENGINE_KEY "webEngine" #define WINDOW_WIDTH 700 #define WINDOW_HEIGHT 610 diff --git a/libsearch/index/search-method-manager.cpp b/libsearch/index/file-index-manager.cpp similarity index 81% rename from libsearch/index/search-method-manager.cpp rename to libsearch/index/file-index-manager.cpp index e045b62..f41121d 100644 --- a/libsearch/index/search-method-manager.cpp +++ b/libsearch/index/file-index-manager.cpp @@ -1,21 +1,21 @@ -#include "search-method-manager.h" +#include "file-index-manager.h" using namespace UkuiSearch; -static SearchMethodManager* global_instance = nullptr; -SearchMethodManager::SearchMethodManager() : m_semaphore(INDEX_SEM, 1, QSystemSemaphore::AccessMode::Create) +static FileIndexManager* global_instance = nullptr; +FileIndexManager::FileIndexManager(QObject *parent) : QObject(parent), m_semaphore(INDEX_SEM, 1, QSystemSemaphore::AccessMode::Create) { m_fi = FirstIndex::getInstance(); m_iw = InotifyWatch::getInstance(); } -SearchMethodManager *SearchMethodManager::getInstance() +FileIndexManager *FileIndexManager::getInstance() { if(!global_instance) { - global_instance = new SearchMethodManager(); + global_instance = new FileIndexManager(); } return global_instance; } -void SearchMethodManager::searchMethod(FileUtils::SearchMethod sm) { +void FileIndexManager::searchMethod(FileUtils::SearchMethod sm) { qWarning() << "searchMethod start: " << static_cast(sm); if(FileUtils::SearchMethod::INDEXSEARCH == sm || FileUtils::SearchMethod::DIRECTSEARCH == sm) { FileUtils::searchMethod = sm; diff --git a/libsearch/index/search-method-manager.h b/libsearch/index/file-index-manager.h similarity index 71% rename from libsearch/index/search-method-manager.h rename to libsearch/index/file-index-manager.h index 5d07698..fa411f1 100644 --- a/libsearch/index/search-method-manager.h +++ b/libsearch/index/file-index-manager.h @@ -1,17 +1,19 @@ #ifndef SEARCHMETHODMANAGER_H #define SEARCHMETHODMANAGER_H +#include #include #include "first-index.h" //#include "inotify-index.h" #include "inotify-watch.h" namespace UkuiSearch { -class SearchMethodManager { +class FileIndexManager : public QObject { + Q_OBJECT public: - static SearchMethodManager *getInstance(); + static FileIndexManager *getInstance(); void searchMethod(FileUtils::SearchMethod sm); private: - SearchMethodManager(); + FileIndexManager(QObject *parent = nullptr); FirstIndex *m_fi; // InotifyIndex* m_ii; InotifyWatch *m_iw = nullptr; diff --git a/libsearch/index/index.pri b/libsearch/index/index.pri index cfae419..e974b47 100644 --- a/libsearch/index/index.pri +++ b/libsearch/index/index.pri @@ -13,13 +13,14 @@ HEADERS += \ $$PWD/pending-file-queue.h \ $$PWD/pending-file.h \ $$PWD/search-manager.h \ - $$PWD/search-method-manager.h \ + $$PWD/file-index-manager.h \ $$PWD/traverse_bfs.h \ $$PWD/ukui-search-qdbus.h SOURCES += \ $$PWD/construct-document.cpp \ $$PWD/document.cpp \ + $$PWD/file-index-manager.cpp \ $$PWD/file-reader.cpp \ $$PWD/file-search-plugin.cpp \ $$PWD/first-index.cpp \ @@ -30,7 +31,6 @@ SOURCES += \ $$PWD/pending-file-queue.cpp \ $$PWD/pending-file.cpp \ $$PWD/search-manager.cpp \ - $$PWD/search-method-manager.cpp \ $$PWD/traverse_bfs.cpp \ $$PWD/ukui-search-qdbus.cpp diff --git a/libsearch/libsearch.h b/libsearch/libsearch.h index 92eb6f8..a47d520 100644 --- a/libsearch/libsearch.h +++ b/libsearch/libsearch.h @@ -27,7 +27,7 @@ #include "plugininterface/search-plugin-iface.h" #include "plugininterface/data-queue.h" -#include "index/search-method-manager.h" +#include "index/file-index-manager.h" #include "index/first-index.h" #include "index/ukui-search-qdbus.h" #include "index/search-manager.h" diff --git a/search-ukcc-plugin/search.h b/search-ukcc-plugin/search.h index 1124af3..1172b16 100644 --- a/search-ukcc-plugin/search.h +++ b/search-ukcc-plugin/search.h @@ -22,7 +22,7 @@ #include #define UKUI_SEARCH_SCHEMAS "org.ukui.search.settings" -#define SEARCH_METHOD_KEY "indexSearch" +#define SEARCH_METHOD_KEY "file-index-enable" #define WEB_ENGINE_KEY "webEngine" //TODO #define CONFIG_FILE "/.config/org.ukui/ukui-search/ukui-search-block-dirs.conf" diff --git a/ukui-search-service/ukui-search-service.cpp b/ukui-search-service/ukui-search-service.cpp index 189be33..aa5d91f 100644 --- a/ukui-search-service/ukui-search-service.cpp +++ b/ukui-search-service/ukui-search-service.cpp @@ -2,7 +2,7 @@ #include "ukui-search-service.h" #include "dir-watcher.h" #define UKUI_SEARCH_SCHEMAS "org.ukui.search.settings" -#define SEARCH_METHOD_KEY "indexSearch" +#define SEARCH_METHOD_KEY "file-index-enable" using namespace UkuiSearch; UkuiSearchService::UkuiSearchService(int &argc, char *argv[], const QString &applicationName): QtSingleApplication (applicationName, argc, argv) { @@ -96,7 +96,8 @@ void UkuiSearchService::setSearchMethodByGsettings() } else { FileUtils::searchMethod = FileUtils::SearchMethod::DIRECTSEARCH; } - SearchMethodManager::getInstance()->searchMethod(FileUtils::searchMethod); + FileIndexManager::getInstance()->searchMethod(FileUtils::searchMethod); + } void UkuiSearchService::indexServiceSwitch(bool startIndex) @@ -106,7 +107,7 @@ void UkuiSearchService::indexServiceSwitch(bool startIndex) } else { FileUtils::searchMethod = FileUtils::SearchMethod::DIRECTSEARCH; } - SearchMethodManager::getInstance()->searchMethod(FileUtils::searchMethod); + FileIndexManager::getInstance()->searchMethod(FileUtils::searchMethod); const QByteArray id(UKUI_SEARCH_SCHEMAS); if(QGSettings::isSchemaInstalled(id)) { diff --git a/ukui-search-service/ukui-search-service.h b/ukui-search-service/ukui-search-service.h index 562756d..a9c13a9 100644 --- a/ukui-search-service/ukui-search-service.h +++ b/ukui-search-service/ukui-search-service.h @@ -5,7 +5,7 @@ #include #include #include "qtsingleapplication.h" -#include "search-method-manager.h" +#include "file-index-manager.h" #include "common.h" namespace UkuiSearch {