summaryrefslogtreecommitdiff
path: root/src/plugins/designer
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2011-08-25 12:54:20 +0200
committerFriedemann Kleint <Friedemann.Kleint@nokia.com>2011-08-26 08:23:16 +0200
commitbd5a1a9bcea4da782494a02f17d37ea42eb01d9b (patch)
treee37bb6e53fa8576a875edd75d6b2453a8fa7163b /src/plugins/designer
parente29881015d385176daca7ecbaace600e9eaa5436 (diff)
downloadqt-creator-bd5a1a9bcea4da782494a02f17d37ea42eb01d9b.tar.gz
Extract Core::TextFile from TextEditor::BaseTextDocument.
Use it in BaseTextEditor and Designer to preserve CRLF of the files. Task-number: QTCREATORBUG-5901 Change-Id: I7599ce78649a3b09f2e5118d02f8cbf3db27ed31 Reviewed-on: http://codereview.qt.nokia.com/3591 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Diffstat (limited to 'src/plugins/designer')
-rw-r--r--src/plugins/designer/formwindoweditor.cpp10
-rw-r--r--src/plugins/designer/formwindowfile.cpp10
-rw-r--r--src/plugins/designer/formwindowfile.h4
3 files changed, 12 insertions, 12 deletions
diff --git a/src/plugins/designer/formwindoweditor.cpp b/src/plugins/designer/formwindoweditor.cpp
index 6057002e2b..803c140aa3 100644
--- a/src/plugins/designer/formwindoweditor.cpp
+++ b/src/plugins/designer/formwindoweditor.cpp
@@ -157,19 +157,19 @@ bool FormWindowEditor::open(QString *errorString, const QString &fileName, const
const QFileInfo fi(fileName);
const QString absfileName = fi.absoluteFilePath();
- Utils::FileReader reader;
- if (!reader.fetch(realFileName, QIODevice::Text, errorString))
+ QString contents;
+ if (d->m_file.read(absfileName, &contents, errorString) != Utils::TextFileFormat::ReadSuccess)
return false;
form->setFileName(absfileName);
- QByteArray contents = reader.data();
#if QT_VERSION >= 0x050000
- QBuffer str(&contents);
+ const QByteArray contentsBA = contents.toUtf8();
+ QBuffer str(&contentsBA);
str.open(QIODevice::ReadOnly);
if (!form->setContents(&str, errorString))
return false;
#else
- form->setContents(QString::fromUtf8(contents));
+ form->setContents(contents);
if (!form->mainContainer())
return false;
#endif
diff --git a/src/plugins/designer/formwindowfile.cpp b/src/plugins/designer/formwindowfile.cpp
index 61b30661fe..0ad8d88082 100644
--- a/src/plugins/designer/formwindowfile.cpp
+++ b/src/plugins/designer/formwindowfile.cpp
@@ -53,16 +53,19 @@
#include <QtCore/QFileInfo>
#include <QtCore/QByteArray>
#include <QtCore/QDebug>
+#include <QtCore/QTextCodec>
namespace Designer {
namespace Internal {
FormWindowFile::FormWindowFile(QDesignerFormWindowInterface *form, QObject *parent)
- : Core::IFile(parent),
+ : Core::TextFile(parent),
m_mimeType(QLatin1String(Designer::Constants::FORM_MIMETYPE)),
m_shouldAutoSave(false),
m_formWindow(form)
{
+ // Designer needs UTF-8 regardless of settings.
+ setCodec(QTextCodec::codecForName("UTF-8"));
connect(m_formWindow->core()->formWindowManager(), SIGNAL(formWindowRemoved(QDesignerFormWindowInterface*)),
this, SLOT(slotFormWindowRemoved(QDesignerFormWindowInterface*)));
connect(m_formWindow->commandHistory(), SIGNAL(indexChanged(int)),
@@ -190,10 +193,7 @@ bool FormWindowFile::writeFile(const QString &fileName, QString *errorString) co
{
if (Designer::Constants::Internal::debug)
qDebug() << Q_FUNC_INFO << m_fileName << fileName;
-
- Utils::FileSaver saver(fileName, QIODevice::Text);
- saver.write(m_formWindow->contents().toUtf8());
- return saver.finalize(errorString);
+ return write(fileName, format(), m_formWindow->contents(), errorString);
}
void FormWindowFile::setFileName(const QString &fname)
diff --git a/src/plugins/designer/formwindowfile.h b/src/plugins/designer/formwindowfile.h
index 13d4956a4b..587fbe70e9 100644
--- a/src/plugins/designer/formwindowfile.h
+++ b/src/plugins/designer/formwindowfile.h
@@ -33,7 +33,7 @@
#ifndef FORMWINDOWFILE_H
#define FORMWINDOWFILE_H
-#include <coreplugin/ifile.h>
+#include <coreplugin/textfile.h>
#include <QtCore/QPointer>
@@ -45,7 +45,7 @@ QT_END_NAMESPACE
namespace Designer {
namespace Internal {
-class FormWindowFile : public Core::IFile
+class FormWindowFile : public Core::TextFile
{
Q_OBJECT