Changeset 37 in tspsg-svn for trunk/src/mainwindow.cpp
- Timestamp:
- Jul 16, 2009, 6:00:27 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/mainwindow.cpp
r33 r37 45 45 connect(actionSettingsLanguageAutodetect,SIGNAL(triggered(bool)),this,SLOT(actionSettingsLanguageAutodetectTriggered(bool))); 46 46 connect(groupSettingsLanguageList,SIGNAL(triggered(QAction *)),this,SLOT(groupSettingsLanguageListTriggered(QAction *))); 47 connect(actionHelpAboutQt,SIGNAL(triggered()),qApp,SLOT(aboutQt())); 47 48 connect(actionHelpAbout,SIGNAL(triggered()),this,SLOT(actionHelpAboutTriggered())); 48 49 #ifndef Q_OS_WINCE … … 78 79 taskView->setModel(tspmodel); 79 80 connect(tspmodel,SIGNAL(numCitiesChanged(int)),this,SLOT(numCitiesChanged(int))); 81 connect(tspmodel,SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)),this,SLOT(dataChanged())); 82 connect(tspmodel,SIGNAL(layoutChanged()),this,SLOT(dataChanged())); 80 83 #ifdef Q_OS_WINCE 81 84 taskView->resizeColumnsToContents(); … … 149 152 void MainWindow::actionFileNewTriggered() 150 153 { 154 if (isWindowModified()) { 155 int res = QMessageBox(QMessageBox::Warning,trUtf8("New Task"),trUtf8("Would you like to save changes in current task?"),QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,this).exec(); 156 if ((res == QMessageBox::Cancel) || ((res == QMessageBox::Yes) && !saveTask())) 157 return; 158 } 151 159 tspmodel->clear(); 160 setWindowModified(false); 152 161 } 153 162 154 163 void MainWindow::actionFileOpenTriggered() 155 164 { 165 if (isWindowModified()) { 166 int res = QMessageBox(QMessageBox::Warning,trUtf8("Task Open"),trUtf8("Would you like to save changes in current task?"),QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,this).exec(); 167 if ((res == QMessageBox::Cancel) || ((res == QMessageBox::Yes) && !saveTask())) 168 return; 169 } 156 170 QFileDialog od(this); 157 171 od.setAcceptMode(QFileDialog::AcceptOpen); … … 168 182 return; 169 183 tspmodel->loadTask(files.first()); 184 setWindowModified(false); 170 185 } 171 186 172 187 void MainWindow::actionFileSaveTaskTriggered() 173 188 { 189 saveTask(); 190 } 191 192 bool MainWindow::saveTask() { 174 193 QFileDialog sd(this); 175 194 sd.setAcceptMode(QFileDialog::AcceptSave); … … 179 198 sd.setDefaultSuffix("tspt"); 180 199 if (sd.exec() != QDialog::Accepted) 181 return ;200 return false; 182 201 QStringList files = sd.selectedFiles(); 183 202 if (files.size() < 1) 184 return; 185 tspmodel->saveTask(files.first()); 203 return false; 204 if (tspmodel->saveTask(files.first())) { 205 setWindowModified(false); 206 return true; 207 } else 208 return false; 186 209 } 187 210 … … 208 231 { 209 232 tspmodel->randomize(); 233 setWindowModified(true); 210 234 #ifdef Q_OS_WINCE 211 235 taskView->resizeColumnsToContents(); … … 244 268 QString about = QString::fromUtf8("TSPSG - TSP Solver and Generator\n"); 245 269 about += QString::fromUtf8(" Copyright (C) 2007-%1 Lёppa <contacts[at]oleksii[dot]name>\n").arg(QDate::currentDate().toString("yyyy")); 246 about += "Qt library versions:\n";247 about += QString::fromUtf8(" OS: %1\n").arg(OS);270 about += QString::fromUtf8("Target OS: %1\n").arg(OS); 271 about += "Qt library:\n"; 248 272 about += QString::fromUtf8(" Compile time: %1\n").arg(QT_VERSION_STR); 249 273 about += QString::fromUtf8(" Runtime: %1\n").arg(qVersion()); … … 312 336 void MainWindow::closeEvent(QCloseEvent *event) 313 337 { 338 if (isWindowModified()) { 339 int res = QMessageBox(QMessageBox::Warning,trUtf8("Application Close"),trUtf8("Would you like to save changes in current task?"),QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,this).exec(); 340 if ((res == QMessageBox::Cancel) || ((res == QMessageBox::Yes) && !saveTask())) { 341 event->ignore(); 342 return; 343 } 344 } 314 345 settings->setValue("NumCities",spinCities->value()); 315 346 #ifndef Q_OS_WINCE … … 328 359 } 329 360 361 void MainWindow::dataChanged() 362 { 363 setWindowModified(true); 364 } 365 330 366 void MainWindow::numCitiesChanged(int nCities) 331 367 {
Note: See TracChangeset
for help on using the changeset viewer.