Mercurial > hg > syntilista
comparison main.h @ 0:fec4d0c461f2
Initial import of the post-prototyping phase code.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 30 Mar 2017 03:20:08 +0300 |
parents | |
children | edc1e8cf6e2c |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:fec4d0c461f2 |
---|---|
1 // | |
2 // Syntilista - velkalistasovellus Kampus-kahvilaan | |
3 // Programmed and designed by Matti Hämäläinen <ccr@tnsp.org> | |
4 // (C) Copyright 2017 Tecnic Software productions (TNSP) | |
5 // | |
6 #ifndef MAINWINDOW_H | |
7 #define MAINWINDOW_H | |
8 | |
9 #include <QMainWindow> | |
10 #include <QDialog> | |
11 #include <QtSql> | |
12 #include <QSqlQueryModel> | |
13 | |
14 | |
15 // | |
16 // | |
17 // | |
18 #define APP_VENDOR "TNSP" | |
19 #define APP_NAME "Syntilista" | |
20 #define APP_VERSION "0.1" | |
21 | |
22 | |
23 // | |
24 // Custom SQL models | |
25 // | |
26 class PersonInfo : public QObject | |
27 { | |
28 Q_OBJECT | |
29 | |
30 public: | |
31 explicit PersonInfo() | |
32 { | |
33 } | |
34 | |
35 ~PersonInfo() | |
36 { | |
37 } | |
38 | |
39 qint64 id; | |
40 QString firstName, lastName, extraInfo; | |
41 }; | |
42 | |
43 | |
44 | |
45 class PersonSQLModel : public QSqlQueryModel | |
46 { | |
47 Q_OBJECT | |
48 | |
49 private: | |
50 | |
51 public: | |
52 PersonSQLModel(QObject *parent = 0); | |
53 | |
54 QVariant data(const QModelIndex &item, int role) const Q_DECL_OVERRIDE; | |
55 | |
56 void updatePerson(const QModelIndex &item, const PersonInfo &person); | |
57 void addPerson(const PersonInfo &person); | |
58 void updateModel(); | |
59 }; | |
60 | |
61 | |
62 | |
63 class TransactionSQLModel : public QSqlQueryModel | |
64 { | |
65 Q_OBJECT | |
66 | |
67 private: | |
68 | |
69 public: | |
70 TransactionSQLModel(QObject *parent = 0); | |
71 | |
72 QVariant data(const QModelIndex &item, int role) const Q_DECL_OVERRIDE; | |
73 | |
74 void updateModel(); | |
75 }; | |
76 | |
77 | |
78 | |
79 // | |
80 // Main window | |
81 // | |
82 namespace Ui { | |
83 class SyntilistaMainWindow; | |
84 class EditPerson; | |
85 } | |
86 | |
87 class SyntilistaMainWindow : public QMainWindow | |
88 { | |
89 Q_OBJECT | |
90 | |
91 public: | |
92 explicit SyntilistaMainWindow(QWidget *parent = 0); | |
93 ~SyntilistaMainWindow(); | |
94 | |
95 void statusMsg(const QString &msg); | |
96 | |
97 void readSettings(); | |
98 void saveSettings(); | |
99 void setActivePerson(qint64 id); | |
100 bool addTransaction(bool debt, double value); | |
101 void updatePersonList(); | |
102 | |
103 PersonSQLModel *model_People; | |
104 | |
105 private slots: | |
106 void on_button_AddPerson_clicked(); | |
107 | |
108 void on_button_EditPerson_clicked(); | |
109 | |
110 void on_button_ClearFilter_clicked(); | |
111 | |
112 void on_button_Quit_clicked(); | |
113 | |
114 void on_button_XXX_clicked(); | |
115 | |
116 void on_button_AddDebt_clicked(); | |
117 | |
118 void on_button_SubDebt_clicked(); | |
119 | |
120 void on_edit_PersonFilter_textChanged(const QString &arg1); | |
121 | |
122 void on_tableview_People_doubleClicked(const QModelIndex &index); | |
123 | |
124 void selectedPersonChanged(const QModelIndex &, const QModelIndex &); | |
125 | |
126 void updatePersonData(qint64 id); | |
127 | |
128 void updateSortOrder(int index, Qt::SortOrder order); | |
129 | |
130 private: | |
131 Ui::SyntilistaMainWindow *ui; | |
132 | |
133 TransactionSQLModel *model_Latest; | |
134 qint64 personID; | |
135 int peopleSortIndex; | |
136 Qt::SortOrder peopleSortOrder; | |
137 QString peopleFilter; | |
138 }; | |
139 | |
140 | |
141 class EditPerson : public QDialog | |
142 { | |
143 Q_OBJECT | |
144 | |
145 public: | |
146 explicit EditPerson(QWidget *parent = 0); | |
147 ~EditPerson(); | |
148 | |
149 void statusMsg(const QString &msg); | |
150 | |
151 void clearForm(); | |
152 bool validateForm(PersonInfo &info); | |
153 bool validateForm(); | |
154 void setPerson(qint64 id); | |
155 | |
156 private slots: | |
157 void on_button_OK_clicked(); | |
158 | |
159 void on_button_Cancel_clicked(); | |
160 | |
161 void on_edit_FirstName_textChanged(const QString &arg1); | |
162 | |
163 void on_edit_LastName_textChanged(const QString &arg1); | |
164 | |
165 private: | |
166 Ui::EditPerson *ui; | |
167 | |
168 qint64 personID; | |
169 TransactionSQLModel *model_Transactions; | |
170 }; | |
171 | |
172 #endif // MAINWINDOW_H |