KMyMoney Plugin API

kmymoneyplugin.cpp
1/*
2 SPDX-FileCopyrightText: 2005-2021 Thomas Baumgart <ipwizard@users.sourceforge.net>
3 SPDX-FileCopyrightText: 2015 Christian Dávid <christian-david@web.de>
4 SPDX-FileCopyrightText: 2021 Dawid Wróbel <me@dawidwrobel.com>
5 SPDX-License-Identifier: GPL-2.0-or-later
6*/
7
8#include "kmymoneyplugin.h"
9
10// ----------------------------------------------------------------------------
11// QT Includes
12
13#include <QMap>
14#include <QMimeDatabase>
15
16// ----------------------------------------------------------------------------
17// KDE Includes
18
19#include <KActionCollection>
20#include <KPluginMetaData>
21#include <KToggleAction>
22
23// ----------------------------------------------------------------------------
24// Project Includes
25#include "interfaceloader.h"
26
28
29KMyMoneyPlugin::Plugin::Plugin(QObject* parent, const KPluginMetaData& metaData, const QVariantList& args)
30 : QObject()
32{
33 Q_UNUSED(parent)
34 Q_UNUSED(args)
35
36 setObjectName(metaData.pluginId());
37 m_componentDisplayName = metaData.name();
38 setComponentName(metaData.pluginId(), m_componentDisplayName);
39}
40
41KMyMoneyPlugin::Plugin::~Plugin()
42{
43}
44
45QString KMyMoneyPlugin::Plugin::componentDisplayName() const
46{
47 return m_componentDisplayName;
48}
49
51{
52 Q_UNUSED(guiFactory)
53}
54
58
59void KMyMoneyPlugin::Plugin::updateActions(const SelectedObjects& selections)
60{
61 Q_UNUSED(selections)
62}
63
67
69{
70 static KToggleAction dummyAction(QString("Dummy"), nullptr);
71
72 KToggleAction* p = dynamic_cast<KToggleAction*>(actionCollection()->action(QString(actionName.toLatin1())));
73 if (!p) {
74 qWarning("Action '%s' is not of type KToggleAction", qPrintable(actionName));
75 p = &dummyAction;
76 }
77
78 qWarning("Action with name '%s' not found!", qPrintable(actionName));
79 return p;
80}
81
82KMyMoneyPlugin::OnlinePlugin::OnlinePlugin()
83{
84}
85
86KMyMoneyPlugin::OnlinePlugin::~OnlinePlugin()
87{
88}
89
90KMyMoneyPlugin::AppInterface* KMyMoneyPlugin::Plugin::appInterface() const
91{
92 Q_CHECK_PTR(KMyMoneyPlugin::pluginInterfaces().appInterface);
93 return KMyMoneyPlugin::pluginInterfaces().appInterface;
94}
95
96KMyMoneyPlugin::ViewInterface* KMyMoneyPlugin::Plugin::viewInterface() const
97{
98 Q_CHECK_PTR(KMyMoneyPlugin::pluginInterfaces().viewInterface);
99 return KMyMoneyPlugin::pluginInterfaces().viewInterface;
100}
101
102KMyMoneyPlugin::StatementInterface* KMyMoneyPlugin::Plugin::statementInterface() const
103{
104 Q_CHECK_PTR(KMyMoneyPlugin::pluginInterfaces().statementInterface);
105 return KMyMoneyPlugin::pluginInterfaces().statementInterface;
106}
107
108KMyMoneyPlugin::ImportInterface* KMyMoneyPlugin::Plugin::importInterface() const
109{
110 Q_CHECK_PTR(KMyMoneyPlugin::pluginInterfaces().importInterface);
111 return KMyMoneyPlugin::pluginInterfaces().importInterface;
112}
113
114KMyMoneyPlugin::ImporterPlugin::ImporterPlugin()
115{
116}
117
119{
120 QMimeDatabase db;
121 QMimeType mime = db.mimeTypeForFile(filename);
122
123 if (!mime.isDefault()) {
124 const QStringList formatTypes = formatMimeTypes();
125 for (const auto& mimeTypeName : qAsConst(formatTypes))
126 if (mime.inherits(mimeTypeName)) {
127 return true;
128 }
129 }
130 return false;
131}
132
133KMyMoneyPlugin::ImporterPlugin::~ImporterPlugin()
134{
135}
This abstract class represents the ImportInterface to add new importers to KMyMoney.
virtual bool isMyFormat(const QString &filename) const
This method checks whether the file provided is of expected format.
virtual void plug(KXMLGUIFactory *guiFactory)
Called during plug in process.
KToggleAction * toggleAction(const QString &name) const
See KMyMoneyApp::toggleAction() for a description.
virtual void updateConfiguration()
This method is called by the application whenever the configuration changes.
virtual void unplug()
Called before unloading.
virtual void updateActions(const SelectedObjects &selections)
This method is called by the application whenever a selection changes.
This abstract class represents the interface to import statements into the KMyMoney application.
This abstract class represents the ViewInterface to add new view pages to the JanusWidget of KMyMoney...
QString pluginId() const
QString name() const
KMyMoneyPlugin::Container pPlugins
Structure of plugins objects by their interfaces.
QMimeType mimeTypeForFile(const QFileInfo &fileInfo, MatchMode mode) const const
bool inherits(const QString &mimeTypeName) const const
QByteArray toLatin1() const const
The Container struct to hold all plugin interfaces.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:15:40 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.