forked from qt-creator/qt-creator
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user