# HG changeset patch # User SokoL_SD # Date 1247575804 0 # Node ID 7ea67ec3cf290fa0b6f7ef34fa6947810333ad85 # Parent 3ea0efe4d31e9a6f7140f64f3b9e8955c030bd2b another fixes in examples diff -r 3ea0efe4d31e -r 7ea67ec3cf29 demos/interview/model.d --- a/demos/interview/model.d Tue Jul 14 11:25:43 2009 +0000 +++ b/demos/interview/model.d Tue Jul 14 12:50:04 2009 +0000 @@ -35,7 +35,7 @@ ** ****************************************************************************/ -module model_d2; +module model; import qt.gui.QIcon; import qt.gui.QPixmap; diff -r 3ea0efe4d31e -r 7ea67ec3cf29 demos/interview/model_d1.d --- a/demos/interview/model_d1.d Tue Jul 14 11:25:43 2009 +0000 +++ b/demos/interview/model_d1.d Tue Jul 14 12:50:04 2009 +0000 @@ -35,7 +35,7 @@ ** ****************************************************************************/ -module model; +module model_d1; import qt.gui.QIcon; import qt.gui.QPixmap; diff -r 3ea0efe4d31e -r 7ea67ec3cf29 examples/dialogs/classwizard/classwizard.d --- a/examples/dialogs/classwizard/classwizard.d Tue Jul 14 11:25:43 2009 +0000 +++ b/examples/dialogs/classwizard/classwizard.d Tue Jul 14 12:50:04 2009 +0000 @@ -54,9 +54,21 @@ import qt.core.QDir; import qt.core.QRegExp; -import tango.text.convert.Format; -import tango.core.Array; -import tango.text.Ascii; +version(Tango) +{ + import tango.text.convert.Format: Format = format; + import tango.core.Array; + import tango.text.Ascii; + alias toUpper toupper; + alias toLower tolower; + + const string cannot_write_file_str = tr("Cannot write file {}:\n{}"); +} +else { + import std.string; + import std.algorithm; + const string cannot_write_file_str = tr("Cannot write file %s:\n%s"); +} class ClassWizard : public QWizard @@ -80,6 +92,12 @@ void accept() { + version(Tango) + const string cannot_write_file_str = tr("Cannot write file {}:\n{}"); + else + const string cannot_write_file_str = tr("Cannot write file %s:\n%s"); + + string className = field("className").toString(); string baseClass = field("baseClass").toString(); string macroName = field("macroName").toString(); @@ -143,7 +161,7 @@ auto headerFile = new QFile(outputDir ~ "/" ~ header); if (!headerFile.open(QFile.WriteOnly | QFile.Text)) { QMessageBox.warning(null, tr("Simple Wizard"), - Format("Cannot write file {}:\n{}", + format(cannot_write_file_str, headerFile.fileName(), headerFile.errorString())); return; @@ -197,7 +215,7 @@ auto implementationFile = new QFile(outputDir ~ "/" ~ implementation); if (!implementationFile.open(QFile.WriteOnly | QFile.Text)) { QMessageBox.warning(null, tr("Simple Wizard"), - Format(tr("Cannot write file {}:\n{}"), + format(cannot_write_file_str, implementationFile.fileName(), implementationFile.errorString())); return; @@ -362,7 +380,7 @@ void initializePage() { string className = field("className").toString(); - macroNameLineEdit.setText(className.toUpper() ~ "_H"); + macroNameLineEdit.setText(toupper(className) ~ "_H"); string baseClass = field("baseClass").toString(); @@ -376,7 +394,7 @@ } else if ((new QRegExp("Q[A-Z].*")).exactMatch(baseClass)) { baseIncludeLineEdit.setText("<" ~ baseClass ~ ">"); } else { - baseIncludeLineEdit.setText("\"" ~ baseClass.toLower() ~ ".h\""); + baseIncludeLineEdit.setText("\"" ~ tolower(baseClass) ~ ".h\""); } } @@ -433,8 +451,8 @@ void initializePage() { string className = field("className").toString(); - headerLineEdit.setText(toLower(className) ~ ".h"); - implementationLineEdit.setText(toLower(className) ~ ".cpp"); + headerLineEdit.setText(tolower(className) ~ ".h"); + implementationLineEdit.setText(tolower(className) ~ ".cpp"); outputDirLineEdit.setText(QDir.convertSeparators(QDir.tempPath())); } @@ -470,9 +488,18 @@ void initializePage() { - string finishText = wizard().buttonText(QWizard.FinishButton).dup; - auto pos = remove(finishText, '&'); - label.setText(Format(tr("Click {} to generate the class skeleton."), finishText)); + string finishText = wizard().buttonText(QWizard.FinishButton); + version(Tango) + { + auto pos = remove(finishText, '&'); + const string str = tr("Click {} to generate the class skeleton."); + } + else + { + const string str = tr("Click %s to generate the class skeleton."); + // TODO: port to D2. + } + label.setText(format(str, finishText)); } private: diff -r 3ea0efe4d31e -r 7ea67ec3cf29 examples/dialogs/standarddialogs/dialog.d --- a/examples/dialogs/standarddialogs/dialog.d Tue Jul 14 11:25:43 2009 +0000 +++ b/examples/dialogs/standarddialogs/dialog.d Tue Jul 14 12:50:04 2009 +0000 @@ -55,10 +55,13 @@ import qt.gui.QFileDialog; import qt.core.QFile; -import tango.text.convert.Format; +version(Tango) + import tango.text.convert.Format; +else + import std.string; -char[] MESSAGE = tr("

Message boxes have a caption, a text, " +string MESSAGE = tr("

Message boxes have a caption, a text, " "and any number of buttons, each with standard or custom texts." "

Click a button to close the message box. Pressing the Esc button " "will activate the detected escape button (if any)."); @@ -209,7 +212,10 @@ bool ok; int i = QInputDialog.getInt(this, tr("QInputgetInteger()"), tr("Percentage:"), 25, 0, 100, 1, ok); if (ok) - integerLabel.setText(Format("{}", i)); + version(Tango) + integerLabel.setText(Format("{}", i)); + else + integerLabel.setText(format("%d", i)); } void setDouble() @@ -218,7 +224,10 @@ double d = QInputDialog.getDouble(this, tr("QInputgetDouble()"), tr("Amount:"), 37.56, -10000, 10000, 2, ok); if (ok) - doubleLabel.setText(Format("${}", d)); + version(Tango) + doubleLabel.setText(Format("${}", d)); + else + integerLabel.setText(format("%g", d)); } void setItem() @@ -305,7 +314,12 @@ options); if (files.length) { openFilesPath = files[0]; - openFileNamesLabel.setText(Format("{}", files)); + version(Tango) + openFileNamesLabel.setText(Format("{}", files)); + else + { + openFileNamesLabel.setText(join(files, "; ")); + } } } @@ -406,5 +420,5 @@ QLabel errorLabel; QErrorMessage errorMessageDialog; - char[] openFilesPath; + string openFilesPath; } diff -r 3ea0efe4d31e -r 7ea67ec3cf29 examples/draganddrop/dropsite/dropsitewindow.d --- a/examples/draganddrop/dropsite/dropsitewindow.d Tue Jul 14 11:25:43 2009 +0000 +++ b/examples/draganddrop/dropsite/dropsitewindow.d Tue Jul 14 12:50:04 2009 +0000 @@ -44,7 +44,7 @@ version(Tango) { import tango.text.Util; import tango.text.Ascii; - import tango.text.convert.Format: format = Format; + import tango.text.convert.Format; } else { import std.string; alias strip trim; @@ -133,7 +133,7 @@ QByteArray data = mimeData.data(format); for (int i = 0; i < data.size() && i < 32; ++i) { version(Tango) - string hex = toUupper(Format("{0:x}", data.at(i))); + string hex = toUpper(Format("{0:x}", data.at(i))); else string hex = toupper(std.string.format("%x", data.at(i))); text ~= hex ~ " "; diff -r 3ea0efe4d31e -r 7ea67ec3cf29 examples/layouts/borderlayout/borderlayout_d1.d --- a/examples/layouts/borderlayout/borderlayout_d1.d Tue Jul 14 11:25:43 2009 +0000 +++ b/examples/layouts/borderlayout/borderlayout_d1.d Tue Jul 14 12:50:04 2009 +0000 @@ -38,7 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -module borderlayout; +module borderlayout_d1; import qt.gui.QLayout; diff -r 3ea0efe4d31e -r 7ea67ec3cf29 examples/widgets/calculator/calculator.d --- a/examples/widgets/calculator/calculator.d Tue Jul 14 11:25:43 2009 +0000 +++ b/examples/widgets/calculator/calculator.d Tue Jul 14 12:50:04 2009 +0000 @@ -86,11 +86,11 @@ } int ToInt(string s) { - return to!int(s); + return to!(int)(s); } float ToFloat(string s) { - return to!float(s); + return to!(float)(s); } int find(string s, dchar c) {