src/format.h

Thu, 07 Feb 2019 13:45:07 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Thu, 07 Feb 2019 13:45:07 +0200
changeset 1438
988b6563d47d
parent 1422
bf373bd83c1f
permissions
-rw-r--r--

stuff

655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 /*
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 * LDForge: LDraw parts authoring CAD
1326
69a90bd2dba2 Happy new year 2018
Teemu Piippo <teemu@hecknology.net>
parents: 1316
diff changeset
3 * Copyright (C) 2013 - 2018 Teemu Piippo
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 *
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 * (at your option) any later version.
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 *
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 * GNU General Public License for more details.
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 *
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 */
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 #pragma once
1039
f68ebbae4efb Fixed compilation.
Teemu Piippo <teemu@hecknology.net>
parents: 1014
diff changeset
20 #include <QIODevice>
1092
7a50a7f6b492 Switched from euler angle rotation to matrix rotation. Gimbal lock is now broken.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
21 #include <QGenericMatrix>
1244
68e126e8c629 begin model rework
Santeri Piippo
parents: 1159
diff changeset
22 #include <QModelIndex>
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 #include "basics.h"
795
195fa1fff9c3 - changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 794
diff changeset
24 #include "colors.h"
1316
31f4293cec30 reworked includes
Teemu Piippo <teemu@hecknology.net>
parents: 1244
diff changeset
25 #include "types/vertex.h"
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
26
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
27 // Converts a given value into a string that can be retrieved with text().
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
28 // Used as the argument type to the formatting functions, hence its name.
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29 class StringFormatArg
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
30 {
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
31 public:
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
32 StringFormatArg (const QString& a) : m_text (a) {}
1010
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
33 StringFormatArg (char a) : m_text (a) {}
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
34 StringFormatArg (uchar a) : m_text (a) {}
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
35 StringFormatArg (QChar a) : m_text (a) {}
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
36 StringFormatArg (int a) : m_text (QString::number (a)) {}
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
37 StringFormatArg (long a) : m_text (QString::number (a)) {}
1010
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
38 StringFormatArg (float a) : m_text (QString::number (a)) {}
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
39 StringFormatArg (double a) : m_text (QString::number (a)) {}
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
40 StringFormatArg (const Vertex& a) : m_text (a.toString()) {}
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
41 StringFormatArg (const char* a) : m_text (a) {}
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
42 StringFormatArg (LDColor a) : m_text (a.indexString()) {}
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
43
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
44 StringFormatArg (const void* a)
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
45 {
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
46 m_text.sprintf ("%p", a);
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
47 }
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
48
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
49 template<typename T>
1058
695edd4f0411 Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents: 1039
diff changeset
50 StringFormatArg (const QVector<T>& a)
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
51 {
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
52 m_text = "{";
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
53
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
54 for (const T& it : a)
784
f82ab4d3c7b4 - made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents: 739
diff changeset
55 {
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
56 if (&it != &a.first())
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
57 m_text += ", ";
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
58
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
59 StringFormatArg arg (it);
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
60 m_text += arg.text();
784
f82ab4d3c7b4 - made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents: 739
diff changeset
61 }
f82ab4d3c7b4 - made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents: 739
diff changeset
62
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
63 m_text += "}";
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
64 }
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
65
1092
7a50a7f6b492 Switched from euler angle rotation to matrix rotation. Gimbal lock is now broken.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
66 template<int Columns, int Rows, typename Type>
7a50a7f6b492 Switched from euler angle rotation to matrix rotation. Gimbal lock is now broken.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
67 StringFormatArg(const QGenericMatrix<Columns, Rows, Type>& matrix)
7a50a7f6b492 Switched from euler angle rotation to matrix rotation. Gimbal lock is now broken.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
68 {
7a50a7f6b492 Switched from euler angle rotation to matrix rotation. Gimbal lock is now broken.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
69 m_text = "{";
7a50a7f6b492 Switched from euler angle rotation to matrix rotation. Gimbal lock is now broken.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
70 for (int row = 0; row < Rows; ++row)
7a50a7f6b492 Switched from euler angle rotation to matrix rotation. Gimbal lock is now broken.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
71 {
7a50a7f6b492 Switched from euler angle rotation to matrix rotation. Gimbal lock is now broken.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
72 if (row > 0)
7a50a7f6b492 Switched from euler angle rotation to matrix rotation. Gimbal lock is now broken.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
73 m_text += ", ";
7a50a7f6b492 Switched from euler angle rotation to matrix rotation. Gimbal lock is now broken.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
74
7a50a7f6b492 Switched from euler angle rotation to matrix rotation. Gimbal lock is now broken.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
75 m_text += "{";
7a50a7f6b492 Switched from euler angle rotation to matrix rotation. Gimbal lock is now broken.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
76
7a50a7f6b492 Switched from euler angle rotation to matrix rotation. Gimbal lock is now broken.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
77 for (int column = 0; column < Rows; ++column)
7a50a7f6b492 Switched from euler angle rotation to matrix rotation. Gimbal lock is now broken.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
78 {
7a50a7f6b492 Switched from euler angle rotation to matrix rotation. Gimbal lock is now broken.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
79 if (column > 0)
7a50a7f6b492 Switched from euler angle rotation to matrix rotation. Gimbal lock is now broken.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
80 m_text += ", ";
7a50a7f6b492 Switched from euler angle rotation to matrix rotation. Gimbal lock is now broken.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
81
1095
cb58a160bed3 - Use a QGenericMatrix to store the matrix, instead of a C array
Teemu Piippo <teemu@hecknology.net>
parents: 1092
diff changeset
82 m_text += StringFormatArg {matrix(row, column)}.text();
1092
7a50a7f6b492 Switched from euler angle rotation to matrix rotation. Gimbal lock is now broken.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
83 }
7a50a7f6b492 Switched from euler angle rotation to matrix rotation. Gimbal lock is now broken.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
84
7a50a7f6b492 Switched from euler angle rotation to matrix rotation. Gimbal lock is now broken.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
85 m_text += "}";
7a50a7f6b492 Switched from euler angle rotation to matrix rotation. Gimbal lock is now broken.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
86 }
1095
cb58a160bed3 - Use a QGenericMatrix to store the matrix, instead of a C array
Teemu Piippo <teemu@hecknology.net>
parents: 1092
diff changeset
87 m_text += "}";
1092
7a50a7f6b492 Switched from euler angle rotation to matrix rotation. Gimbal lock is now broken.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
88 }
7a50a7f6b492 Switched from euler angle rotation to matrix rotation. Gimbal lock is now broken.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
89
1244
68e126e8c629 begin model rework
Santeri Piippo
parents: 1159
diff changeset
90 StringFormatArg(const QModelIndex& index)
68e126e8c629 begin model rework
Santeri Piippo
parents: 1159
diff changeset
91 {
68e126e8c629 begin model rework
Santeri Piippo
parents: 1159
diff changeset
92 m_text = QString("{%1, %2}").arg(index.row(), index.column());
68e126e8c629 begin model rework
Santeri Piippo
parents: 1159
diff changeset
93 }
68e126e8c629 begin model rework
Santeri Piippo
parents: 1159
diff changeset
94
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
95 inline QString text() const
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
96 {
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
97 return m_text;
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
98 }
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
99
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
100 private:
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
101 QString m_text;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
102 };
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
103
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
104 // Format the message with the given args.
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
105 //
1011
4fdd74a04790 Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1010
diff changeset
106 // The formatting ultimately uses String's arg() method to actually format the args so the format string should be
4fdd74a04790 Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1010
diff changeset
107 // prepared accordingly, with %1 referring to the first arg, %2 to the second, etc.
1422
bf373bd83c1f simplified format()
Teemu Piippo <teemu@hecknology.net>
parents: 1403
diff changeset
108 template<typename T, typename... Rest>
bf373bd83c1f simplified format()
Teemu Piippo <teemu@hecknology.net>
parents: 1403
diff changeset
109 QString format(const QString& formatString, const T& arg, Rest... rest)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
110 {
1422
bf373bd83c1f simplified format()
Teemu Piippo <teemu@hecknology.net>
parents: 1403
diff changeset
111 return format(formatString.arg(StringFormatArg(arg).text()), rest...);
bf373bd83c1f simplified format()
Teemu Piippo <teemu@hecknology.net>
parents: 1403
diff changeset
112 }
bf373bd83c1f simplified format()
Teemu Piippo <teemu@hecknology.net>
parents: 1403
diff changeset
113
bf373bd83c1f simplified format()
Teemu Piippo <teemu@hecknology.net>
parents: 1403
diff changeset
114 // Recursion base
bf373bd83c1f simplified format()
Teemu Piippo <teemu@hecknology.net>
parents: 1403
diff changeset
115 inline QString format(const QString& formatString)
bf373bd83c1f simplified format()
Teemu Piippo <teemu@hecknology.net>
parents: 1403
diff changeset
116 {
bf373bd83c1f simplified format()
Teemu Piippo <teemu@hecknology.net>
parents: 1403
diff changeset
117 return formatString;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
118 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
119
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
120 template<typename... Args>
1422
bf373bd83c1f simplified format()
Teemu Piippo <teemu@hecknology.net>
parents: 1403
diff changeset
121 void fprint(FILE* fp, const QString& formatString, Args... args)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
122 {
1422
bf373bd83c1f simplified format()
Teemu Piippo <teemu@hecknology.net>
parents: 1403
diff changeset
123 fprintf(fp, "%s", qPrintable(format(formatString, args...)));
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
124 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
125
1011
4fdd74a04790 Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1010
diff changeset
126
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
127 template<typename... Args>
1422
bf373bd83c1f simplified format()
Teemu Piippo <teemu@hecknology.net>
parents: 1403
diff changeset
128 void fprint (QIODevice& dev, const QString& formatString, Args... args)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
129 {
1422
bf373bd83c1f simplified format()
Teemu Piippo <teemu@hecknology.net>
parents: 1403
diff changeset
130 dev.write(format(formatString, args...).toUtf8());
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
131 }
1380
bc799b965418 added a status bar and moved printed messages there
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
132
bc799b965418 added a status bar and moved printed messages there
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
133 class Printer : public QObject
bc799b965418 added a status bar and moved printed messages there
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
134 {
bc799b965418 added a status bar and moved printed messages there
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
135 Q_OBJECT
bc799b965418 added a status bar and moved printed messages there
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
136
bc799b965418 added a status bar and moved printed messages there
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
137 public:
bc799b965418 added a status bar and moved printed messages there
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
138 void printLine(const QString& line)
bc799b965418 added a status bar and moved printed messages there
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
139 {
bc799b965418 added a status bar and moved printed messages there
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
140 printf("%s\n", line.toUtf8().constData());
bc799b965418 added a status bar and moved printed messages there
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
141 emit linePrinted(line);
bc799b965418 added a status bar and moved printed messages there
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
142 }
bc799b965418 added a status bar and moved printed messages there
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
143
bc799b965418 added a status bar and moved printed messages there
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
144 signals:
bc799b965418 added a status bar and moved printed messages there
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
145 void linePrinted(const QString& line);
bc799b965418 added a status bar and moved printed messages there
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
146 };
bc799b965418 added a status bar and moved printed messages there
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
147
bc799b965418 added a status bar and moved printed messages there
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
148 /*
bc799b965418 added a status bar and moved printed messages there
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
149 * Format and print the given args to stdout. Also is reflected to the status bar.
bc799b965418 added a status bar and moved printed messages there
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
150 */
bc799b965418 added a status bar and moved printed messages there
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
151 template<typename... Args>
bc799b965418 added a status bar and moved printed messages there
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
152 void print(QString formatString, Args&&... args)
bc799b965418 added a status bar and moved printed messages there
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
153 {
bc799b965418 added a status bar and moved printed messages there
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
154 singleton<Printer>().printLine(format(formatString, args...));
bc799b965418 added a status bar and moved printed messages there
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
155 }

mercurial