Changeset 244c614c6b in tspsg
- Timestamp:
- Aug 30, 2009, 11:02:07 PM (15 years ago)
- Branches:
- 0.1.3.145-beta1-symbian, 0.1.4.170-beta2-bb10, appveyor, imgbot, master, readme
- Children:
- 9cf98b9bd6
- Parents:
- 5a81a64d74
- Location:
- src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mainwindow.cpp
r5a81a64d74 r244c614c6b 242 242 if (files.empty()) 243 243 return; 244 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); 245 if (!tspmodel->loadTask(files.first())) { 246 QApplication::restoreOverrideCursor(); 247 return; 248 } 244 if (!tspmodel->loadTask(files.first())) 245 return; 249 246 setFileName(files.first()); 250 247 tabWidget->setCurrentIndex(0); … … 252 249 solutionText->clear(); 253 250 enableSolutionActions(false); 254 QApplication::restoreOverrideCursor();255 251 } 256 252 … … 259 255 if ((fileName == trUtf8("Untitled") + ".tspt") || (!fileName.endsWith(".tspt",Qt::CaseInsensitive))) 260 256 saveTask(); 261 else { 262 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); 257 else 263 258 if (tspmodel->saveTask(fileName)) 264 259 setWindowModified(false); 265 QApplication::restoreOverrideCursor();266 }267 260 } 268 261 … … 347 340 if (files.empty()) 348 341 return false; 349 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));350 342 if (tspmodel->saveTask(files.first())) { 351 343 setFileName(files.first()); 352 344 setWindowModified(false); 353 QApplication::restoreOverrideCursor();354 345 return true; 355 346 } 356 QApplication::restoreOverrideCursor();357 347 return false; 358 348 } -
src/tspmodel.cpp
r5a81a64d74 r244c614c6b 150 150 else 151 151 err = trUtf8("Unknown error."); 152 QApplication::restoreOverrideCursor(); 152 153 QMessageBox(QMessageBox::Critical,trUtf8("Task Load"),trUtf8("Unable to load task:") + "\n" + err,QMessageBox::Ok).exec(); 153 154 return true; … … 156 157 bool CTSPModel::loadTask(QString fname) 157 158 { 159 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); 158 160 QFile f(fname); 159 161 if (!f.open(QIODevice::ReadOnly)) { 162 QApplication::restoreOverrideCursor(); 160 163 QMessageBox(QMessageBox::Critical,trUtf8("Task Load"),QString(trUtf8("Unable to open task file.\nError: %1")).arg(f.errorString()),QMessageBox::Ok).exec(); 161 164 return false; … … 165 168 quint32 sig; 166 169 ds >> sig; 167 if (loadError(ds.status())) 168 return false; 170 if (loadError(ds.status())) { 171 return false; 172 } 169 173 ds.device()->reset(); 170 174 if (sig == TSPT) { … … 179 183 } 180 184 } else { 185 f.close(); 186 QApplication::restoreOverrideCursor(); 181 187 QMessageBox(QMessageBox::Critical,trUtf8("Task Load"),trUtf8("Unable to load task:") + "\n" + trUtf8("Unknown file format or file is corrupted."),QMessageBox::Ok).exec(); 182 f.close();183 188 return false; 184 189 } 185 190 f.close(); 191 QApplication::restoreOverrideCursor(); 186 192 return true; 187 193 } … … 199 205 return false; 200 206 if (version > TSPT_VERSION) { 207 QApplication::restoreOverrideCursor(); 201 208 QMessageBox(QMessageBox::Critical,trUtf8("Task Load"),trUtf8("Unable to load task:") + "\n" + trUtf8("File version is newer than application supports.\nPlease, try to update application."),QMessageBox::Ok).exec(); 202 209 return false; … … 212 219 return false; 213 220 if ((size < 3) || (size > MAX_NUM_CITIES)) { 221 QApplication::restoreOverrideCursor(); 214 222 QMessageBox(QMessageBox::Critical,trUtf8("Task Load"),trUtf8("Unable to load task:") + "\n" + trUtf8("Unexpected data read.\nFile is possibly corrupted."),QMessageBox::Ok).exec(); 215 223 return false; … … 230 238 } 231 239 emit dataChanged(index(0,0),index(nCities - 1,nCities - 1)); 240 QApplication::restoreOverrideCursor(); 232 241 return true; 233 242 } … … 245 254 return false; 246 255 if (version > ZKT_VERSION) { 256 QApplication::restoreOverrideCursor(); 247 257 QMessageBox(QMessageBox::Critical,trUtf8("Task Load"),trUtf8("Unable to load task:") + "\n" + trUtf8("File version is newer than application supports.\nPlease, try to update application."),QMessageBox::Ok).exec(); 248 258 return false; … … 254 264 return false; 255 265 if ((size < 3) || (size > 5)) { 266 QApplication::restoreOverrideCursor(); 256 267 QMessageBox(QMessageBox::Critical,trUtf8("Task Load"),trUtf8("Unable to load task:") + "\n" + trUtf8("Unexpected data read.\nFile is possibly corrupted."),QMessageBox::Ok).exec(); 257 268 return false; … … 280 291 } 281 292 emit dataChanged(index(0,0),index(nCities - 1,nCities - 1)); 293 QApplication::restoreOverrideCursor(); 282 294 return true; 283 295 } … … 285 297 bool CTSPModel::saveTask(QString fname) 286 298 { 299 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); 287 300 QFile f(fname); 288 301 if (!f.open(QIODevice::WriteOnly)) { 302 QApplication::restoreOverrideCursor(); 289 303 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(); 290 304 return false; … … 293 307 ds.setVersion(QDataStream::Qt_4_4); 294 308 if (f.error() != QFile::NoError) { 295 QMessageBox(QMessageBox::Critical,trUtf8("Task Save"),trUtf8("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec(); 296 f.close(); 309 f.close(); 310 QApplication::restoreOverrideCursor(); 311 QMessageBox(QMessageBox::Critical,trUtf8("Task Save"),trUtf8("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec(); 297 312 return false; 298 313 } … … 300 315 ds << TSPT; 301 316 if (f.error() != QFile::NoError) { 302 QMessageBox(QMessageBox::Critical,trUtf8("Task Save"),trUtf8("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec(); 303 f.close(); 317 f.close(); 318 QApplication::restoreOverrideCursor(); 319 QMessageBox(QMessageBox::Critical,trUtf8("Task Save"),trUtf8("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec(); 304 320 return false; 305 321 } … … 307 323 ds << TSPT_VERSION; 308 324 if (f.error() != QFile::NoError) { 309 QMessageBox(QMessageBox::Critical,trUtf8("Task Save"),trUtf8("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec(); 310 f.close(); 325 f.close(); 326 QApplication::restoreOverrideCursor(); 327 QMessageBox(QMessageBox::Critical,trUtf8("Task Save"),trUtf8("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec(); 311 328 return false; 312 329 } … … 314 331 ds << TSPT_META_VERSION; 315 332 if (f.error() != QFile::NoError) { 316 QMessageBox(QMessageBox::Critical,trUtf8("Task Save"),trUtf8("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec(); 317 f.close(); 333 f.close(); 334 QApplication::restoreOverrideCursor(); 335 QMessageBox(QMessageBox::Critical,trUtf8("Task Save"),trUtf8("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec(); 318 336 return false; 319 337 } … … 321 339 ds << OSID; 322 340 if (f.error() != QFile::NoError) { 323 QMessageBox(QMessageBox::Critical,trUtf8("Task Save"),trUtf8("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec(); 324 f.close(); 341 f.close(); 342 QApplication::restoreOverrideCursor(); 343 QMessageBox(QMessageBox::Critical,trUtf8("Task Save"),trUtf8("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec(); 325 344 return false; 326 345 } … … 328 347 ds << nCities; 329 348 if (f.error() != QFile::NoError) { 330 QMessageBox(QMessageBox::Critical,trUtf8("Task Save"),trUtf8("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec(); 331 f.close(); 349 f.close(); 350 QApplication::restoreOverrideCursor(); 351 QMessageBox(QMessageBox::Critical,trUtf8("Task Save"),trUtf8("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec(); 332 352 return false; 333 353 } … … 338 358 ds << table[r][c]; 339 359 if (f.error() != QFile::NoError) { 360 f.close(); 361 QApplication::restoreOverrideCursor(); 340 362 QMessageBox(QMessageBox::Critical,trUtf8("Task Save"),trUtf8("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec(); 341 f.close();342 363 return false; 343 364 } 344 365 } 345 366 f.close(); 367 QApplication::restoreOverrideCursor(); 346 368 return true; 347 369 } -
src/tspsolver.h
r5a81a64d74 r244c614c6b 34 34 tMatrix matrix; // Steps's matrix 35 35 double price; // Price of travel to this step 36 struct { unsigned int nRow; unsignedint nCol;} candidate; // Candiadate for branching in current matrix36 struct {int nRow; int nCol;} candidate; // Candiadate for branching in current matrix 37 37 bool alts; // This matrix has alternative candidates 38 38 sStep *plNode, *prNode; // Pointers to left and right branch steps
Note: See TracChangeset
for help on using the changeset viewer.