-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocumenthandler.cpp
60 lines (49 loc) · 1.43 KB
/
documenthandler.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
50
51
52
53
54
55
56
57
58
59
#include "documenthandler.h"
#include "documentslistmodule.h"
#include <QFile>
#include <QFileInfo>
#include <QFileSelector>
#include <QQmlFile>
#include <QQmlFileSelector>
#include <QQuickTextDocument>
#include <QTextCharFormat>
#include <QTextCodec>
#include <QTextDocument>
#include <QDebug>
DocumentHandler::DocumentHandler()
{
}
void DocumentHandler::load(const QUrl &fileUrl)
{
if (fileUrl == m_fileUrl)
return;
QQmlEngine *engine = qmlEngine(this);
if (!engine) {
qWarning() << "load() called before DocumentHandler has QQmlEngine";
return;
}
const QUrl path = QQmlFileSelector::get(engine)->selector()->select(fileUrl);
const QString fileName = QQmlFile::urlToLocalFileOrQrc(path);
if (QFile::exists(fileName)) {
qDebug() << fileName << " " << path;
}
m_fileUrl = fileUrl;
//emit fileUrlChanged();
}
void DocumentHandler::loadFile(const QUrl &fileUrl)
{
QQmlEngine *engine = qmlEngine(this);
if (!engine) {
qWarning() << "load() called before DocumentHandler has QQmlEngine";
return;
}
const QUrl path = QQmlFileSelector::get(engine)->selector()->select(fileUrl);
const QString fileName = QQmlFile::urlToLocalFileOrQrc(path);
if (!QFile::exists(fileName)) {
qWarning() << "dont exists filename: " << fileName << " . path: " << path;
}
m_fileUrl = fileUrl;
}
void DocumentHandler::loadFolder(const QUrl &folderUrl)
{
}