File indexing completed on 2024-05-26 05:10:43

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 SKGPAYEEPLUGINWIDGET_H
0007 #define SKGPAYEEPLUGINWIDGET_H
0008 /** @file
0009  * A skrooge plugin to payee transactions
0010 *
0011 * @author Stephane MANKOWSKI
0012 */
0013 #include "skgtabpage.h"
0014 #include "ui_skgpayeepluginwidget_base.h"
0015 
0016 /**
0017  * A skrooge plugin to track transactions
0018  */
0019 class SKGPayeePluginWidget : public SKGTabPage
0020 {
0021     Q_OBJECT
0022 
0023 public:
0024     /**
0025      * Default Constructor
0026      * @param iParent the parent widget
0027      * @param iDocument the document
0028      */
0029     explicit SKGPayeePluginWidget(QWidget* iParent, SKGDocument* iDocument);
0030 
0031     /**
0032      * Default Destructor
0033      */
0034     ~SKGPayeePluginWidget() override;
0035 
0036     /**
0037      * Get the current state
0038      * MUST BE OVERWRITTEN
0039      * @return a string containing all information needed to set the same state.
0040      * Could be an XML stream
0041      */
0042     QString getState() override;
0043 
0044     /**
0045      * Set the current state
0046      * MUST BE OVERWRITTEN
0047      * @param iState must be interpreted to set the state of the widget
0048      */
0049     void setState(const QString& iState) override;
0050 
0051     /**
0052      * Get attribute name to save the default state
0053      * MUST BE OVERWRITTEN
0054      * @return attribute name to save the default state.
0055      */
0056     QString getDefaultStateAttribute() override;
0057 
0058     /**
0059      * Get the main widget
0060      * @return a widget
0061      */
0062     QWidget* mainWidget() override;
0063 
0064     /**
0065      * To know if this page contains an editor. MUST BE OVERWRITTEN
0066      * @return the editor state
0067      */
0068     bool isEditor() override;
0069 
0070     /**
0071      * To activate the editor by setting focus on right widget. MUST BE OVERWRITTEN
0072      */
0073     void activateEditor() override;
0074 
0075 protected:
0076     /**
0077      * Event filtering
0078      * @param iObject object
0079      * @param iEvent event
0080      * @return In your reimplementation of this function, if you want to filter the event out, i.e. stop it being handled further, return true; otherwise return false.
0081      */
0082     bool eventFilter(QObject* iObject, QEvent* iEvent) override;
0083 
0084 private Q_SLOTS:
0085     void dataModified(const QString& iTableName, int iIdTransaction, bool iLightTransaction = false);
0086     void onSelectionChanged();
0087     void onEditorModified();
0088     void onAddPayee();
0089     void onModifyPayee();
0090     void cleanEditor();
0091     void onDeleteUnused();
0092 
0093 private:
0094     Q_DISABLE_COPY(SKGPayeePluginWidget)
0095 
0096     Ui::skgpayeeplugin_base ui{};
0097 };
0098 
0099 #endif  // SKGPAYEEPLUGINWIDGET_H