aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/texteditor/basetexteditor.cpp
diff options
context:
space:
mode:
authorhjk <hjk121@nokiamail.com>2014-09-01 16:16:44 +0200
committerhjk <hjk121@nokiamail.com>2014-09-02 10:06:54 +0200
commit6775e623eedf510b65e7541d8696c46d30ee8d23 (patch)
treeeb6f42505601e6946dc99ab3cd14f0cf46e2a215 /src/plugins/texteditor/basetexteditor.cpp
parentb9f861f1cb4d595348f02c249b51d4fbf9e3a460 (diff)
TextEditor: Move comment definitions back to *Widget
Only used there, and avoids back-links to editors. Change-Id: I81206057ce89d42aef7febb840cf9e44b869df0e Reviewed-by: Christian Stenger <christian.stenger@digia.com>
Diffstat (limited to 'src/plugins/texteditor/basetexteditor.cpp')
-rw-r--r--src/plugins/texteditor/basetexteditor.cpp43
1 files changed, 19 insertions, 24 deletions
diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp
index c1e2dbc34c..ffe470e8ee 100644
--- a/src/plugins/texteditor/basetexteditor.cpp
+++ b/src/plugins/texteditor/basetexteditor.cpp
@@ -230,7 +230,6 @@ class BaseTextEditorPrivate
public:
BaseTextEditorPrivate() {}
- CommentDefinition m_commentDefinition;
std::function<CompletionAssistProvider *()> m_completionAssistProvider;
QPointer<BaseTextEditorFactory> m_origin;
@@ -442,6 +441,7 @@ public:
bool m_editorIsFallBack;
QScopedPointer<AutoCompleter> m_autoCompleter;
+ CommentDefinition m_commentDefinition;
};
BaseTextEditorWidgetPrivate::BaseTextEditorWidgetPrivate(BaseTextEditorWidget *parent)
@@ -1540,18 +1540,17 @@ void BaseTextEditorWidgetPrivate::moveLineUpDown(bool up)
m_refactorOverlay->setMarkers(nonAffectedMarkers + affectedMarkers);
bool shouldReindent = true;
- const CommentDefinition &cd = q->editor()->commentDefinition();
- if (cd.isValid()) {
+ if (m_commentDefinition.isValid()) {
QString trimmedText(text.trimmed());
- if (cd.hasSingleLineStyle()) {
- if (trimmedText.startsWith(cd.singleLine))
+ if (m_commentDefinition.hasSingleLineStyle()) {
+ if (trimmedText.startsWith(m_commentDefinition.singleLine))
shouldReindent = false;
}
- if (shouldReindent && cd.hasMultiLineStyle()) {
+ if (shouldReindent && m_commentDefinition.hasMultiLineStyle()) {
// Don't have any single line comments; try multi line.
- if (trimmedText.startsWith(cd.multiLineStart)
- && trimmedText.endsWith(cd.multiLineEnd)) {
+ if (trimmedText.startsWith(m_commentDefinition.multiLineStart)
+ && trimmedText.endsWith(m_commentDefinition.multiLineEnd)) {
shouldReindent = false;
}
}
@@ -6022,7 +6021,7 @@ void BaseTextEditorWidget::rewrapParagraph()
void BaseTextEditorWidget::unCommentSelection()
{
- Utils::unCommentSelection(this, editor()->commentDefinition());
+ Utils::unCommentSelection(this, d->m_commentDefinition);
}
void BaseTextEditorWidget::showEvent(QShowEvent* e)
@@ -6708,16 +6707,6 @@ void BaseTextEditor::select(int toPos)
editorWidget()->setTextCursor(tc);
}
-CommentDefinition &BaseTextEditor::commentDefinition() const
-{
- return d->m_commentDefinition;
-}
-
-void BaseTextEditor::setCommentStyle(CommentDefinition::Style style)
-{
- d->m_commentDefinition.setStyle(style);
-}
-
CompletionAssistProvider *BaseTextEditor::completionAssistProvider()
{
return d->m_completionAssistProvider();
@@ -7132,11 +7121,10 @@ void BaseTextEditorWidget::configureMimeType(const MimeType &mimeType)
const QSharedPointer<HighlightDefinition> &definition =
Manager::instance()->definition(definitionId);
if (!definition.isNull() && definition->isValid()) {
- CommentDefinition &cd = editor()->commentDefinition();
- cd.isAfterWhiteSpaces = definition->isCommentAfterWhiteSpaces();
- cd.singleLine = definition->singleLineComment();
- cd.multiLineStart = definition->multiLineCommentStart();
- cd.multiLineEnd = definition->multiLineCommentEnd();
+ d->m_commentDefinition.isAfterWhiteSpaces = definition->isCommentAfterWhiteSpaces();
+ d->m_commentDefinition.singleLine = definition->singleLineComment();
+ d->m_commentDefinition.multiLineStart = definition->multiLineCommentStart();
+ d->m_commentDefinition.multiLineEnd = definition->multiLineCommentEnd();
setCodeFoldingSupported(true);
}
@@ -7227,6 +7215,7 @@ BaseTextEditorFactory::BaseTextEditorFactory(QObject *parent)
{
m_editorCreator = []() { return new BaseTextEditor; };
m_widgetCreator = []() { return new BaseTextEditorWidget; };
+ m_commentStyle = CommentDefinition::NoStyle;
}
void BaseTextEditorFactory::setDocumentCreator(const DocumentCreator &creator)
@@ -7278,6 +7267,11 @@ void BaseTextEditorFactory::setEditorActionHandlers(uint optionalActions)
new TextEditorActionHandler(this, id(), optionalActions);
}
+void BaseTextEditorFactory::setCommentStyle(CommentDefinition::Style style)
+{
+ m_commentStyle = style;
+}
+
BaseTextEditor *BaseTextEditorFactory::duplicateTextEditor(BaseTextEditor *other)
{
BaseTextEditor *editor = createEditorHelper(other->editorWidget()->textDocumentPtr());
@@ -7312,6 +7306,7 @@ BaseTextEditor *BaseTextEditorFactory::createEditorHelper(const BaseTextDocument
widget->setTextDocument(document);
widget->d->m_codeAssistant.configure(editor);
+ widget->d->m_commentDefinition.setStyle(m_commentStyle);
if (m_autoCompleterCreator)
widget->setAutoCompleter(m_autoCompleterCreator());