Optimized search interface frame, add some annotation.

This commit is contained in:
iaom 2022-01-12 18:01:59 +08:00
parent cf20f35181
commit 0e3f594028
8 changed files with 24 additions and 7 deletions

View File

@ -20,6 +20,7 @@ Q_SIGNALS:
private:
explicit SearchTaskPluginManager(QObject *parent = nullptr);
//这里初衷是把内外部插件分开管理,内部插件可以增加枚举值,外部插件似乎只能用编写者自定义的字符串区分?
QHash<int, SearchTaskPluginIface*> m_buildinPlugin;
QHash<QString, SearchTaskPluginIface*> m_loadedPlugin;

View File

@ -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);

View File

@ -37,7 +37,9 @@ public:
private:
void copyData();
//TODO: 这里是否可以改为字节对齐的写法?
DataQueue<ResultItem>* m_dataQueue = nullptr ;
std::shared_ptr<DataQueue<ResultItem>> m_sharedDataueue = nullptr;
size_t m_searchId = 0;
QMutex m_searchIdMutex;
SearchController *q = nullptr;

View File

@ -4,8 +4,10 @@
#include <QDebug>
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<ResultItem> *SearchControllerPrivate::refreshDataqueue()
{
if(!m_dataQueue) {
m_dataQueue = new DataQueue<ResultItem>;
m_sharedDataueue = std::shared_ptr<DataQueue<ResultItem>>(m_dataQueue);
return m_dataQueue;
}
m_dataQueue->clear();
@ -34,6 +37,7 @@ DataQueue<ResultItem> *SearchControllerPrivate::initDataQueue()
{
if(!m_dataQueue) {
m_dataQueue = new DataQueue<ResultItem>;
m_sharedDataueue = std::shared_ptr<DataQueue<ResultItem>>(m_dataQueue);
return m_dataQueue;
}
return m_dataQueue;
@ -81,7 +85,7 @@ size_t SearchControllerPrivate::getCurrentSearchId()
DataQueue<ResultItem> *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();

View File

@ -9,6 +9,11 @@ namespace UkuiSearch {
class UkuiSearchTask;
class ResultItem;
class SearchControllerPrivate;
/*
*ID
*
*使
*/
class SearchController
{
friend class SearchControllerPrivate;

View File

@ -8,6 +8,9 @@
#include "search-controller.h"
#include "result-item.h"
namespace UkuiSearch {
/*
*
*/
class FileSearchTask : public SearchTaskPluginIface
{
Q_OBJECT

View File

@ -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()

View File

@ -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: