QmlJSEditor: Use a BaseTextEditorFactory for creation

Change-Id: I37e81cf3eda57780c893f4e8d7f2c5c6adf75b55
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
This commit is contained in:
hjk
2014-08-23 00:19:48 +02:00
parent 173879eb1f
commit 74c572b532
3 changed files with 25 additions and 38 deletions

View File

@@ -106,12 +106,8 @@ namespace Internal {
// QmlJSEditorWidget
//
QmlJSEditorWidget::QmlJSEditorWidget(BaseTextDocumentPtr doc)
QmlJSEditorWidget::QmlJSEditorWidget()
{
setTextDocument(doc);
setAutoCompleter(new AutoCompleter);
m_qmlJsEditorDocument = static_cast<QmlJSEditorDocument *>(doc.data());
m_outlineCombo = 0;
m_contextPane = 0;
m_findReferences = new FindReferences(this);
@@ -120,6 +116,11 @@ QmlJSEditorWidget::QmlJSEditorWidget(BaseTextDocumentPtr doc)
setMarksVisible(true);
setCodeFoldingSupported(true);
setLanguageSettingsId(QmlJSTools::Constants::QML_JS_SETTINGS_ID);
}
void QmlJSEditorWidget::finalizeInitialization()
{
m_qmlJsEditorDocument = static_cast<QmlJSEditorDocument *>(textDocument());
m_updateUsesTimer = new QTimer(this);
m_updateUsesTimer->setInterval(UPDATE_USES_DEFAULT_INTERVAL);
@@ -160,10 +161,6 @@ QmlJSEditorWidget::QmlJSEditorWidget(BaseTextDocumentPtr doc)
createToolBar();
}
QmlJSEditorWidget::~QmlJSEditorWidget()
{
}
QModelIndex QmlJSEditorWidget::outlineModelIndex()
{
if (!m_outlineModelIndex.isValid()) {
@@ -173,15 +170,6 @@ QModelIndex QmlJSEditorWidget::outlineModelIndex()
return m_outlineModelIndex;
}
IEditor *QmlJSEditor::duplicate()
{
auto editor = new QmlJSEditor;
auto widget = new QmlJSEditorWidget(editorWidget()->textDocumentPtr());
editor->setEditorWidget(widget);
editor->configureCodeAssistant();
return editor;
}
bool QmlJSEditor::open(QString *errorString, const QString &fileName, const QString &realFileName)
{
bool b = BaseTextEditor::open(errorString, fileName, realFileName);
@@ -898,6 +886,11 @@ QmlJSEditor::QmlJSEditor()
setCompletionAssistProvider(ExtensionSystem::PluginManager::getObject<Internal::QmlJSCompletionAssistProvider>());
}
void QmlJSEditor::finalizeInitialization()
{
configureCodeAssistant();
}
bool QmlJSEditor::isDesignModePreferred() const
{
// stay in design mode if we are there
@@ -921,7 +914,13 @@ QmlJSEditorFactory::QmlJSEditorFactory()
addMimeType(QmlJSTools::Constants::QMLTYPES_MIMETYPE);
addMimeType(QmlJSTools::Constants::JS_MIMETYPE);
addMimeType(QmlJSTools::Constants::JSON_MIMETYPE);
new TextEditorActionHandler(this, Constants::C_QMLJSEDITOR_ID,
setDocumentCreator([]() { return new QmlJSEditorDocument; });
setEditorWidgetCreator([]() { return new QmlJSEditorWidget; });
setEditorCreator([]() { return new QmlJSEditor; });
setAutoCompleterCreator([]() { return new AutoCompleter; });
setEditorActionHandlers(Constants::C_QMLJSEDITOR_ID,
TextEditorActionHandler::Format
| TextEditorActionHandler::UnCommentSelection
| TextEditorActionHandler::UnCollapseAll
@@ -929,13 +928,5 @@ QmlJSEditorFactory::QmlJSEditorFactory()
}
IEditor *QmlJSEditorFactory::createEditor()
{
auto editor = new QmlJSEditor;
editor->setEditorWidget(new QmlJSEditorWidget(BaseTextDocumentPtr(new QmlJSEditorDocument)));
editor->configureCodeAssistant();
return editor;
}
} // namespace Internal
} // namespace QmlJSEditor