Warning, file /office/skrooge/skgbasegui/skgsimpleperiodedit.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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 SKGSIMPLEPERIODEDIT_H
0007 #define SKGSIMPLEPERIODEDIT_H
0008 /** @file
0009  * A simple period selector.
0010  *
0011  * @author Stephane MANKOWSKI / Guillaume DE BURE
0012  */
0013 
0014 #include <qdatetime.h>
0015 #include <qflags.h>
0016 
0017 #include "skgbasegui_export.h"
0018 #include "skgcombobox.h"
0019 /**
0020  * This file is a simple period selector.
0021  */
0022 class SKGBASEGUI_EXPORT SKGSimplePeriodEdit : public SKGComboBox
0023 {
0024     Q_OBJECT
0025     /**
0026      * First date
0027      */
0028     Q_PROPERTY(QDate firstDate READ firstDate WRITE setFirstDate NOTIFY changed USER true)
0029 
0030     /**
0031      * Previous mode
0032      */
0033     Q_PROPERTY(Modes mode READ mode WRITE setMode NOTIFY changed)
0034 
0035     /**
0036      * Period
0037      */
0038     Q_PROPERTY(QString period READ period NOTIFY changed)
0039 
0040 public:
0041     /**
0042      * This enumerate for mode
0043      */
0044     enum Mode {
0045         NONE = 0u,                                              /**< None */
0046         PREVIOUS_MONTHS = 1u,                                   /**< Only previous months */
0047         PREVIOUS_YEARS = 32u,                                   /**< Only previous years */
0048         PREVIOUS_PERIODS = 2u,                                  /**< All previous periods including quarters, semesters and years*/
0049         CURRENT_MONTH = 4u,                                     /**< Current month */
0050         CURRENT_YEAR = 64u,                                     /**< Current years */
0051         CURRENT_PERIOD = 8u,                                    /**< Current period including quarter, semester and year */
0052         ALL = 16u,                                              /**< The "All dates" period */
0053         PREVIOUS_AND_CURRENT_MONTHS = 1u | 4u,                  /**< Previous and current months*/
0054         PREVIOUS_AND_CURRENT_YEARS = 32u | 64u,                 /**< Previous and current years*/
0055         PREVIOUS_AND_CURRENT_PERIODS = 1u | 2u | 4u | 8u,       /**< Previous and current periods including quarters, semesters and years*/
0056         ALL_PERIODS =  1u | 2u | 4u | 8u | 16u                  /**< All periods*/
0057     };
0058 
0059     /**
0060      * This enumerate for additional options in menu
0061      */
0062     Q_ENUM(Mode)
0063 
0064     Q_DECLARE_FLAGS(Modes, Mode)
0065 
0066     /**
0067      * Default Constructor
0068      * @param iParent the parent
0069      */
0070     explicit SKGSimplePeriodEdit(QWidget* iParent);
0071 
0072     /**
0073      * Default Destructor
0074      */
0075     ~SKGSimplePeriodEdit() override;
0076 
0077     /**
0078      * Get the period
0079      * @return the period
0080      */
0081     virtual QString period() const;
0082 
0083     /**
0084      * Get the first date to take into account
0085      * @return the first date to take into account
0086      */
0087     virtual QDate firstDate() const;
0088 
0089     /**
0090      * Set the first date to take into account
0091      * @param iDate the first date to take into account
0092      */
0093     // cppcheck-suppress passedByValue
0094     virtual void setFirstDate(QDate iDate);
0095 
0096     /**
0097      * To know if the mode of widget (default: PREVIOUS_MONTHS)
0098      * @return previous mode
0099      */
0100     virtual Modes mode() const;
0101 
0102     /**
0103      * Set the widget mode
0104      * @param iMode the mode
0105      */
0106     virtual void setMode(Modes iMode);
0107 
0108 Q_SIGNALS:
0109     /**
0110      * Emitted when the changed
0111      */
0112     void changed();
0113 
0114 private:
0115     QDate m_FirstDate;
0116     Modes m_Mode;
0117 
0118     void refreshList();
0119 };
0120 
0121 Q_DECLARE_OPERATORS_FOR_FLAGS(SKGSimplePeriodEdit::Modes)
0122 
0123 #endif  // SKGSIMPLEPERIODEDIT_H