Commit ce6f3477 authored by hjk's avatar hjk

TextEditor: Move remaining PlainTextEditorWidget functions to Base

Change-Id: Ib10d938fce352f59bcd40f1c6aa493794fe90f8d
Reviewed-by: default avatarChristian Stenger <christian.stenger@digia.com>
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 01822144
......@@ -43,7 +43,7 @@ DesignerXmlEditorWidget::DesignerXmlEditorWidget(QDesignerFormWindowInterface *f
m_designerEditor(new FormWindowEditor(this))
{
setReadOnly(true);
configure(baseTextDocument()->mimeType());
configureMimeType(baseTextDocument()->mimeType());
}
TextEditor::BaseTextEditor *DesignerXmlEditorWidget::createEditor()
......
......@@ -172,7 +172,7 @@ void BarDescriptorEditorWidget::initSourcePage()
addWidget(m_xmlSourceWidget);
TextEditor::TextEditorSettings::initializeEditor(m_xmlSourceWidget);
m_xmlSourceWidget->configure(QLatin1String(Constants::QNX_BAR_DESCRIPTOR_MIME_TYPE));
m_xmlSourceWidget->configureMimeType(QLatin1String(Constants::QNX_BAR_DESCRIPTOR_MIME_TYPE));
}
void BarDescriptorEditorWidget::initPanelSize(ProjectExplorer::PanelsWidget *panelsWidget)
......
......@@ -6933,6 +6933,11 @@ BaseTextEditorWidget *BaseTextEditor::editorWidget() const
return d->m_editorWidget;
}
void BaseTextEditorWidget::configureMimeType(const QString &mimeType)
{
configureMimeType(MimeDatabase::findByType(mimeType));
}
void BaseTextEditorWidget::configureMimeType(const MimeType &mimeType)
{
Highlighter *highlighter = new Highlighter();
......@@ -6981,6 +6986,22 @@ bool BaseTextEditorWidget::isMissingSyntaxDefinition() const
return d->m_isMissingSyntaxDefinition;
}
void BaseTextEditorWidget::acceptMissingSyntaxDefinitionInfo()
{
ICore::showOptionsDialog(Constants::TEXT_EDITOR_SETTINGS_CATEGORY,
Constants::TEXT_EDITOR_HIGHLIGHTER_SETTINGS,
this);
}
void BaseTextEditorWidget::configureMimeType()
{
MimeType mimeType;
if (baseTextDocument())
mimeType = MimeDatabase::findByFile(baseTextDocument()->filePath());
configureMimeType(mimeType);
}
} // namespace TextEditor
#include "basetexteditor.moc"
......@@ -463,6 +463,10 @@ public slots:
/// Abort code assistant if it is running.
void abortAssist();
void acceptMissingSyntaxDefinitionInfo();
void configureMimeType(const QString &mimeType);
void configureMimeType(const Core::MimeType &mimeType);
signals:
......@@ -581,6 +585,8 @@ protected slots:
virtual void slotUpdateBlockNotify(const QTextBlock &);
virtual void slotCodeStyleSettingsChanged(const QVariant &);
void configureMimeType();
private slots:
void updateTabStops();
void applyFontSettingsDelayed();
......
......@@ -87,8 +87,8 @@ void PlainTextEditorWidget::ctor()
baseTextDocument()->setMimeType(QLatin1String(TextEditor::Constants::C_TEXTEDITOR_MIMETYPE_TEXT));
connect(baseTextDocument(), SIGNAL(filePathChanged(QString,QString)),
this, SLOT(configure()));
connect(Manager::instance(), SIGNAL(mimeTypesRegistered()), this, SLOT(configure()));
this, SLOT(configureMimeType()));
connect(Manager::instance(), SIGNAL(mimeTypesRegistered()), this, SLOT(configureMimeType()));
}
IEditor *PlainTextEditor::duplicate()
......@@ -99,26 +99,6 @@ IEditor *PlainTextEditor::duplicate()
return newWidget->editor();
}
void PlainTextEditorWidget::configure()
{
MimeType mimeType;
if (baseTextDocument())
mimeType = MimeDatabase::findByFile(baseTextDocument()->filePath());
configureMimeType(mimeType);
}
void PlainTextEditorWidget::configure(const QString &mimeType)
{
configureMimeType(MimeDatabase::findByType(mimeType));
}
void PlainTextEditorWidget::acceptMissingSyntaxDefinitionInfo()
{
ICore::showOptionsDialog(Constants::TEXT_EDITOR_SETTINGS_CATEGORY,
Constants::TEXT_EDITOR_HIGHLIGHTER_SETTINGS,
this);
}
PlainTextDocument::PlainTextDocument()
{
setId(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID);
......
......@@ -62,12 +62,6 @@ public:
PlainTextEditorWidget(PlainTextDocument *doc, QWidget *parent = 0);
PlainTextEditorWidget(PlainTextEditorWidget *other);
void configure(const QString& mimeType);
private slots:
void configure();
void acceptMissingSyntaxDefinitionInfo();
protected:
virtual BaseTextEditor *createEditor() { return new PlainTextEditor(this); }
......
......@@ -82,7 +82,7 @@ void PlainTextEditorFactory::updateEditorInfoBar(Core::IEditor *editor)
BaseTextDocument *file = qobject_cast<BaseTextDocument *>(editor->document());
if (!file)
return;
PlainTextEditorWidget *textEditor = static_cast<PlainTextEditorWidget *>(editorEditable->editorWidget());
BaseTextEditorWidget *textEditor = editorEditable->editorWidget();
Core::Id infoSyntaxDefinition(Constants::INFO_SYNTAX_DEFINITION);
Core::InfoBar *infoBar = file->infoBar();
if (!textEditor->isMissingSyntaxDefinition()) {
......
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