Verified Commit 99dc15ea authored by Alexander Lohnau's avatar Alexander Lohnau
Browse files

moa porting

parent 002d0fda
Pipeline #90866 failed with stage
in 2 minutes and 58 seconds
......@@ -16,7 +16,6 @@
#include <QList>
#include <QDebug>
#include <QPluginLoader>
#include <QJsonArray>
// ----------------------------------------------------------------------------
......@@ -186,16 +185,8 @@ onlineTask* onlineJobAdministration::rootOnlineTask(const QString& name) const
if (plugins.length() != 1)
qWarning() << "Multiple plugins which offer the online task \"" << name << "\" were found. Loading a random one.";
// Load plugin
std::unique_ptr<QPluginLoader> loader = std::unique_ptr<QPluginLoader>(new QPluginLoader{plugins.first().fileName()});
QObject* plugin = loader->instance();
if (!plugin) {
qWarning() << "Could not load plugin for online task " << name << ", file name " << plugins.first().fileName() << ".";
return nullptr;
}
// Cast to KPluginFactory
KPluginFactory* pluginFactory = qobject_cast< KPluginFactory* >(plugin);
KPluginFactory* pluginFactory = KPluginFactory::loadFactory(plugins.first()).plugin;
if (!pluginFactory) {
qWarning() << "Could not create plugin factory for online task " << name << ", file name " << plugins.first().fileName() << ".";
return nullptr;
......@@ -349,11 +340,9 @@ onlineJobAdministration::onlineJobEditOffers onlineJobAdministration::onlineJobE
QJsonArray editorsArray = data.rawData()["KMyMoney"].toObject()["OnlineTask"].toObject()["Editors"].toArray();
for(QJsonValue entry: editorsArray) {
if (!entry.toObject()["OnlineTaskIds"].isNull()) {
list.append(onlineJobAdministration::onlineJobEditOffer{
data.fileName(),
entry.toObject()["PluginKeyword"].toString(),
KPluginMetaData::readTranslatedString(entry.toObject(), "Name")
});
list.append(onlineJobAdministration::onlineJobEditOffer{data,
entry.toObject()["PluginKeyword"].toString(),
KPluginMetaData::readTranslatedString(entry.toObject(), "Name")});
}
}
}
......
......@@ -15,6 +15,7 @@
// ----------------------------------------------------------------------------
// KDE Includes
#include <KPluginMetaData>
// ----------------------------------------------------------------------------
// Project Includes
......@@ -62,7 +63,7 @@ public:
~onlineJobAdministration();
struct onlineJobEditOffer {
QString fileName;
KPluginMetaData metaData;
QString pluginKeyword;
QString name;
};
......
......@@ -107,24 +107,9 @@ void pluginHandling(Action action, Container& ctnPlugins, QObject* parent, KXMLG
auto& refPlugins = referencePluginDatas;
for (auto it = refPlugins.cbegin(); it != refPlugins.cend(); ++it) {
if (!ctnPlugins.standard.contains(it.key())) {
qDebug() << "Loading" << (*it).fileName();
KPluginLoader loader((*it).fileName());
auto factory = loader.factory();
if (!factory) {
qWarning("Could not load plugin '%s', error: %s", qPrintable((*it).fileName()), qPrintable(loader.errorString()));
loader.unload();
continue;
}
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 77, 0)
Plugin* plugin = factory->create<Plugin>(parent, QVariantList { (*it).pluginId(), (*it).name() });
#else
Plugin* plugin = factory->create<Plugin>(parent);
#endif
if (!plugin) {
qWarning("This is not KMyMoney plugin: '%s'", qPrintable((*it).fileName()));
loader.unload();
continue;
}
qDebug() << "Loading" << (*it).name();
Plugin* plugin = KPluginFactory::instantiatePlugin<Plugin>(*it, parent, QVariantList{(*it).pluginId(), (*it).name()}).plugin;
qDebug() << "Loading" << plugin;
ctnPlugins.standard.insert((*it).pluginId(), plugin);
plugin->plug(guiFactory);
......
......@@ -191,6 +191,7 @@ CheckPrinting::CheckPrinting(QObject *parent, const KPluginMetaData &metaData, c
// wait until a transaction is selected before enabling the action
d->m_action->setEnabled(false);
PluginSettings::self();
d->m_printedTransactionIdList = PluginSettings::printedChecks();
d->readCheckTemplate();
......
......@@ -12,7 +12,6 @@
#include <QList>
#include <QDebug>
#include <QPluginLoader>
#include <QDateTime>
#include <KStandardAction>
......@@ -84,23 +83,16 @@ kOnlineTransferForm::kOnlineTransferForm(QWidget *parent)
void kOnlineTransferForm::loadOnlineJobEditPlugin(const onlineJobAdministration::onlineJobEditOffer& pluginDesc)
{
try {
std::unique_ptr<QPluginLoader> loader{new QPluginLoader(pluginDesc.fileName, this)};
QObject* plugin = loader->instance();
if (!plugin) {
qWarning() << "Could not load plugin for online job editor from file \"" << pluginDesc.fileName << "\".";
return;
}
// Cast to KPluginFactory
KPluginFactory* pluginFactory = qobject_cast< KPluginFactory* >(plugin);
KPluginFactory* pluginFactory = KPluginFactory::loadFactory(pluginDesc.metaData).plugin;
if (!pluginFactory) {
qWarning() << "Could not create plugin factory for online job editor in file \"" << pluginDesc.fileName << "\".";
qWarning() << "Could not create plugin factory for online job editor in file \"" << pluginDesc.name << "\".";
return;
}
IonlineJobEdit* widget = pluginFactory->create<IonlineJobEdit>(pluginDesc.pluginKeyword, this);
if (!widget) {
qWarning() << "Could not create online job editor in file \"" << pluginDesc.fileName << "\".";
qWarning() << "Could not create online job editor in file \"" << pluginDesc.name << "\".";
return;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment