Changeset 87 in tspsg-svn for trunk/src/mainwindow.cpp
- Timestamp:
- Jan 12, 2010, 3:11:24 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/mainwindow.cpp
r82 r87 1 1 /* 2 2 * TSPSG: TSP Solver and Generator 3 * Copyright (C) 2007-20 09Lёppa <contacts[at]oleksii[dot]name>3 * Copyright (C) 2007-2010 Lёppa <contacts[at]oleksii[dot]name> 4 4 * 5 5 * $Id$ … … 124 124 return; 125 125 126 QStringList filters(tr Utf8("All Supported Formats") + " (*.tspt *.zkt)");127 filters.append(tr Utf8("%1 Task Files").arg("TSPSG") + " (*.tspt)");128 filters.append(tr Utf8("%1 Task Files").arg("ZKomModRd") + " (*.zkt)");129 filters.append(tr Utf8("All Files") + " (*)");126 QStringList filters(tr("All Supported Formats") + " (*.tspt *.zkt)"); 127 filters.append(tr("%1 Task Files").arg("TSPSG") + " (*.tspt)"); 128 filters.append(tr("%1 Task Files").arg("ZKomModRd") + " (*.zkt)"); 129 filters.append(tr("All Files") + " (*)"); 130 130 131 131 QFileDialog::Options opts = settings->value("UseNativeDialogs", DEF_USE_NATIVE_DIALOGS).toBool() ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog; 132 QString file = QFileDialog::getOpenFileName(this, tr Utf8("Task Load"), QString(), filters.join(";;"), NULL, opts);132 QString file = QFileDialog::getOpenFileName(this, tr("Task Load"), QString(), filters.join(";;"), NULL, opts); 133 133 if (file.isEmpty() || !QFileInfo(file).isFile()) 134 134 return; … … 144 144 void MainWindow::actionFileSaveTriggered() 145 145 { 146 if ((fileName == tr Utf8("Untitled") + ".tspt") || (!fileName.endsWith(".tspt",Qt::CaseInsensitive)))146 if ((fileName == tr("Untitled") + ".tspt") || (!fileName.endsWith(".tspt",Qt::CaseInsensitive))) 147 147 saveTask(); 148 148 else … … 160 160 static QString selectedFile; 161 161 if (selectedFile.isEmpty()) { 162 if (fileName == tr Utf8("Untitled") + ".tspt") {162 if (fileName == tr("Untitled") + ".tspt") { 163 163 #ifndef QT_NO_PRINTER 164 164 selectedFile = "solution.pdf"; … … 177 177 QStringList filters; 178 178 #ifndef QT_NO_PRINTER 179 filters.append(tr Utf8("PDF Files") + " (*.pdf)");179 filters.append(tr("PDF Files") + " (*.pdf)"); 180 180 #endif 181 filters.append(tr Utf8("HTML Files") + " (*.html *.htm)");181 filters.append(tr("HTML Files") + " (*.html *.htm)"); 182 182 #if QT_VERSION >= 0x040500 183 filters.append(tr Utf8("OpenDocument Files") + " (*.odt)");183 filters.append(tr("OpenDocument Files") + " (*.odt)"); 184 184 #endif // QT_VERSION >= 0x040500 185 filters.append(tr Utf8("All Files") + " (*)");185 filters.append(tr("All Files") + " (*)"); 186 186 187 187 QFileDialog::Options opts = settings->value("UseNativeDialogs", DEF_USE_NATIVE_DIALOGS).toBool() ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog; … … 252 252 if (sd.colorChanged() || sd.fontChanged()) { 253 253 initDocStyleSheet(); 254 if (!output.isEmpty() && sd.colorChanged() && (QMessageBox(QMessageBox::Question,tr Utf8("Settings Changed"),trUtf8("You have changed color settings.\nDo you wish to apply them to current solution text?"),QMessageBox::Yes | QMessageBox::No,this).exec() == QMessageBox::Yes)) {254 if (!output.isEmpty() && sd.colorChanged() && (QMessageBox(QMessageBox::Question,tr("Settings Changed"),tr("You have changed color settings.\nDo you wish to apply them to current solution text?"),QMessageBox::Yes | QMessageBox::No,this).exec() == QMessageBox::Yes)) { 255 255 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); 256 256 solutionText->clear(); … … 265 265 if (checked) { 266 266 settings->remove("Language"); 267 QMessageBox(QMessageBox::Information,tr Utf8("Language change"),trUtf8("Language will be autodetected on next application start."),QMessageBox::Ok,this).exec();267 QMessageBox(QMessageBox::Information,tr("Language change"),tr("Language will be autodetected on next application start."),QMessageBox::Ok,this).exec(); 268 268 } else 269 269 settings->setValue("Language",groupSettingsLanguageList->checkedAction()->data().toString()); … … 274 274 if (actionSettingsLanguageAutodetect->isChecked()) { 275 275 // We have language autodetection. It needs to be disabled to change language. 276 if (QMessageBox(QMessageBox::Question,tr Utf8("Language change"),trUtf8("You have language autodetection turned on.\nIt needs to be off.\nDo you wish to turn it off?"),QMessageBox::Yes | QMessageBox::No,this).exec() == QMessageBox::Yes) {276 if (QMessageBox(QMessageBox::Question,tr("Language change"),tr("You have language autodetection turned on.\nIt needs to be off.\nDo you wish to turn it off?"),QMessageBox::Yes | QMessageBox::No,this).exec() == QMessageBox::Yes) { 277 277 actionSettingsLanguageAutodetect->trigger(); 278 278 } else 279 279 return; 280 280 } 281 bool untitled = (fileName == tr Utf8("Untitled") + ".tspt");281 bool untitled = (fileName == tr("Untitled") + ".tspt"); 282 282 if (loadLanguage(action->data().toString())) { 283 283 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); … … 357 357 358 358 dlg->setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); 359 dlg->setWindowTitle(tr Utf8("About TSPSG"));359 dlg->setWindowTitle(tr("About TSPSG")); 360 360 dlg->setLayout(vb); 361 361 … … 383 383 { 384 384 TMatrix matrix; 385 QList< double> row;385 QList<qreal> row; 386 386 int n = spinCities->value(); 387 387 bool ok; … … 389 389 row.clear(); 390 390 for (int c = 0; c < n; c++) { 391 row.append(tspmodel->index(r,c).data(Qt::UserRole).to Double(&ok));391 row.append(tspmodel->index(r,c).data(Qt::UserRole).toReal(&ok)); 392 392 if (!ok) { 393 QMessageBox(QMessageBox::Critical,tr Utf8("Data error"),trUtf8("Error in cell [Row %1; Column %2]: Invalid data format.").arg(r + 1).arg(c + 1),QMessageBox::Ok,this).exec();393 QMessageBox(QMessageBox::Critical,tr("Data error"),tr("Error in cell [Row %1; Column %2]: Invalid data format.").arg(r + 1).arg(c + 1),QMessageBox::Ok,this).exec(); 394 394 return; 395 395 } … … 404 404 QColor color = settings->value("Output/Color",DEF_FONT_COLOR).value<QColor>(); 405 405 output.clear(); 406 output.append("<p>" + tr Utf8("Variant #%1").arg(spinVariant->value()) + "</p>");407 output.append("<p>" + tr Utf8("Task:") + "</p>");406 output.append("<p>" + tr("Variant #%1").arg(spinVariant->value()) + "</p>"); 407 output.append("<p>" + tr("Task:") + "</p>"); 408 408 outputMatrix(matrix, output); 409 409 output.append("<hr>"); 410 output.append("<p>" + tr Utf8("Solution of Variant #%1 task").arg(spinVariant->value()) + "</p>");410 output.append("<p>" + tr("Solution of Variant #%1 task").arg(spinVariant->value()) + "</p>"); 411 411 SStep *step = root; 412 412 n = 1; … … 414 414 if (step->prNode->prNode != NULL || ((step->prNode->prNode == NULL) && (step->plNode->prNode == NULL))) { 415 415 if (n != spinCities->value()) { 416 output.append("<p>" + tr Utf8("Step #%1").arg(n++) + "</p>");416 output.append("<p>" + tr("Step #%1").arg(n++) + "</p>"); 417 417 if (settings->value("Output/ShowMatrix", DEF_SHOW_MATRIX).toBool() && settings->value("Output/UseShowMatrixLimit", DEF_USE_SHOW_MATRIX_LIMIT).toBool() && (spinCities->value() <= settings->value("Output/ShowMatrixLimit", DEF_SHOW_MATRIX_LIMIT).toInt())) { 418 418 outputMatrix(*step, output); 419 419 } 420 output.append("<p>" + tr Utf8("Selected candidate for branching: %1.").arg(trUtf8("(%1;%2)").arg(step->candidate.nRow + 1).arg(step->candidate.nCol + 1)) + "</p>");420 output.append("<p>" + tr("Selected candidate for branching: %1.").arg(tr("(%1;%2)").arg(step->candidate.nRow + 1).arg(step->candidate.nCol + 1)) + "</p>"); 421 421 if (!step->alts.empty()) { 422 422 SCandidate cand; … … 425 425 if (!alts.isEmpty()) 426 426 alts += ", "; 427 alts += tr Utf8("(%1;%2)").arg(cand.nRow + 1).arg(cand.nCol + 1);427 alts += tr("(%1;%2)").arg(cand.nRow + 1).arg(cand.nCol + 1); 428 428 } 429 output.append("<p class=\"hasalts\">" + tr Utf8("%n alternate candidate(s) for branching: %1.","",step->alts.count()).arg(alts) + "</p>");429 output.append("<p class=\"hasalts\">" + tr("%n alternate candidate(s) for branching: %1.","",step->alts.count()).arg(alts) + "</p>"); 430 430 } 431 431 output.append("<p> </p>"); … … 440 440 } 441 441 if (solver.isOptimal()) 442 output.append("<p>" + tr Utf8("Optimal path:") + "</p>");442 output.append("<p>" + tr("Optimal path:") + "</p>"); 443 443 else 444 output.append("<p>" + tr Utf8("Resulting path:") + "</p>");444 output.append("<p>" + tr("Resulting path:") + "</p>"); 445 445 output.append("<p> " + solver.getSortedPath() + "</p>"); 446 446 if (isInteger(step->price)) 447 output.append("<p>" + tr Utf8("The price is <b>%n</b> unit(s).", "", step->price) + "</p>");447 output.append("<p>" + tr("The price is <b>%n</b> unit(s).", "", step->price) + "</p>"); 448 448 else 449 output.append("<p>" + tr Utf8("The price is <b>%1</b> units.").arg(step->price, 0, 'f', 2) + "</p>");449 output.append("<p>" + tr("The price is <b>%1</b> units.").arg(step->price, 0, 'f', settings->value("Task/FractionalAccuracy", DEF_FRACTIONAL_ACCURACY).toInt()) + "</p>"); 450 450 if (!solver.isOptimal()) { 451 451 output.append("<p> </p>"); 452 output.append("<p>" + tr Utf8("<b>WARNING!!!</b><br>This result is a record, but it may not be optimal.<br>Iterations need to be continued to check whether this result is optimal or get an optimal one.") + "</p>");452 output.append("<p>" + tr("<b>WARNING!!!</b><br>This result is a record, but it may not be optimal.<br>Iterations need to be continued to check whether this result is optimal or get an optimal one.") + "</p>"); 453 453 } 454 454 output.append("<p></p>"); 455 455 456 456 solutionText->setHtml(output.join("")); 457 solutionText->setDocumentTitle(tr Utf8("Solution of Variant #%1 task").arg(spinVariant->value()));457 solutionText->setDocumentTitle(tr("Solution of Variant #%1 task").arg(spinVariant->value())); 458 458 459 459 if (settings->value("Output/ScrollToEnd", DEF_SCROLL_TO_END).toBool()) { … … 624 624 translator = NULL; 625 625 if (!ad) 626 QMessageBox(QMessageBox::Warning,tr Utf8("Language Change"),trUtf8("Unable to load translation language."),QMessageBox::Ok,this).exec();626 QMessageBox(QMessageBox::Warning,tr("Language Change"),tr("Unable to load translation language."),QMessageBox::Ok,this).exec(); 627 627 return false; 628 628 } … … 634 634 if (!isWindowModified()) 635 635 return true; 636 int res = QMessageBox(QMessageBox::Warning,tr Utf8("Unsaved Changes"),trUtf8("Would you like to save changes in current task?"),QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel,this).exec();636 int res = QMessageBox(QMessageBox::Warning,tr("Unsaved Changes"),tr("Would you like to save changes in current task?"),QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel,this).exec(); 637 637 if (res == QMessageBox::Save) 638 638 return saveTask(); … … 654 654 line += "<td align=\"center\">"INFSTR"</td>"; 655 655 else 656 line += isInteger(matrix.at(r).at(c)) ? QString("<td align=\"center\">%1</td>").arg(matrix.at(r).at(c)) : QString("<td align=\"center\">%1</td>").arg(matrix.at(r).at(c), 0, 'f', 2);656 line += isInteger(matrix.at(r).at(c)) ? QString("<td align=\"center\">%1</td>").arg(matrix.at(r).at(c)) : QString("<td align=\"center\">%1</td>").arg(matrix.at(r).at(c), 0, 'f', settings->value("Task/FractionalAccuracy", DEF_FRACTIONAL_ACCURACY).toInt()); 657 657 } 658 658 line += "</tr>"; … … 673 673 line += "<td align=\"center\">"INFSTR"</td>"; 674 674 else if ((r == step.candidate.nRow) && (c == step.candidate.nCol)) 675 line += isInteger(step.matrix.at(r).at(c)) ? QString("<td align=\"center\" class=\"selected\">%1</td>").arg(step.matrix.at(r).at(c)) : QString("<td align=\"center\" class=\"selected\">%1</td>").arg(step.matrix.at(r).at(c), 0, 'f', 2);675 line += isInteger(step.matrix.at(r).at(c)) ? QString("<td align=\"center\" class=\"selected\">%1</td>").arg(step.matrix.at(r).at(c)) : QString("<td align=\"center\" class=\"selected\">%1</td>").arg(step.matrix.at(r).at(c), 0, 'f', settings->value("Task/FractionalAccuracy", DEF_FRACTIONAL_ACCURACY).toInt()); 676 676 else { 677 677 SCandidate cand; … … 679 679 cand.nCol = c; 680 680 if (step.alts.contains(cand)) 681 line += isInteger(step.matrix.at(r).at(c)) ? QString("<td align=\"center\" class=\"alternate\">%1</td>").arg(step.matrix.at(r).at(c)) : QString("<td align=\"center\" class=\"alternate\">%1</td>").arg(step.matrix.at(r).at(c), 0, 'f', 2);681 line += isInteger(step.matrix.at(r).at(c)) ? QString("<td align=\"center\" class=\"alternate\">%1</td>").arg(step.matrix.at(r).at(c)) : QString("<td align=\"center\" class=\"alternate\">%1</td>").arg(step.matrix.at(r).at(c), 0, 'f', settings->value("Task/FractionalAccuracy", DEF_FRACTIONAL_ACCURACY).toInt()); 682 682 else 683 line += isInteger(step.matrix.at(r).at(c)) ? QString("<td align=\"center\">%1</td>").arg(step.matrix.at(r).at(c)) : QString("<td align=\"center\">%1</td>").arg(step.matrix.at(r).at(c), 0, 'f', 2);683 line += isInteger(step.matrix.at(r).at(c)) ? QString("<td align=\"center\">%1</td>").arg(step.matrix.at(r).at(c)) : QString("<td align=\"center\">%1</td>").arg(step.matrix.at(r).at(c), 0, 'f', settings->value("Task/FractionalAccuracy", DEF_FRACTIONAL_ACCURACY).toInt()); 684 684 } 685 685 } … … 716 716 717 717 bool MainWindow::saveTask() { 718 QStringList filters(tr Utf8("%1 Task File").arg("TSPSG") + " (*.tspt)");719 filters.append(tr Utf8("All Files") + " (*)");718 QStringList filters(tr("%1 Task File").arg("TSPSG") + " (*.tspt)"); 719 filters.append(tr("All Files") + " (*)"); 720 720 QString file; 721 721 if (fileName.endsWith(".tspt", Qt::CaseInsensitive)) … … 725 725 726 726 QFileDialog::Options opts = settings->value("UseNativeDialogs", DEF_USE_NATIVE_DIALOGS).toBool() ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog; 727 file = QFileDialog::getSaveFileName(this, tr Utf8("Task Save"), file, filters.join(";;"), NULL, opts);727 file = QFileDialog::getSaveFileName(this, tr("Task Save"), file, filters.join(";;"), NULL, opts); 728 728 729 729 if (file.isEmpty()) … … 740 740 { 741 741 this->fileName = fileName; 742 setWindowTitle(QString("%1[*] - %2").arg(QFileInfo(fileName).completeBaseName()).arg(tr Utf8("Travelling Salesman Problem")));742 setWindowTitle(QString("%1[*] - %2").arg(QFileInfo(fileName).completeBaseName()).arg(tr("Travelling Salesman Problem"))); 743 743 } 744 744
Note: See TracChangeset
for help on using the changeset viewer.