Commit 70d56494 authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer

Don't show code folding margin when it isn't supported

Introduce setCodeFoldingSupported to the BaseTextEditor, and only
enabled it for the C++ and QtScript editors. This removes the useless
margin meant for code folding markers from the plain text editor and
.pro file editor.
parent a0631d29
......@@ -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);
......
......@@ -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);
......
......@@ -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),
......
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment