Changeset 0ac9690913 in tspsg for src/mainwindow.cpp
- Timestamp:
- Dec 7, 2009, 5:06:44 PM (15 years ago)
- Branches:
- 0.1.3.145-beta1-symbian, 0.1.4.170-beta2-bb10, appveyor, imgbot, master, readme
- Children:
- a218bf2cb2
- Parents:
- 3b1caa32d0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mainwindow.cpp
r3b1caa32d0 r0ac9690913 83 83 connect(spinCities,SIGNAL(valueChanged(int)),this,SLOT(spinCitiesValueChanged(int))); 84 84 setCentralWidget(tabWidget); 85 #ifndef Q_OS_WINCE 86 QRect rect = geometry(); 87 if (settings->value("SavePos",false).toBool()) { 85 86 if (settings->value("SavePos", false).toBool()) { 88 87 // Loading of saved window state 89 88 settings->beginGroup("MainWindow"); 90 resize(settings->value("Size",size()).toSize()); 91 move(settings->value("Position",pos()).toPoint());92 if (settings->value("Maximized",false).toBool()) 93 setWindowState(windowState() | Qt::WindowMaximized);89 #ifndef Q_OS_WINCE 90 restoreGeometry(settings->value("Geometry").toByteArray()); 91 #endif // Q_OS_WINCE 92 restoreState(settings->value("State").toByteArray()); 94 93 settings->endGroup(); 94 #ifndef Q_OS_WINCE 95 95 } else { 96 96 // Centering main window 97 QRect rect = geometry(); 97 98 rect.moveCenter(QApplication::desktop()->availableGeometry(this).center()); 98 99 setGeometry(rect); 99 }100 100 #endif // Q_OS_WINCE 101 } 102 101 103 qsrand(QDateTime().currentDateTime().toTime_t()); 102 tspmodel = new CTSPModel( );104 tspmodel = new CTSPModel(this); 103 105 taskView->setModel(tspmodel); 104 106 connect(tspmodel,SIGNAL(numCitiesChanged(int)),this,SLOT(numCitiesChanged(int))); … … 440 442 } 441 443 442 void MainWindow::closeEvent(QCloseEvent *ev ent)444 void MainWindow::closeEvent(QCloseEvent *ev) 443 445 { 444 446 if (!maybeSave()) { 445 event->ignore(); 446 return; 447 } 448 settings->setValue("NumCities",spinCities->value()); 447 ev->ignore(); 448 return; 449 } 450 settings->setValue("NumCities", spinCities->value()); 451 452 // Saving Main Window state 453 if (settings->value("SavePos", false).toBool()) { 454 settings->beginGroup("MainWindow"); 449 455 #ifndef Q_OS_WINCE 450 // Saving windows state 451 if (settings->value("SavePos",false).toBool()) { 452 settings->beginGroup("MainWindow"); 453 settings->setValue("Maximized",isMaximized()); 454 if (!isMaximized()) { 455 settings->setValue("Size",size()); 456 settings->setValue("Position",pos()); 457 } 456 settings->setValue("Geometry", saveGeometry()); 457 #endif // Q_OS_WINCE 458 settings->setValue("State", saveState()); 458 459 settings->endGroup(); 459 460 } 460 #endif // Q_OS_WINCE 461 QMainWindow::closeEvent(ev ent);461 462 QMainWindow::closeEvent(ev); 462 463 } 463 464 … … 520 521 } 521 522 522 bool MainWindow::loadLanguage( QStringlang)523 bool MainWindow::loadLanguage(const QString &lang) 523 524 { 524 525 // i18n 525 526 bool ad = false; 526 if (lang.isEmpty()) { 527 QString lng = lang; 528 if (lng.isEmpty()) { 527 529 ad = settings->value("Language","").toString().isEmpty(); 528 l ang = settings->value("Language",QLocale::system().name()).toString();530 lng = settings->value("Language",QLocale::system().name()).toString(); 529 531 } 530 532 static QTranslator *qtTranslator; // Qt library translator … … 541 543 } 542 544 translator = new QTranslator(); 543 if (l ang.compare("en") && !lang.startsWith("en_")) {545 if (lng.compare("en") && !lng.startsWith("en_")) { 544 546 // Trying to load system Qt library translation... 545 if (qtTranslator->load("qt_" + l ang,QLibraryInfo::location(QLibraryInfo::TranslationsPath)))547 if (qtTranslator->load("qt_" + lng,QLibraryInfo::location(QLibraryInfo::TranslationsPath))) 546 548 qApp->installTranslator(qtTranslator); 547 549 else 548 550 // No luck. Let's try to load bundled one. 549 if (qtTranslator->load("qt_" + l ang,PATH_I18N))551 if (qtTranslator->load("qt_" + lng,PATH_I18N)) 550 552 qApp->installTranslator(qtTranslator); 551 553 else { … … 555 557 } 556 558 // Now let's load application translation. 557 if (translator->load(l ang,PATH_I18N))559 if (translator->load(lng,PATH_I18N)) 558 560 qApp->installTranslator(translator); 559 561 else { … … 581 583 } 582 584 583 void MainWindow::outputMatrix( tMatrixmatrix, QStringList &output, int nRow, int nCol)585 void MainWindow::outputMatrix(const tMatrix &matrix, QStringList &output, int nRow, int nCol) 584 586 { 585 587 int n = spinCities->value(); … … 589 591 line = "<tr>"; 590 592 for (int c = 0; c < n; c++) { 591 if (matrix [r][c]== INFINITY)593 if (matrix.at(r).at(c) == INFINITY) 592 594 line += "<td align=\"center\">"INFSTR"</td>"; 593 595 else if ((r == nRow) && (c == nCol)) 594 line += "<td align=\"center\" class=\"selected\">" + QVariant(matrix [r][c]).toString() + "</td>";596 line += "<td align=\"center\" class=\"selected\">" + QVariant(matrix.at(r).at(c)).toString() + "</td>"; 595 597 else 596 line += "<td align=\"center\">" + QVariant(matrix [r][c]).toString() + "</td>";598 line += "<td align=\"center\">" + QVariant(matrix.at(r).at(c)).toString() + "</td>"; 597 599 } 598 600 line += "</tr>"; … … 626 628 } 627 629 628 void MainWindow::setFileName( QStringfileName)630 void MainWindow::setFileName(const QString &fileName) 629 631 { 630 632 this->fileName = fileName;
Note: See TracChangeset
for help on using the changeset viewer.