File indexing completed on 2024-05-26 05:10:47
0001 /*************************************************************************** 0002 * SPDX-FileCopyrightText: 2022 S. MANKOWSKI stephane@mankowski.fr 0003 * SPDX-FileCopyrightText: 2022 G. DE BURE support@mankowski.fr 0004 * SPDX-License-Identifier: GPL-3.0-or-later 0005 ***************************************************************************/ 0006 #ifndef SKGUNITPLUGIN_H 0007 #define SKGUNITPLUGIN_H 0008 /** @file 0009 * This file is Skrooge plugin for unit management. 0010 * 0011 * @author Stephane MANKOWSKI / Guillaume DE BURE 0012 */ 0013 #include "skginterfaceplugin.h" 0014 #include "ui_skgunitpluginwidget_pref.h" 0015 0016 class SKGDocumentBank; 0017 0018 /** 0019 * This file is Skrooge plugin for unit management 0020 */ 0021 class SKGUnitPlugin : public SKGInterfacePlugin 0022 { 0023 Q_OBJECT 0024 Q_INTERFACES(SKGInterfacePlugin) 0025 0026 public: 0027 /** 0028 * Default Constructor 0029 */ 0030 explicit SKGUnitPlugin(QWidget* iWidget, QObject* iParent, const QVariantList& iArg); 0031 0032 /** 0033 * Default Destructor 0034 */ 0035 ~SKGUnitPlugin() override; 0036 0037 /** 0038 * Called to initialise the plugin 0039 * @param iDocument the main document 0040 * @return true if the plugin is compatible with the document 0041 */ 0042 bool setupActions(SKGDocument* iDocument) override; 0043 0044 /** 0045 * The page widget of the plugin. 0046 * @return The page widget of the plugin 0047 */ 0048 SKGTabPage* getWidget() override; 0049 0050 /** 0051 * The number of dashboard widgets of the plugin. 0052 * @return The number of dashboard widgets of the plugin 0053 */ 0054 int getNbDashboardWidgets() override; 0055 0056 /** 0057 * Get a dashboard widget title of the plugin. 0058 * @param iIndex the index of the widget 0059 * @return The title 0060 */ 0061 QString getDashboardWidgetTitle(int iIndex) override; 0062 0063 /** 0064 * Get a dashboard widget of the plugin. 0065 * @param iIndex the index of the widget 0066 * @return The dashboard widget of the plugin 0067 */ 0068 SKGBoardWidget* getDashboardWidget(int iIndex) override; 0069 0070 /** 0071 * Must be modified to refresh widgets after a modification. 0072 */ 0073 void refresh() override; 0074 0075 /** 0076 * The preference widget of the plugin. 0077 * @return The preference widget of the plugin 0078 */ 0079 QWidget* getPreferenceWidget() override; 0080 0081 /** 0082 * The preference skeleton of the plugin. 0083 * @return The preference skeleton of the plugin 0084 */ 0085 KConfigSkeleton* getPreferenceSkeleton() override; 0086 0087 /** 0088 * The title of the plugin. 0089 * @return The title of the plugin 0090 */ 0091 QString title() const override; 0092 0093 /** 0094 * The icon of the plugin. 0095 * @return The icon of the plugin 0096 */ 0097 QString icon() const override; 0098 0099 /** 0100 * The toolTip of the plugin. 0101 * @return The toolTip of the plugin 0102 */ 0103 QString toolTip() const override; 0104 0105 /** 0106 * The tips list of the plugin. 0107 * @return The tips list of the plugin 0108 */ 0109 QStringList tips() const override; 0110 0111 /** 0112 * The sub plugins services types list of the plugin. 0113 * This will be used to display authors in the "About" of the application 0114 * @return The sub plugins list of the plugin 0115 */ 0116 QStringList subPlugins() const override; 0117 0118 /** 0119 * Must be implemented to set the position of the plugin. 0120 * @return integer value between 0 and 999 (default = 999) 0121 */ 0122 int getOrder() const override; 0123 0124 /** 0125 * Must be implemented to know if a plugin must be display in pages chooser. 0126 * @return true of false (default = false) 0127 */ 0128 bool isInPagesChooser() const override; 0129 0130 /** 0131 * The advice list of the plugin. 0132 * @return The advice list of the plugin 0133 */ 0134 SKGAdviceList advice(const QStringList& iIgnoredAdvice) override; 0135 0136 /** 0137 * Must be implemented to execute the automatic correction for the advice. 0138 * @param iAdviceIdentifier the identifier of the advice 0139 * @param iSolution the identifier of the possible solution 0140 * @return an object managing the error. MUST return ERR_NOTIMPL if iAdviceIdentifier is not known 0141 * @see SKGError 0142 */ 0143 SKGError executeAdviceCorrection(const QString& iAdviceIdentifier, int iSolution) override; 0144 0145 private Q_SLOTS: 0146 void onSplitShare(); 0147 void deleteUnusedUnits() const; 0148 0149 private: 0150 Q_DISABLE_COPY(SKGUnitPlugin) 0151 0152 SKGDocumentBank* m_currentBankDocument; 0153 QString m_docUniqueIdentifier; 0154 0155 Ui::skgunitplugin_pref ui{}; 0156 }; 0157 0158 #endif // SKGUNITPLUGIN_H