Changeset 99 in tspsg-svn for trunk/src/tspmodel.cpp
- Timestamp:
- Mar 22, 2010, 9:45:16 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 1 1 *.idb 2 *.ini3 2 *.ncb 4 3 *.pdb
-
- Property svn:ignore
-
trunk/src/tspmodel.cpp
r95 r99 81 81 } else if (role == Qt::DisplayRole || role == Qt::EditRole) { 82 82 if (index.row() < nCities && index.column() < nCities) 83 if (table [index.row()][index.column()]== INFINITY)83 if (table.at(index.row()).at(index.column()) == INFINITY) 84 84 return tr(INFSTR); 85 85 else 86 86 //! \hack HACK: Converting to string to prevent spinbox in edit mode 87 return QVariant(table [index.row()][index.column()]).toString();87 return QVariant(table.at(index.row()).at(index.column())).toString(); 88 88 else 89 89 return QVariant(); … … 139 139 if (!f.open(QIODevice::ReadOnly)) { 140 140 QApplication::restoreOverrideCursor(); 141 QMessageBox(QMessageBox::Critical,tr("Task Load"),QString(tr("Unable to open task file.\nError: %1")).arg(f.errorString()),QMessageBox::Ok).exec(); 141 QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor)); 142 QMessageBox::critical(QApplication::activeWindow(), tr("Task Load"), QString(tr("Unable to open task file.\nError: %1")).arg(f.errorString())); 143 QApplication::restoreOverrideCursor(); 142 144 return false; 143 145 } … … 163 165 f.close(); 164 166 QApplication::restoreOverrideCursor(); 165 QMessageBox(QMessageBox::Critical,tr("Task Load"),tr("Unable to load task:") + "\n" + tr("Unknown file format or file is corrupted."),QMessageBox::Ok).exec(); 167 QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor)); 168 QMessageBox::critical(QApplication::activeWindow(), tr("Task Load"), tr("Unable to load task:") + "\n" + tr("Unknown file format or file is corrupted.")); 169 QApplication::restoreOverrideCursor(); 166 170 return false; 167 171 } … … 232 236 if (!f.open(QIODevice::WriteOnly)) { 233 237 QApplication::restoreOverrideCursor(); 234 QMessageBox(QMessageBox::Critical,tr("Task Save"),QString(tr("Unable to create task file.\nError: %1\nMaybe, file is read-only?")).arg(f.errorString()),QMessageBox::Ok).exec(); 238 QMessageBox::critical(QApplication::activeWindow(), tr("Task Save"), QString(tr("Unable to create task file.\nError: %1\nMaybe, file is read-only?")).arg(f.errorString())); 239 f.remove(); 235 240 return false; 236 241 } … … 238 243 ds.setVersion(QDataStream::Qt_4_4); 239 244 if (f.error() != QFile::NoError) { 240 f.close(); 241 QApplication::restoreOverrideCursor(); 242 QMessageBox(QMessageBox::Critical,tr("Task Save"),tr("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec(); 245 QApplication::restoreOverrideCursor(); 246 QMessageBox::critical(QApplication::activeWindow(), tr("Task Save"), tr("Unable to save task.\nError: %1").arg(f.errorString())); 247 f.close(); 248 f.remove(); 243 249 return false; 244 250 } … … 246 252 ds << TSPT; 247 253 if (f.error() != QFile::NoError) { 248 f.close(); 249 QApplication::restoreOverrideCursor(); 250 QMessageBox(QMessageBox::Critical,tr("Task Save"),tr("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec(); 254 QApplication::restoreOverrideCursor(); 255 QMessageBox::critical(QApplication::activeWindow(), tr("Task Save"), tr("Unable to save task.\nError: %1").arg(f.errorString())); 256 f.close(); 257 f.remove(); 251 258 return false; 252 259 } … … 254 261 ds << TSPT_VERSION; 255 262 if (f.error() != QFile::NoError) { 256 f.close(); 257 QApplication::restoreOverrideCursor(); 258 QMessageBox(QMessageBox::Critical,tr("Task Save"),tr("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec(); 263 QApplication::restoreOverrideCursor(); 264 QMessageBox::critical(QApplication::activeWindow(), tr("Task Save"), tr("Unable to save task.\nError: %1").arg(f.errorString())); 265 f.close(); 266 f.remove(); 259 267 return false; 260 268 } … … 262 270 ds << TSPT_META_VERSION; 263 271 if (f.error() != QFile::NoError) { 264 f.close(); 265 QApplication::restoreOverrideCursor(); 266 QMessageBox(QMessageBox::Critical,tr("Task Save"),tr("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec(); 272 QApplication::restoreOverrideCursor(); 273 QMessageBox::critical(QApplication::activeWindow(), tr("Task Save"), tr("Unable to save task.\nError: %1").arg(f.errorString())); 274 f.close(); 275 f.remove(); 267 276 return false; 268 277 } … … 270 279 ds << OSID; 271 280 if (f.error() != QFile::NoError) { 272 f.close(); 273 QApplication::restoreOverrideCursor(); 274 QMessageBox(QMessageBox::Critical,tr("Task Save"),tr("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec(); 281 QApplication::restoreOverrideCursor(); 282 QMessageBox::critical(QApplication::activeWindow(), tr("Task Save"), tr("Unable to save task.\nError: %1").arg(f.errorString())); 283 f.close(); 284 f.remove(); 275 285 return false; 276 286 } … … 278 288 ds << nCities; 279 289 if (f.error() != QFile::NoError) { 280 f.close(); 281 QApplication::restoreOverrideCursor(); 282 QMessageBox(QMessageBox::Critical,tr("Task Save"),tr("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec(); 290 QApplication::restoreOverrideCursor(); 291 QMessageBox::critical(QApplication::activeWindow(), tr("Task Save"), tr("Unable to save task.\nError: %1").arg(f.errorString())); 292 f.close(); 293 f.remove(); 283 294 return false; 284 295 } … … 289 300 ds << static_cast<double>(table[r][c]); // We cast to double because double may be float on some platforms and we store double values in file 290 301 if (f.error() != QFile::NoError) { 302 QApplication::restoreOverrideCursor(); 303 QMessageBox::critical(QApplication::activeWindow(), tr("Task Save"), tr("Unable to save task.\nError: %1").arg(f.errorString())); 291 304 f.close(); 292 QApplication::restoreOverrideCursor(); 293 QMessageBox(QMessageBox::Critical,tr("Task Save"),tr("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec(); 305 f.remove(); 294 306 return false; 295 307 } … … 369 381 err = tr("Unknown error."); 370 382 QApplication::restoreOverrideCursor(); 371 QMessageBox(QMessageBox::Critical,tr("Task Load"),tr("Unable to load task:") + "\n" + err,QMessageBox::Ok).exec(); 383 QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor)); 384 QMessageBox::critical(QApplication::activeWindow(), tr("Task Load"), tr("Unable to load task:") + "\n" + err); 385 QApplication::restoreOverrideCursor(); 372 386 return true; 373 387 } … … 386 400 if (version > TSPT_VERSION) { 387 401 QApplication::restoreOverrideCursor(); 388 QMessageBox(QMessageBox::Critical,tr("Task Load"),tr("Unable to load task:") + "\n" + tr("File version is newer than application supports.\nPlease, try to update application."),QMessageBox::Ok).exec(); 402 QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor)); 403 QMessageBox::critical(QApplication::activeWindow(), tr("Task Load"), tr("Unable to load task:") + "\n" + tr("File version is newer than application supports.\nPlease, try to update application.")); 404 QApplication::restoreOverrideCursor(); 389 405 return false; 390 406 } … … 400 416 if ((size < 3) || (size > MAX_NUM_CITIES)) { 401 417 QApplication::restoreOverrideCursor(); 402 QMessageBox(QMessageBox::Critical,tr("Task Load"),tr("Unable to load task:") + "\n" + tr("Unexpected data read.\nFile is possibly corrupted."),QMessageBox::Ok).exec(); 418 QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor)); 419 QMessageBox::critical(QApplication::activeWindow(), tr("Task Load"), tr("Unable to load task:") + "\n" + tr("Unexpected data read.\nFile is possibly corrupted.")); 420 QApplication::restoreOverrideCursor(); 403 421 return false; 404 422 } … … 438 456 if (version > ZKT_VERSION) { 439 457 QApplication::restoreOverrideCursor(); 440 QMessageBox(QMessageBox::Critical,tr("Task Load"),tr("Unable to load task:") + "\n" + tr("File version is newer than application supports.\nPlease, try to update application."),QMessageBox::Ok).exec(); 458 QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor)); 459 QMessageBox::critical(QApplication::activeWindow(), tr("Task Load"), tr("Unable to load task:") + "\n" + tr("File version is newer than application supports.\nPlease, try to update application.")); 460 QApplication::restoreOverrideCursor(); 441 461 return false; 442 462 } … … 448 468 if ((size < 3) || (size > 5)) { 449 469 QApplication::restoreOverrideCursor(); 450 QMessageBox(QMessageBox::Critical,tr("Task Load"),tr("Unable to load task:") + "\n" + tr("Unexpected data read.\nFile is possibly corrupted."),QMessageBox::Ok).exec(); 470 QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor)); 471 QMessageBox::critical(QApplication::activeWindow(), tr("Task Load"), tr("Unable to load task:") + "\n" + tr("Unexpected data read.\nFile is possibly corrupted.")); 472 QApplication::restoreOverrideCursor(); 451 473 return false; 452 474 }
Note: See TracChangeset
for help on using the changeset viewer.