Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/widgets/kmymoneyreportconfigtabimpl.cpp
Context not available. | |||||
18 | */ | 18 | */ | ||
---|---|---|---|---|---|
19 | 19 | | |||
20 | #include "kmymoneyreportconfigtabimpl.h" | 20 | #include "kmymoneyreportconfigtabimpl.h" | ||
21 | #include "kmymoneyglobalsettings.h" | ||||
21 | 22 | | |||
22 | #include <klocalizedstring.h> | 23 | #include <klocalizedstring.h> | ||
24 | #include <daterangedlg.h> | ||||
23 | 25 | | |||
24 | #include "ui_kmymoneyreportconfigtab1decl.h" | 26 | #include "ui_kmymoneyreportconfigtab1decl.h" | ||
25 | #include "ui_kmymoneyreportconfigtab2decl.h" | 27 | #include "ui_kmymoneyreportconfigtab2decl.h" | ||
26 | #include "ui_kmymoneyreportconfigtab3decl.h" | 28 | #include "ui_kmymoneyreportconfigtab3decl.h" | ||
27 | #include "ui_kmymoneyreportconfigtabchartdecl.h" | 29 | #include "ui_kmymoneyreportconfigtabchartdecl.h" | ||
30 | #include "ui_kmymoneyreportconfigtabrangedecl.h" | ||||
31 | #include "ui_daterangedlgdecl.h" | ||||
28 | 32 | | |||
29 | #include "mymoney/mymoneyreport.h" | 33 | #include "mymoney/mymoneyreport.h" | ||
30 | 34 | | |||
Context not available. | |||||
86 | ui->m_comboType->addItem(i18nc("type of graphic chart", "Stacked Bar"), MyMoneyReport::eChartStackedBar); | 90 | ui->m_comboType->addItem(i18nc("type of graphic chart", "Stacked Bar"), MyMoneyReport::eChartStackedBar); | ||
87 | ui->m_comboType->addItem(i18nc("type of graphic chart", "Pie"), MyMoneyReport::eChartPie); | 91 | ui->m_comboType->addItem(i18nc("type of graphic chart", "Pie"), MyMoneyReport::eChartPie); | ||
88 | ui->m_comboType->addItem(i18nc("type of graphic chart", "Ring"), MyMoneyReport::eChartRing); | 92 | ui->m_comboType->addItem(i18nc("type of graphic chart", "Ring"), MyMoneyReport::eChartRing); | ||
93 | connect(ui->m_comboType, SIGNAL(currentIndexChanged(int)), this, SLOT(slotChartTypeChanged(int))); | ||||
94 | emit ui->m_comboType->currentIndexChanged(ui->m_comboType->currentIndex()); | ||||
89 | } | 95 | } | ||
90 | 96 | | |||
91 | kMyMoneyReportConfigTabChartDecl::~kMyMoneyReportConfigTabChartDecl() | 97 | kMyMoneyReportConfigTabChartDecl::~kMyMoneyReportConfigTabChartDecl() | ||
Context not available. | |||||
93 | delete ui; | 99 | delete ui; | ||
94 | } | 100 | } | ||
95 | 101 | | |||
102 | void kMyMoneyReportConfigTabChartDecl::slotChartTypeChanged(int index) | ||||
103 | { | ||||
104 | if (index == MyMoneyReport::EChartType::eChartPie || | ||||
105 | index == MyMoneyReport::EChartType::eChartRing) { | ||||
106 | ui->m_checkCHGridLines->setText(i18n("Show circular grid lines")); | ||||
107 | ui->m_checkSVGridLines->setText(i18n("Show sagittal grid lines")); | ||||
108 | ui->m_logYaxis->setChecked(false); | ||||
109 | ui->m_logYaxis->setEnabled(false); | ||||
110 | } else { | ||||
111 | ui->m_checkCHGridLines->setText(i18n("Show horizontal grid lines")); | ||||
112 | ui->m_checkSVGridLines->setText(i18n("Show vertical grid lines")); | ||||
113 | ui->m_logYaxis->setEnabled(true); | ||||
114 | } | ||||
115 | } | ||||
116 | | ||||
117 | kMyMoneyReportConfigTabRangeDecl::kMyMoneyReportConfigTabRangeDecl(QWidget *parent) | ||||
118 | : QWidget(parent) | ||||
119 | { | ||||
120 | ui = new Ui::kMyMoneyReportConfigTabRangeDecl; | ||||
121 | ui->setupUi(this); | ||||
122 | m_dateRange = new DateRangeDlg(this->parentWidget()); | ||||
123 | ui->dateRangeGrid->addWidget(m_dateRange,0,0,1,2); | ||||
124 | MyDoubleValidator *dblVal = new MyDoubleValidator(KMyMoneyGlobalSettings::pricePrecision()); | ||||
125 | ui->m_dataRangeStart->setValidator(dblVal); | ||||
126 | ui->m_dataRangeEnd->setValidator(dblVal); | ||||
127 | ui->m_dataMajorTick->setValidator(dblVal); | ||||
128 | ui->m_dataMinorTick->setValidator(dblVal); | ||||
129 | connect(ui->m_dataRangeStart, SIGNAL(editingFinished()), this, SLOT(slotEditingFinishedStart())); | ||||
130 | connect(ui->m_dataRangeEnd, SIGNAL(editingFinished()), this, SLOT(slotEditingFinishedEnd())); | ||||
131 | connect(ui->m_dataMajorTick, SIGNAL(editingFinished()), this, SLOT(slotEditingFinishedMajor())); | ||||
132 | connect(ui->m_dataMinorTick, SIGNAL(editingFinished()), this, SLOT(slotEditingFinishedMinor())); | ||||
133 | connect(ui->m_dataLock, SIGNAL(currentIndexChanged(int)), this, SLOT(slotDataLockChanged(int))); | ||||
134 | emit ui->m_dataLock->currentIndexChanged(ui->m_dataLock->currentIndex()); | ||||
135 | } | ||||
136 | | ||||
137 | kMyMoneyReportConfigTabRangeDecl::~kMyMoneyReportConfigTabRangeDecl() | ||||
138 | { | ||||
139 | delete ui; | ||||
140 | } | ||||
141 | | ||||
142 | void kMyMoneyReportConfigTabRangeDecl::setRangeLogarythmic(bool set) | ||||
143 | { | ||||
144 | // major and minor tick have no influence if axis is logarithmic so hide them | ||||
145 | if (set) { | ||||
146 | ui->lblDataMajorTick->hide(); | ||||
147 | ui->lblDataMinorTick->hide(); | ||||
148 | ui->m_dataMajorTick->hide(); | ||||
149 | ui->m_dataMinorTick->hide(); | ||||
150 | } else { | ||||
151 | ui->lblDataMajorTick->show(); | ||||
152 | ui->lblDataMinorTick->show(); | ||||
153 | ui->m_dataMajorTick->show(); | ||||
154 | ui->m_dataMinorTick->show(); | ||||
155 | } | ||||
156 | } | ||||
157 | | ||||
158 | void kMyMoneyReportConfigTabRangeDecl::slotEditingFinished(EDimension dim) | ||||
159 | { | ||||
160 | qreal dataRangeStart = locale().toDouble(ui->m_dataRangeStart->text()); | ||||
161 | qreal dataRangeEnd = locale().toDouble(ui->m_dataRangeEnd->text()); | ||||
162 | qreal dataMajorTick = locale().toDouble(ui->m_dataMajorTick->text()); | ||||
163 | qreal dataMinorTick = locale().toDouble(ui->m_dataMinorTick->text()); | ||||
164 | if (dataRangeEnd < dataRangeStart) { // end must be higher than start | ||||
165 | if (dim == eRangeEnd) { | ||||
166 | ui->m_dataRangeStart->setText(ui->m_dataRangeEnd->text()); | ||||
167 | dataRangeStart = dataRangeEnd; | ||||
168 | } else { | ||||
169 | ui->m_dataRangeEnd->setText(ui->m_dataRangeStart->text()); | ||||
170 | dataRangeEnd = dataRangeStart; | ||||
171 | } | ||||
172 | } | ||||
173 | if ((dataRangeStart != 0 || dataRangeEnd != 0)) { // if data range isn't going to be reset | ||||
174 | if ((dataRangeEnd - dataRangeStart) < dataMajorTick) // major tick cannot be greater than data range | ||||
175 | dataMajorTick = dataRangeEnd - dataRangeStart; | ||||
176 | | ||||
177 | if (dataMajorTick != 0 && // if major tick isn't going to be reset | ||||
178 | dataMajorTick < (dataRangeEnd - dataRangeStart) * 0.01) // constraint major tick to be greater or equal to 1% of data range | ||||
179 | dataMajorTick = (dataRangeEnd - dataRangeStart) * 0.01; // that should produce more than 256 Y labels in KReportChartView::slotNeedUpdate | ||||
180 | | ||||
181 | ui->m_dataMajorTick->setText(locale().toString(dataMajorTick, 'f', KMyMoneySettings::pricePrecision()).remove(locale().groupSeparator()).remove(QRegularExpression("0+$")).remove(QRegularExpression("\\" + locale().decimalPoint() + "$"))); | ||||
182 | } | ||||
183 | | ||||
184 | if (dataMajorTick < dataMinorTick) { // major tick must be higher than minor | ||||
185 | if (dim == eMinorTick) { | ||||
186 | ui->m_dataMajorTick->setText(ui->m_dataMinorTick->text()); | ||||
187 | dataMajorTick = dataMinorTick; | ||||
188 | } else { | ||||
189 | ui->m_dataMinorTick->setText(ui->m_dataMajorTick->text()); | ||||
190 | dataMinorTick = dataMajorTick; | ||||
191 | } | ||||
192 | } | ||||
193 | | ||||
194 | if (dataMinorTick < dataMajorTick * 0.1) { // constraint minor tick to be greater or equal to 10% of major tick | ||||
195 | dataMinorTick = dataMajorTick * 0.1; | ||||
196 | ui->m_dataMinorTick->setText(locale().toString(dataMinorTick, 'f', KMyMoneySettings::pricePrecision()).remove(locale().groupSeparator()).remove(QRegularExpression("0+$")).remove(QRegularExpression("\\" + locale().decimalPoint() + "$"))); | ||||
197 | } | ||||
198 | } | ||||
199 | | ||||
200 | void kMyMoneyReportConfigTabRangeDecl::slotEditingFinishedStart() | ||||
201 | { | ||||
202 | slotEditingFinished(eRangeStart); | ||||
203 | } | ||||
204 | | ||||
205 | void kMyMoneyReportConfigTabRangeDecl::slotEditingFinishedEnd() | ||||
206 | { | ||||
207 | slotEditingFinished(eRangeEnd); | ||||
208 | } | ||||
209 | | ||||
210 | void kMyMoneyReportConfigTabRangeDecl::slotEditingFinishedMajor() | ||||
211 | { | ||||
212 | slotEditingFinished(eMajorTick); | ||||
213 | } | ||||
214 | | ||||
215 | void kMyMoneyReportConfigTabRangeDecl::slotEditingFinishedMinor() | ||||
216 | { | ||||
217 | slotEditingFinished(eMinorTick); | ||||
218 | } | ||||
219 | | ||||
220 | void kMyMoneyReportConfigTabRangeDecl::slotDataLockChanged(int index) { | ||||
221 | if (index == MyMoneyReport::dataOptionE::automatic) { | ||||
222 | ui->m_dataRangeStart->setText(QStringLiteral("0")); | ||||
223 | ui->m_dataRangeEnd->setText(QStringLiteral("0")); | ||||
224 | ui->m_dataMajorTick->setText(QStringLiteral("0")); | ||||
225 | ui->m_dataMinorTick->setText(QStringLiteral("0")); | ||||
226 | ui->m_dataRangeStart->setEnabled(false); | ||||
227 | ui->m_dataRangeEnd->setEnabled(false); | ||||
228 | ui->m_dataMajorTick->setEnabled(false); | ||||
229 | ui->m_dataMinorTick->setEnabled(false); | ||||
230 | } else { | ||||
231 | ui->m_dataRangeStart->setEnabled(true); | ||||
232 | ui->m_dataRangeEnd->setEnabled(true); | ||||
233 | ui->m_dataMajorTick->setEnabled(true); | ||||
234 | ui->m_dataMinorTick->setEnabled(true); | ||||
235 | } | ||||
236 | } | ||||
Context not available. |