forked from qt-creator/qt-creator
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>
This commit is contained in:
committed by
Orgad Shaneh
parent
32d665e3be
commit
3306c9c969
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user