Changeset 50 in tspsg-svn for trunk/src/mainwindow.cpp
- Timestamp:
- Aug 3, 2009, 5:15:46 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/mainwindow.cpp
r47 r50 46 46 actionSettingsLanguageEnglish->setActionGroup(groupSettingsLanguageList); 47 47 loadLangList(); 48 spinCities->set Value(settings->value("NumCities",5).toInt());48 spinCities->setMaximum(MAX_NUM_CITIES); 49 49 actionSettingsLanguageAutodetect->setChecked(settings->value("Language","").toString().isEmpty()); 50 50 connect(actionFileNew,SIGNAL(triggered()),this,SLOT(actionFileNewTriggered())); 51 51 connect(actionFileOpen,SIGNAL(triggered()),this,SLOT(actionFileOpenTriggered())); 52 connect(actionFileSave,SIGNAL(triggered()),this,SLOT(actionFileSaveTriggered())); 52 53 connect(actionFileSaveAsTask,SIGNAL(triggered()),this,SLOT(actionFileSaveAsTaskTriggered())); 53 54 connect(actionFileSaveAsSolution,SIGNAL(triggered()),this,SLOT(actionFileSaveAsSolutionTriggered())); … … 62 63 connect(buttonSolve,SIGNAL(clicked()),this,SLOT(buttonSolveClicked())); 63 64 connect(buttonRandom,SIGNAL(clicked()),this,SLOT(buttonRandomClicked())); 65 connect(buttonBackToTask,SIGNAL(clicked()),this,SLOT(buttonBackToTaskClicked())); 64 66 connect(spinCities,SIGNAL(valueChanged(int)),this,SLOT(spinCitiesValueChanged(int))); 67 setCentralWidget(tabWidget); 65 68 QRect rect = geometry(); 66 setCentralWidget(tabWidget);67 69 #ifndef Q_OS_WINCE 68 70 if (settings->value("SavePos",false).toBool()) { … … 82 84 qsrand(QDateTime().currentDateTime().toTime_t()); 83 85 tspmodel = new CTSPModel(); 84 tspmodel->setNumCities(spinCities->value());85 taskView->setModel(tspmodel);86 86 connect(tspmodel,SIGNAL(numCitiesChanged(int)),this,SLOT(numCitiesChanged(int))); 87 87 connect(tspmodel,SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)),this,SLOT(dataChanged())); 88 88 connect(tspmodel,SIGNAL(layoutChanged()),this,SLOT(dataChanged())); 89 if ((QCoreApplication::arguments().count() > 1) && (tspmodel->loadTask(QCoreApplication::arguments().at(1)))) {89 if ((QCoreApplication::arguments().count() > 1) && (tspmodel->loadTask(QCoreApplication::arguments().at(1)))) 90 90 setFileName(QCoreApplication::arguments().at(1)); 91 setWindowModified(false); 92 } else 91 else { 93 92 setFileName(); 94 #ifdef Q_OS_WINCE 93 spinCities->setValue(settings->value("NumCities",DEF_NUM_CITIES).toInt()); 94 } 95 taskView->setModel(tspmodel); 96 setWindowModified(false); 95 97 taskView->resizeColumnsToContents(); 96 98 taskView->resizeRowsToContents(); 97 #endif // Q_OS_WINCE98 99 } 99 100 100 101 void MainWindow::enableSolutionActions(bool enable) 101 102 { 103 buttonSaveSolution->setEnabled(enable); 102 104 actionFileSaveAsSolution->setEnabled(enable); 103 105 solutionText->setEnabled(enable); … … 173 175 void MainWindow::spinCitiesValueChanged(int n) 174 176 { 175 #ifdef Q_OS_WINCE176 177 int count = tspmodel->numCities(); 177 #endif // Q_OS_WINCE178 178 tspmodel->setNumCities(n); 179 #ifdef Q_OS_WINCE180 179 if (n > count) 181 180 for (int k = count; k < n; k++) { … … 183 182 taskView->resizeRowToContents(k); 184 183 } 185 #endif // Q_OS_WINCE186 184 } 187 185 … … 204 202 return; 205 203 tspmodel->clear(); 206 #ifdef Q_OS_WINCE207 204 taskView->resizeColumnsToContents(); 208 205 taskView->resizeRowsToContents(); 209 #endif210 206 setFileName(); 211 207 setWindowModified(false); … … 238 234 } 239 235 setFileName(files.first()); 240 #ifdef Q_OS_WINCE241 236 taskView->resizeColumnsToContents(); 242 237 taskView->resizeRowsToContents(); 243 #endif244 238 tabWidget->setCurrentIndex(0); 245 239 setWindowModified(false); … … 247 241 enableSolutionActions(false); 248 242 QApplication::restoreOverrideCursor(); 243 } 244 245 void MainWindow::actionFileSaveTriggered() 246 { 247 if ((fileName == trUtf8("Untitled") + ".tspt") || (!fileName.endsWith(".tspt",Qt::CaseInsensitive))) 248 saveTask(); 249 else { 250 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); 251 if (tspmodel->saveTask(fileName)) 252 setWindowModified(false); 253 QApplication::restoreOverrideCursor(); 254 } 249 255 } 250 256 … … 350 356 tspmodel->randomize(); 351 357 setWindowModified(true); 352 #ifdef Q_OS_WINCE353 358 taskView->resizeColumnsToContents(); 354 359 taskView->resizeRowsToContents(); 355 #endif // Q_OS_WINCE 360 } 361 362 void MainWindow::buttonBackToTaskClicked() 363 { 364 tabWidget->setCurrentIndex(0); 356 365 } 357 366 … … 395 404 } 396 405 CTSPSolver solver; 397 sStep *root = solver.solve( spinCities->value(),matrix);406 sStep *root = solver.solve(n,matrix,this); 398 407 if (!root) 399 408 return; … … 542 551 void MainWindow::numCitiesChanged(int nCities) 543 552 { 553 blockSignals(true); 544 554 spinCities->setValue(nCities); 545 } 555 blockSignals(false); 556 }
Note: See TracChangeset
for help on using the changeset viewer.