aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quickcontrols2/texteditor/documenthandler.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-08-11 22:41:11 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-08-12 10:51:30 +0000
commit9a6bdf52a387b9266f78f2576dfee9bbf7285730 (patch)
tree0d9ec6240c03ef8f2274d86423890c868cf7367d /examples/quickcontrols2/texteditor/documenthandler.cpp
parent90842fdc865c3b7e9937bbd75f3fd5d74ec588ef (diff)
texteditor: replace setFileUrl() with load()
This allows to remove the text property to avoid storing the whole document's initial content for no real purpose. Change-Id: Iad59576b5304be9739c1dfb0a7d4c263323b0edb Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'examples/quickcontrols2/texteditor/documenthandler.cpp')
-rw-r--r--examples/quickcontrols2/texteditor/documenthandler.cpp20
1 files changed, 2 insertions, 18 deletions
diff --git a/examples/quickcontrols2/texteditor/documenthandler.cpp b/examples/quickcontrols2/texteditor/documenthandler.cpp
index 57322512..45c0f4cb 100644
--- a/examples/quickcontrols2/texteditor/documenthandler.cpp
+++ b/examples/quickcontrols2/texteditor/documenthandler.cpp
@@ -253,20 +253,6 @@ void DocumentHandler::setFontSize(int size)
emit fontSizeChanged();
}
-QString DocumentHandler::text() const
-{
- return m_text;
-}
-
-void DocumentHandler::setText(const QString &text)
-{
- if (text == m_text)
- return;
-
- m_text = text;
- emit textChanged();
-}
-
QString DocumentHandler::fileName() const
{
const QString filePath = QQmlFile::urlToLocalFileOrQrc(m_fileUrl);
@@ -286,7 +272,7 @@ QUrl DocumentHandler::fileUrl() const
return m_fileUrl;
}
-void DocumentHandler::setFileUrl(const QUrl &fileUrl)
+void DocumentHandler::load(const QUrl &fileUrl)
{
if (fileUrl == m_fileUrl)
return;
@@ -297,12 +283,10 @@ void DocumentHandler::setFileUrl(const QUrl &fileUrl)
if (file.open(QFile::ReadOnly)) {
QByteArray data = file.readAll();
QTextCodec *codec = QTextCodec::codecForHtml(data);
- setText(codec->toUnicode(data));
if (QTextDocument *doc = textDocument())
doc->setModified(false);
- emit textChanged();
-
+ emit loaded(codec->toUnicode(data));
reset();
}
}