forked from qt-creator/qt-creator
TextEditor: Factory cosmetics
Pimpl, add some convenience setters. Change-Id: I525c080179fddab6fe2bd2270505fdbf33e56be2 Reviewed-by: David Schulz <david.schulz@digia.com>
This commit is contained in:
@@ -98,6 +98,7 @@ JavaEditorFactory::JavaEditorFactory()
|
|||||||
setCommentStyle(Utils::CommentDefinition::CppStyle);
|
setCommentStyle(Utils::CommentDefinition::CppStyle);
|
||||||
setEditorActionHandlers(TextEditor::TextEditorActionHandler::UnCommentSelection);
|
setEditorActionHandlers(TextEditor::TextEditorActionHandler::UnCommentSelection);
|
||||||
setCompletionAssistProvider(new JavaCompletionAssistProvider);
|
setCompletionAssistProvider(new JavaCompletionAssistProvider);
|
||||||
|
setMarksVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ QString CMakeEditor::contextHelpId() const
|
|||||||
class CMakeEditorWidget : public TextEditorWidget
|
class CMakeEditorWidget : public TextEditorWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CMakeEditorWidget();
|
CMakeEditorWidget() {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool save(const QString &fileName = QString());
|
bool save(const QString &fileName = QString());
|
||||||
@@ -152,11 +152,6 @@ private:
|
|||||||
void contextMenuEvent(QContextMenuEvent *e);
|
void contextMenuEvent(QContextMenuEvent *e);
|
||||||
};
|
};
|
||||||
|
|
||||||
CMakeEditorWidget::CMakeEditorWidget()
|
|
||||||
{
|
|
||||||
setCodeFoldingSupported(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMakeEditorWidget::contextMenuEvent(QContextMenuEvent *e)
|
void CMakeEditorWidget::contextMenuEvent(QContextMenuEvent *e)
|
||||||
{
|
{
|
||||||
showDefaultContextMenu(e, Constants::M_CONTEXT);
|
showDefaultContextMenu(e, Constants::M_CONTEXT);
|
||||||
@@ -283,6 +278,7 @@ CMakeEditorFactory::CMakeEditorFactory(CMakeSettingsPage *settingsPage)
|
|||||||
setDocumentCreator([]() { return new CMakeDocument; });
|
setDocumentCreator([]() { return new CMakeDocument; });
|
||||||
setGenericSyntaxHighlighter(QLatin1String(Constants::CMAKEMIMETYPE));
|
setGenericSyntaxHighlighter(QLatin1String(Constants::CMAKEMIMETYPE));
|
||||||
setCommentStyle(Utils::CommentDefinition::HashStyle);
|
setCommentStyle(Utils::CommentDefinition::HashStyle);
|
||||||
|
setCodeFoldingSupported(true);
|
||||||
|
|
||||||
setCompletionAssistProvider(new CMakeFileCompletionAssistProvider(settingsPage));
|
setCompletionAssistProvider(new CMakeFileCompletionAssistProvider(settingsPage));
|
||||||
|
|
||||||
|
|||||||
@@ -150,9 +150,6 @@ void CppEditorWidget::finalizeInitialization()
|
|||||||
d->m_cppEditorDocument = qobject_cast<CppEditorDocument *>(textDocument());
|
d->m_cppEditorDocument = qobject_cast<CppEditorDocument *>(textDocument());
|
||||||
|
|
||||||
setLanguageSettingsId(CppTools::Constants::CPP_SETTINGS_ID);
|
setLanguageSettingsId(CppTools::Constants::CPP_SETTINGS_ID);
|
||||||
setCodeFoldingSupported(true);
|
|
||||||
setMarksVisible(true);
|
|
||||||
setParenthesesMatchingEnabled(true);
|
|
||||||
setRevisionsVisible(true);
|
setRevisionsVisible(true);
|
||||||
|
|
||||||
// function combo box sorting
|
// function combo box sorting
|
||||||
|
|||||||
@@ -91,6 +91,9 @@ public:
|
|||||||
setEditorCreator([]() { return new CppEditor; });
|
setEditorCreator([]() { return new CppEditor; });
|
||||||
setAutoCompleterCreator([]() { return new CppAutoCompleter; });
|
setAutoCompleterCreator([]() { return new CppAutoCompleter; });
|
||||||
setCommentStyle(Utils::CommentDefinition::CppStyle);
|
setCommentStyle(Utils::CommentDefinition::CppStyle);
|
||||||
|
setCodeFoldingSupported(true);
|
||||||
|
setMarksVisible(true);
|
||||||
|
setParenthesesMatchingEnabled(true);
|
||||||
|
|
||||||
setEditorActionHandlers(TextEditorActionHandler::Format
|
setEditorActionHandlers(TextEditorActionHandler::Format
|
||||||
| TextEditorActionHandler::UnCommentSelection
|
| TextEditorActionHandler::UnCommentSelection
|
||||||
|
|||||||
@@ -137,9 +137,6 @@ GlslEditorWidget::GlslEditorWidget()
|
|||||||
{
|
{
|
||||||
setAutoCompleter(new GlslCompleter);
|
setAutoCompleter(new GlslCompleter);
|
||||||
m_outlineCombo = 0;
|
m_outlineCombo = 0;
|
||||||
setParenthesesMatchingEnabled(true);
|
|
||||||
setMarksVisible(true);
|
|
||||||
setCodeFoldingSupported(true);
|
|
||||||
|
|
||||||
m_updateDocumentTimer.setInterval(UPDATE_DOCUMENT_DEFAULT_INTERVAL);
|
m_updateDocumentTimer.setInterval(UPDATE_DOCUMENT_DEFAULT_INTERVAL);
|
||||||
m_updateDocumentTimer.setSingleShot(true);
|
m_updateDocumentTimer.setSingleShot(true);
|
||||||
@@ -344,6 +341,9 @@ GlslEditorFactory::GlslEditorFactory()
|
|||||||
setSyntaxHighlighterCreator([]() { return new GlslHighlighter; });
|
setSyntaxHighlighterCreator([]() { return new GlslHighlighter; });
|
||||||
setCommentStyle(Utils::CommentDefinition::CppStyle);
|
setCommentStyle(Utils::CommentDefinition::CppStyle);
|
||||||
setCompletionAssistProvider(new GlslCompletionAssistProvider);
|
setCompletionAssistProvider(new GlslCompletionAssistProvider);
|
||||||
|
setParenthesesMatchingEnabled(true);
|
||||||
|
setMarksVisible(true);
|
||||||
|
setCodeFoldingSupported(true);
|
||||||
|
|
||||||
setEditorActionHandlers(TextEditorActionHandler::Format
|
setEditorActionHandlers(TextEditorActionHandler::Format
|
||||||
| TextEditorActionHandler::UnCommentSelection
|
| TextEditorActionHandler::UnCommentSelection
|
||||||
|
|||||||
@@ -45,26 +45,6 @@ using namespace TextEditor;
|
|||||||
namespace PythonEditor {
|
namespace PythonEditor {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
//
|
|
||||||
// PythonEditorWidget
|
|
||||||
//
|
|
||||||
|
|
||||||
class PythonEditorWidget : public TextEditorWidget
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
PythonEditorWidget()
|
|
||||||
{
|
|
||||||
setParenthesesMatchingEnabled(true);
|
|
||||||
setMarksVisible(true);
|
|
||||||
setCodeFoldingSupported(true);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// PythonEditorFactory
|
|
||||||
//
|
|
||||||
|
|
||||||
PythonEditorFactory::PythonEditorFactory()
|
PythonEditorFactory::PythonEditorFactory()
|
||||||
{
|
{
|
||||||
setId(Constants::C_PYTHONEDITOR_ID);
|
setId(Constants::C_PYTHONEDITOR_ID);
|
||||||
@@ -76,10 +56,12 @@ PythonEditorFactory::PythonEditorFactory()
|
|||||||
| TextEditorActionHandler::UnCollapseAll);
|
| TextEditorActionHandler::UnCollapseAll);
|
||||||
|
|
||||||
setDocumentCreator([]() { return new TextDocument(Constants::C_PYTHONEDITOR_ID); });
|
setDocumentCreator([]() { return new TextDocument(Constants::C_PYTHONEDITOR_ID); });
|
||||||
setEditorWidgetCreator([]() { return new PythonEditorWidget; });
|
|
||||||
setIndenterCreator([]() { return new PythonIndenter; });
|
setIndenterCreator([]() { return new PythonIndenter; });
|
||||||
setSyntaxHighlighterCreator([]() { return new PythonHighlighter; });
|
setSyntaxHighlighterCreator([]() { return new PythonHighlighter; });
|
||||||
setCommentStyle(Utils::CommentDefinition::HashStyle);
|
setCommentStyle(Utils::CommentDefinition::HashStyle);
|
||||||
|
setParenthesesMatchingEnabled(true);
|
||||||
|
setMarksVisible(true);
|
||||||
|
setCodeFoldingSupported(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -114,9 +114,6 @@ QmlJSEditorWidget::QmlJSEditorWidget()
|
|||||||
m_firstSementicInfo = true;
|
m_firstSementicInfo = true;
|
||||||
m_findReferences = new FindReferences(this);
|
m_findReferences = new FindReferences(this);
|
||||||
|
|
||||||
setParenthesesMatchingEnabled(true);
|
|
||||||
setMarksVisible(true);
|
|
||||||
setCodeFoldingSupported(true);
|
|
||||||
setLanguageSettingsId(QmlJSTools::Constants::QML_JS_SETTINGS_ID);
|
setLanguageSettingsId(QmlJSTools::Constants::QML_JS_SETTINGS_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -920,6 +917,9 @@ QmlJSEditorFactory::QmlJSEditorFactory()
|
|||||||
setEditorCreator([]() { return new QmlJSEditor; });
|
setEditorCreator([]() { return new QmlJSEditor; });
|
||||||
setAutoCompleterCreator([]() { return new AutoCompleter; });
|
setAutoCompleterCreator([]() { return new AutoCompleter; });
|
||||||
setCommentStyle(Utils::CommentDefinition::CppStyle);
|
setCommentStyle(Utils::CommentDefinition::CppStyle);
|
||||||
|
setParenthesesMatchingEnabled(true);
|
||||||
|
setMarksVisible(true);
|
||||||
|
setCodeFoldingSupported(true);
|
||||||
|
|
||||||
addHoverHandler(new QmlJSHoverHandler);
|
addHoverHandler(new QmlJSHoverHandler);
|
||||||
setCompletionAssistProvider(new QmlJSCompletionAssistProvider);
|
setCompletionAssistProvider(new QmlJSCompletionAssistProvider);
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ class BaseTextEditorPrivate
|
|||||||
public:
|
public:
|
||||||
BaseTextEditorPrivate() {}
|
BaseTextEditorPrivate() {}
|
||||||
|
|
||||||
QPointer<TextEditorFactory> m_origin;
|
TextEditorFactoryPrivate *m_origin;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TextEditorWidgetPrivate : public QObject
|
class TextEditorWidgetPrivate : public QObject
|
||||||
@@ -7199,66 +7199,93 @@ void TextEditorWidget::setupAsPlainEditor()
|
|||||||
updateEditorInfoBar(this);
|
updateEditorInfoBar(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
IEditor *BaseTextEditor::duplicate()
|
|
||||||
{
|
|
||||||
// Use new standard setup if that's available.
|
|
||||||
if (d->m_origin)
|
|
||||||
return d->m_origin->duplicateTextEditor(this);
|
|
||||||
|
|
||||||
// If neither is sufficient, you need to implement 'YourEditor::duplicate'.
|
|
||||||
QTC_CHECK(false);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// BaseTextEditorFactory
|
// BaseTextEditorFactory
|
||||||
//
|
//
|
||||||
|
|
||||||
TextEditorFactory::TextEditorFactory(QObject *parent)
|
namespace Internal {
|
||||||
: IEditorFactory(parent)
|
|
||||||
|
class TextEditorFactoryPrivate
|
||||||
{
|
{
|
||||||
m_editorCreator = []() { return new BaseTextEditor; };
|
public:
|
||||||
m_widgetCreator = []() { return new TextEditorWidget; };
|
TextEditorFactoryPrivate(TextEditorFactory *parent) :
|
||||||
m_commentStyle = CommentDefinition::NoStyle;
|
q(parent),
|
||||||
m_duplicatedSupported = true;
|
m_widgetCreator([]() { return new TextEditorWidget; }),
|
||||||
m_completionAssistProvider = 0;
|
m_editorCreator([]() { return new BaseTextEditor; }),
|
||||||
|
m_commentStyle(CommentDefinition::NoStyle),
|
||||||
|
m_completionAssistProvider(0),
|
||||||
|
m_duplicatedSupported(true),
|
||||||
|
m_codeFoldingSupported(false),
|
||||||
|
m_paranthesesMatchinEnabled(false),
|
||||||
|
m_marksVisible(false)
|
||||||
|
{}
|
||||||
|
|
||||||
|
BaseTextEditor *duplicateTextEditor(BaseTextEditor *other)
|
||||||
|
{
|
||||||
|
BaseTextEditor *editor = createEditorHelper(other->editorWidget()->textDocumentPtr());
|
||||||
|
editor->editorWidget()->finalizeInitializationAfterDuplication(other->editorWidget());
|
||||||
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BaseTextEditor *createEditorHelper(const TextDocumentPtr &doc);
|
||||||
|
|
||||||
|
TextEditorFactory *q;
|
||||||
|
TextEditorFactory::DocumentCreator m_documentCreator;
|
||||||
|
TextEditorFactory::EditorWidgetCreator m_widgetCreator;
|
||||||
|
TextEditorFactory::EditorCreator m_editorCreator;
|
||||||
|
TextEditorFactory::AutoCompleterCreator m_autoCompleterCreator;
|
||||||
|
TextEditorFactory::IndenterCreator m_indenterCreator;
|
||||||
|
TextEditorFactory::SyntaxHighLighterCreator m_syntaxHighlighterCreator;
|
||||||
|
Utils::CommentDefinition::Style m_commentStyle;
|
||||||
|
QList<BaseHoverHandler *> m_hoverHandlers; // owned
|
||||||
|
CompletionAssistProvider * m_completionAssistProvider; // owned
|
||||||
|
bool m_duplicatedSupported;
|
||||||
|
bool m_codeFoldingSupported;
|
||||||
|
bool m_paranthesesMatchinEnabled;
|
||||||
|
bool m_marksVisible;
|
||||||
|
};
|
||||||
|
|
||||||
|
} /// namespace Internal
|
||||||
|
|
||||||
|
TextEditorFactory::TextEditorFactory(QObject *parent)
|
||||||
|
: IEditorFactory(parent), d(new TextEditorFactoryPrivate(this))
|
||||||
|
{}
|
||||||
|
|
||||||
TextEditorFactory::~TextEditorFactory()
|
TextEditorFactory::~TextEditorFactory()
|
||||||
{
|
{
|
||||||
qDeleteAll(m_hoverHandlers);
|
qDeleteAll(d->m_hoverHandlers);
|
||||||
delete m_completionAssistProvider;
|
delete d->m_completionAssistProvider;
|
||||||
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextEditorFactory::setDocumentCreator(const DocumentCreator &creator)
|
void TextEditorFactory::setDocumentCreator(const DocumentCreator &creator)
|
||||||
{
|
{
|
||||||
m_documentCreator = creator;
|
d->m_documentCreator = creator;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextEditorFactory::setEditorWidgetCreator(const EditorWidgetCreator &creator)
|
void TextEditorFactory::setEditorWidgetCreator(const EditorWidgetCreator &creator)
|
||||||
{
|
{
|
||||||
m_widgetCreator = creator;
|
d->m_widgetCreator = creator;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextEditorFactory::setEditorCreator(const EditorCreator &creator)
|
void TextEditorFactory::setEditorCreator(const EditorCreator &creator)
|
||||||
{
|
{
|
||||||
m_editorCreator = creator;
|
d->m_editorCreator = creator;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextEditorFactory::setIndenterCreator(const IndenterCreator &creator)
|
void TextEditorFactory::setIndenterCreator(const IndenterCreator &creator)
|
||||||
{
|
{
|
||||||
m_indenterCreator = creator;
|
d->m_indenterCreator = creator;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextEditorFactory::setSyntaxHighlighterCreator(const SyntaxHighLighterCreator &creator)
|
void TextEditorFactory::setSyntaxHighlighterCreator(const SyntaxHighLighterCreator &creator)
|
||||||
{
|
{
|
||||||
m_syntaxHighlighterCreator = creator;
|
d->m_syntaxHighlighterCreator = creator;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextEditorFactory::setGenericSyntaxHighlighter(const QString &mimeType)
|
void TextEditorFactory::setGenericSyntaxHighlighter(const QString &mimeType)
|
||||||
{
|
{
|
||||||
m_syntaxHighlighterCreator = [this, mimeType]() -> SyntaxHighlighter * {
|
d->m_syntaxHighlighterCreator = [this, mimeType]() -> SyntaxHighlighter * {
|
||||||
Highlighter *highlighter = new Highlighter;
|
Highlighter *highlighter = new Highlighter;
|
||||||
setMimeTypeForHighlighter(highlighter, MimeDatabase::findByType(mimeType));
|
setMimeTypeForHighlighter(highlighter, MimeDatabase::findByType(mimeType));
|
||||||
return highlighter;
|
return highlighter;
|
||||||
@@ -7267,7 +7294,7 @@ void TextEditorFactory::setGenericSyntaxHighlighter(const QString &mimeType)
|
|||||||
|
|
||||||
void TextEditorFactory::setAutoCompleterCreator(const AutoCompleterCreator &creator)
|
void TextEditorFactory::setAutoCompleterCreator(const AutoCompleterCreator &creator)
|
||||||
{
|
{
|
||||||
m_autoCompleterCreator = creator;
|
d->m_autoCompleterCreator = creator;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextEditorFactory::setEditorActionHandlers(Id contextId, uint optionalActions)
|
void TextEditorFactory::setEditorActionHandlers(Id contextId, uint optionalActions)
|
||||||
@@ -7282,52 +7309,64 @@ void TextEditorFactory::setEditorActionHandlers(uint optionalActions)
|
|||||||
|
|
||||||
void TextEditorFactory::addHoverHandler(BaseHoverHandler *handler)
|
void TextEditorFactory::addHoverHandler(BaseHoverHandler *handler)
|
||||||
{
|
{
|
||||||
m_hoverHandlers.append(handler);
|
d->m_hoverHandlers.append(handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextEditorFactory::setCompletionAssistProvider(CompletionAssistProvider *provider)
|
void TextEditorFactory::setCompletionAssistProvider(CompletionAssistProvider *provider)
|
||||||
{
|
{
|
||||||
m_completionAssistProvider = provider;
|
d->m_completionAssistProvider = provider;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextEditorFactory::setCommentStyle(CommentDefinition::Style style)
|
void TextEditorFactory::setCommentStyle(CommentDefinition::Style style)
|
||||||
{
|
{
|
||||||
m_commentStyle = style;
|
d->m_commentStyle = style;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextEditorFactory::setDuplicatedSupported(bool on)
|
void TextEditorFactory::setDuplicatedSupported(bool on)
|
||||||
{
|
{
|
||||||
m_duplicatedSupported = on;
|
d->m_duplicatedSupported = on;
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseTextEditor *TextEditorFactory::duplicateTextEditor(BaseTextEditor *other)
|
void TextEditorFactory::setMarksVisible(bool on)
|
||||||
{
|
{
|
||||||
BaseTextEditor *editor = createEditorHelper(other->editorWidget()->textDocumentPtr());
|
d->m_marksVisible = on;
|
||||||
editor->editorWidget()->finalizeInitializationAfterDuplication(other->editorWidget());
|
}
|
||||||
return editor;
|
|
||||||
|
void TextEditorFactory::setCodeFoldingSupported(bool on)
|
||||||
|
{
|
||||||
|
d->m_codeFoldingSupported = on;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextEditorFactory::setParenthesesMatchingEnabled(bool on)
|
||||||
|
{
|
||||||
|
d->m_paranthesesMatchinEnabled = on;
|
||||||
}
|
}
|
||||||
|
|
||||||
IEditor *TextEditorFactory::createEditor()
|
IEditor *TextEditorFactory::createEditor()
|
||||||
{
|
{
|
||||||
TextDocumentPtr doc(m_documentCreator());
|
TextDocumentPtr doc(d->m_documentCreator());
|
||||||
|
|
||||||
if (m_indenterCreator)
|
if (d->m_indenterCreator)
|
||||||
doc->setIndenter(m_indenterCreator());
|
doc->setIndenter(d->m_indenterCreator());
|
||||||
|
|
||||||
if (m_syntaxHighlighterCreator)
|
if (d->m_syntaxHighlighterCreator)
|
||||||
doc->setSyntaxHighlighter(m_syntaxHighlighterCreator());
|
doc->setSyntaxHighlighter(d->m_syntaxHighlighterCreator());
|
||||||
|
|
||||||
doc->setCompletionAssistProvider(m_completionAssistProvider);
|
doc->setCompletionAssistProvider(d->m_completionAssistProvider);
|
||||||
|
|
||||||
return createEditorHelper(doc);
|
return d->createEditorHelper(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseTextEditor *TextEditorFactory::createEditorHelper(const TextDocumentPtr &document)
|
BaseTextEditor *TextEditorFactoryPrivate::createEditorHelper(const TextDocumentPtr &document)
|
||||||
{
|
{
|
||||||
TextEditorWidget *widget = m_widgetCreator();
|
TextEditorWidget *widget = m_widgetCreator();
|
||||||
|
widget->setMarksVisible(m_marksVisible);
|
||||||
|
widget->setParenthesesMatchingEnabled(m_paranthesesMatchinEnabled);
|
||||||
|
widget->setCodeFoldingSupported(m_codeFoldingSupported);
|
||||||
|
|
||||||
BaseTextEditor *editor = m_editorCreator();
|
BaseTextEditor *editor = m_editorCreator();
|
||||||
editor->setDuplicateSupported(m_duplicatedSupported);
|
editor->setDuplicateSupported(m_duplicatedSupported);
|
||||||
editor->addContext(id());
|
editor->addContext(q->id());
|
||||||
editor->d->m_origin = this;
|
editor->d->m_origin = this;
|
||||||
|
|
||||||
editor->m_widget = widget;
|
editor->m_widget = widget;
|
||||||
@@ -7342,13 +7381,13 @@ BaseTextEditor *TextEditorFactory::createEditorHelper(const TextDocumentPtr &doc
|
|||||||
widget->d->m_codeAssistant.configure(widget);
|
widget->d->m_codeAssistant.configure(widget);
|
||||||
widget->d->m_commentDefinition.setStyle(m_commentStyle);
|
widget->d->m_commentDefinition.setStyle(m_commentStyle);
|
||||||
|
|
||||||
connect(widget, &TextEditorWidget::activateEditor,
|
QObject::connect(widget, &TextEditorWidget::activateEditor,
|
||||||
[editor]() { Core::EditorManager::activateEditor(editor); });
|
[editor]() { Core::EditorManager::activateEditor(editor); });
|
||||||
|
|
||||||
widget->finalizeInitialization();
|
widget->finalizeInitialization();
|
||||||
editor->finalizeInitialization();
|
editor->finalizeInitialization();
|
||||||
|
|
||||||
connect(widget->d->m_cursorPositionLabel, &LineColumnLabel::clicked, [editor] {
|
QObject::connect(widget->d->m_cursorPositionLabel, &LineColumnLabel::clicked, [editor] {
|
||||||
EditorManager::activateEditor(editor, EditorManager::IgnoreNavigationHistory);
|
EditorManager::activateEditor(editor, EditorManager::IgnoreNavigationHistory);
|
||||||
if (Core::Command *cmd = ActionManager::command(Core::Constants::GOTO)) {
|
if (Core::Command *cmd = ActionManager::command(Core::Constants::GOTO)) {
|
||||||
if (QAction *act = cmd->action())
|
if (QAction *act = cmd->action())
|
||||||
@@ -7358,6 +7397,18 @@ BaseTextEditor *TextEditorFactory::createEditorHelper(const TextDocumentPtr &doc
|
|||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IEditor *BaseTextEditor::duplicate()
|
||||||
|
{
|
||||||
|
// Use new standard setup if that's available.
|
||||||
|
if (d->m_origin)
|
||||||
|
return d->m_origin->duplicateTextEditor(this);
|
||||||
|
|
||||||
|
// If neither is sufficient, you need to implement 'YourEditor::duplicate'.
|
||||||
|
QTC_CHECK(false);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace TextEditor
|
} // namespace TextEditor
|
||||||
|
|
||||||
#include "texteditor.moc"
|
#include "texteditor.moc"
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ typedef QList<RefactorMarker> RefactorMarkers;
|
|||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
class BaseTextEditorPrivate;
|
class BaseTextEditorPrivate;
|
||||||
|
class TextEditorFactoryPrivate;
|
||||||
class TextEditorWidgetPrivate;
|
class TextEditorWidgetPrivate;
|
||||||
class TextEditorOverlay;
|
class TextEditorOverlay;
|
||||||
}
|
}
|
||||||
@@ -200,6 +201,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
friend class TextEditorFactory;
|
friend class TextEditorFactory;
|
||||||
|
friend class Internal::TextEditorFactoryPrivate;
|
||||||
Internal::BaseTextEditorPrivate *d;
|
Internal::BaseTextEditorPrivate *d;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -615,6 +617,7 @@ private:
|
|||||||
Internal::TextEditorWidgetPrivate *d;
|
Internal::TextEditorWidgetPrivate *d;
|
||||||
friend class BaseTextEditor;
|
friend class BaseTextEditor;
|
||||||
friend class TextEditorFactory;
|
friend class TextEditorFactory;
|
||||||
|
friend class Internal::TextEditorFactoryPrivate;
|
||||||
friend class Internal::TextEditorWidgetPrivate;
|
friend class Internal::TextEditorWidgetPrivate;
|
||||||
friend class Internal::TextEditorOverlay;
|
friend class Internal::TextEditorOverlay;
|
||||||
friend class RefactorOverlay;
|
friend class RefactorOverlay;
|
||||||
@@ -651,26 +654,16 @@ public:
|
|||||||
|
|
||||||
void setCommentStyle(Utils::CommentDefinition::Style style);
|
void setCommentStyle(Utils::CommentDefinition::Style style);
|
||||||
void setDuplicatedSupported(bool on);
|
void setDuplicatedSupported(bool on);
|
||||||
|
void setMarksVisible(bool on);
|
||||||
|
void setParenthesesMatchingEnabled(bool on);
|
||||||
|
void setCodeFoldingSupported(bool on);
|
||||||
|
|
||||||
Core::IEditor *createEditor();
|
Core::IEditor *createEditor();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class BaseTextEditor;
|
friend class BaseTextEditor;
|
||||||
friend class PlainTextEditorFactory;
|
friend class PlainTextEditorFactory;
|
||||||
|
Internal::TextEditorFactoryPrivate *d;
|
||||||
BaseTextEditor *createEditorHelper(const TextDocumentPtr &doc);
|
|
||||||
BaseTextEditor *duplicateTextEditor(BaseTextEditor *);
|
|
||||||
|
|
||||||
DocumentCreator m_documentCreator;
|
|
||||||
EditorWidgetCreator m_widgetCreator;
|
|
||||||
EditorCreator m_editorCreator;
|
|
||||||
AutoCompleterCreator m_autoCompleterCreator;
|
|
||||||
IndenterCreator m_indenterCreator;
|
|
||||||
SyntaxHighLighterCreator m_syntaxHighlighterCreator;
|
|
||||||
Utils::CommentDefinition::Style m_commentStyle;
|
|
||||||
QList<BaseHoverHandler *> m_hoverHandlers; // owned
|
|
||||||
CompletionAssistProvider * m_completionAssistProvider; // owned
|
|
||||||
bool m_duplicatedSupported;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace TextEditor
|
} // namespace TextEditor
|
||||||
|
|||||||
Reference in New Issue
Block a user