aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/texteditor/textdocumentlayout.h
diff options
context:
space:
mode:
authorOrgad Shaneh <orgad.shaneh@audiocodes.com>2018-04-08 23:40:30 +0300
committerOrgad Shaneh <orgads@gmail.com>2018-05-07 06:08:07 +0000
commit3306c9c96966731c365763ec36c8c03509475a06 (patch)
treeb22b0d756867867ab07d769e84f183c74ddec291 /src/plugins/texteditor/textdocumentlayout.h
parent32d665e3be4b01864906925372162e19cf432fb2 (diff)
TextEditor: Cleanup TextDocumentLayout
* Use range-based for * Use nullptr * Use inline member initialization * Fix real/int implicit casts Change-Id: I17fc35382ef22c97b34faba741915b9b914e38ff Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/texteditor/textdocumentlayout.h')
-rw-r--r--src/plugins/texteditor/textdocumentlayout.h39
1 files changed, 18 insertions, 21 deletions
diff --git a/src/plugins/texteditor/textdocumentlayout.h b/src/plugins/texteditor/textdocumentlayout.h
index 17a3a781f6..8bb9b2e30b 100644
--- a/src/plugins/texteditor/textdocumentlayout.h
+++ b/src/plugins/texteditor/textdocumentlayout.h
@@ -41,12 +41,12 @@ struct TEXTEDITOR_EXPORT Parenthesis
{
enum Type : char { Opened, Closed };
- inline Parenthesis() : pos(-1), type(Opened) {}
+ inline Parenthesis() = default;
inline Parenthesis(Type t, QChar c, int position)
: pos(position), chr(c), type(t) {}
- int pos;
+ int pos = -1;
QChar chr;
- Type type;
+ Type type = Opened;
};
class TEXTEDITOR_EXPORT CodeFormatterData
@@ -61,12 +61,12 @@ public:
inline TextBlockUserData()
: m_foldingIndent(0)
+ , m_lexerState(0)
, m_folded(false)
, m_ifdefedOut(false)
- , m_lexerState(0)
, m_foldingStartIncluded(false)
, m_foldingEndIncluded(false)
- , m_codeFormatterData(0)
+ , m_codeFormatterData(nullptr)
{}
~TextBlockUserData();
@@ -75,9 +75,9 @@ public:
inline bool removeMark(TextMark *mark) { return m_marks.removeAll(mark); }
inline TextMarks documentClosing() {
- TextMarks marks = m_marks;
- foreach (TextMark *mrk, m_marks)
- mrk->setBaseTextDocument(0);
+ const TextMarks marks = m_marks;
+ for (TextMark *mrk : marks)
+ mrk->setBaseTextDocument(nullptr);
m_marks.clear();
return marks;
}
@@ -124,7 +124,7 @@ public:
inline void setFoldingEndIncluded(bool included) { m_foldingEndIncluded = included; }
inline bool foldingEndIncluded() const { return m_foldingEndIncluded; }
inline int lexerState() const { return m_lexerState; }
- inline void setLexerState(int state) {m_lexerState = state; }
+ inline void setLexerState(int state) { m_lexerState = state; }
inline void setAdditionalAnnotationHeight(int annotationHeight)
{ m_additionalAnnotationHeight = annotationHeight; }
@@ -136,9 +136,9 @@ public:
private:
TextMarks m_marks;
int m_foldingIndent : 16;
+ int m_lexerState : 8;
uint m_folded : 1;
uint m_ifdefedOut : 1;
- uint m_lexerState : 8;
uint m_foldingStartIncluded : 1;
uint m_foldingEndIncluded : 1;
int m_additionalAnnotationHeight = 0;
@@ -153,7 +153,7 @@ class TEXTEDITOR_EXPORT TextDocumentLayout : public QPlainTextDocumentLayout
public:
TextDocumentLayout(QTextDocument *doc);
- ~TextDocumentLayout();
+ ~TextDocumentLayout() override;
static void setParentheses(const QTextBlock &block, const Parentheses &parentheses);
static void clearParentheses(const QTextBlock &block) { setParentheses(block, Parentheses());}
@@ -179,17 +179,15 @@ public:
class TEXTEDITOR_EXPORT FoldValidator
{
public:
- FoldValidator();
-
void setup(TextDocumentLayout *layout);
void reset();
void process(QTextBlock block);
void finalize();
private:
- TextDocumentLayout *m_layout;
- bool m_requestDocUpdate;
- int m_insideFold;
+ TextDocumentLayout *m_layout = nullptr;
+ bool m_requestDocUpdate = false;
+ int m_insideFold = 0;
};
static TextBlockUserData *testUserData(const QTextBlock &block) {
@@ -206,11 +204,10 @@ public:
void emitDocumentSizeChanged() { emit documentSizeChanged(documentSize()); }
- int lastSaveRevision;
- bool hasMarks;
- double maxMarkWidthFactor;
-
- int m_requiredWidth;
+ int lastSaveRevision = 0;
+ bool hasMarks = false;
+ double maxMarkWidthFactor = 1.0;
+ int m_requiredWidth = 0;
void setRequiredWidth(int width);