-
Notifications
You must be signed in to change notification settings - Fork 0
/
diagram_writer.cc
69 lines (52 loc) · 1.21 KB
/
diagram_writer.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <diagram_writer.h>
diagram_writer::diagram_writer(const QString &filename, editor *edit,
QWidget *parent)
{
QFile qf;
QString error = "";
QTextStream qts;
/*
** Write the data to the specified file.
*/
saved = false;
qf.setName(filename);
if(!qf.open(IO_Truncate | IO_Translate | IO_WriteOnly))
{
error = "Unable to open " + filename + ".";
goto error_label;
}
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
qts.setDevice(&qf);
/*
** Include a warning message in the file.
*/
qts << "Created by QtNQC. Please do not edit this file." << endl << endl;
/*
** Now it gets interesting.
*/
edit->writeToFile(qts, error);
/*
** Set this only if the writes were successful.
*/
if(parent != NULL && error.isEmpty())
parent->setCaption("QtNQC " + QString(VERSION) + ": " + filename);
QApplication::restoreOverrideCursor();
error_label:
if(!error.isEmpty())
{
if(parent != NULL)
(void) QMessageBox::critical(parent, "Error", error,
QMessageBox::Ok | QMessageBox::Default,
0);
}
else
saved = true;
qf.close();
}
/*
** -- isSaved() --
*/
bool diagram_writer::isSaved(void)
{
return saved;
}