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

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