From cf20f35181f3ab6c80e91ea0b47bfdb14742d952 Mon Sep 17 00:00:00 2001 From: iaom Date: Tue, 11 Jan 2022 16:20:40 +0800 Subject: [PATCH 1/2] Add file search task plugin frame. --- .../searchinterface/result-item-private.h | 6 +- libsearch/searchinterface/result-item.cpp | 32 ++++- libsearch/searchinterface/result-item.h | 5 +- .../search-controller-private.h | 12 +- .../searchinterface/search-controller.cpp | 109 ++++++++++++++---- libsearch/searchinterface/search-controller.h | 12 +- .../searchtasks/file-search-task.cpp | 37 +++++- .../searchtasks/file-search-task.h | 23 +++- .../ukui-search-task-private.h | 6 +- .../searchinterface/ukui-search-task.cpp | 24 +++- libsearch/searchinterface/ukui-search-task.h | 2 + 11 files changed, 224 insertions(+), 44 deletions(-) diff --git a/libsearch/searchinterface/result-item-private.h b/libsearch/searchinterface/result-item-private.h index ae682ac..826c6ef 100644 --- a/libsearch/searchinterface/result-item-private.h +++ b/libsearch/searchinterface/result-item-private.h @@ -6,10 +6,12 @@ namespace UkuiSearch { class ResultItemPrivate { public: - explicit ResultItemPrivate(const QString &itemKey, ResultItem *parent); + explicit ResultItemPrivate(ResultItem *parent); ~ResultItemPrivate(); + void setSearchId(size_t searchId); + void setItemKey(QString itemKey); private: - size_t searchId; + size_t m_searchId; QString m_itemKey; QString m_label; QVariant m_extral; diff --git a/libsearch/searchinterface/result-item.cpp b/libsearch/searchinterface/result-item.cpp index 79ff90e..a7b9e34 100644 --- a/libsearch/searchinterface/result-item.cpp +++ b/libsearch/searchinterface/result-item.cpp @@ -1,18 +1,42 @@ #include "result-item.h" #include "result-item-private.h" using namespace UkuiSearch; -ResultItemPrivate::ResultItemPrivate::ResultItemPrivate(const QString &itemKey, ResultItem *parent) +ResultItemPrivate::ResultItemPrivate::ResultItemPrivate(ResultItem *parent) : q(parent) { - } ResultItemPrivate::~ResultItemPrivate() { } -ResultItem::ResultItem(const QString &itemKey) + +void ResultItemPrivate::setSearchId(size_t searchId) { - d = new ResultItemPrivate(itemKey, this); + m_searchId = searchId; +} + +void ResultItemPrivate::setItemKey(QString itemKey) +{ + m_itemKey = itemKey; +} +ResultItem::ResultItem() : d(new ResultItemPrivate(this)) +{ +} + +ResultItem::ResultItem(const size_t searchId) : d(new ResultItemPrivate(this)) +{ + d->setSearchId(searchId); +} + +ResultItem::ResultItem(const QString itemKey) : d(new ResultItemPrivate(this)) +{ + d->setItemKey(itemKey); +} + +ResultItem::ResultItem(const size_t searchId, const QString itemKey) +{ + d->setSearchId(searchId); + d->setItemKey(itemKey); } ResultItem::~ResultItem() diff --git a/libsearch/searchinterface/result-item.h b/libsearch/searchinterface/result-item.h index 3689692..be32ae3 100644 --- a/libsearch/searchinterface/result-item.h +++ b/libsearch/searchinterface/result-item.h @@ -8,7 +8,10 @@ class ResultItemPrivate; class ResultItem { public: - explicit ResultItem(const QString &itemKey); + explicit ResultItem(); + explicit ResultItem(const size_t searchId); + explicit ResultItem(const QString itemKey); + explicit ResultItem(const size_t searchId, const QString itemKey); ~ResultItem(); private: ResultItemPrivate *d; diff --git a/libsearch/searchinterface/search-controller-private.h b/libsearch/searchinterface/search-controller-private.h index c39b41a..706af3a 100644 --- a/libsearch/searchinterface/search-controller-private.h +++ b/libsearch/searchinterface/search-controller-private.h @@ -2,7 +2,6 @@ #define SEARCHCONTROLLERPRIVATE_H #include -#include #include "search-controller.h" namespace UkuiSearch { @@ -20,6 +19,8 @@ public: void addKeyword(QString &keyword); void setActiveKeywordSegmentation(bool active); void addFileLabel(QString &label); + void setOnlySearchFile(bool onlySearchFile); + void setOnlySearchDir(bool onlySearchDir); size_t getCurrentSearchId(); DataQueue* getDataQueue(); @@ -31,19 +32,24 @@ public: QStringList getKeyword(); bool isKeywordSegmentationActived(); QStringList getFileLabel(); + bool isSearchFileOnly(); + bool isSearchDirOnly(); private: + void copyData(); DataQueue* m_dataQueue = nullptr ; size_t m_searchId = 0; QMutex m_searchIdMutex; - SearchController *q; - QSharedPointer m_formerController; + SearchController *q = nullptr; + std::shared_ptr m_formerController = nullptr; QStringList m_keywords; QStringList m_searchDirs; QStringList m_FileLabels; bool m_recurse = true; bool m_activeKeywordSegmentation = false; + bool m_onlySearchFile = false; + bool m_onlySearchDir = false; }; } diff --git a/libsearch/searchinterface/search-controller.cpp b/libsearch/searchinterface/search-controller.cpp index 8ee243e..3d840ec 100644 --- a/libsearch/searchinterface/search-controller.cpp +++ b/libsearch/searchinterface/search-controller.cpp @@ -4,23 +4,12 @@ #include using namespace UkuiSearch; SearchControllerPrivate::SearchControllerPrivate(SearchController *parent) - : q(parent) + : q(parent), m_formerController(q->m_parent) { - if(q->m_parent) { - m_formerController = QSharedPointer(q->m_parent); - m_searchId = q->m_parent->d->m_searchId; - m_dataQueue = q->m_parent->d->m_dataQueue; - m_keywords = q->m_parent->d->m_keywords; - m_searchDirs = q->m_parent->d->m_searchDirs; - m_FileLabels = q->m_parent->d->m_FileLabels; - m_recurse = q->m_parent->d->m_recurse; - m_activeKeywordSegmentation = q->m_parent->d->m_activeKeywordSegmentation; - } } SearchControllerPrivate::~SearchControllerPrivate() { - m_formerController.clear(); } size_t SearchControllerPrivate::refreshSearchId() @@ -75,6 +64,16 @@ void SearchControllerPrivate::addFileLabel(QString &label) m_FileLabels.append(label); } +void SearchControllerPrivate::setOnlySearchFile(bool onlySearchFile) +{ + m_onlySearchFile = onlySearchFile; +} + +void SearchControllerPrivate::setOnlySearchDir(bool onlySearchDir) +{ + m_onlySearchDir = onlySearchDir; +} + size_t SearchControllerPrivate::getCurrentSearchId() { return m_searchId; @@ -112,30 +111,55 @@ void SearchControllerPrivate::stop() QStringList SearchControllerPrivate::getSearchDir() { - + return m_searchDirs; } bool SearchControllerPrivate::isRecurse() { - + return m_recurse; } QStringList SearchControllerPrivate::getKeyword() { - + return m_keywords; } bool SearchControllerPrivate::isKeywordSegmentationActived() { - + return m_activeKeywordSegmentation; } QStringList SearchControllerPrivate::getFileLabel() { - + return m_FileLabels; } -SearchController::SearchController(SearchController *parent) : m_parent(parent), d(new SearchControllerPrivate(this)) +bool SearchControllerPrivate::isSearchFileOnly() +{ + return m_onlySearchFile; +} + +bool SearchControllerPrivate::isSearchDirOnly() +{ + return m_onlySearchDir; +} + +void SearchControllerPrivate::copyData() +{ + if(m_formerController.get()) { + m_searchId = m_formerController.get()->getCurrentSearchId(); + m_dataQueue = m_formerController.get()->getDataQueue(); + m_keywords = m_formerController.get()->getKeyword(); + m_searchDirs = m_formerController.get()->getSearchDir(); + m_FileLabels = m_formerController.get()->getFileLabel(); + m_onlySearchFile = m_formerController.get()->isSearchFileOnly(); + m_onlySearchDir = m_formerController.get()->isSearchDirOnly(); + m_recurse = m_formerController.get()->isRecurse(); + m_activeKeywordSegmentation = m_formerController.get()->isKeywordSegmentationActived(); + } +} + +SearchController::SearchController(std::shared_ptr parent) : m_parent(parent), d(new SearchControllerPrivate(this)) { } @@ -176,7 +200,7 @@ void SearchController::addKeyword(QString &keyword) size_t SearchController::getCurrentSearchId() { - d->getCurrentSearchId(); + return d->getCurrentSearchId(); } DataQueue *SearchController::getDataQueue() @@ -194,6 +218,16 @@ void SearchController::addFileLabel(QString &label) d->addFileLabel(label); } +void SearchController::setOnlySearchFile(bool onlySearchFile) +{ + d->setOnlySearchFile(onlySearchFile); +} + +void SearchController::setOnlySearchDir(bool onlySearchDir) +{ + d->setOnlySearchDir(onlySearchDir); +} + bool SearchController::beginSearchIdCheck(size_t searchId) { return d->beginSearchIdCheck(searchId); @@ -201,7 +235,42 @@ bool SearchController::beginSearchIdCheck(size_t searchId) void SearchController::finishSearchIdCheck() { - d->finishSearchIdCheck(); + d->finishSearchIdCheck(); +} + +QStringList SearchController::getSearchDir() +{ + return d->getSearchDir(); +} + +bool SearchController::isRecurse() +{ + return d->isRecurse(); +} + +QStringList SearchController::getKeyword() +{ + return d->getKeyword(); +} + +bool SearchController::isKeywordSegmentationActived() +{ + return d->isKeywordSegmentationActived(); +} + +QStringList SearchController::getFileLabel() +{ + return d->getFileLabel(); +} + +bool SearchController::isSearchFileOnly() +{ + return d->isSearchFileOnly(); +} + +bool SearchController::isSearchDirOnly() +{ + return d->isSearchDirOnly(); } void SearchController::stop() diff --git a/libsearch/searchinterface/search-controller.h b/libsearch/searchinterface/search-controller.h index 1d19a4b..0efc16e 100644 --- a/libsearch/searchinterface/search-controller.h +++ b/libsearch/searchinterface/search-controller.h @@ -2,6 +2,7 @@ #define SEARCHCONTROLLER_H #include +#include #include "data-queue.h" //todo: url parser? namespace UkuiSearch { @@ -12,7 +13,7 @@ class SearchController { friend class SearchControllerPrivate; public: - explicit SearchController(SearchController *parent = nullptr); + explicit SearchController(std::shared_ptr parent = nullptr); ~SearchController(); DataQueue* refreshDataqueue(); size_t refreshSearchId(); @@ -24,6 +25,8 @@ public: void addKeyword(QString &keyword); void setActiveKeywordSegmentation(bool active); void addFileLabel(QString &label); + void setOnlySearchFile(bool onlySearchFile); + void setOnlySearchDir(bool onlySearchDir); //以上方法插件请不要调用 //以下方法插件可以调用 @@ -37,9 +40,12 @@ public: QStringList getKeyword(); bool isKeywordSegmentationActived(); QStringList getFileLabel(); + bool isSearchFileOnly(); + bool isSearchDirOnly(); private: - SearchControllerPrivate *d; - SearchController *m_parent; + std::shared_ptr m_parent = nullptr; + SearchControllerPrivate *d = nullptr; + }; } diff --git a/libsearch/searchinterface/searchtasks/file-search-task.cpp b/libsearch/searchinterface/searchtasks/file-search-task.cpp index a76aac7..4b9d70e 100644 --- a/libsearch/searchinterface/searchtasks/file-search-task.cpp +++ b/libsearch/searchinterface/searchtasks/file-search-task.cpp @@ -2,26 +2,30 @@ using namespace UkuiSearch; FileSearchTask::FileSearchTask(SearchController searchController): m_searchControl(searchController) { + m_pool = new QThreadPool(this); + m_pool->setMaxThreadCount(1); } const QString FileSearchTask::name() { - + return "File"; } const QString FileSearchTask::description() { - + return "File search."; } QString FileSearchTask::getCustomSearchType() { - + return "File"; } void FileSearchTask::startSearch(SearchController searchController) { - + FileSearchWorker *fileSearchWorker; + fileSearchWorker = new FileSearchWorker(this, searchController); + m_pool->start(fileSearchWorker); } void FileSearchTask::stop() @@ -29,6 +33,11 @@ void FileSearchTask::stop() } +void FileSearchTask::sendFinishSignal(size_t searchId) +{ + Q_EMIT searchFinished(searchId); +} + void FileSearchTask::run() { //file search, based on index or direct search? @@ -41,3 +50,23 @@ void FileSearchTask::run() m_searchControl.finishSearchIdCheck(); //finish } + +FileSearchWorker::FileSearchWorker(FileSearchTask *fileSarchTask, SearchController searchController) : m_FileSearchTask(fileSarchTask), m_searchController(searchController) +{ +} + +void FileSearchWorker::run() +{ + //TODO do search here + + size_t searchId = m_searchController.getCurrentSearchId(); + ResultItem ri(searchId); + if(m_searchController.beginSearchIdCheck(m_searchController.getCurrentSearchId())) { + m_searchController.getDataQueue()->enqueue(ri); + m_searchController.finishSearchIdCheck(); + } else { + m_searchController.finishSearchIdCheck(); + return; + } + QMetaObject::invokeMethod(m_FileSearchTask, "searchFinished", Q_ARG(size_t, searchId)); +} diff --git a/libsearch/searchinterface/searchtasks/file-search-task.h b/libsearch/searchinterface/searchtasks/file-search-task.h index 9e7f828..a83d610 100644 --- a/libsearch/searchinterface/searchtasks/file-search-task.h +++ b/libsearch/searchinterface/searchtasks/file-search-task.h @@ -1,8 +1,12 @@ #ifndef FILESEARCHTASK_H #define FILESEARCHTASK_H + +#include +#include +#include #include "search-task-plugin-iface.h" #include "search-controller.h" -#include +#include "result-item.h" namespace UkuiSearch { class FileSearchTask : public SearchTaskPluginIface { @@ -13,17 +17,30 @@ public: const QString name(); const QString description(); const QIcon icon() {return QIcon::fromTheme("folder");} - void setEnable(bool enable) {} - bool isEnable() {} + void setEnable() {} + bool isEnable() { return true;} SearchType getSearchType() {return SearchType::File;} QString getCustomSearchType(); void startSearch(SearchController searchController); void stop(); + Q_INVOKABLE void sendFinishSignal(size_t searchId); protected: void run(); private: SearchController m_searchControl; + QThreadPool *m_pool = nullptr; +}; + +class FileSearchWorker : public QRunnable +{ +public: + explicit FileSearchWorker(FileSearchTask *fileSarchTask, SearchController searchController); +protected: + void run(); +private: + FileSearchTask *m_FileSearchTask; + SearchController m_searchController; }; } #endif // FILESEARCHTASK_H diff --git a/libsearch/searchinterface/ukui-search-task-private.h b/libsearch/searchinterface/ukui-search-task-private.h index f2bfa10..10ddd13 100644 --- a/libsearch/searchinterface/ukui-search-task-private.h +++ b/libsearch/searchinterface/ukui-search-task-private.h @@ -4,7 +4,7 @@ #include "ukui-search-task.h" #include #include -#include +#include #include "data-queue.h" #include "search-controller.h" @@ -20,12 +20,14 @@ public: void setRecurse(bool recurse = true); void addKeyword(QString &keyword); void addFileLabel(QString &label); + void setOnlySearchFile(bool onlySearchFile); + void setOnlySearchDir(bool onlySearchDir); void setSearchOnlineApps(bool searchOnlineApps); size_t startSearch(SearchType searchtype, QString customSearchType = QString()); void stop(); private: - SearchController* m_searchCotroller; + std::shared_ptr m_searchCotroller = nullptr; size_t m_searchId = 0; UkuiSearchTask* q = nullptr; diff --git a/libsearch/searchinterface/ukui-search-task.cpp b/libsearch/searchinterface/ukui-search-task.cpp index 9a9e676..7cc6179 100644 --- a/libsearch/searchinterface/ukui-search-task.cpp +++ b/libsearch/searchinterface/ukui-search-task.cpp @@ -7,7 +7,7 @@ UkuiSearchTaskPrivate::UkuiSearchTaskPrivate(UkuiSearchTask *parent) : QObject(parent), q(parent) { - m_searchCotroller = new SearchController(); + m_searchCotroller = std::shared_ptr(new SearchController()); } UkuiSearchTaskPrivate::~UkuiSearchTaskPrivate() @@ -40,6 +40,16 @@ void UkuiSearchTaskPrivate::addFileLabel(QString &label) m_searchCotroller->addFileLabel(label); } +void UkuiSearchTaskPrivate::setOnlySearchFile(bool onlySearchFile) +{ + m_searchCotroller->setOnlySearchFile(onlySearchFile); +} + +void UkuiSearchTaskPrivate::setOnlySearchDir(bool onlySearchDir) +{ + m_searchCotroller->setOnlySearchDir(onlySearchDir); +} + void UkuiSearchTaskPrivate::setSearchOnlineApps(bool searchOnlineApps) { } @@ -79,7 +89,7 @@ UkuiSearchTask::~UkuiSearchTask() DataQueue *UkuiSearchTask::init() { - d->init(); + return d->init(); } void UkuiSearchTask::addSearchDir(QString &path) @@ -102,6 +112,16 @@ void UkuiSearchTask::addFileLabel(QString &label) d->addFileLabel(label); } +void UkuiSearchTask::setOnlySearchFile(bool onlySearchFile) +{ + d->setOnlySearchFile(onlySearchFile); +} + +void UkuiSearchTask::setOnlySearchDir(bool onlySearchDir) +{ + d->setOnlySearchDir(onlySearchDir); +} + void UkuiSearchTask::setSearchOnlineApps(bool searchOnlineApps) { d->setSearchOnlineApps(searchOnlineApps); diff --git a/libsearch/searchinterface/ukui-search-task.h b/libsearch/searchinterface/ukui-search-task.h index 642f671..ad15a42 100644 --- a/libsearch/searchinterface/ukui-search-task.h +++ b/libsearch/searchinterface/ukui-search-task.h @@ -17,6 +17,8 @@ public: void setRecurse(bool recurse = true); void addKeyword(QString &keyword); void addFileLabel(QString &label); + void setOnlySearchFile(bool onlySearchFile); + void setOnlySearchDir(bool onlySearchDir); void setSearchOnlineApps(bool searchOnlineApps); size_t startSearch(SearchType searchtype, QString customSearchTYpe = QString()); void stop(); From 0e3f59402840cc5a63d48a40110605d2d3ac35f4 Mon Sep 17 00:00:00 2001 From: iaom Date: Wed, 12 Jan 2022 18:01:59 +0800 Subject: [PATCH 2/2] Optimized search interface frame, add some annotation. --- libsearch/pluginmanage/search-task-plugin-manager.h | 1 + libsearch/searchinterface/result-item.cpp | 2 +- .../searchinterface/search-controller-private.h | 2 ++ libsearch/searchinterface/search-controller.cpp | 12 +++++++++--- libsearch/searchinterface/search-controller.h | 5 +++++ .../searchinterface/searchtasks/file-search-task.h | 3 +++ libsearch/searchinterface/ukui-search-task.cpp | 4 ++-- libsearch/searchinterface/ukui-search-task.h | 2 +- 8 files changed, 24 insertions(+), 7 deletions(-) diff --git a/libsearch/pluginmanage/search-task-plugin-manager.h b/libsearch/pluginmanage/search-task-plugin-manager.h index dcee0bb..0435b21 100644 --- a/libsearch/pluginmanage/search-task-plugin-manager.h +++ b/libsearch/pluginmanage/search-task-plugin-manager.h @@ -20,6 +20,7 @@ Q_SIGNALS: private: explicit SearchTaskPluginManager(QObject *parent = nullptr); + //这里初衷是把内外部插件分开管理,内部插件可以增加枚举值,外部插件似乎只能用编写者自定义的字符串区分? QHash m_buildinPlugin; QHash m_loadedPlugin; diff --git a/libsearch/searchinterface/result-item.cpp b/libsearch/searchinterface/result-item.cpp index a7b9e34..5910a50 100644 --- a/libsearch/searchinterface/result-item.cpp +++ b/libsearch/searchinterface/result-item.cpp @@ -33,7 +33,7 @@ ResultItem::ResultItem(const QString itemKey) : d(new ResultItemPrivate(this)) d->setItemKey(itemKey); } -ResultItem::ResultItem(const size_t searchId, const QString itemKey) +ResultItem::ResultItem(const size_t searchId, const QString itemKey) : d(new ResultItemPrivate(this)) { d->setSearchId(searchId); d->setItemKey(itemKey); diff --git a/libsearch/searchinterface/search-controller-private.h b/libsearch/searchinterface/search-controller-private.h index 706af3a..7fae89c 100644 --- a/libsearch/searchinterface/search-controller-private.h +++ b/libsearch/searchinterface/search-controller-private.h @@ -37,7 +37,9 @@ public: private: void copyData(); + //TODO: 这里是否可以改为字节对齐的写法? DataQueue* m_dataQueue = nullptr ; + std::shared_ptr> m_sharedDataueue = nullptr; size_t m_searchId = 0; QMutex m_searchIdMutex; SearchController *q = nullptr; diff --git a/libsearch/searchinterface/search-controller.cpp b/libsearch/searchinterface/search-controller.cpp index 3d840ec..aa3d47a 100644 --- a/libsearch/searchinterface/search-controller.cpp +++ b/libsearch/searchinterface/search-controller.cpp @@ -4,8 +4,10 @@ #include using namespace UkuiSearch; SearchControllerPrivate::SearchControllerPrivate(SearchController *parent) - : q(parent), m_formerController(q->m_parent) + : q(parent), + m_formerController(q->m_parent) //如果构造参数里包含父节点智能指针,则子节点带有一个智能指针指向父节点 { + copyData(); } SearchControllerPrivate::~SearchControllerPrivate() @@ -24,6 +26,7 @@ DataQueue *SearchControllerPrivate::refreshDataqueue() { if(!m_dataQueue) { m_dataQueue = new DataQueue; + m_sharedDataueue = std::shared_ptr>(m_dataQueue); return m_dataQueue; } m_dataQueue->clear(); @@ -34,6 +37,7 @@ DataQueue *SearchControllerPrivate::initDataQueue() { if(!m_dataQueue) { m_dataQueue = new DataQueue; + m_sharedDataueue = std::shared_ptr>(m_dataQueue); return m_dataQueue; } return m_dataQueue; @@ -81,7 +85,7 @@ size_t SearchControllerPrivate::getCurrentSearchId() DataQueue *SearchControllerPrivate::getDataQueue() { - return m_dataQueue; + return m_sharedDataueue.get(); } bool SearchControllerPrivate::beginSearchIdCheck(size_t searchId) @@ -146,9 +150,11 @@ bool SearchControllerPrivate::isSearchDirOnly() void SearchControllerPrivate::copyData() { + if(m_formerController.get()) { m_searchId = m_formerController.get()->getCurrentSearchId(); - m_dataQueue = m_formerController.get()->getDataQueue(); + //所有子节点都有一个指向根节点的队列的智能指针 + m_sharedDataueue = m_formerController.get()->d->m_sharedDataueue; m_keywords = m_formerController.get()->getKeyword(); m_searchDirs = m_formerController.get()->getSearchDir(); m_FileLabels = m_formerController.get()->getFileLabel(); diff --git a/libsearch/searchinterface/search-controller.h b/libsearch/searchinterface/search-controller.h index 0efc16e..866dbad 100644 --- a/libsearch/searchinterface/search-controller.h +++ b/libsearch/searchinterface/search-controller.h @@ -9,6 +9,11 @@ namespace UkuiSearch { class UkuiSearchTask; class ResultItem; class SearchControllerPrivate; +/* + *搜索控制,用于传递搜索条件,搜索唯一ID,以及管理队列等。 + *为树形结构,所有子节点含有智能指针指向父节点。 + *只要有插件还在使用资源,其对应的子节点以及通向根节点上所有的实例就不会被释放,析构时,从下往上由智能指针自动析构 + */ class SearchController { friend class SearchControllerPrivate; diff --git a/libsearch/searchinterface/searchtasks/file-search-task.h b/libsearch/searchinterface/searchtasks/file-search-task.h index a83d610..5323b13 100644 --- a/libsearch/searchinterface/searchtasks/file-search-task.h +++ b/libsearch/searchinterface/searchtasks/file-search-task.h @@ -8,6 +8,9 @@ #include "search-controller.h" #include "result-item.h" namespace UkuiSearch { +/* + * 这里只写了大概框架,具体逻辑未实现,可以当成伪代码参考。 +*/ class FileSearchTask : public SearchTaskPluginIface { Q_OBJECT diff --git a/libsearch/searchinterface/ukui-search-task.cpp b/libsearch/searchinterface/ukui-search-task.cpp index 7cc6179..acdd2b0 100644 --- a/libsearch/searchinterface/ukui-search-task.cpp +++ b/libsearch/searchinterface/ukui-search-task.cpp @@ -127,9 +127,9 @@ void UkuiSearchTask::setSearchOnlineApps(bool searchOnlineApps) d->setSearchOnlineApps(searchOnlineApps); } -size_t UkuiSearchTask::startSearch(SearchType searchtype, QString customSearchTYpe) +size_t UkuiSearchTask::startSearch(SearchType searchtype, QString customSearchType) { - return d->startSearch(searchtype, customSearchTYpe); + return d->startSearch(searchtype, customSearchType); } void UkuiSearchTask::stop() diff --git a/libsearch/searchinterface/ukui-search-task.h b/libsearch/searchinterface/ukui-search-task.h index ad15a42..6f6fc9e 100644 --- a/libsearch/searchinterface/ukui-search-task.h +++ b/libsearch/searchinterface/ukui-search-task.h @@ -20,7 +20,7 @@ public: void setOnlySearchFile(bool onlySearchFile); void setOnlySearchDir(bool onlySearchDir); void setSearchOnlineApps(bool searchOnlineApps); - size_t startSearch(SearchType searchtype, QString customSearchTYpe = QString()); + size_t startSearch(SearchType searchtype, QString customSearchType = QString()); void stop(); Q_SIGNALS: