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:
@@ -364,14 +364,6 @@ Core::IEditor *DiffEditor::duplicate()
|
||||
return editor;
|
||||
}
|
||||
|
||||
bool DiffEditor::open(QString *errorString,
|
||||
const QString &fileName,
|
||||
const QString &realFileName)
|
||||
{
|
||||
Q_UNUSED(realFileName)
|
||||
return m_document->open(errorString, fileName);
|
||||
}
|
||||
|
||||
Core::IDocument *DiffEditor::document()
|
||||
{
|
||||
return m_document.data();
|
||||
|
||||
@@ -63,12 +63,7 @@ public:
|
||||
~DiffEditor() override;
|
||||
|
||||
Core::IEditor *duplicate() override;
|
||||
|
||||
bool open(QString *errorString,
|
||||
const QString &fileName,
|
||||
const QString &realFileName) override;
|
||||
Core::IDocument *document() override;
|
||||
|
||||
QWidget *toolBar() override;
|
||||
|
||||
private slots:
|
||||
|
||||
@@ -235,12 +235,14 @@ bool DiffEditorDocument::reload(QString *errorString, ReloadFlag flag, ChangeTyp
|
||||
Q_UNUSED(type)
|
||||
if (flag == FlagIgnore)
|
||||
return true;
|
||||
return open(errorString, filePath().toString());
|
||||
return open(errorString, filePath().toString(), filePath().toString());
|
||||
}
|
||||
|
||||
bool DiffEditorDocument::open(QString *errorString, const QString &fileName)
|
||||
bool DiffEditorDocument::open(QString *errorString, const QString &fileName,
|
||||
const QString &realFileName)
|
||||
{
|
||||
QTC_ASSERT(errorString, return false);
|
||||
QTC_ASSERT(fileName == realFileName, return false); // does not support autosave
|
||||
beginReload();
|
||||
QString patch;
|
||||
if (read(fileName, &patch, errorString) != TextFileFormat::ReadSuccess)
|
||||
|
||||
@@ -77,7 +77,7 @@ public:
|
||||
bool save(QString *errorString, const QString &fileName, bool autoSave);
|
||||
void reload();
|
||||
bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
|
||||
bool open(QString *errorString, const QString &fileName);
|
||||
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
|
||||
|
||||
QString plainText() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user