ukui-search/libsearch/searchinterface/ukui-search-task.cpp

139 lines
3.1 KiB
C++
Raw Normal View History

2021-12-28 15:56:41 +08:00
#include "ukui-search-task.h"
#include "ukui-search-task-private.h"
2021-12-31 17:38:02 +08:00
#include "search-task-plugin-manager.h"
2021-12-28 15:56:41 +08:00
#include <QDebug>
using namespace UkuiSearch;
UkuiSearchTaskPrivate::UkuiSearchTaskPrivate(UkuiSearchTask *parent)
: QObject(parent),
q(parent)
{
2022-01-11 16:20:40 +08:00
m_searchCotroller = std::shared_ptr<SearchController>(new SearchController());
2021-12-28 15:56:41 +08:00
}
UkuiSearchTaskPrivate::~UkuiSearchTaskPrivate()
{
this->stop();
}
DataQueue<ResultItem> *UkuiSearchTaskPrivate::init()
{
return m_searchCotroller->initDataQueue();
}
void UkuiSearchTaskPrivate::addSearchDir(QString &path)
{
m_searchCotroller->addSearchDir(path);
}
void UkuiSearchTaskPrivate::setRecurse(bool recurse)
{
m_searchCotroller->setRecurse(recurse);
}
void UkuiSearchTaskPrivate::addKeyword(QString &keyword)
{
m_searchCotroller->addKeyword(keyword);
}
void UkuiSearchTaskPrivate::addFileLabel(QString &label)
{
m_searchCotroller->addFileLabel(label);
}
2022-01-11 16:20:40 +08:00
void UkuiSearchTaskPrivate::setOnlySearchFile(bool onlySearchFile)
{
m_searchCotroller->setOnlySearchFile(onlySearchFile);
}
void UkuiSearchTaskPrivate::setOnlySearchDir(bool onlySearchDir)
{
m_searchCotroller->setOnlySearchDir(onlySearchDir);
}
2021-12-28 15:56:41 +08:00
void UkuiSearchTaskPrivate::setSearchOnlineApps(bool searchOnlineApps)
{
}
2021-12-31 17:38:02 +08:00
size_t UkuiSearchTaskPrivate::startSearch(SearchType searchtype, QString customSearchType)
2021-12-28 15:56:41 +08:00
{
m_searchId = m_searchCotroller->refreshSearchId();
2021-12-31 17:38:02 +08:00
if(m_searchCotroller->getDataQueue() == nullptr) {
qWarning() << "the date queue has not been initialized, you need run init first!";
}
2021-12-28 15:56:41 +08:00
//plugin manager do async search here
2021-12-31 17:38:02 +08:00
if(SearchType::Custom != searchtype) {
SearchTaskPluginManager::getInstance()->pluginSearch(searchtype, SearchController(m_searchCotroller));
} else {
SearchTaskPluginManager::getInstance()->pluginSearch(customSearchType, SearchController(m_searchCotroller));
}
2021-12-28 15:56:41 +08:00
return m_searchId;
}
void UkuiSearchTaskPrivate::stop()
{
m_searchCotroller->stop();
}
UkuiSearchTask::UkuiSearchTask(QObject *parent) : QObject(parent), d(new UkuiSearchTaskPrivate(this))
{
connect(d, &UkuiSearchTaskPrivate::searchFinished, this, &UkuiSearchTask::searchFinished);
}
UkuiSearchTask::~UkuiSearchTask()
{
}
DataQueue<ResultItem> *UkuiSearchTask::init()
{
2022-01-11 16:20:40 +08:00
return d->init();
2021-12-28 15:56:41 +08:00
}
void UkuiSearchTask::addSearchDir(QString &path)
{
d->addSearchDir(path);
}
void UkuiSearchTask::setRecurse(bool recurse)
{
d->setRecurse(recurse);
}
void UkuiSearchTask::addKeyword(QString &keyword)
{
d->addKeyword(keyword);
}
void UkuiSearchTask::addFileLabel(QString &label)
{
d->addFileLabel(label);
}
2022-01-11 16:20:40 +08:00
void UkuiSearchTask::setOnlySearchFile(bool onlySearchFile)
{
d->setOnlySearchFile(onlySearchFile);
}
void UkuiSearchTask::setOnlySearchDir(bool onlySearchDir)
{
d->setOnlySearchDir(onlySearchDir);
}
2021-12-28 15:56:41 +08:00
void UkuiSearchTask::setSearchOnlineApps(bool searchOnlineApps)
{
d->setSearchOnlineApps(searchOnlineApps);
}
size_t UkuiSearchTask::startSearch(SearchType searchtype, QString customSearchType)
2021-12-28 15:56:41 +08:00
{
return d->startSearch(searchtype, customSearchType);
2021-12-28 15:56:41 +08:00
}
void UkuiSearchTask::stop()
{
d->stop();
}