comparison src/main.h @ 80:c8fd927cd2c4

Restructure the project by placing source code, images into appropriate subdirectories.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 24 Apr 2017 12:12:39 +0300
parents main.h@f48b8fc1de64
children efab68769c75
comparison
equal deleted inserted replaced
79:f48b8fc1de64 80:c8fd927cd2c4
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 // Distributed under 3-clause BSD style license, refer to
7 // included file "COPYING" for exact terms.
8 //
9 #ifndef SYNTILISTA_H
10 #define SYNTILISTA_H
11
12 #include <QMainWindow>
13 #include <QShortcut>
14 #include <QDialog>
15 #include <QtSql>
16 #include <QSqlQueryModel>
17
18
19 //
20 // Global application defines
21 //
22 #define APP_VENDOR "TNSP" // Vendor ID (for settings, etc.)
23 #define APP_ID "Kampus Syntilista" // Application ID (for settings)
24 #define APP_NAME "Café Kampus Syntilista" // Application title/name
25 #define APP_SQLITE_FILE "syntilista.sqlite3" // SQLite3 database file name (without path)
26
27
28 //
29 // Custom SQL models
30 //
31 class PersonInfo : public QObject
32 {
33 Q_OBJECT
34
35 public:
36 explicit PersonInfo()
37 {
38 id = -1;
39 firstName = "";
40 lastName = "";
41 extraInfo = "";
42 balance = 0;
43 }
44
45 ~PersonInfo()
46 {
47 }
48
49 void dump();
50
51 qint64 id;
52 QString firstName, lastName, extraInfo;
53 double balance;
54 QDateTime added, updated;
55 };
56
57
58
59 class PersonSQLModel : public QSqlQueryModel
60 {
61 Q_OBJECT
62
63 private:
64
65 public:
66 PersonSQLModel(QObject *parent = 0);
67
68 QVariant data(const QModelIndex &item, int role) const Q_DECL_OVERRIDE;
69
70 int updatePerson(const PersonInfo &person);
71 int addPerson(const PersonInfo &person);
72 int deletePerson(qint64 id);
73 void updateModel();
74 };
75
76
77
78 class TransactionSQLModel : public QSqlQueryModel
79 {
80 Q_OBJECT
81
82 private:
83
84 public:
85 TransactionSQLModel(QObject *parent = 0);
86
87 QVariant data(const QModelIndex &item, int role) const Q_DECL_OVERRIDE;
88
89 void updateModel();
90 };
91
92
93
94 //
95 // Main window
96 //
97 namespace Ui {
98 class SyntilistaMainWindow;
99 class EditPerson;
100 }
101
102 class SyntilistaMainWindow : public QMainWindow
103 {
104 Q_OBJECT
105
106 public:
107 explicit SyntilistaMainWindow(QWidget *parent = 0);
108 ~SyntilistaMainWindow();
109
110 void statusMsg(const QString &msg);
111
112 void readSettings();
113 void saveSettings();
114 void setActivePerson(qint64 id);
115 int addTransaction(qint64 id, double value, PersonInfo &info);
116 int addTransactionGUI(qint64 id, bool debt, double value);
117 void updatePersonList();
118
119 PersonSQLModel *model_People;
120
121 private slots:
122 void on_button_AddPerson_clicked();
123 void on_button_EditPerson_clicked();
124 void on_button_DeletePerson_clicked();
125
126 void on_edit_PersonFilter_textChanged(const QString &arg1);
127 void on_button_ClearFilter_clicked();
128
129 void on_button_Quit_clicked();
130 void on_button_About_clicked();
131 void on_button_Help_clicked();
132
133 void on_button_AddDebt_clicked();
134 void on_button_PayDebt_clicked();
135 void on_button_PayFullDebt_clicked();
136
137 void on_tableview_People_doubleClicked(const QModelIndex &index);
138
139 void selectedPersonChanged(const QModelIndex &, const QModelIndex &);
140
141 void focusDebtEdit();
142 void selectRowPrev();
143 void selectRowNext();
144
145 void changeUIZoomIn();
146 void changeUIZoomOut();
147 void changeUIZoomReset();
148
149 void updateSortOrder(int index, Qt::SortOrder order);
150
151
152 private:
153 Ui::SyntilistaMainWindow *ui;
154
155 TransactionSQLModel *model_Latest;
156 PersonInfo currPerson;
157
158 int peopleSortIndex;
159 Qt::SortOrder peopleSortOrder;
160 QString peopleFilter;
161 };
162
163
164 //
165 // Person edit / new person dialog
166 //
167 class EditPerson : public QDialog
168 {
169 Q_OBJECT
170
171 public:
172 explicit EditPerson(QWidget *parent = 0);
173 ~EditPerson();
174
175 void statusMsg(const QString &msg);
176
177 void clearForm();
178 bool validateForm();
179 void setPerson(qint64 id);
180
181 private slots:
182 void on_button_OK_clicked();
183
184 void on_button_Cancel_clicked();
185
186 void on_edit_FirstName_textChanged(const QString &arg1);
187
188 void on_edit_LastName_textChanged(const QString &arg1);
189
190 private:
191 Ui::EditPerson *ui;
192
193 PersonInfo selPerson;
194 TransactionSQLModel *model_Transactions;
195 };
196
197 #endif // SYNTILISTA_H