18 setAttribute(Qt::WA_DeleteOnClose);
28 static int sequenceNumber = 1;
31 curFile = tr(
"graph%1.gv").arg(sequenceNumber++);
32 setWindowTitle(curFile + QLatin1String(
"[*]"));
34 connect(document(), &QTextDocument::contentsChange,
this,
35 &MdiChild::documentWasModified);
40 if (!file.open(QFile::ReadOnly | QFile::Text)) {
43 tr(
"Cannot read file %1:\n%2.").arg(
fileName).arg(file.errorString()));
47 QTextStream in(&file);
48 QApplication::setOverrideCursor(Qt::WaitCursor);
49 setPlainText(in.readAll());
50 QApplication::restoreOverrideCursor();
54 connect(document(), &QTextDocument::contentsChange,
this,
55 &MdiChild::documentWasModified);
68 QString
fileName = QFileDialog::getSaveFileName(
this, tr(
"Save As"), curFile);
77 if (!file.open(QFile::WriteOnly | QFile::Text)) {
80 tr(
"Cannot write file %1:\n%2.").arg(
fileName).arg(file.errorString()));
84 QTextStream
out(&file);
85 QApplication::setOverrideCursor(Qt::WaitCursor);
86#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
87 out.setCodec(
"UTF-8");
91 QApplication::restoreOverrideCursor();
107void MdiChild::documentWasModified() {
108 setWindowModified(document()->isModified());
111bool MdiChild::maybeSave() {
112 if (document()->isModified()) {
113 QMessageBox::StandardButton ret;
114 ret = QMessageBox::warning(
this, tr(
"MDI"),
115 tr(
"'%1' has been modified.\n"
116 "Do you want to save your changes?")
118 QMessageBox::Save | QMessageBox::Discard |
119 QMessageBox::Cancel);
120 if (ret == QMessageBox::Save)
122 if (ret == QMessageBox::Cancel)
128void MdiChild::setCurrentFile(
const QString &
fileName) {
129 curFile = QFileInfo(
fileName).canonicalFilePath();
131 document()->setModified(
false);
132 setWindowModified(
false);
136QString MdiChild::strippedName(
const QString &fullFileName) {
137 return QFileInfo(fullFileName).fileName();
static void out(agerrlevel_t level, const char *fmt, va_list args)
Report messages using a user-supplied or default write function.
QString userFriendlyCurrentFile()
std::unique_ptr< ImageViewer > previewFrm
bool saveFile(const QString &fileName)
bool loadPreview(const QString &fileName)
bool loadFile(const QString &fileName)
void closeEvent(QCloseEvent *event)
char * fileName(ingraph_state *sp)
Return name of current file being processed.