143 void fprint (QIODevice& dev, QString fmtstr, Args... args) |
143 void fprint (QIODevice& dev, QString fmtstr, Args... args) |
144 { |
144 { |
145 formatHelper (fmtstr, args...); |
145 formatHelper (fmtstr, args...); |
146 dev.write (fmtstr.toUtf8()); |
146 dev.write (fmtstr.toUtf8()); |
147 } |
147 } |
|
148 |
|
149 class Printer : public QObject |
|
150 { |
|
151 Q_OBJECT |
|
152 |
|
153 public: |
|
154 void printLine(const QString& line) |
|
155 { |
|
156 printf("%s\n", line.toUtf8().constData()); |
|
157 emit linePrinted(line); |
|
158 } |
|
159 |
|
160 signals: |
|
161 void linePrinted(const QString& line); |
|
162 }; |
|
163 |
|
164 /* |
|
165 * Format and print the given args to stdout. Also is reflected to the status bar. |
|
166 */ |
|
167 template<typename... Args> |
|
168 void print(QString formatString, Args&&... args) |
|
169 { |
|
170 singleton<Printer>().printLine(format(formatString, args...)); |
|
171 } |