diff options
author | Eike Ziller <eike.ziller@theqtcompany.com> | 2015-06-02 17:14:48 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@theqtcompany.com> | 2015-06-10 11:21:17 +0000 |
commit | 4f927e4c87f07c4d50efcef5b61478df61cc9d3f (patch) | |
tree | a9bbeafa63ea92a5171990bdc8639f93282a7252 /src/plugins/vcsbase/submiteditorfile.cpp | |
parent | c916d250b3c1ff28a4ad0c93ccbd6005c9ff9f42 (diff) | |
download | qt-creator-4f927e4c87f07c4d50efcef5b61478df61cc9d3f.tar.gz |
Move "open" from IEditor to IDocument
For non-editor documents it currently is not used, but for editors it
makes more sense to have that on the document instead of the editor.
Most actual implementations of "open" were done in the documents already
anyhow, because it is needed for reloading.
Change-Id: I29d4df2078995cbe80172b51a9bebeecb3afad3c
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
Diffstat (limited to 'src/plugins/vcsbase/submiteditorfile.cpp')
-rw-r--r-- | src/plugins/vcsbase/submiteditorfile.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/plugins/vcsbase/submiteditorfile.cpp b/src/plugins/vcsbase/submiteditorfile.cpp index cc5175849e..0346b0a198 100644 --- a/src/plugins/vcsbase/submiteditorfile.cpp +++ b/src/plugins/vcsbase/submiteditorfile.cpp @@ -57,6 +57,24 @@ SubmitEditorFile::SubmitEditorFile(const VcsBaseSubmitEditorParameters *paramete setTemporary(true); } +bool SubmitEditorFile::open(QString *errorString, const QString &fileName, const QString &realFileName) +{ + if (fileName.isEmpty()) + return false; + + FileReader reader; + if (!reader.fetch(realFileName, QIODevice::Text, errorString)) + return false; + + const QString text = QString::fromLocal8Bit(reader.data()); + if (!m_editor->setFileContents(text.toUtf8())) + return false; + + setFilePath(FileName::fromString(fileName)); + setModified(fileName != realFileName); + return true; +} + bool SubmitEditorFile::setContents(const QByteArray &contents) { return m_editor->setFileContents(contents); |