Changeset 690f6939a7 in tspsg for src
- Timestamp:
- Jul 16, 2009, 6:00:27 PM (15 years ago)
- Branches:
- 0.1.3.145-beta1-symbian, 0.1.4.170-beta2-bb10, appveyor, imgbot, master, readme
- Children:
- 134a9158bd
- Parents:
- 4c96f94558
- Location:
- src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mainwindow.cpp
r4c96f94558 r690f6939a7 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 { -
src/mainwindow.h
r4c96f94558 r690f6939a7 49 49 void groupSettingsLanguageListTriggered(QAction *); 50 50 void actionHelpAboutTriggered(); 51 void dataChanged(); 51 52 #ifndef Q_OS_WINCE 52 53 void actionFilePrintSetupTriggered(); … … 63 64 bool loadLanguage(QString lang = ""); 64 65 void loadLangList(); 66 bool saveTask(); 65 67 }; 66 68 -
src/os.h
r4c96f94558 r690f6939a7 25 25 #define OS_H 26 26 27 #ifdef _WIN64 28 #define BITS " (64-bit)" 29 #elif defined _WIN32 30 #define BITS " (32-bit)" 31 #else 32 #define BITS "" 33 #endif // BITS 34 27 35 #ifdef Q_OS_AIX 28 #define OS "AIX" 36 #define OS "AIX"BITS 29 37 #define OSID quint8(1) 30 38 #elif defined Q_OS_BSD4 31 #define OS "BSD 4.4" 39 #define OS "BSD 4.4"BITS 32 40 #define OSID quint8(2) 33 41 #elif defined Q_OS_BSDI 34 #define OS "BSD/OS" 42 #define OS "BSD/OS"BITS 35 43 #define OSID quint8(3) 36 44 #elif defined Q_OS_CYGWIN 37 #define OS "Cygwin" 45 #define OS "Cygwin"BITS 38 46 #define OSID quint8(4) 39 47 #elif defined Q_OS_DARWIN 40 #define OS "Darwin OS" 48 #define OS "Darwin OS"BITS 41 49 #define OSID quint8(5) 42 50 #elif defined Q_OS_DGUX 43 #define OS "DG/UX" 51 #define OS "DG/UX"BITS 44 52 #define OSID quint8(6) 45 53 #elif defined Q_OS_DYNIX 46 #define OS "DYNIX/ptx" 54 #define OS "DYNIX/ptx"BITS 47 55 #define OSID quint8(7) 48 56 #elif defined Q_OS_FREEBSD 49 #define OS "FreeBSD" 57 #define OS "FreeBSD"BITS 50 58 #define OSID quint8(8) 51 59 #elif defined Q_OS_HPUX 52 #define OS "HP-UX" 60 #define OS "HP-UX"BITS 53 61 #define OSID quint8(9) 54 62 #elif defined Q_OS_HURD 55 #define OS "GNU Hurd" 63 #define OS "GNU Hurd"BITS 56 64 #define OSID quint8(10) 57 65 #elif defined Q_OS_IRIX 58 #define OS "SGI Irix" 66 #define OS "SGI Irix"BITS 59 67 #define OSID quint8(11) 60 68 #elif defined Q_OS_LINUX 61 #define OS "Linux" 69 #define OS "Linux"BITS 62 70 #define OSID quint8(12) 63 71 #elif defined Q_OS_LYNX 64 #define OS "LynxOS" 72 #define OS "LynxOS"BITS 65 73 #define OSID quint8(13) 66 74 #elif defined Q_OS_MSDOS 67 #define OS "MS-DOS" 75 #define OS "MS-DOS"BITS 68 76 #define OSID quint8(14) 69 77 #elif defined Q_OS_NETBSD 70 #define OS "NetBSD" 78 #define OS "NetBSD"BITS 71 79 #define OSID quint8(15) 72 80 #elif defined Q_OS_OS2 73 #define OS "OS/2" 81 #define OS "OS/2"BITS 74 82 #define OSID quint8(16) 75 83 #elif defined Q_OS_OPENBSD 76 #define OS "OpenBSD" 84 #define OS "OpenBSD"BITS 77 85 #define OSID quint8(17) 78 86 #elif defined Q_OS_OS2EMX 79 #define OS "OS/2" 87 #define OS "OS/2"BITS 80 88 #define OSID quint8(18) 81 89 #elif defined Q_OS_OSF 82 #define OS "HP Tru64 UNIX" 90 #define OS "HP Tru64 UNIX"BITS 83 91 #define OSID quint8(19) 84 92 #elif defined Q_OS_QNX6 85 #define OS "QNX RTP 6.1" 93 #define OS "QNX RTP 6.1"BITS 86 94 #define OSID quint8(20) 87 95 #elif defined Q_OS_QNX 88 #define OS "QNX" 96 #define OS "QNX"BITS 89 97 #define OSID quint8(21) 90 98 #elif defined Q_OS_RELIANT 91 #define OS "Reliant UNIX" 99 #define OS "Reliant UNIX"BITS 92 100 #define OSID quint8(22) 93 101 #elif defined Q_OS_SCO 94 #define OS "SCO OpenServer 5" 102 #define OS "SCO OpenServer 5"BITS 95 103 #define OSID quint8(23) 96 104 #elif defined Q_OS_SOLARIS 97 #define OS "Sun Solaris" 105 #define OS "Sun Solaris"BITS 98 106 #define OSID quint8(24) 99 107 #elif defined Q_OS_ULTRIX 100 #define OS "DEC Ultrix" 108 #define OS "DEC Ultrix"BITS 101 109 #define OSID quint8(25) 102 110 #elif defined Q_OS_UNIX 103 #define OS "UNIX BSD/SYSV" 111 #define OS "UNIX BSD/SYSV"BITS 104 112 #define OSID quint8(26) 105 113 #elif defined Q_OS_UNIXWARE 106 #define OS "UnixWare 7/Open UNIX 8" 114 #define OS "UnixWare 7/Open UNIX 8"BITS 107 115 #define OSID quint8(27) 108 116 #elif defined Q_OS_WIN32 109 #define OS "Windows" 117 #define OS "Windows"BITS 110 118 #define OSID quint8(28) 111 119 #elif defined Q_OS_WINCE … … 113 121 #define OSID quint8(29) 114 122 #else 115 #define OS "Unknown" 123 #define OS "Unknown"BITS 116 124 #define OSID quint8(255) 117 #endif 125 #endif // OS 118 126 119 127 #endif // OS_H -
src/tspmodel.cpp
r4c96f94558 r690f6939a7 276 276 } 277 277 278 voidCTSPModel::saveTask(QString fname)278 bool CTSPModel::saveTask(QString fname) 279 279 { 280 280 QFile f(fname); 281 281 if (!f.open(QIODevice::WriteOnly)) { 282 282 QMessageBox(QMessageBox::Critical,trUtf8("Task Save"),QString(trUtf8("Unable to create task file.\nError: %1\nMaybe, file is read-only?")).arg(f.errorString()),QMessageBox::Ok).exec(); 283 return ;283 return false; 284 284 } 285 285 QDataStream ds(&f); … … 288 288 QMessageBox(QMessageBox::Critical,trUtf8("Task Save"),trUtf8("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec(); 289 289 f.close(); 290 return ;290 return false; 291 291 } 292 292 // File signature … … 295 295 QMessageBox(QMessageBox::Critical,trUtf8("Task Save"),trUtf8("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec(); 296 296 f.close(); 297 return ;297 return false; 298 298 } 299 299 // File version … … 302 302 QMessageBox(QMessageBox::Critical,trUtf8("Task Save"),trUtf8("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec(); 303 303 f.close(); 304 return ;304 return false; 305 305 } 306 306 // File metadata version … … 309 309 QMessageBox(QMessageBox::Critical,trUtf8("Task Save"),trUtf8("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec(); 310 310 f.close(); 311 return ;311 return false; 312 312 } 313 313 // Metadata … … 316 316 QMessageBox(QMessageBox::Critical,trUtf8("Task Save"),trUtf8("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec(); 317 317 f.close(); 318 return ;318 return false; 319 319 } 320 320 // Number of cities … … 323 323 QMessageBox(QMessageBox::Critical,trUtf8("Task Save"),trUtf8("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec(); 324 324 f.close(); 325 return ;325 return false; 326 326 } 327 327 // Costs … … 333 333 QMessageBox(QMessageBox::Critical,trUtf8("Task Save"),trUtf8("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec(); 334 334 f.close(); 335 return ;335 return false; 336 336 } 337 337 } 338 338 f.close(); 339 return true; 339 340 } 340 341 -
src/tspmodel.h
r4c96f94558 r690f6939a7 42 42 void clear(); 43 43 void loadTask(QString); 44 voidsaveTask(QString);44 bool saveTask(QString); 45 45 void randomize(); 46 46 signals:
Note: See TracChangeset
for help on using the changeset viewer.