diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index 7711ae7777872090dd8c5f4c1bed54c74bac5cb0..c4fc65a1045c9777c65dc9d8b249e7ed05950955 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 bbd2cd0db555e9403d83cffab4231da09b00c7fc..e33a1f85263f3910602deca0c8c3616b62257004 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<int>& 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 0caa502d7570a23d708104f05da1526e1c5f2f22..de4feaa586304944bcc51d7ce9d3104a66ca8fae 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 24b5382b79e2c342909aaf3bbe19c94191d1fb58..ce155a168a3f338e39a4097f7ab042d8b90d65cb 100644 --- a/src/plugins/texteditor/basetexteditor.h +++ b/src/plugins/texteditor/basetexteditor.h @@ -68,6 +68,7 @@ struct StorageSettings; struct Parenthesis; typedef QVector<Parenthesis> 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 1fa3a46d063025b505243f8792dd743f3c02432f..9609d3c6ea14c541583f39fb892b904053300792 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;