Mercurial > projects > qtd
comparison examples/dialogs/classwizard/classwizard.d @ 215:8aaa84d48451
Improve examples.
author | SokoL_SD |
---|---|
date | Tue, 14 Jul 2009 15:25:45 +0000 |
parents | 7ea67ec3cf29 |
children | 256ab6cb8e85 |
comparison
equal
deleted
inserted
replaced
214:11f1760d1700 | 215:8aaa84d48451 |
---|---|
52 import qt.gui.QGridLayout; | 52 import qt.gui.QGridLayout; |
53 import qt.core.QFile; | 53 import qt.core.QFile; |
54 import qt.core.QDir; | 54 import qt.core.QDir; |
55 import qt.core.QRegExp; | 55 import qt.core.QRegExp; |
56 | 56 |
57 version(Tango) | 57 import std.string; |
58 { | |
59 import tango.text.convert.Format: Format = format; | |
60 import tango.core.Array; | |
61 import tango.text.Ascii; | |
62 alias toUpper toupper; | |
63 alias toLower tolower; | |
64 | |
65 const string cannot_write_file_str = tr("Cannot write file {}:\n{}"); | |
66 } | |
67 else { | |
68 import std.string; | |
69 import std.algorithm; | |
70 const string cannot_write_file_str = tr("Cannot write file %s:\n%s"); | |
71 } | |
72 | 58 |
73 | 59 |
74 class ClassWizard : public QWizard | 60 class ClassWizard : public QWizard |
75 { | 61 { |
76 public: | 62 public: |
90 setWindowTitle(tr("Class Wizard")); | 76 setWindowTitle(tr("Class Wizard")); |
91 } | 77 } |
92 | 78 |
93 void accept() | 79 void accept() |
94 { | 80 { |
95 version(Tango) | |
96 const string cannot_write_file_str = tr("Cannot write file {}:\n{}"); | |
97 else | |
98 const string cannot_write_file_str = tr("Cannot write file %s:\n%s"); | |
99 | |
100 | |
101 string className = field("className").toString(); | 81 string className = field("className").toString(); |
102 string baseClass = field("baseClass").toString(); | 82 string baseClass = field("baseClass").toString(); |
103 string macroName = field("macroName").toString(); | 83 string macroName = field("macroName").toString(); |
104 string baseInclude = field("baseInclude").toString(); | 84 string baseInclude = field("baseInclude").toString(); |
105 | 85 |
159 } | 139 } |
160 | 140 |
161 auto headerFile = new QFile(outputDir ~ "/" ~ header); | 141 auto headerFile = new QFile(outputDir ~ "/" ~ header); |
162 if (!headerFile.open(QFile.WriteOnly | QFile.Text)) { | 142 if (!headerFile.open(QFile.WriteOnly | QFile.Text)) { |
163 QMessageBox.warning(null, tr("Simple Wizard"), | 143 QMessageBox.warning(null, tr("Simple Wizard"), |
164 format(cannot_write_file_str, | 144 format(tr("Cannot write file %s:\n%s"), |
165 headerFile.fileName(), | 145 headerFile.fileName(), |
166 headerFile.errorString())); | 146 headerFile.errorString())); |
167 return; | 147 return; |
168 } | 148 } |
169 headerFile.write(block); | 149 headerFile.write(block); |
213 } | 193 } |
214 | 194 |
215 auto implementationFile = new QFile(outputDir ~ "/" ~ implementation); | 195 auto implementationFile = new QFile(outputDir ~ "/" ~ implementation); |
216 if (!implementationFile.open(QFile.WriteOnly | QFile.Text)) { | 196 if (!implementationFile.open(QFile.WriteOnly | QFile.Text)) { |
217 QMessageBox.warning(null, tr("Simple Wizard"), | 197 QMessageBox.warning(null, tr("Simple Wizard"), |
218 format(cannot_write_file_str, | 198 format(tr("Cannot write file %s:\n%s"), |
219 implementationFile.fileName(), | 199 implementationFile.fileName(), |
220 implementationFile.errorString())); | 200 implementationFile.errorString())); |
221 return; | 201 return; |
222 } | 202 } |
223 implementationFile.write(block); | 203 implementationFile.write(block); |
487 protected: | 467 protected: |
488 | 468 |
489 void initializePage() | 469 void initializePage() |
490 { | 470 { |
491 string finishText = wizard().buttonText(QWizard.FinishButton); | 471 string finishText = wizard().buttonText(QWizard.FinishButton); |
492 version(Tango) | 472 // TODO: port to D2: auto pos = remove(finishText, '&'); |
493 { | 473 label.setText(format(tr("Click %s to generate the class skeleton."), finishText)); |
494 auto pos = remove(finishText, '&'); | |
495 const string str = tr("Click {} to generate the class skeleton."); | |
496 } | |
497 else | |
498 { | |
499 const string str = tr("Click %s to generate the class skeleton."); | |
500 // TODO: port to D2. | |
501 } | |
502 label.setText(format(str, finishText)); | |
503 } | 474 } |
504 | 475 |
505 private: | 476 private: |
506 | 477 |
507 QLabel label; | 478 QLabel label; |