1 /*  This file is part of the KDE project
2     Copyright (C) 2009 Laurent Montel <montel@kde.org>
3     (C) 2017 by Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com>
4         2018 by Michael Kiefer <Michael-Kiefer@web.de>
5 
6     This library is free software; you can redistribute it and/or
7     modify it under the terms of the GNU Library General Public
8     License as published by the Free Software Foundation; either
9     version 2 of the License, or (at your option) any later version.
10 
11     This library is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14     Library General Public License for more details.
15 
16     You should have received a copy of the GNU Library General Public License
17     along with this library; see the file COPYING.LIB.  If not, write to
18     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19     Boston, MA 02110-1301, USA.
20 */
21 
22 #ifndef REPORTTABIMPL_H
23 #define REPORTTABIMPL_H
24 
25 #include <QWidget>
26 #include <QDoubleValidator>
27 
28 class DateRangeDlg;
29 
30 namespace Ui
31 {
32 class ReportTabGeneral;
33 class ReportTabRowColPivot;
34 class ReportTabRowColQuery;
35 class ReportTabChart;
36 class ReportTabRange;
37 class ReportTabCapitalGain;
38 class ReportTabPerformance;
39 }
40 
41 class ReportTabGeneral : public QWidget
42 {
43   Q_DISABLE_COPY(ReportTabGeneral)
44 
45 public:
46   explicit ReportTabGeneral(QWidget *parent);
47   ~ReportTabGeneral();
48 
49   Ui::ReportTabGeneral* ui;
50 };
51 
52 class ReportTabRowColPivot : public QWidget
53 {
54   Q_DISABLE_COPY(ReportTabRowColPivot)
55 
56 public:
57   explicit ReportTabRowColPivot(QWidget *parent);
58   ~ReportTabRowColPivot();
59 
60   Ui::ReportTabRowColPivot* ui;
61 };
62 
63 class ReportTabRowColQuery : public QWidget
64 {
65   Q_OBJECT
66   Q_DISABLE_COPY(ReportTabRowColQuery)
67 
68 public:
69   explicit ReportTabRowColQuery(QWidget *parent);
70   ~ReportTabRowColQuery();
71 
72   Ui::ReportTabRowColQuery* ui;
73 private Q_SLOTS:
74   void slotHideTransactionsChanged(bool checked);
75 };
76 
77 class ReportTabChart : public QWidget
78 {
79   Q_OBJECT
80   Q_DISABLE_COPY(ReportTabChart)
81 
82 public:
83   explicit ReportTabChart(QWidget *parent);
84   ~ReportTabChart();
85 
86   Ui::ReportTabChart* ui;
87   void setNegExpenses(bool set);
88 
89 private Q_SLOTS:
90   void slotChartTypeChanged(int index);
91 };
92 
93 class ReportTabRange : public QWidget
94 {
95   Q_OBJECT
96   Q_DISABLE_COPY(ReportTabRange)
97 
98 public:
99   explicit ReportTabRange(QWidget *parent);
100   ~ReportTabRange();
101 
102   Ui::ReportTabRange* ui;
103   DateRangeDlg *m_dateRange;
104   void setRangeLogarythmic(bool set);
105 private:
106   enum EDimension { eRangeStart = 0, eRangeEnd, eMajorTick, eMinorTick};
107   bool m_logYaxis;
108   /**
109    * Update data range start and data range end text validators
110    * and re-validate the contents of those text fields against the updated validator.
111    * If re-validation fails, arbitrary default values will be set depending on vertical axis type.
112    * This fucntion should be called when vertical axis type or labels precision changed.
113    */
114   void updateDataRangeValidators(const int& precision);
115 private Q_SLOTS:
116   void slotEditingFinished(EDimension dim);
117   void slotEditingFinishedStart();
118   void slotEditingFinishedEnd();
119   void slotEditingFinishedMajor();
120   void slotEditingFinishedMinor();
121   void slotYLabelsPrecisionChanged(const int &value);
122   void slotDataLockChanged(int index);
123 };
124 
125 class ReportTabCapitalGain : public QWidget
126 {
127   Q_OBJECT
128   Q_DISABLE_COPY(ReportTabCapitalGain)
129 
130 public:
131   explicit ReportTabCapitalGain(QWidget *parent);
132   ~ReportTabCapitalGain();
133 
134   Ui::ReportTabCapitalGain* ui;
135 
136 private Q_SLOTS:
137   void slotInvestmentSumChanged(int index);
138 };
139 
140 class ReportTabPerformance : public QWidget
141 {
142 public:
143   explicit ReportTabPerformance(QWidget *parent);
144   ~ReportTabPerformance();
145 
146   Ui::ReportTabPerformance* ui;
147 };
148 
149 class MyDoubleValidator : public QDoubleValidator
150 {
151 public:
152   explicit MyDoubleValidator(int decimals, QObject * parent = 0);
153 
154   QValidator::State validate(QString &s, int &i) const final override;
155 };
156 
157 class MyLogarithmicDoubleValidator : public QDoubleValidator
158 {
159 public:
160   explicit MyLogarithmicDoubleValidator(const int decimals, const qreal defaultValue, QObject *parent = nullptr);
161 
162   QValidator::State validate(QString &s, int &i) const final Q_DECL_OVERRIDE;
163   void fixup(QString &input) const final Q_DECL_OVERRIDE;
164 private:
165   QString m_defaultText;
166 };
167 #endif /* REPORTTABIMPL_H */
168 
169