Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/plugins/csvimport/csvwizard.h
Show All 17 Lines | |||||
18 | ********************************************************************************/ | 18 | ********************************************************************************/ | ||
19 | 19 | | |||
20 | #ifndef CSVWIZARD_H | 20 | #ifndef CSVWIZARD_H | ||
21 | #define CSVWIZARD_H | 21 | #define CSVWIZARD_H | ||
22 | 22 | | |||
23 | // ---------------------------------------------------------------------------- | 23 | // ---------------------------------------------------------------------------- | ||
24 | // QT Includes | 24 | // QT Includes | ||
25 | 25 | | |||
26 | #include <QDialog> | | |||
27 | #include <QWizard> | 26 | #include <QWizard> | ||
28 | #include <QLabel> | 27 | #include <QLabel> | ||
29 | #include <QScrollBar> | 28 | #include <QScrollBar> | ||
30 | #include <QVBoxLayout> | | |||
31 | 29 | | |||
32 | // ---------------------------------------------------------------------------- | 30 | // ---------------------------------------------------------------------------- | ||
33 | // KDE Includes | 31 | // KDE Includes | ||
34 | 32 | | |||
35 | #include <KSharedConfig> | 33 | #include <KSharedConfig> | ||
36 | 34 | | |||
37 | // ---------------------------------------------------------------------------- | 35 | // ---------------------------------------------------------------------------- | ||
38 | // Project Includes | 36 | // Project Includes | ||
39 | 37 | | |||
40 | #include "transactiondlg.h" | 38 | #include "transactiondlg.h" | ||
41 | #include "securitydlg.h" | 39 | #include "securitydlg.h" | ||
42 | #include "securitiesdlg.h" | 40 | #include "securitiesdlg.h" | ||
43 | #include "currenciesdlg.h" | 41 | #include "currenciesdlg.h" | ||
44 | 42 | | |||
45 | //#include "csvimporter.h" | 43 | #include "csvwizardpage.h" | ||
46 | #include "csvimporterplugin.h" | | |||
47 | #include "bankingwizardpage.h" | 44 | #include "bankingwizardpage.h" | ||
48 | #include "investmentwizardpage.h" | 45 | #include "investmentwizardpage.h" | ||
49 | #include "priceswizardpage.h" | 46 | #include "priceswizardpage.h" | ||
50 | 47 | | |||
51 | | ||||
52 | class CsvImporterPlugin; | 48 | class CsvImporterPlugin; | ||
53 | class CSVImporter; | 49 | class CSVImporter; | ||
54 | 50 | | |||
55 | class TransactionDlg; | 51 | class TransactionDlg; | ||
56 | class SecurityDlg; | 52 | class SecurityDlg; | ||
57 | class SecuritiesDlg; | 53 | class SecuritiesDlg; | ||
58 | class CurrenciesDlg; | 54 | class CurrenciesDlg; | ||
59 | 55 | | |||
Show All 21 Lines | |||||
81 | public: | 77 | public: | ||
82 | CSVWizard(CsvImporterPlugin *plugin, CSVImporter *importer); | 78 | CSVWizard(CsvImporterPlugin *plugin, CSVImporter *importer); | ||
83 | ~CSVWizard(); | 79 | ~CSVWizard(); | ||
84 | 80 | | |||
85 | enum wizardPageE { PageIntro, PageSeparator, PageRows, | 81 | enum wizardPageE { PageIntro, PageSeparator, PageRows, | ||
86 | PageBanking, PageInvestment, PagePrices, PageFormats | 82 | PageBanking, PageInvestment, PagePrices, PageFormats | ||
87 | }; | 83 | }; | ||
88 | 84 | | |||
89 | Ui::CSVWizard* ui; | 85 | Ui::CSVWizard *ui; | ||
90 | | ||||
91 | CsvImporterPlugin* m_plugin; | | |||
92 | CSVImporter* m_imp; | | |||
93 | QWizard* m_wiz; | | |||
94 | | ||||
95 | IntroPage *m_pageIntro; | | |||
96 | SeparatorPage *m_pageSeparator; | | |||
97 | RowsPage *m_pageRows; | | |||
98 | QPointer<BankingPage> m_pageBanking; | | |||
99 | QPointer<InvestmentPage> m_pageInvestment; | | |||
100 | QPointer<PricesPage> m_pagePrices; | | |||
101 | FormatsPage *m_pageFormats; | | |||
102 | | ||||
103 | MyMoneyStatement m_st; | 86 | MyMoneyStatement m_st; | ||
104 | | ||||
105 | QList<QLabel *> m_stageLabels; | | |||
106 | QScrollBar *m_vScrollBar; | 87 | QScrollBar *m_vScrollBar; | ||
88 | IntroPage *m_pageIntro; | ||||
89 | | ||||
90 | int m_initialHeight; | ||||
91 | int m_initialWidth; | ||||
107 | 92 | | |||
108 | QBrush m_clearBrush; | 93 | QBrush m_clearBrush; | ||
109 | QBrush m_clearBrushText; | 94 | QBrush m_clearBrushText; | ||
110 | QBrush m_colorBrush; | 95 | QBrush m_colorBrush; | ||
111 | QBrush m_colorBrushText; | 96 | QBrush m_colorBrushText; | ||
112 | QBrush m_errorBrush; | 97 | QBrush m_errorBrush; | ||
113 | QBrush m_errorBrushText; | 98 | QBrush m_errorBrushText; | ||
114 | 99 | | |||
115 | int m_initialHeight; | 100 | QMap <Column, QString> m_colTypeName; | ||
116 | int m_initialWidth; | | |||
117 | | ||||
118 | QMap <columnTypeE, QString> m_colTypeName; | | |||
119 | bool m_skipSetup; | 101 | bool m_skipSetup; | ||
120 | 102 | | |||
121 | void showStage(); | | |||
122 | | ||||
123 | void clearColumnsBackground(const int col); | 103 | void clearColumnsBackground(const int col); | ||
124 | void clearColumnsBackground(const QList<int> &columnList); | 104 | void clearColumnsBackground(const QList<int> &columnList); | ||
125 | void clearBackground(); | 105 | void clearBackground(); | ||
126 | void markUnwantedRows(); | 106 | void markUnwantedRows(); | ||
127 | 107 | void importClicked(); | |||
128 | public slots: | | |||
129 | | ||||
130 | /** | | |||
131 | * This method is called when 'Exit' is clicked. The plugin settings will | | |||
132 | * be saved and the plugin will be terminated. | | |||
133 | */ | | |||
134 | void slotClose(); | | |||
135 | | ||||
136 | /** | 108 | /** | ||
137 | * Called in order to adjust window size to suit the file, | 109 | * Called in order to adjust window size to suit the file, | ||
138 | */ | 110 | */ | ||
139 | void updateWindowSize(); | 111 | void updateWindowSize(); | ||
140 | 112 | | |||
113 | void initializeComboBoxes(const QHash<Column, QComboBox *> &columns); | ||||
114 | | ||||
115 | private: | ||||
116 | QList<QLabel *> m_stageLabels; | ||||
117 | | ||||
118 | int m_curId; | ||||
119 | int m_lastId; | ||||
120 | | ||||
121 | SeparatorPage *m_pageSeparator; | ||||
122 | RowsPage *m_pageRows; | ||||
123 | QPointer<BankingPage> m_pageBanking; | ||||
124 | QPointer<InvestmentPage> m_pageInvestment; | ||||
125 | QPointer<PricesPage> m_pagePrices; | ||||
126 | FormatsPage *m_pageFormats; | ||||
127 | | ||||
128 | CsvImporterPlugin* m_plugin; | ||||
129 | CSVImporter* m_imp; | ||||
130 | QWizard* m_wiz; | ||||
131 | | ||||
141 | void readWindowSize(const KSharedConfigPtr& config); | 132 | void readWindowSize(const KSharedConfigPtr& config); | ||
142 | void saveWindowSize(const KSharedConfigPtr& config); | 133 | void saveWindowSize(const KSharedConfigPtr& config); | ||
134 | void showStage(); | ||||
143 | 135 | | |||
136 | void closeEvent(QCloseEvent *event); | ||||
137 | bool eventFilter(QObject *object, QEvent *event); | ||||
144 | 138 | | |||
139 | private slots: | ||||
140 | /** | ||||
141 | * This method is called when 'Exit' is clicked. The plugin settings will | ||||
142 | * be saved and the plugin will be terminated. | ||||
143 | */ | ||||
144 | void slotClose(); | ||||
145 | void slotIdChanged(int id); | 145 | void slotIdChanged(int id); | ||
146 | | ||||
147 | void fileDialogClicked(); | 146 | void fileDialogClicked(); | ||
148 | void importClicked(); | | |||
149 | void saveAsQIFClicked(); | 147 | void saveAsQIFClicked(); | ||
150 | private: | | |||
151 | int m_curId; | | |||
152 | int m_lastId; | | |||
153 | 148 | | |||
154 | void closeEvent(QCloseEvent *event); | 149 | signals: | ||
155 | bool eventFilter(QObject *object, QEvent *event); | 150 | void statementReady(MyMoneyStatement&); | ||
156 | // void resizeEvent(QResizeEvent* ev); | 151 | }; | ||
157 | } | | |||
158 | ; | | |||
159 | 152 | | |||
160 | namespace Ui | 153 | namespace Ui | ||
161 | { | 154 | { | ||
162 | class IntroPage; | 155 | class IntroPage; | ||
163 | } | 156 | } | ||
164 | 157 | | |||
165 | class IntroPage : public CSVWizardPage | 158 | class IntroPage : public CSVWizardPage | ||
166 | { | 159 | { | ||
167 | Q_OBJECT | 160 | Q_OBJECT | ||
168 | 161 | | |||
169 | public: | 162 | public: | ||
170 | explicit IntroPage(CSVWizard *dlg, CSVImporter *imp); | 163 | explicit IntroPage(CSVWizard *dlg, CSVImporter *imp); | ||
171 | ~IntroPage(); | 164 | ~IntroPage(); | ||
172 | 165 | | |||
173 | Ui::IntroPage *ui; | | |||
174 | void initializePage(); | 166 | void initializePage(); | ||
175 | // void setParent(CSVWizard* dlg, CSVImporter *imp); | | |||
176 | 167 | | |||
177 | QVBoxLayout* m_pageLayout; | 168 | Profile m_profileType; | ||
178 | profileTypeE m_profileType; | 169 | Ui::IntroPage *ui; | ||
179 | 170 | | |||
180 | signals: | 171 | signals: | ||
181 | void signalBankClicked(bool); | 172 | void signalBankClicked(bool); | ||
182 | void activated(int); | 173 | void activated(int); | ||
183 | void returnPressed(); | 174 | void returnPressed(); | ||
184 | 175 | | |||
185 | private: | 176 | private: | ||
186 | bool validatePage(); | | |||
187 | int nextId() const; | | |||
188 | | ||||
189 | QStringList m_profiles; | 177 | QStringList m_profiles; | ||
190 | 178 | | |||
191 | void profileChanged(const profilesActionE action); | 179 | bool validatePage(); | ||
192 | void profileTypeChanged(const profileTypeE profileType, bool toggled); | 180 | int nextId() const; | ||
193 | 181 | | |||
194 | public slots: | 182 | void profileChanged(const ProfileAction action); | ||
183 | void profileTypeChanged(const Profile profileType, bool toggled); | ||||
195 | 184 | | |||
196 | private slots: | 185 | private slots: | ||
197 | void slotAddProfile(); | 186 | void slotAddProfile(); | ||
198 | void slotRemoveProfile(); | 187 | void slotRemoveProfile(); | ||
199 | void slotRenameProfile(); | 188 | void slotRenameProfile(); | ||
200 | void slotComboSourceIndexChanged(int idx); | 189 | void slotComboSourceIndexChanged(int idx); | ||
201 | void slotBankRadioToggled(bool toggled); | 190 | void slotBankRadioToggled(bool toggled); | ||
202 | void slotInvestRadioToggled(bool toggled); | 191 | void slotInvestRadioToggled(bool toggled); | ||
Show All 9 Lines | |||||
212 | class SeparatorPage : public CSVWizardPage | 201 | class SeparatorPage : public CSVWizardPage | ||
213 | { | 202 | { | ||
214 | Q_OBJECT | 203 | Q_OBJECT | ||
215 | 204 | | |||
216 | public: | 205 | public: | ||
217 | explicit SeparatorPage(CSVWizard *dlg, CSVImporter *imp); | 206 | explicit SeparatorPage(CSVWizard *dlg, CSVImporter *imp); | ||
218 | ~SeparatorPage(); | 207 | ~SeparatorPage(); | ||
219 | 208 | | |||
220 | Ui::SeparatorPage *ui; | 209 | private slots: | ||
221 | | ||||
222 | QVBoxLayout *m_pageLayout; | | |||
223 | | ||||
224 | void initializePage(); | | |||
225 | bool isComplete() const; | | |||
226 | | ||||
227 | public slots: | | |||
228 | void encodingChanged(const int index); | 210 | void encodingChanged(const int index); | ||
229 | void fieldDelimiterChanged(const int index); | 211 | void fieldDelimiterChanged(const int index); | ||
230 | void textDelimiterChanged(const int index); | 212 | void textDelimiterChanged(const int index); | ||
231 | 213 | | |||
232 | signals: | 214 | signals: | ||
233 | void completeChanged(); | 215 | void completeChanged(); | ||
234 | 216 | | |||
235 | private: | 217 | private: | ||
218 | Ui::SeparatorPage *ui; | ||||
236 | void initializeEncodingCombobox(); | 219 | void initializeEncodingCombobox(); | ||
220 | void initializePage(); | ||||
221 | bool isComplete() const; | ||||
237 | void cleanupPage(); | 222 | void cleanupPage(); | ||
238 | bool validatePage(); | 223 | bool validatePage(); | ||
239 | | ||||
240 | private slots: | | |||
241 | | ||||
242 | signals: | | |||
243 | }; | 224 | }; | ||
244 | 225 | | |||
245 | namespace Ui | 226 | namespace Ui | ||
246 | { | 227 | { | ||
247 | class RowsPage; | 228 | class RowsPage; | ||
248 | } | 229 | } | ||
249 | 230 | | |||
250 | class RowsPage : public CSVWizardPage | 231 | class RowsPage : public CSVWizardPage | ||
251 | { | 232 | { | ||
252 | Q_OBJECT | 233 | Q_OBJECT | ||
253 | 234 | | |||
254 | public: | 235 | public: | ||
255 | explicit RowsPage(CSVWizard *dlg, CSVImporter *imp); | 236 | explicit RowsPage(CSVWizard *dlg, CSVImporter *imp); | ||
256 | ~RowsPage(); | 237 | ~RowsPage(); | ||
257 | 238 | | |||
258 | Ui::RowsPage *ui; | 239 | private slots: | ||
259 | | ||||
260 | QVBoxLayout *m_pageLayout; | | |||
261 | | ||||
262 | void initializePage(); | | |||
263 | int nextId() const; | | |||
264 | | ||||
265 | signals: | | |||
266 | | ||||
267 | public slots: | | |||
268 | /** | 240 | /** | ||
269 | * This method is called when the user edits the startLine setting. | 241 | * This method is called when the user edits the startLine setting. | ||
270 | */ | 242 | */ | ||
271 | void startRowChanged(int val); | 243 | void startRowChanged(int val); | ||
272 | 244 | | |||
273 | /** | 245 | /** | ||
274 | * This method is called when the user edits the lastLine setting. | 246 | * This method is called when the user edits the lastLine setting. | ||
275 | */ | 247 | */ | ||
276 | void endRowChanged(int val); | 248 | void endRowChanged(int val); | ||
277 | private: | 249 | private: | ||
250 | Ui::RowsPage *ui; | ||||
251 | void initializePage(); | ||||
252 | int nextId() const; | ||||
278 | void cleanupPage(); | 253 | void cleanupPage(); | ||
279 | }; | 254 | }; | ||
280 | 255 | | |||
281 | | ||||
282 | | ||||
283 | namespace Ui | 256 | namespace Ui | ||
284 | { | 257 | { | ||
285 | class FormatsPage; | 258 | class FormatsPage; | ||
286 | } | 259 | } | ||
287 | 260 | | |||
288 | class FormatsPage : public CSVWizardPage | 261 | class FormatsPage : public CSVWizardPage | ||
289 | { | 262 | { | ||
290 | Q_OBJECT | 263 | Q_OBJECT | ||
291 | 264 | | |||
292 | public: | 265 | public: | ||
293 | explicit FormatsPage(CSVWizard *dlg, CSVImporter *imp); | 266 | explicit FormatsPage(CSVWizard *dlg, CSVImporter *imp); | ||
294 | ~FormatsPage(); | 267 | ~FormatsPage(); | ||
295 | 268 | | |||
269 | private: | ||||
296 | Ui::FormatsPage *ui; | 270 | Ui::FormatsPage *ui; | ||
297 | 271 | bool m_isDecimalSymbolOK; | |||
298 | QVBoxLayout *m_pageLayout; | 272 | bool m_isDateFormatOK; | ||
299 | | ||||
300 | void initializePage(); | | |||
301 | 273 | | |||
302 | /** | 274 | /** | ||
303 | * This method is called when the user selects a new decimal symbol. The | 275 | * This method is called when the user selects a new decimal symbol. The | ||
304 | * UI is updated using the new symbol, and on importing, the new symbol | 276 | * UI is updated using the new symbol, and on importing, the new symbol | ||
305 | * also will be used. | 277 | * also will be used. | ||
306 | */ | 278 | */ | ||
307 | bool validateDecimalSymbols(const QList<int> &columns); | 279 | bool validateDecimalSymbols(const QList<int> &columns); | ||
308 | 280 | | |||
309 | /** | 281 | /** | ||
310 | * This method checks if all dates in date column are valid. | 282 | * This method checks if all dates in date column are valid. | ||
311 | */ | 283 | */ | ||
312 | bool validateDateFormat(const int index); | 284 | bool validateDateFormat(const int index); | ||
313 | 285 | | |||
286 | void initializePage(); | ||||
287 | bool isComplete() const; | ||||
288 | void cleanupPage(); | ||||
289 | | ||||
314 | signals: | 290 | signals: | ||
315 | void completeChanged(); | 291 | void completeChanged(); | ||
316 | public slots: | | |||
317 | | ||||
318 | 292 | | |||
293 | private slots: | ||||
319 | void decimalSymbolChanged(int); | 294 | void decimalSymbolChanged(int); | ||
320 | void dateFormatChanged(const int index); | 295 | void dateFormatChanged(const int index); | ||
321 | private: | | |||
322 | bool m_isDecimalSymbolOK; | | |||
323 | bool m_isDateFormatOK; | | |||
324 | | ||||
325 | bool isComplete() const; | | |||
326 | void cleanupPage(); | | |||
327 | }; | 296 | }; | ||
328 | 297 | | |||
329 | #endif // CSVWIZARD_H | 298 | #endif // CSVWIZARD_H |