diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index 7711ae77778..c4fc65a1045 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -185,6 +185,7 @@ CPPEditor::CPPEditor(QWidget *parent) { setParenthesesMatchingEnabled(true); setMarksVisible(true); + setCodeFoldingSupported(true); setCodeFoldingVisible(true); baseTextDocument()->setSyntaxHighlighter(new CppHighlighter); // new QShortcut(QKeySequence("Ctrl+Alt+M"), this, SLOT(foo()), 0, Qt::WidgetShortcut); diff --git a/src/plugins/qtscripteditor/qtscripteditor.cpp b/src/plugins/qtscripteditor/qtscripteditor.cpp index bbd2cd0db55..e33a1f85263 100644 --- a/src/plugins/qtscripteditor/qtscripteditor.cpp +++ b/src/plugins/qtscripteditor/qtscripteditor.cpp @@ -49,7 +49,6 @@ namespace Internal { ScriptEditorEditable::ScriptEditorEditable(ScriptEditor *editor, const QList& context) : BaseTextEditorEditable(editor), m_context(context) { - } ScriptEditor::ScriptEditor(const Context &context, @@ -61,6 +60,7 @@ ScriptEditor::ScriptEditor(const Context &context, { setParenthesesMatchingEnabled(true); setMarksVisible(true); + setCodeFoldingSupported(true); setCodeFoldingVisible(true); setMimeType(QtScriptEditor::Constants::C_QTSCRIPTEDITOR_MIMETYPE); diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 0caa502d757..de4feaa5863 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -1198,7 +1198,7 @@ bool BaseTextEditor::lineSeparatorsAllowed() const void BaseTextEditor::setCodeFoldingVisible(bool b) { - d->m_codeFoldingVisible = b; + d->m_codeFoldingVisible = b && d->m_codeFoldingSupported; slotUpdateExtraAreaWidth(); } @@ -1207,6 +1207,22 @@ bool BaseTextEditor::codeFoldingVisible() const return d->m_codeFoldingVisible; } +/** + * Sets whether code folding is supported by the syntax highlighter. When not + * supported (the default), this makes sure the code folding is not shown. + * + * Needs to be called before calling setCodeFoldingVisible. + */ +void BaseTextEditor::setCodeFoldingSupported(bool b) +{ + d->m_codeFoldingSupported = b; +} + +bool BaseTextEditor::codeFoldingSupported() const +{ + return d->m_codeFoldingSupported; +} + void BaseTextEditor::setRevisionsVisible(bool b) { d->m_revisionsVisible = b; @@ -1294,6 +1310,7 @@ BaseTextEditorPrivate::BaseTextEditorPrivate() m_extraArea(0), m_marksVisible(false), m_codeFoldingVisible(false), + m_codeFoldingSupported(false), m_revisionsVisible(false), m_lineNumbersVisible(true), m_highlightCurrentLine(true), diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h index 24b5382b79e..ce155a168a3 100644 --- a/src/plugins/texteditor/basetexteditor.h +++ b/src/plugins/texteditor/basetexteditor.h @@ -68,6 +68,7 @@ struct StorageSettings; struct Parenthesis; typedef QVector Parentheses; + struct TEXTEDITOR_EXPORT Parenthesis { enum Type { Opened, Closed }; @@ -84,7 +85,6 @@ struct TEXTEDITOR_EXPORT Parenthesis }; - class TEXTEDITOR_EXPORT TextBlockUserData : public QTextBlockUserData { public: @@ -285,6 +285,9 @@ public: void setCodeFoldingVisible(bool b); bool codeFoldingVisible() const; + void setCodeFoldingSupported(bool b); + bool codeFoldingSupported() const; + void setRevisionsVisible(bool b); bool revisionsVisible() const; diff --git a/src/plugins/texteditor/basetexteditor_p.h b/src/plugins/texteditor/basetexteditor_p.h index 1fa3a46d063..9609d3c6ea1 100644 --- a/src/plugins/texteditor/basetexteditor_p.h +++ b/src/plugins/texteditor/basetexteditor_p.h @@ -180,6 +180,7 @@ public: void updateMarksBlock(const QTextBlock &block); uint m_marksVisible : 1; uint m_codeFoldingVisible : 1; + uint m_codeFoldingSupported : 1; uint m_revisionsVisible : 1; uint m_lineNumbersVisible : 1; uint m_highlightCurrentLine : 1;