summaryrefslogtreecommitdiffstats
path: root/common/resource.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'common/resource.cpp')
-rw-r--r--common/resource.cpp29
1 files changed, 12 insertions, 17 deletions
diff --git a/common/resource.cpp b/common/resource.cpp
index 5cbb2f2..6713686 100644
--- a/common/resource.cpp
+++ b/common/resource.cpp
@@ -27,19 +27,16 @@
27 27
28#include "facadefactory.h" 28#include "facadefactory.h"
29 29
30namespace Sink 30namespace Sink {
31{
32 31
33Resource::Resource() 32Resource::Resource() : QObject(), d(0)
34 : QObject(),
35 d(0)
36{ 33{
37 Q_UNUSED(d); 34 Q_UNUSED(d);
38} 35}
39 36
40Resource::~Resource() 37Resource::~Resource()
41{ 38{
42 //delete d; 39 // delete d;
43} 40}
44 41
45void Resource::processCommand(int commandId, const QByteArray &data) 42void Resource::processCommand(int commandId, const QByteArray &data)
@@ -71,21 +68,19 @@ void Resource::removeDataFromDisk()
71class ResourceFactory::Private 68class ResourceFactory::Private
72{ 69{
73public: 70public:
74 static QHash<QString, QPointer<ResourceFactory> > s_loadedFactories; 71 static QHash<QString, QPointer<ResourceFactory>> s_loadedFactories;
75}; 72};
76 73
77QHash<QString, QPointer<ResourceFactory> > ResourceFactory::Private::s_loadedFactories; 74QHash<QString, QPointer<ResourceFactory>> ResourceFactory::Private::s_loadedFactories;
78 75
79ResourceFactory::ResourceFactory(QObject *parent) 76ResourceFactory::ResourceFactory(QObject *parent) : QObject(parent), d(0)
80 : QObject(parent),
81 d(0)
82{ 77{
83 Q_UNUSED(d); 78 Q_UNUSED(d);
84} 79}
85 80
86ResourceFactory::~ResourceFactory() 81ResourceFactory::~ResourceFactory()
87{ 82{
88 //delete d; 83 // delete d;
89} 84}
90 85
91ResourceFactory *ResourceFactory::load(const QString &resourceName) 86ResourceFactory *ResourceFactory::load(const QString &resourceName)
@@ -95,15 +90,15 @@ ResourceFactory *ResourceFactory::load(const QString &resourceName)
95 return factory; 90 return factory;
96 } 91 }
97 92
98 for (auto const &path: QCoreApplication::instance()->libraryPaths()) { 93 for (auto const &path : QCoreApplication::instance()->libraryPaths()) {
99 if (path.endsWith(QLatin1String("plugins"))) { 94 if (path.endsWith(QLatin1String("plugins"))) {
100 QDir pluginDir(path); 95 QDir pluginDir(path);
101 //TODO: centralize this so that it is easy to change centrally 96 // TODO: centralize this so that it is easy to change centrally
102 // also ref'd in cmake as ${SINK_RESOURCE_PLUGINS_PATH} 97 // also ref'd in cmake as ${SINK_RESOURCE_PLUGINS_PATH}
103 pluginDir.cd(QStringLiteral("sink")); 98 pluginDir.cd(QStringLiteral("sink"));
104 pluginDir.cd(QStringLiteral("resources")); 99 pluginDir.cd(QStringLiteral("resources"));
105 100
106 for (const QString &fileName: pluginDir.entryList(QDir::Files)) { 101 for (const QString &fileName : pluginDir.entryList(QDir::Files)) {
107 const QString path = pluginDir.absoluteFilePath(fileName); 102 const QString path = pluginDir.absoluteFilePath(fileName);
108 QPluginLoader loader(path); 103 QPluginLoader loader(path);
109 104
@@ -115,7 +110,7 @@ ResourceFactory *ResourceFactory::load(const QString &resourceName)
115 if (factory) { 110 if (factory) {
116 Private::s_loadedFactories.insert(resourceName, factory); 111 Private::s_loadedFactories.insert(resourceName, factory);
117 factory->registerFacades(FacadeFactory::instance()); 112 factory->registerFacades(FacadeFactory::instance());
118 //TODO: if we need more data on it const QJsonObject json = loader.metaData()[QStringLiteral("MetaData")].toObject(); 113 // TODO: if we need more data on it const QJsonObject json = loader.metaData()[QStringLiteral("MetaData")].toObject();
119 return factory; 114 return factory;
120 } else { 115 } else {
121 qWarning() << "Plugin for" << resourceName << "from plugin" << loader.fileName() << "produced the wrong object type:" << object; 116 qWarning() << "Plugin for" << resourceName << "from plugin" << loader.fileName() << "produced the wrong object type:" << object;
@@ -135,7 +130,7 @@ ResourceFactory *ResourceFactory::load(const QString &resourceName)
135 130
136} // namespace Sink 131} // namespace Sink
137 132
138//Ignore warning I don't know how to fix in a moc file 133// Ignore warning I don't know how to fix in a moc file
139#pragma clang diagnostic push 134#pragma clang diagnostic push
140#pragma clang diagnostic ignored "-Wundefined-reinterpret-cast" 135#pragma clang diagnostic ignored "-Wundefined-reinterpret-cast"
141#include "moc_resource.cpp" 136#include "moc_resource.cpp"