Sun, 08 Sep 2013 17:17:13 +0300
For some God-knows-why reason, adding operator>> overloads to QDataStream leads into crashes with QFileDialog. Fixed by removing these overloads.
13
9bdddd2ccde6
now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
1 | /* |
9bdddd2ccde6
now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
2 | * ZanDemo: Zandronum demo launcher |
9bdddd2ccde6
now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
3 | * Copyright (C) 2013 Santeri Piippo |
9bdddd2ccde6
now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
4 | * |
9bdddd2ccde6
now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
9bdddd2ccde6
now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
9bdddd2ccde6
now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
9bdddd2ccde6
now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
8 | * (at your option) any later version. |
9bdddd2ccde6
now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
9 | * |
9bdddd2ccde6
now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
9bdddd2ccde6
now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
9bdddd2ccde6
now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
9bdddd2ccde6
now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
13 | * GNU General Public License for more details. |
9bdddd2ccde6
now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
14 | * |
9bdddd2ccde6
now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
9bdddd2ccde6
now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
9bdddd2ccde6
now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
17 | */ |
9bdddd2ccde6
now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
18 | |
0 | 19 | #include <QObject> |
20 | #include <QStringList> | |
21 | #include <QTextStream> | |
22 | #include <assert.h> | |
23 | #include "types.h" | |
24 | ||
11
3ddebf76105e
made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
25 | str doFormat (initlist<StringFormatArg> args) { |
3ddebf76105e
made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
26 | assert (args.size() >= 1); |
1 | 27 | str text = args.begin()->value(); |
0 | 28 | |
11
3ddebf76105e
made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
29 | for (initlist<StringFormatArg>::iterator it = args.begin() + 1; it != args.end(); ++it) |
3ddebf76105e
made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
30 | text = text.arg (it->value()); |
0 | 31 | |
32 | return text; | |
33 | } | |
34 | ||
11
3ddebf76105e
made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
35 | void doPrint (FILE* fp, initlist<StringFormatArg> args) { |
3ddebf76105e
made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
36 | fprintf (fp, "%s", doFormat (args).toStdString().c_str()); |
0 | 37 | } |
38 | ||
39 | // ============================================================================= | |
11
3ddebf76105e
made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
40 | StringFormatArg::StringFormatArg (const str& v) { m_val = v; } |
3ddebf76105e
made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
41 | StringFormatArg::StringFormatArg (const char& v) { m_val = v; } |
3ddebf76105e
made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
42 | StringFormatArg::StringFormatArg (const uchar& v) { m_val = v; } |
21
99225eac33ba
use proper names QVariant and QChar instead of ambigous/dumb "var" and "qchar"
Teemu Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
43 | StringFormatArg::StringFormatArg (const QChar& v) { m_val = v; } |
11
3ddebf76105e
made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
44 | StringFormatArg::StringFormatArg (const float& v) { m_val = str::number (v); } |
3ddebf76105e
made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
45 | StringFormatArg::StringFormatArg (const double& v) { m_val = str::number (v); } |
3ddebf76105e
made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
46 | StringFormatArg::StringFormatArg (const char* v) { m_val = v; } |
3ddebf76105e
made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
47 | StringFormatArg::StringFormatArg (const void* v) { m_val.sprintf ("%p", v); } |