ukui-search/libsearch/pluginmanage/search-plugin-manager.cpp

53 lines
1.1 KiB
C++
Raw Normal View History

2021-05-28 10:16:28 +08:00
#include <QDebug>
2021-05-03 00:21:36 +08:00
#include "search-plugin-manager.h"
2021-05-27 21:10:11 +08:00
#include "file-search-plugin.h"
2021-06-17 14:08:55 +08:00
#include "app-search-plugin.h"-
2021-05-03 00:21:36 +08:00
using namespace Zeeker;
static SearchPluginManager *global_instance = nullptr;
2021-05-27 21:10:11 +08:00
SearchPluginManager::SearchPluginManager(QObject *parent)
{
registerPlugin(new FileSearchPlugin(this));
registerPlugin(new DirSearchPlugin(this));
registerPlugin(new FileContengSearchPlugin(this));
2021-06-17 14:08:55 +08:00
registerPlugin(new AppSearchPlugin(this));
2021-05-27 21:10:11 +08:00
}
2021-05-03 00:21:36 +08:00
bool SearchPluginManager::registerPlugin(Zeeker::SearchPluginIface *plugin)
{
if (m_hash.value(plugin->name())) {
return false;
}
m_hash.insert(plugin->name(), plugin);
return true;
}
SearchPluginManager *SearchPluginManager::getInstance()
{
if (!global_instance) {
global_instance = new SearchPluginManager;
}
return global_instance;
}
const QStringList SearchPluginManager::getPluginIds()
{
return m_hash.keys();
}
SearchPluginIface *SearchPluginManager::getPlugin(const QString &pluginId)
{
return m_hash.value(pluginId);
}
void SearchPluginManager::close()
{
this->deleteLater();
}
2021-05-06 20:23:36 +08:00
SearchPluginManager::~SearchPluginManager()
{
m_hash.clear();
}