Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/plugins/csvimport/bankingwizardpage.h
Show All 18 Lines | |||||
19 | 19 | | |||
20 | #ifndef BANKINGWIZARDPAGE_H | 20 | #ifndef BANKINGWIZARDPAGE_H | ||
21 | #define BANKINGWIZARDPAGE_H | 21 | #define BANKINGWIZARDPAGE_H | ||
22 | 22 | | |||
23 | // ---------------------------------------------------------------------------- | 23 | // ---------------------------------------------------------------------------- | ||
24 | // QT Includes | 24 | // QT Includes | ||
25 | 25 | | |||
26 | #include <QtCore/QFile> | 26 | #include <QtCore/QFile> | ||
27 | #include <QPointer> | | |||
28 | #include <QWizardPage> | | |||
29 | #include <QVBoxLayout> | 27 | #include <QVBoxLayout> | ||
30 | #include <QSet> | | |||
31 | 28 | | |||
32 | // ---------------------------------------------------------------------------- | 29 | // ---------------------------------------------------------------------------- | ||
33 | // KDE Includes | 30 | // KDE Includes | ||
34 | 31 | | |||
35 | #include <KSharedConfig> | | |||
36 | | ||||
37 | // ---------------------------------------------------------------------------- | 32 | // ---------------------------------------------------------------------------- | ||
38 | // Project Includes | 33 | // Project Includes | ||
39 | 34 | | |||
40 | #include <mymoneystatement.h> | 35 | #include <mymoneystatement.h> | ||
36 | #include <csvimporter.h> | ||||
41 | 37 | | |||
42 | // ---------------------------------------------------------------------------- | 38 | // ---------------------------------------------------------------------------- | ||
43 | 39 | | |||
44 | class CSVWizard; | 40 | class BankingProfile; | ||
45 | class BankingPage; | | |||
46 | 41 | | |||
47 | namespace Ui | 42 | namespace Ui | ||
48 | { | 43 | { | ||
49 | class BankingPage; | 44 | class BankingPage; | ||
50 | } | 45 | } | ||
51 | 46 | | |||
52 | class BankingPage : public QWizardPage | 47 | class BankingPage : public CSVWizardPage | ||
53 | { | 48 | { | ||
54 | Q_OBJECT | 49 | Q_OBJECT | ||
55 | 50 | | |||
56 | public: | 51 | public: | ||
57 | explicit BankingPage(QDialog *parent = 0); | 52 | explicit BankingPage(CSVWizard *dlg, CSVImporter *imp); | ||
58 | ~BankingPage(); | 53 | ~BankingPage(); | ||
59 | 54 | | |||
60 | Ui::BankingPage *ui; | 55 | Ui::BankingPage *ui; | ||
61 | QVBoxLayout *m_pageLayout; | 56 | QVBoxLayout *m_pageLayout; | ||
62 | 57 | | |||
63 | CSVWizard* m_wiz; | 58 | bool validateCreditDebit(); | ||
64 | | ||||
65 | typedef enum:uchar { ColumnNumber, ColumnDate, ColumnPayee, ColumnAmount, | | |||
66 | ColumnCredit, ColumnDebit, ColumnCategory, | | |||
67 | ColumnMemo, ColumnEmpty = 0xFE, ColumnInvalid = 0xFF | | |||
68 | } columnTypeE; | | |||
69 | | ||||
70 | QMap<columnTypeE, int> m_colTypeNum; | | |||
71 | QMap<int ,columnTypeE> m_colNumType; | | |||
72 | QMap<columnTypeE, QString> m_colTypeName; | | |||
73 | | ||||
74 | void saveSettings(); | | |||
75 | void readSettings(const KSharedConfigPtr &config); | | |||
76 | void setParent(CSVWizard* dlg); | | |||
77 | | ||||
78 | /** | 59 | /** | ||
79 | * This method fills QIF file with bank/credit card data | 60 | * This method fills QIF file with bank/credit card data | ||
80 | */ | 61 | */ | ||
81 | void makeQIF(MyMoneyStatement &st, QFile &file); | 62 | void makeQIF(MyMoneyStatement &st, QFile &file); | ||
82 | 63 | | |||
83 | /** | | |||
84 | * This method feeds file buffer in banking lines parser. | | |||
85 | */ | | |||
86 | bool createStatement(MyMoneyStatement& st); | | |||
87 | | ||||
88 | private: | 64 | private: | ||
89 | | ||||
90 | QStringList m_columnList; | | |||
91 | QSet<QString> m_hashSet; | | |||
92 | int m_oppositeSigns; | | |||
93 | | ||||
94 | void initializePage(); | 65 | void initializePage(); | ||
95 | bool isComplete() const; | 66 | bool isComplete() const; | ||
96 | int nextId() const; | 67 | int nextId() const; | ||
97 | 68 | | |||
98 | void initializeComboBoxes(); | 69 | void initializeComboBoxes(); | ||
99 | bool validateMemoComboBox(); | 70 | bool validateMemoComboBox(); | ||
100 | void resetComboBox(const columnTypeE comboBox); | 71 | void resetComboBox(const columnTypeE comboBox); | ||
101 | bool validateSelectedColumn(int col, columnTypeE type); | 72 | bool validateSelectedColumn(const int col, const columnTypeE type); | ||
102 | 73 | | |||
103 | /** | 74 | BankingProfile *m_profile; | ||
104 | * This method is called during processing. It ensures that processed credit/debit | | |||
105 | * are valid. | | |||
106 | */ | | |||
107 | bool processCreditDebit(QString& credit, QString& debit , MyMoneyMoney& amount); | | |||
108 | | ||||
109 | /** | | |||
110 | * This method is called when the user clicks 'import'. | | |||
111 | * or 'Make QIF' It will evaluate a line and prepare it to be added to a statement, | | |||
112 | * and to a QIF file, if required. | | |||
113 | */ | | |||
114 | bool processBankLine(const QString &line, MyMoneyStatement &st); | | |||
115 | 75 | | |||
116 | private slots: | 76 | private slots: | ||
117 | void slotMemoColSelected(int col); | 77 | void memoColSelected(int col); | ||
118 | void slotCategoryColSelected(int col); | 78 | void categoryColSelected(int col); | ||
119 | void slotNumberColSelected(int col); | 79 | void numberColSelected(int col); | ||
120 | void slotPayeeColSelected(int col); | 80 | void payeeColSelected(int col); | ||
121 | void slotDateColSelected(int col); | 81 | void dateColSelected(int col); | ||
122 | void slotDebitColSelected(int col); | 82 | void debitColSelected(int col); | ||
123 | void slotCreditColSelected(int col); | 83 | void creditColSelected(int col); | ||
124 | void slotAmountColSelected(int col); | 84 | void amountColSelected(int col); | ||
125 | void slotAmountToggled(bool checked); | 85 | void amountToggled(bool checked); | ||
126 | void slotDebitCreditToggled(bool checked); | 86 | void debitCreditToggled(bool checked); | ||
127 | void slotOppositeSignsClicked(bool checked); | 87 | void oppositeSignsClicked(bool checked); | ||
128 | void slotClearColumns(); | 88 | void clearColumns(); | ||
129 | }; | 89 | }; | ||
130 | 90 | | |||
131 | #endif // BANKINGWIZARDPAGE_H | 91 | #endif // BANKINGWIZARDPAGE_H |