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>
This commit is contained in:
Eike Ziller
2015-06-02 17:14:48 +02:00
parent c916d250b3
commit 4f927e4c87
36 changed files with 123 additions and 122 deletions

View File

@@ -44,6 +44,7 @@
#include <texteditor/generichighlighter/highlighter.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/editormanager/documentmodel.h>
#include <utils/mimetypes/mimedatabase.h>
#include <QApplication>
#include <QDir>
@@ -558,6 +559,19 @@ void TextDocument::checkPermissions()
}
bool TextDocument::open(QString *errorString, const QString &fileName, const QString &realFileName)
{
emit aboutToOpen(fileName, realFileName);
bool success = openImpl(errorString, fileName, realFileName);
if (success) {
Utils::MimeDatabase mdb;
setMimeType(mdb.mimeTypeForFile(fileName).name());
emit openFinishedSuccessfully();
return true;
}
return false;
}
bool TextDocument::openImpl(QString *errorString, const QString &fileName, const QString &realFileName)
{
QStringList content;
@@ -620,7 +634,7 @@ bool TextDocument::reload(QString *errorString)
if (documentLayout)
marks = documentLayout->documentClosing(); // removes text marks non-permanently
bool success = open(errorString, filePath().toString(), filePath().toString());
bool success = openImpl(errorString, filePath().toString(), filePath().toString());
if (documentLayout)
documentLayout->documentReloaded(marks, this); // re-adds text marks