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:
@@ -681,6 +681,10 @@ void TextEditorWidgetPrivate::ctor(const QSharedPointer<TextDocument> &doc)
|
||||
|
||||
updateCannotDecodeInfo();
|
||||
|
||||
QObject::connect(m_document.data(), &TextDocument::aboutToOpen,
|
||||
q, &TextEditorWidget::aboutToOpen);
|
||||
QObject::connect(m_document.data(), &TextDocument::openFinishedSuccessfully,
|
||||
q, &TextEditorWidget::openFinishedSuccessfully);
|
||||
connect(m_fileEncodingLabel, &LineColumnLabel::clicked,
|
||||
q, &TextEditorWidget::selectEncoding);
|
||||
connect(m_document->document(), &QTextDocument::modificationChanged,
|
||||
@@ -972,17 +976,6 @@ void TextEditorWidgetPrivate::updateCannotDecodeInfo()
|
||||
}
|
||||
}
|
||||
|
||||
bool TextEditorWidget::open(QString *errorString, const QString &fileName, const QString &realFileName)
|
||||
{
|
||||
if (d->m_document->open(errorString, fileName, realFileName)) {
|
||||
moveCursor(QTextCursor::Start);
|
||||
d->updateCannotDecodeInfo();
|
||||
updateTextCodecLabel();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
Collapses the first comment in a file, if there is only whitespace above
|
||||
*/
|
||||
@@ -1014,6 +1007,19 @@ TextDocument *TextEditorWidget::textDocument() const
|
||||
return d->m_document.data();
|
||||
}
|
||||
|
||||
void TextEditorWidget::aboutToOpen(const QString &fileName, const QString &realFileName)
|
||||
{
|
||||
Q_UNUSED(fileName)
|
||||
Q_UNUSED(realFileName)
|
||||
}
|
||||
|
||||
void TextEditorWidget::openFinishedSuccessfully()
|
||||
{
|
||||
moveCursor(QTextCursor::Start);
|
||||
d->updateCannotDecodeInfo();
|
||||
updateTextCodecLabel();
|
||||
}
|
||||
|
||||
TextDocumentPtr TextEditorWidget::textDocumentPtr() const
|
||||
{
|
||||
return d->m_document;
|
||||
@@ -7142,15 +7148,6 @@ QString TextEditorWidget::foldReplacementText(const QTextBlock &) const
|
||||
return QLatin1String("...");
|
||||
}
|
||||
|
||||
bool BaseTextEditor::open(QString *errorString, const QString &fileName, const QString &realFileName)
|
||||
{
|
||||
if (!editorWidget()->open(errorString, fileName, realFileName))
|
||||
return false;
|
||||
Utils::MimeDatabase mdb;
|
||||
textDocument()->setMimeType(mdb.mimeTypeForFile(fileName).name());
|
||||
return true;
|
||||
}
|
||||
|
||||
QByteArray BaseTextEditor::saveState() const
|
||||
{
|
||||
return editorWidget()->saveState();
|
||||
|
||||
Reference in New Issue
Block a user