Warning, file /office/skrooge/skgbasegui/skgperiodedit.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 SKGPERIODEDIT_H
0007 #define SKGPERIODEDIT_H
0008 /** @file
0009  * A period editor.
0010  *
0011  * @author Stephane MANKOWSKI / Guillaume DE BURE
0012  */
0013 
0014 #include "skgbasegui_export.h"
0015 #include "ui_skgperiodedit.h"
0016 /**
0017  * This file is a period editor.
0018  */
0019 class SKGBASEGUI_EXPORT SKGPeriodEdit : public QWidget
0020 {
0021     Q_OBJECT
0022 
0023     /**
0024      * Where clause
0025      */
0026     Q_PROPERTY(QString whereClause READ getWhereClause NOTIFY changed)
0027 
0028     /**
0029      * Text
0030      */
0031     Q_PROPERTY(QString text READ text NOTIFY changed)
0032 
0033 public:
0034     /**
0035      * This enumerate defines the period mode
0036      */
0037     enum PeriodMode {ALL,        /**< All date*/
0038                      CURRENT,    /**< Current month, year, …*/
0039                      PREVIOUS,   /**< Previous month, year, …*/
0040                      LAST,       /**< Last month, year, …*/
0041                      CUSTOM,     /**< Custom dates*/
0042                      TIMELINE    /**< Timeline.*/
0043                     };
0044     /**
0045      * This enumerate defines the period mode
0046      */
0047     Q_ENUM(PeriodMode)
0048 
0049     /**
0050      * This enumerate defines the period mode
0051      */
0052     enum PeriodInterval {DAY = 0, /**< Day*/
0053                          WEEK = 1,    /**< Week (7 days)*/
0054                          MONTH = 2,   /**< Month*/
0055                          QUARTER = 4, /**< Quarter (3 months)*/
0056                          SEMESTER = 5, /**< Semester (6 months)*/
0057                          YEAR = 3     /**< Year*/
0058                         };
0059     /**
0060      * This enumerate defines the period interval
0061      */
0062     Q_ENUM(PeriodInterval)
0063 
0064     /**
0065      * Default Constructor
0066      * @param iParent the parent
0067      * @param iModeEnabled if true then the widgets are enabled/disabled instead of shown/hidden
0068      */
0069     explicit SKGPeriodEdit(QWidget* iParent, bool iModeEnabled = false);
0070 
0071     /**
0072      * Default Destructor
0073      */
0074     ~SKGPeriodEdit() override;
0075 
0076     /**
0077      * Get the current state
0078      * MUST BE OVERWRITTEN
0079      * @return a string containing all information needed to set the same state.
0080      * Could be an XML stream
0081      */
0082     virtual QString getState();
0083 
0084     /**
0085      * Set the current state
0086      * MUST BE OVERWRITTEN
0087      * @param iState must be interpreted to set the state of the widget
0088      */
0089     virtual void setState(const QString& iState);
0090 
0091     /**
0092      * Get the text
0093      * @return the text
0094      */
0095     virtual QString text() const;
0096 
0097     /**
0098      * Get the mode
0099      * @return the mode
0100      */
0101     virtual SKGPeriodEdit::PeriodMode mode() const;
0102 
0103     /**
0104      * Get the where clauses
0105      * @param iForecast enable forecast where clause
0106      * @param oWhereClausForPreviousData the where clause for previous data. Can be nullptr.
0107      * @param oWhereClausForForecastData the where clause for forecast data. Can be nullptr.
0108      * @return the where clause
0109      */
0110     virtual QString getWhereClause(bool iForecast = true, QString* oWhereClausForPreviousData = nullptr, QString*  oWhereClausForForecastData = nullptr) const;
0111 
0112     /**
0113      * Get begin and end dates
0114      * @param iPeriod the period
0115      * @param iInterval the interval
0116      * @param iValue the number of iInterval
0117      * @param oBeginDate the begin date of the period
0118      * @param oEndDate the end date of the period
0119      * @param iDate the input date
0120      */
0121     // cppcheck-suppress passedByValue
0122     static void getDates(PeriodMode iPeriod, PeriodInterval iInterval, int iValue, QDate& oBeginDate, QDate& oEndDate, QDate iDate = QDate::currentDate());
0123 
0124     /**
0125      * Get begin and end dates
0126      * @param oBeginDate the begin date of the period
0127      * @param oEndDate the end date of the period
0128      */
0129     // cppcheck-suppress passedByValue
0130     void getDates(QDate& oBeginDate, QDate& oEndDate);
0131 
0132 private Q_SLOTS:
0133     void refresh();
0134 
0135 Q_SIGNALS:
0136     /**
0137      * Emitted when the period change
0138      */
0139     void changed();
0140 
0141 private:
0142     Ui::skgperiodedit_base ui{};
0143 
0144     bool m_modeEnable;
0145     int m_count;
0146 };
0147 
0148 #endif  // SKGPERIODEDIT_H