-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocument.cpp
49 lines (42 loc) · 1.11 KB
/
document.cpp
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
#include "document.h"
#include "util.h"
#include <QMessageBox>
#include <QFileDialog>
#include <QSettings>
#include <QFileInfo>
#include <QDir>
#include "newdialog.h"
#include "editor.h"
Document::Document(Session &session, const QString &fileName) :
QObject(), fileInfo(fileName), editors(), session(session)
{
session.documents.append(this);
emit session.layoutChanged();
}
Document::~Document()
{
session.documents.removeOne(this);
emit session.layoutChanged();
}
bool Document::save(QString fileName)
{
bool saved = false;
if (fileInfo.fileName().isNull()) {
fileName = fileInfo.fileName();
}
if (!fileName.isNull()) {
saved = doSave(fileName);
if (saved) {
fileInfo.setFileName(fileName);
fileInfo.clearDirty();
}
}
return saved;
}
TreeModel::Item *Document::child(int row) {
return editors.value(row);
}
//const struct DocumentType DOCUMENT_TYPES[] = {
//// {"image", (char *[]){"png", "gif", "bmp"}, &ImageDocument::create, &ImageDocument::open},
// {"palette", (char *[]){"gpl", "pal"}, nullptr, nullptr},
//};