Mercurial > hg > syntilista
annotate src/main.h @ 209:6f404158ce8c
Get rid of tiny bit of code duplication.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 21 Nov 2017 11:27:15 +0200 |
parents | 2438ea2611f9 |
children | 6585cac42b75 |
rev | line source |
---|---|
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1 // |
140
783417da6da3
Change the program description to english etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
130
diff
changeset
|
2 // Syntilista - debt list/management database program |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
3 // Programmed and designed by Matti Hämäläinen <ccr@tnsp.org> |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
4 // (C) Copyright 2017 Tecnic Software productions (TNSP) |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
5 // |
57 | 6 // Distributed under 3-clause BSD style license, refer to |
7 // included file "COPYING" for exact terms. | |
8 // | |
41 | 9 #ifndef SYNTILISTA_H |
10 #define SYNTILISTA_H | |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
11 |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
12 #include <QMainWindow> |
17
d40345d63733
Implement some keyboard shortcuts.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
13 #include <QShortcut> |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
14 #include <QDialog> |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
15 #include <QtSql> |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
16 #include <QSqlQueryModel> |
114
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
17 #include <QPainter> |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
18 #include <QPrinter> |
142
36c9cb759326
Implement simple SQLite database backup at program exit using Qt HTTP/HTTPS
Matti Hamalainen <ccr@tnsp.org>
parents:
141
diff
changeset
|
19 #include <QProgressDialog> |
150
2a8c97753381
Make the backup stuff compile-time optional.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
20 #ifdef USE_QTHTTP |
2a8c97753381
Make the backup stuff compile-time optional.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
21 # include <QNetworkAccessManager> |
2a8c97753381
Make the backup stuff compile-time optional.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
22 # include <QNetworkRequest> |
2a8c97753381
Make the backup stuff compile-time optional.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
23 # include <QNetworkReply> |
2a8c97753381
Make the backup stuff compile-time optional.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
24 # include <QHttpMultiPart> |
2a8c97753381
Make the backup stuff compile-time optional.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
25 #endif |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
26 |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
27 |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
28 // |
41 | 29 // Global application defines |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
30 // |
149 | 31 #define APP_VENDOR "TNSP" // Vendor ID (for settings, etc.) |
32 #define APP_ID "Kampus Syntilista" // Application ID (for settings) | |
33 #define APP_NAME "Café Kampus Syntilista" // Application title/name | |
34 #define APP_SQLITE_FILE "syntilista.sqlite3" // SQLite3 database file name (without path) | |
35 #define APP_LOG_FILE "log.txt" // Application log file name (without path) | |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
36 |
149 | 37 // SQL database field width/lengths |
38 #define SQL_LEN_FIRST_NAME 128 | |
39 #define SQL_LEN_LAST_NAME 128 | |
40 #define SQL_LEN_EXTRA_INFO 2048 | |
113
907f2ddf6801
Use #defines for SQL table field lengths.
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
41 |
150
2a8c97753381
Make the backup stuff compile-time optional.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
42 // Supported database backup modes |
2a8c97753381
Make the backup stuff compile-time optional.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
43 #define BACKUP_NONE 0 // No backup |
2a8c97753381
Make the backup stuff compile-time optional.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
44 #define BACKUP_HTTP 1 // HTTP(s) POST to a PHP script |
2a8c97753381
Make the backup stuff compile-time optional.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
45 |
113
907f2ddf6801
Use #defines for SQL table field lengths.
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
46 |
157
325e7590f93e
Move most of the printing related code to printing.cpp
Matti Hamalainen <ccr@tnsp.org>
parents:
152
diff
changeset
|
47 |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
48 // |
157
325e7590f93e
Move most of the printing related code to printing.cpp
Matti Hamalainen <ccr@tnsp.org>
parents:
152
diff
changeset
|
49 // Person information record |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
50 // |
174
636a24c76232
Rename some classes to add a SL prefix to their names.
Matti Hamalainen <ccr@tnsp.org>
parents:
160
diff
changeset
|
51 class SLPersonInfo : public QObject |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
52 { |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
53 Q_OBJECT |
112 | 54 |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
55 public: |
174
636a24c76232
Rename some classes to add a SL prefix to their names.
Matti Hamalainen <ccr@tnsp.org>
parents:
160
diff
changeset
|
56 explicit SLPersonInfo() |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
57 { |
5 | 58 id = -1; |
59 firstName = ""; | |
60 lastName = ""; | |
61 extraInfo = ""; | |
62 balance = 0; | |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
63 } |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
64 |
174
636a24c76232
Rename some classes to add a SL prefix to their names.
Matti Hamalainen <ccr@tnsp.org>
parents:
160
diff
changeset
|
65 ~SLPersonInfo() |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
66 { |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
67 } |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
68 |
5 | 69 void dump(); |
70 | |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
71 qint64 id; |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
72 QString firstName, lastName, extraInfo; |
5 | 73 double balance; |
4 | 74 QDateTime added, updated; |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
75 }; |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
76 |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
77 |
157
325e7590f93e
Move most of the printing related code to printing.cpp
Matti Hamalainen <ccr@tnsp.org>
parents:
152
diff
changeset
|
78 // |
325e7590f93e
Move most of the printing related code to printing.cpp
Matti Hamalainen <ccr@tnsp.org>
parents:
152
diff
changeset
|
79 // Global functions |
325e7590f93e
Move most of the printing related code to printing.cpp
Matti Hamalainen <ccr@tnsp.org>
parents:
152
diff
changeset
|
80 // |
325e7590f93e
Move most of the printing related code to printing.cpp
Matti Hamalainen <ccr@tnsp.org>
parents:
152
diff
changeset
|
81 double slMoneyStrToValue(const QString &str); |
325e7590f93e
Move most of the printing related code to printing.cpp
Matti Hamalainen <ccr@tnsp.org>
parents:
152
diff
changeset
|
82 QString slMoneyValueToStr(double val); |
325e7590f93e
Move most of the printing related code to printing.cpp
Matti Hamalainen <ccr@tnsp.org>
parents:
152
diff
changeset
|
83 QString slCleanupStr(const QString &str); |
325e7590f93e
Move most of the printing related code to printing.cpp
Matti Hamalainen <ccr@tnsp.org>
parents:
152
diff
changeset
|
84 const QDateTime slDateTimeToLocal(const QDateTime &val); |
325e7590f93e
Move most of the printing related code to printing.cpp
Matti Hamalainen <ccr@tnsp.org>
parents:
152
diff
changeset
|
85 const QString slDateTimeToStr(const QDateTime &val); |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
86 |
157
325e7590f93e
Move most of the printing related code to printing.cpp
Matti Hamalainen <ccr@tnsp.org>
parents:
152
diff
changeset
|
87 void slLog(const QString &mtype, const QString &msg); |
200 | 88 int slErrorMsg(const QString &title, const QString &msg); |
157
325e7590f93e
Move most of the printing related code to printing.cpp
Matti Hamalainen <ccr@tnsp.org>
parents:
152
diff
changeset
|
89 bool slCheckAndReportSQLError(const QString where, const QSqlError &err, bool report = false); |
325e7590f93e
Move most of the printing related code to printing.cpp
Matti Hamalainen <ccr@tnsp.org>
parents:
152
diff
changeset
|
90 |
174
636a24c76232
Rename some classes to add a SL prefix to their names.
Matti Hamalainen <ccr@tnsp.org>
parents:
160
diff
changeset
|
91 void slGetPersonInfoRec(QSqlQuery &query, SLPersonInfo &info); |
157
325e7590f93e
Move most of the printing related code to printing.cpp
Matti Hamalainen <ccr@tnsp.org>
parents:
152
diff
changeset
|
92 |
325e7590f93e
Move most of the printing related code to printing.cpp
Matti Hamalainen <ccr@tnsp.org>
parents:
152
diff
changeset
|
93 |
325e7590f93e
Move most of the printing related code to printing.cpp
Matti Hamalainen <ccr@tnsp.org>
parents:
152
diff
changeset
|
94 // |
325e7590f93e
Move most of the printing related code to printing.cpp
Matti Hamalainen <ccr@tnsp.org>
parents:
152
diff
changeset
|
95 // Custom SQL models |
325e7590f93e
Move most of the printing related code to printing.cpp
Matti Hamalainen <ccr@tnsp.org>
parents:
152
diff
changeset
|
96 // |
174
636a24c76232
Rename some classes to add a SL prefix to their names.
Matti Hamalainen <ccr@tnsp.org>
parents:
160
diff
changeset
|
97 class SLPersonSQLModel : public QSqlQueryModel |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
98 { |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
99 Q_OBJECT |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
100 |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
101 private: |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
102 |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
103 public: |
174
636a24c76232
Rename some classes to add a SL prefix to their names.
Matti Hamalainen <ccr@tnsp.org>
parents:
160
diff
changeset
|
104 SLPersonSQLModel(QObject *parent = 0); |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
105 |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
106 QVariant data(const QModelIndex &item, int role) const Q_DECL_OVERRIDE; |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
107 |
174
636a24c76232
Rename some classes to add a SL prefix to their names.
Matti Hamalainen <ccr@tnsp.org>
parents:
160
diff
changeset
|
108 int updatePerson(const SLPersonInfo &person); |
636a24c76232
Rename some classes to add a SL prefix to their names.
Matti Hamalainen <ccr@tnsp.org>
parents:
160
diff
changeset
|
109 qint64 addPerson(const SLPersonInfo &person); |
13 | 110 int deletePerson(qint64 id); |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
111 void updateModel(); |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
112 }; |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
113 |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
114 |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
115 |
174
636a24c76232
Rename some classes to add a SL prefix to their names.
Matti Hamalainen <ccr@tnsp.org>
parents:
160
diff
changeset
|
116 class SLTransactionSQLModel : public QSqlQueryModel |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
117 { |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
118 Q_OBJECT |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
119 |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
120 private: |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
121 |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
122 public: |
174
636a24c76232
Rename some classes to add a SL prefix to their names.
Matti Hamalainen <ccr@tnsp.org>
parents:
160
diff
changeset
|
123 SLTransactionSQLModel(QObject *parent = 0); |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
124 |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
125 QVariant data(const QModelIndex &item, int role) const Q_DECL_OVERRIDE; |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
126 |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
127 void updateModel(); |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
128 }; |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
129 |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
130 |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
131 |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
132 // |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
133 // Main window |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
134 // |
100 | 135 namespace Ui |
136 { | |
137 class SyntilistaMainWindow; | |
138 class EditPerson; | |
139 class AboutWindow; | |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
140 } |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
141 |
114
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
142 typedef struct |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
143 { |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
144 int nlinesPerPage; |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
145 int npages; |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
146 } SLPageInfo; |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
147 |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
148 |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
149 class SyntilistaMainWindow : public QMainWindow |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
150 { |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
151 Q_OBJECT |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
152 |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
153 public: |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
154 explicit SyntilistaMainWindow(QWidget *parent = 0); |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
155 ~SyntilistaMainWindow(); |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
156 |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
157 void statusMsg(const QString &msg); |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
158 |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
159 void readSettings(); |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
160 void saveSettings(); |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
161 void setActivePerson(qint64 id); |
174
636a24c76232
Rename some classes to add a SL prefix to their names.
Matti Hamalainen <ccr@tnsp.org>
parents:
160
diff
changeset
|
162 int addTransaction(qint64 id, double value, SLPersonInfo &info); |
4 | 163 int addTransactionGUI(qint64 id, bool debt, double value); |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
164 void updatePersonList(); |
145
9f3c0a99bcb1
Add display for total number of people on the database.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
165 void updateMiscValues(); |
142
36c9cb759326
Implement simple SQLite database backup at program exit using Qt HTTP/HTTPS
Matti Hamalainen <ccr@tnsp.org>
parents:
141
diff
changeset
|
166 void backupDatabase(); |
190
76afbf6508c8
Add check for last successful database backup, and show a warning dialog at
Matti Hamalainen <ccr@tnsp.org>
parents:
174
diff
changeset
|
167 void backupSuccess(); |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
168 |
160
1c2f9d09e87b
Begin working on printing fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
157
diff
changeset
|
169 bool printDocumentPage(const bool getPageInfo, const int page, QPainter *pt, QPrinter *printer); |
114
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
170 |
174
636a24c76232
Rename some classes to add a SL prefix to their names.
Matti Hamalainen <ccr@tnsp.org>
parents:
160
diff
changeset
|
171 SLPersonSQLModel *model_People; |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
172 |
109
62e570222f66
Return inserted person ID from addPerson() (or negative value in case of errors.)
Matti Hamalainen <ccr@tnsp.org>
parents:
100
diff
changeset
|
173 public slots: |
62e570222f66
Return inserted person ID from addPerson() (or negative value in case of errors.)
Matti Hamalainen <ccr@tnsp.org>
parents:
100
diff
changeset
|
174 void focusDebtEdit(); |
62e570222f66
Return inserted person ID from addPerson() (or negative value in case of errors.)
Matti Hamalainen <ccr@tnsp.org>
parents:
100
diff
changeset
|
175 |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
176 private slots: |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
177 void on_button_AddPerson_clicked(); |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
178 void on_button_EditPerson_clicked(); |
66 | 179 void on_button_DeletePerson_clicked(); |
180 | |
79 | 181 void on_edit_PersonFilter_textChanged(const QString &arg1); |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
182 void on_button_ClearFilter_clicked(); |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
183 |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
184 void on_button_Quit_clicked(); |
60
d7a2a48ebe24
Add a separate "About" button, don't use the logo as one. Change logo widget
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
185 void on_button_About_clicked(); |
114
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
186 void on_button_Print_clicked(); |
47 | 187 |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
188 void on_button_AddDebt_clicked(); |
2
edc1e8cf6e2c
Implement "pay debt in full" button.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
189 void on_button_PayDebt_clicked(); |
edc1e8cf6e2c
Implement "pay debt in full" button.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
190 void on_button_PayFullDebt_clicked(); |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
191 |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
192 void on_tableview_People_doubleClicked(const QModelIndex &index); |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
193 |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
194 void selectedPersonChanged(const QModelIndex &, const QModelIndex &); |
65 | 195 |
209
6f404158ce8c
Get rid of tiny bit of code duplication.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
196 void selectRowDelta(const int delta); |
65 | 197 void selectRowPrev(); |
198 void selectRowNext(); | |
199 | |
46
372c1be58996
Improve shortcuts functionality a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
200 void changeUIZoomIn(); |
372c1be58996
Improve shortcuts functionality a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
201 void changeUIZoomOut(); |
372c1be58996
Improve shortcuts functionality a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
202 void changeUIZoomReset(); |
112 | 203 |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
204 void updateSortOrder(int index, Qt::SortOrder order); |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
205 |
114
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
206 void printDocument(QPrinter *printer); |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
207 |
150
2a8c97753381
Make the backup stuff compile-time optional.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
208 #ifdef USE_QTHTTP |
2a8c97753381
Make the backup stuff compile-time optional.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
209 void httpBackupProgress(qint64 bytesSent, qint64 bytesTotal); |
2a8c97753381
Make the backup stuff compile-time optional.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
210 void httpBackupFinished(); |
2a8c97753381
Make the backup stuff compile-time optional.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
211 void httpBackupError(QNetworkReply::NetworkError code); |
2a8c97753381
Make the backup stuff compile-time optional.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
212 #endif |
142
36c9cb759326
Implement simple SQLite database backup at program exit using Qt HTTP/HTTPS
Matti Hamalainen <ccr@tnsp.org>
parents:
141
diff
changeset
|
213 |
6
0315a3b9f560
Implement person and transaction history deletion.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
214 |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
215 private: |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
216 Ui::SyntilistaMainWindow *ui; |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
217 |
142
36c9cb759326
Implement simple SQLite database backup at program exit using Qt HTTP/HTTPS
Matti Hamalainen <ccr@tnsp.org>
parents:
141
diff
changeset
|
218 QProgressDialog *backupDialog; |
150
2a8c97753381
Make the backup stuff compile-time optional.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
219 #ifdef USE_QTHTTP |
2a8c97753381
Make the backup stuff compile-time optional.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
220 QNetworkReply *httpBackupReply; |
2a8c97753381
Make the backup stuff compile-time optional.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
221 #endif |
142
36c9cb759326
Implement simple SQLite database backup at program exit using Qt HTTP/HTTPS
Matti Hamalainen <ccr@tnsp.org>
parents:
141
diff
changeset
|
222 |
174
636a24c76232
Rename some classes to add a SL prefix to their names.
Matti Hamalainen <ccr@tnsp.org>
parents:
160
diff
changeset
|
223 SLTransactionSQLModel *model_Latest; |
636a24c76232
Rename some classes to add a SL prefix to their names.
Matti Hamalainen <ccr@tnsp.org>
parents:
160
diff
changeset
|
224 SLPersonInfo currPerson; |
2
edc1e8cf6e2c
Implement "pay debt in full" button.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
225 |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
226 int peopleSortIndex; |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
227 Qt::SortOrder peopleSortOrder; |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
228 QString peopleFilter; |
160
1c2f9d09e87b
Begin working on printing fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
157
diff
changeset
|
229 |
1c2f9d09e87b
Begin working on printing fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
157
diff
changeset
|
230 SLPageInfo pinfo; |
174
636a24c76232
Rename some classes to add a SL prefix to their names.
Matti Hamalainen <ccr@tnsp.org>
parents:
160
diff
changeset
|
231 |
636a24c76232
Rename some classes to add a SL prefix to their names.
Matti Hamalainen <ccr@tnsp.org>
parents:
160
diff
changeset
|
232 int totalPeople; |
636a24c76232
Rename some classes to add a SL prefix to their names.
Matti Hamalainen <ccr@tnsp.org>
parents:
160
diff
changeset
|
233 double totalBalance; |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
234 }; |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
235 |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
236 |
41 | 237 // |
238 // Person edit / new person dialog | |
239 // | |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
240 class EditPerson : public QDialog |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
241 { |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
242 Q_OBJECT |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
243 |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
244 public: |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
245 explicit EditPerson(QWidget *parent = 0); |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
246 ~EditPerson(); |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
247 |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
248 void statusMsg(const QString &msg); |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
249 |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
250 void clearForm(); |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
251 bool validateForm(); |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
252 void setPerson(qint64 id); |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
253 |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
254 private slots: |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
255 void on_button_OK_clicked(); |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
256 void on_button_Cancel_clicked(); |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
257 |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
258 void on_edit_FirstName_textChanged(const QString &arg1); |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
259 void on_edit_LastName_textChanged(const QString &arg1); |
121
404d567edaab
Validate the length of extra info field in the add/edit person dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
114
diff
changeset
|
260 void on_textedit_ExtraInfo_textChanged(); |
404d567edaab
Validate the length of extra info field in the add/edit person dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
114
diff
changeset
|
261 |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
262 private: |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
263 Ui::EditPerson *ui; |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
264 |
174
636a24c76232
Rename some classes to add a SL prefix to their names.
Matti Hamalainen <ccr@tnsp.org>
parents:
160
diff
changeset
|
265 SLPersonInfo selPerson; |
636a24c76232
Rename some classes to add a SL prefix to their names.
Matti Hamalainen <ccr@tnsp.org>
parents:
160
diff
changeset
|
266 SLTransactionSQLModel *model_Transactions; |
0
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
267 }; |
fec4d0c461f2
Initial import of the post-prototyping phase code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
268 |
90
efab68769c75
Implement new separate About dialog/help window.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
269 |
efab68769c75
Implement new separate About dialog/help window.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
270 // |
efab68769c75
Implement new separate About dialog/help window.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
271 // About dialog |
efab68769c75
Implement new separate About dialog/help window.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
272 // |
efab68769c75
Implement new separate About dialog/help window.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
273 class AboutWindow : public QDialog |
efab68769c75
Implement new separate About dialog/help window.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
274 { |
efab68769c75
Implement new separate About dialog/help window.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
275 Q_OBJECT |
efab68769c75
Implement new separate About dialog/help window.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
276 |
efab68769c75
Implement new separate About dialog/help window.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
277 public: |
efab68769c75
Implement new separate About dialog/help window.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
278 explicit AboutWindow(QWidget *parent = 0); |
efab68769c75
Implement new separate About dialog/help window.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
279 ~AboutWindow(); |
efab68769c75
Implement new separate About dialog/help window.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
280 |
efab68769c75
Implement new separate About dialog/help window.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
281 private slots: |
efab68769c75
Implement new separate About dialog/help window.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
282 void on_button_Close_clicked(); |
efab68769c75
Implement new separate About dialog/help window.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
283 |
efab68769c75
Implement new separate About dialog/help window.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
284 private: |
efab68769c75
Implement new separate About dialog/help window.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
285 Ui::AboutWindow *ui; |
efab68769c75
Implement new separate About dialog/help window.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
286 }; |
efab68769c75
Implement new separate About dialog/help window.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
287 |
efab68769c75
Implement new separate About dialog/help window.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
288 |
114
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
289 // |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
290 // Custom painter drawing helper class |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
291 // |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
292 class SLDrawContext : public QObject |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
293 { |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
294 Q_OBJECT |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
295 |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
296 public: |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
297 QPointF m_pos; |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
298 QString m_str; |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
299 qreal m_lf_add; |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
300 |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
301 explicit SLDrawContext(QPainter *pt) |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
302 { |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
303 painter = pt; |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
304 metrics = NULL; |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
305 m_str = "ABC"; |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
306 setPos(0, 0); |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
307 m_lf_add = 0; |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
308 } |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
309 |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
310 ~SLDrawContext() |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
311 { |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
312 if (metrics) |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
313 delete metrics; |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
314 } |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
315 |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
316 void setFont(const QFont &ft) |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
317 { |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
318 if (metrics) |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
319 delete metrics; |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
320 |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
321 font = QFont(ft, painter->device()); |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
322 painter->setFont(font); |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
323 metrics = new QFontMetricsF(font); |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
324 } |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
325 |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
326 void setLFAdd(const qreal lf_add) |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
327 { |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
328 m_lf_add = lf_add; |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
329 } |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
330 |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
331 void drawText(const QPointF &pos, const QString &str) |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
332 { |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
333 m_str = str; |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
334 painter->drawText(m_pos + pos, str); |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
335 } |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
336 |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
337 void drawText(const QString &str) |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
338 { |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
339 drawText(QPointF(0, 0), str); |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
340 } |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
341 |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
342 void drawText(const qreal xc, const qreal width, const QString &str, const int flags = 0) |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
343 { |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
344 m_str = str; |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
345 painter->drawText( |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
346 m_pos.x() + xc, m_pos.y(), |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
347 width, boundRect().height(), |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
348 flags, |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
349 str); |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
350 } |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
351 |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
352 const QRectF boundRect(const QString str) |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
353 { |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
354 return metrics->boundingRect(str); |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
355 } |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
356 |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
357 const QRectF boundRect() |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
358 { |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
359 return metrics->boundingRect(m_str); |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
360 } |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
361 |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
362 void lf(qreal yadd) |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
363 { |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
364 m_pos.setY(m_pos.y() + boundRect().height() + yadd); |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
365 } |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
366 |
125 | 367 qreal lfq(qreal yadd) |
368 { | |
369 return m_pos.y() + boundRect().height() + yadd; | |
370 } | |
371 | |
114
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
372 void lf() |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
373 { |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
374 lf(m_lf_add); |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
375 } |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
376 |
125 | 377 qreal lfq() |
378 { | |
379 return m_pos.y() + boundRect().height() + m_lf_add; | |
380 } | |
381 | |
114
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
382 void setPos(const QPointF &pos) |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
383 { |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
384 m_pos = pos; |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
385 } |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
386 |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
387 void setPos(const qreal x, const qreal y) |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
388 { |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
389 setPos(QPointF(x, y)); |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
390 } |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
391 |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
392 void move(const QPointF &pos) |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
393 { |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
394 m_pos += pos; |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
395 } |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
396 |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
397 void move(const qreal x, const qreal y) |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
398 { |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
399 move(QPointF(x, y)); |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
400 } |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
401 |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
402 private: |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
403 QPainter *painter; |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
404 QFont font; |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
405 QFontMetricsF *metrics; |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
406 }; |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
407 |
a5c8741b8662
Initial prototype support for printing list of users + print preview dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
408 |
41 | 409 #endif // SYNTILISTA_H |