Commit 355f104d authored by Eike Ziller's avatar Eike Ziller

BaseTextEditor: Remove some unnecessary indirections through widget

Change-Id: I4f71448d6788a4e553b1495b72263a004e65d8c0
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 7f031394
......@@ -1525,7 +1525,7 @@ IEditor *ClearCasePlugin::showOutputInEditor(const QString& title, const QString
return 0;
e->setForceReadOnly(true);
s.replace(QLatin1Char(' '), QLatin1Char('_'));
e->setSuggestedFileName(s);
e->baseTextDocument()->setSuggestedFileName(s);
if (!source.isEmpty())
e->setSource(source);
if (codec)
......
......@@ -1515,7 +1515,7 @@ bool CPPEditor::open(QString *errorString, const QString &fileName, const QStrin
{
if (!TextEditor::BaseTextEditor::open(errorString, fileName, realFileName))
return false;
editorWidget()->setMimeType(Core::MimeDatabase::findByFile(QFileInfo(fileName)).type());
baseTextDocument()->setMimeType(Core::MimeDatabase::findByFile(QFileInfo(fileName)).type());
return true;
}
......
......@@ -1176,7 +1176,7 @@ IEditor *CvsPlugin::showOutputInEditor(const QString& title, const QString &outp
if (!e)
return 0;
s.replace(QLatin1Char(' '), QLatin1Char('_'));
e->setSuggestedFileName(s);
e->baseTextDocument()->setSuggestedFileName(s);
e->setForceReadOnly(true);
if (!source.isEmpty())
e->setSource(source);
......
......@@ -213,7 +213,7 @@ Core::Id GLSLEditorEditable::id() const
bool GLSLEditorEditable::open(QString *errorString, const QString &fileName, const QString &realFileName)
{
editorWidget()->setMimeType(Core::MimeDatabase::findByFile(QFileInfo(fileName)).type());
baseTextDocument()->setMimeType(Core::MimeDatabase::findByFile(QFileInfo(fileName)).type());
bool b = TextEditor::BaseTextEditor::open(errorString, fileName, realFileName);
return b;
}
......@@ -281,7 +281,7 @@ void GLSLTextEditorWidget::updateDocumentNow()
{
m_updateDocumentTimer->stop();
int variant = languageVariant(mimeType());
int variant = languageVariant(baseTextDocument()->mimeType());
const QString contents = toPlainText(); // get the code from the editor
const QByteArray preprocessedCode = contents.toLatin1(); // ### use the QtCreator C++ preprocessor.
......@@ -389,7 +389,7 @@ TextEditor::IAssistInterface *GLSLTextEditorWidget::createAssistInterface(
position(),
editor()->document()->filePath(),
reason,
mimeType(),
baseTextDocument()->mimeType(),
m_glslDocument);
return BaseTextEditorWidget::createAssistInterface(kind, reason);
}
......@@ -1182,7 +1182,7 @@ Core::IEditor *PerforcePlugin::showOutputInEditor(const QString &title, const QS
e->setForceReadOnly(true);
e->setSource(source);
s.replace(QLatin1Char(' '), QLatin1Char('_'));
e->setSuggestedFileName(s);
e->baseTextDocument()->setSuggestedFileName(s);
if (codec)
e->setCodec(codec);
Core::EditorManager::activateEditor(editor);
......
......@@ -78,7 +78,7 @@ bool PythonEditor::open(QString *errorString,
const QString &realFileName)
{
Core::MimeType mimeType = Core::MimeDatabase::findByFile(QFileInfo(fileName));
editorWidget()->setMimeType(mimeType.type());
baseTextDocument()->setMimeType(mimeType.type());
return TextEditor::BaseTextEditor::open(errorString, fileName, realFileName);
}
......
......@@ -608,7 +608,7 @@ Id QmlJSEditor::id() const
bool QmlJSEditor::open(QString *errorString, const QString &fileName, const QString &realFileName)
{
bool b = TextEditor::BaseTextEditor::open(errorString, fileName, realFileName);
editorWidget()->setMimeType(MimeDatabase::findByFile(QFileInfo(fileName)).type());
baseTextDocument()->setMimeType(MimeDatabase::findByFile(QFileInfo(fileName)).type());
return b;
}
......
......@@ -1031,7 +1031,7 @@ Core::IEditor *SubversionPlugin::showOutputInEditor(const QString &title, const
return 0;
e->setForceReadOnly(true);
s.replace(QLatin1Char(' '), QLatin1Char('_'));
e->setSuggestedFileName(s);
e->baseTextDocument()->setSuggestedFileName(s);
if (!source.isEmpty())
e->setSource(source);
if (codec)
......
......@@ -285,16 +285,6 @@ BaseTextEditorWidget::~BaseTextEditorWidget()
d = 0;
}
QString BaseTextEditorWidget::mimeType() const
{
return d->m_document->mimeType();
}
void BaseTextEditorWidget::setMimeType(const QString &mt)
{
d->m_document->setMimeType(mt);
}
void BaseTextEditorWidget::print(QPrinter *printer)
{
const bool oldFullPage = printer->fullPage();
......@@ -2190,16 +2180,6 @@ bool BaseTextEditorWidget::restoreState(const QByteArray &state)
return true;
}
void BaseTextEditorWidget::setDefaultPath(const QString &defaultPath)
{
baseTextDocument()->setDefaultPath(defaultPath);
}
void BaseTextEditorWidget::setSuggestedFileName(const QString &suggestedFileName)
{
baseTextDocument()->setSuggestedFileName(suggestedFileName);
}
void BaseTextEditorWidget::setParenthesesMatchingEnabled(bool b)
{
d->m_parenthesesMatchingEnabled = b;
......
......@@ -154,10 +154,6 @@ public:
void print(QPrinter *);
void setSuggestedFileName(const QString &suggestedFileName);
QString mimeType() const;
virtual void setMimeType(const QString &mt);
void appendMenuActionsFromContext(QMenu *menu, Core::Id menuContextId);
void appendStandardContextMenuActions(QMenu *menu);
......@@ -355,8 +351,6 @@ private:
void collectToCircularClipboard();
protected:
void setDefaultPath(const QString &defaultPath);
virtual BaseTextEditor *createEditor() = 0;
private slots:
......
......@@ -83,7 +83,7 @@ void PlainTextEditorWidget::ctor()
setLineSeparatorsAllowed(true);
setIndenter(new NormalIndenter); // Currently only "normal" indentation is supported.
setMimeType(QLatin1String(TextEditor::Constants::C_TEXTEDITOR_MIMETYPE_TEXT));
baseTextDocument()->setMimeType(QLatin1String(TextEditor::Constants::C_TEXTEDITOR_MIMETYPE_TEXT));
m_commentDefinition.clearCommentStyles();
......@@ -146,7 +146,7 @@ void PlainTextEditorWidget::configure(const MimeType &mimeType)
setMimeTypeForHighlighter(highlighter, mimeType);
const QString &type = mimeType.type();
setMimeType(type);
baseTextDocument()->setMimeType(type);
QString definitionId = Manager::instance()->definitionIdByMimeType(type);
if (definitionId.isEmpty())
......
......@@ -81,7 +81,7 @@ Core::IEditor *BaseVcsEditorFactory::createEditor()
{
VcsBaseEditorWidget *vcsEditor = createVcsBaseEditor(d->m_type);
vcsEditor->setMimeType(mimeTypes().front());
vcsEditor->baseTextDocument()->setMimeType(mimeTypes().front());
TextEditor::TextEditorSettings::initializeEditor(vcsEditor);
return vcsEditor->editor();
......
......@@ -657,7 +657,7 @@ VcsBaseEditorWidget::VcsBaseEditorWidget(const VcsBaseEditorParameters *type, QW
d(new Internal::VcsBaseEditorWidgetPrivate(this, type))
{
viewport()->setMouseTracking(true);
setMimeType(QLatin1String(d->m_parameters->mimeType));
baseTextDocument()->setMimeType(QLatin1String(d->m_parameters->mimeType));
}
void VcsBaseEditorWidget::setDiffFilePattern(const QRegExp &pattern)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment