MCPcopy Create free account
hub / github.com/Simsys/qhexedit2 / saveFile

Method saveFile

example/mainwindow.cpp:419–450  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

417}
418
419bool MainWindow::saveFile(const QString &fileName)
420{
421 QString tmpFileName = fileName + ".~tmp";
422
423 QApplication::setOverrideCursor(Qt::WaitCursor);
424 QFile file(tmpFileName);
425 bool ok = hexEdit->write(file);
426 if (QFile::exists(fileName))
427 ok = QFile::remove(fileName);
428 if (ok)
429 {
430 file.setFileName(tmpFileName);
431 ok = file.copy(fileName);
432 if (ok) {
433 ok = QFile::remove(tmpFileName);
434 isModified = false;
435 setWindowModified(false);
436 }
437 }
438 QApplication::restoreOverrideCursor();
439
440 if (!ok) {
441 QMessageBox::warning(this, tr("QHexEdit"),
442 tr("Cannot write file %1.")
443 .arg(fileName));
444 return false;
445 }
446
447 setCurrentFile(fileName);
448 statusBar()->showMessage(tr("File saved"), 2000);
449 return true;
450}
451
452void MainWindow::setCurrentFile(const QString &fileName)
453{

Callers

nothing calls this directly

Calls 1

writeMethod · 0.45

Tested by

no test coverage detected