mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 13:36:48 +08:00
70 lines
2.1 KiB
C++
70 lines
2.1 KiB
C++
/* Copyright (C) 2016
|
|
* swift Project Community / Contributors
|
|
*
|
|
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
|
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
|
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
|
* contained in the LICENSE file.
|
|
*/
|
|
|
|
#include "pluginmanagerweatherdata.h"
|
|
#include "weatherdata.h"
|
|
#include <QStringBuilder>
|
|
#include <QCoreApplication>
|
|
|
|
namespace BlackCore
|
|
{
|
|
|
|
using namespace BlackMisc;
|
|
|
|
CPluginManagerWeatherData::CPluginManagerWeatherData(QObject *parent) : IPluginManager(parent)
|
|
{
|
|
}
|
|
|
|
IWeatherDataFactory *CPluginManagerWeatherData::getFactory(const QString &pluginId)
|
|
{
|
|
return getPluginById<IWeatherDataFactory>(pluginId);
|
|
}
|
|
|
|
Weather::CWeatherDataPluginInfoList CPluginManagerWeatherData::getAvailableWeatherDataPlugins() const
|
|
{
|
|
BlackMisc::Weather::CWeatherDataPluginInfoList list;
|
|
for (const auto &i : m_plugins.values())
|
|
{
|
|
list.push_back(i.info);
|
|
}
|
|
return list;
|
|
}
|
|
|
|
void CPluginManagerWeatherData::collectPlugins()
|
|
{
|
|
IPluginManager::collectPlugins();
|
|
|
|
const CSequence<QJsonObject> &plugins = getPlugins();
|
|
for (const QJsonObject &json : plugins)
|
|
{
|
|
QString iid = json["IID"].toString();
|
|
if (iid == QStringLiteral("org.swift-project.blackcore.weatherdata"))
|
|
{
|
|
// PluginExtended() instead of {} to silence wrong warning for gcc < 5.X
|
|
auto it = m_plugins.insert(pluginIdentifier(json), PluginExtended());
|
|
it->info.convertFromJson(json);
|
|
}
|
|
}
|
|
}
|
|
|
|
BlackMisc::CSequence<QString> CPluginManagerWeatherData::acceptedIids() const
|
|
{
|
|
return
|
|
{
|
|
QStringLiteral("org.swift-project.blackcore.weatherdata")
|
|
};
|
|
}
|
|
|
|
QString CPluginManagerWeatherData::pluginDirectory() const
|
|
{
|
|
return qApp->applicationDirPath() % QStringLiteral("/plugins/weatherdata");
|
|
}
|
|
|
|
}
|