Skip to content

Commit bb8270b

Browse files
committed
VcsBase: Modernize headers
* Use pragma once * Use override * Remove Q_DECLARE_PRIVATE as that makes no sense for QtCreator Change-Id: Ic31d4868c172a0b8fcb50cc9a71a6e95639cf84c Reviewed-by: Orgad Shaneh <[email protected]>
1 parent 96ca2e5 commit bb8270b

33 files changed

+170
-297
lines changed

src/plugins/vcsbase/baseannotationhighlighter.cpp

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,43 +51,31 @@ namespace VcsBase {
5151

5252
class BaseAnnotationHighlighterPrivate
5353
{
54-
BaseAnnotationHighlighter *q_ptr;
55-
Q_DECLARE_PUBLIC(BaseAnnotationHighlighter)
5654
public:
5755
enum Formats {
5856
BackgroundFormat // C_TEXT
5957
};
6058

61-
BaseAnnotationHighlighterPrivate();
59+
BaseAnnotationHighlighterPrivate(BaseAnnotationHighlighter *q_) : q(q_) { }
6260

6361
void updateOtherFormats();
6462

6563
ChangeNumberFormatMap m_changeNumberMap;
6664
QColor m_background;
65+
BaseAnnotationHighlighter *const q;
6766
};
6867

69-
BaseAnnotationHighlighterPrivate::BaseAnnotationHighlighterPrivate()
70-
: q_ptr(0)
71-
{
72-
}
73-
7468
void BaseAnnotationHighlighterPrivate::updateOtherFormats()
7569
{
76-
Q_Q(BaseAnnotationHighlighter);
7770
m_background = q->formatForCategory(BackgroundFormat).brushProperty(QTextFormat::BackgroundBrush).color();
7871
q->setChangeNumbers(m_changeNumberMap.keys().toSet());
7972
}
8073

81-
8274
BaseAnnotationHighlighter::BaseAnnotationHighlighter(const ChangeNumbers &changeNumbers,
8375
QTextDocument *document) :
8476
TextEditor::SyntaxHighlighter(document),
85-
d_ptr(new BaseAnnotationHighlighterPrivate())
77+
d(new BaseAnnotationHighlighterPrivate(this))
8678
{
87-
d_ptr->q_ptr = this;
88-
89-
Q_D(BaseAnnotationHighlighter);
90-
9179
static QVector<TextEditor::TextStyle> categories;
9280
if (categories.isEmpty())
9381
categories << TextEditor::C_TEXT;
@@ -100,11 +88,11 @@ BaseAnnotationHighlighter::BaseAnnotationHighlighter(const ChangeNumbers &change
10088

10189
BaseAnnotationHighlighter::~BaseAnnotationHighlighter()
10290
{
91+
delete d;
10392
}
10493

10594
void BaseAnnotationHighlighter::setChangeNumbers(const ChangeNumbers &changeNumbers)
10695
{
107-
Q_D(BaseAnnotationHighlighter);
10896
d->m_changeNumberMap.clear();
10997
if (!changeNumbers.isEmpty()) {
11098
// Assign a color gradient to annotation change numbers. Give
@@ -125,7 +113,6 @@ void BaseAnnotationHighlighter::setChangeNumbers(const ChangeNumbers &changeNumb
125113

126114
void BaseAnnotationHighlighter::highlightBlock(const QString &text)
127115
{
128-
Q_D(BaseAnnotationHighlighter);
129116
if (text.isEmpty() || d->m_changeNumberMap.empty())
130117
return;
131118
const QString change = changeNumber(text);
@@ -136,7 +123,6 @@ void BaseAnnotationHighlighter::highlightBlock(const QString &text)
136123

137124
void BaseAnnotationHighlighter::setFontSettings(const TextEditor::FontSettings &fontSettings)
138125
{
139-
Q_D(BaseAnnotationHighlighter);
140126
SyntaxHighlighter::setFontSettings(fontSettings);
141127
d->updateOtherFormats();
142128
}

src/plugins/vcsbase/baseannotationhighlighter.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
**
2424
****************************************************************************/
2525

26-
#ifndef BASEANNOTATIONHIGHLIGHTER_H
27-
#define BASEANNOTATIONHIGHLIGHTER_H
26+
#pragma once
2827

2928
#include "vcsbase_global.h"
3029

@@ -36,27 +35,26 @@ class BaseAnnotationHighlighterPrivate;
3635
class VCSBASE_EXPORT BaseAnnotationHighlighter : public TextEditor::SyntaxHighlighter
3736
{
3837
Q_OBJECT
39-
Q_DECLARE_PRIVATE(BaseAnnotationHighlighter)
38+
4039
public:
4140
typedef QSet<QString> ChangeNumbers;
4241

4342
explicit BaseAnnotationHighlighter(const ChangeNumbers &changeNumbers,
4443
QTextDocument *document = 0);
45-
virtual ~BaseAnnotationHighlighter();
44+
~BaseAnnotationHighlighter() override;
4645

4746
void setChangeNumbers(const ChangeNumbers &changeNumbers);
4847

49-
virtual void highlightBlock(const QString &text);
48+
virtual void highlightBlock(const QString &text) override;
5049

51-
virtual void setFontSettings(const TextEditor::FontSettings &fontSettings);
50+
virtual void setFontSettings(const TextEditor::FontSettings &fontSettings) override;
5251

5352
private:
5453
// Implement this to return the change number of a line
5554
virtual QString changeNumber(const QString &block) const = 0;
5655

57-
QScopedPointer<BaseAnnotationHighlighterPrivate> d_ptr;
56+
BaseAnnotationHighlighterPrivate *const d;
57+
friend class BaseAnnotationHighlighterPrivate;
5858
};
5959

6060
} // namespace VcsBase
61-
62-
#endif // BASEANNOTATIONHIGHLIGHTER_H

src/plugins/vcsbase/basevcseditorfactory.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
**
2424
****************************************************************************/
2525

26-
#ifndef BASEVCSEDITORFACTORY_H
27-
#define BASEVCSEDITORFACTORY_H
26+
#pragma once
2827

2928
#include "vcsbase_global.h"
3029

@@ -48,6 +47,3 @@ class VCSBASE_EXPORT VcsEditorFactory : public TextEditor::TextEditorFactory
4847
};
4948

5049
} // namespace VcsBase
51-
52-
#endif // BASEVCSEDITORFACTORY_H
53-

src/plugins/vcsbase/basevcssubmiteditorfactory.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ VcsSubmitEditorFactory::VcsSubmitEditorFactory
3737
addMimeType(parameters->mimeType);
3838
}
3939

40-
VcsSubmitEditorFactory::~VcsSubmitEditorFactory()
41-
{
42-
}
43-
4440
Core::IEditor *VcsSubmitEditorFactory::createEditor()
4541
{
4642
return m_editorCreator();

src/plugins/vcsbase/basevcssubmiteditorfactory.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
**
2424
****************************************************************************/
2525

26-
#ifndef BASEVCSSUBMITEDITORFACTORY_H
27-
#define BASEVCSSUBMITEDITORFACTORY_H
26+
#pragma once
2827

2928
#include "vcsbase_global.h"
3029

@@ -46,14 +45,11 @@ class VCSBASE_EXPORT VcsSubmitEditorFactory : public Core::IEditorFactory
4645
typedef std::function<VcsBaseSubmitEditor *()> EditorCreator;
4746

4847
VcsSubmitEditorFactory(const VcsBaseSubmitEditorParameters *parameters, const EditorCreator &editorCreator);
49-
~VcsSubmitEditorFactory();
5048

51-
Core::IEditor *createEditor();
49+
Core::IEditor *createEditor() override;
5250

5351
private:
5452
EditorCreator m_editorCreator;
5553
};
5654

5755
} // namespace VcsBase
58-
59-
#endif // BASEVCSSUBMITEDITORFACTORY_H

src/plugins/vcsbase/cleandialog.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
**
2424
****************************************************************************/
2525

26-
#ifndef CLEANDIALOG_H
27-
#define CLEANDIALOG_H
26+
#pragma once
2827

2928
#include "vcsbase_global.h"
3029

@@ -44,19 +43,19 @@ class VCSBASE_EXPORT CleanDialog : public QDialog
4443

4544
public:
4645
explicit CleanDialog(QWidget *parent = 0);
47-
~CleanDialog();
46+
~CleanDialog() override;
4847

49-
void setFileList(const QString &workingDirectory, const QStringList &files, const QStringList &ignoredFiles);
48+
void setFileList(const QString &workingDirectory, const QStringList &files,
49+
const QStringList &ignoredFiles);
5050

5151
public slots:
52-
void accept();
52+
void accept() override;
5353

54-
private slots:
54+
private:
5555
void slotDoubleClicked(const QModelIndex &);
5656
void selectAllItems(bool checked);
5757
void updateSelectAllCheckBox();
5858

59-
private:
6059
QStringList checkedFiles() const;
6160
bool promptToDelete();
6261
void addFile(const QString &workingDirectory, QString fileName, bool checked);
@@ -65,5 +64,3 @@ private slots:
6564
};
6665

6766
} // namespace VcsBase
68-
69-
#endif // CLEANDIALOG_H

src/plugins/vcsbase/commonsettingspage.h

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
**
2424
****************************************************************************/
2525

26-
#ifndef COMMONSETTINGSPAGE_H
27-
#define COMMONSETTINGSPAGE_H
26+
#pragma once
2827

2928
#include "commonvcssettings.h"
3029

@@ -44,15 +43,14 @@ class CommonSettingsWidget : public QWidget
4443

4544
public:
4645
explicit CommonSettingsWidget(QWidget *parent = 0);
47-
~CommonSettingsWidget();
46+
~CommonSettingsWidget() override;
4847

4948
CommonVcsSettings settings() const;
5049
void setSettings(const CommonVcsSettings &s);
5150

52-
private slots:
51+
private:
5352
void updatePath();
5453

55-
private:
5654
Ui::CommonSettingsPage *m_ui;
5755
};
5856

@@ -63,9 +61,9 @@ class CommonOptionsPage : public VcsBaseOptionsPage
6361
public:
6462
explicit CommonOptionsPage(QObject *parent = 0);
6563

66-
QWidget *widget();
67-
void apply();
68-
void finish();
64+
QWidget *widget() override;
65+
void apply() override;
66+
void finish() override;
6967

7068
CommonVcsSettings settings() const { return m_settings; }
7169

@@ -79,5 +77,3 @@ class CommonOptionsPage : public VcsBaseOptionsPage
7977

8078
} // namespace Internal
8179
} // namespace VcsBase
82-
83-
#endif // COMMONSETTINGSPAGE_H

src/plugins/vcsbase/commonvcssettings.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
**
2424
****************************************************************************/
2525

26-
#ifndef COMMONVCSSETTINGS_H
27-
#define COMMONVCSSETTINGS_H
26+
#pragma once
2827

2928
#include <QString>
3029

@@ -66,5 +65,3 @@ QDebug operator<<(QDebug, const CommonVcsSettings &);
6665

6766
} // namespace Internal
6867
} // namespace VcsBase
69-
70-
#endif // COMMONVCSSETTINGS_H

src/plugins/vcsbase/diffandloghighlighter.cpp

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,25 @@ static inline QTextCharFormat invertedColorFormat(const QTextCharFormat &in)
9797
// --- DiffAndLogHighlighterPrivate
9898
class DiffAndLogHighlighterPrivate
9999
{
100-
DiffAndLogHighlighter *q_ptr;
101-
Q_DECLARE_PUBLIC(DiffAndLogHighlighter)
102100
public:
103-
DiffAndLogHighlighterPrivate(const QRegExp &filePattern, const QRegExp &changePattern);
101+
DiffAndLogHighlighterPrivate(DiffAndLogHighlighter *q_, const QRegExp &filePattern,
102+
const QRegExp &changePattern) :
103+
q(q_),
104+
m_filePattern(filePattern),
105+
m_changePattern(changePattern),
106+
m_locationIndicator(QLatin1String("@@")),
107+
m_diffInIndicator(QLatin1Char('+')),
108+
m_diffOutIndicator(QLatin1Char('-')),
109+
m_foldingState(Internal::StartOfFile)
110+
{
111+
QTC_CHECK(filePattern.isValid());
112+
}
104113

105114
Internal::DiffFormats analyzeLine(const QString &block) const;
106115
void updateOtherFormats();
107116

117+
DiffAndLogHighlighter *const q;
118+
108119
mutable QRegExp m_filePattern;
109120
mutable QRegExp m_changePattern;
110121
const QString m_locationIndicator;
@@ -115,18 +126,6 @@ class DiffAndLogHighlighterPrivate
115126
Internal::FoldingState m_foldingState;
116127
};
117128

118-
DiffAndLogHighlighterPrivate::DiffAndLogHighlighterPrivate(const QRegExp &filePattern, const QRegExp &changePattern) :
119-
q_ptr(0),
120-
m_filePattern(filePattern),
121-
m_changePattern(changePattern),
122-
m_locationIndicator(QLatin1String("@@")),
123-
m_diffInIndicator(QLatin1Char('+')),
124-
m_diffOutIndicator(QLatin1Char('-')),
125-
m_foldingState(Internal::StartOfFile)
126-
{
127-
QTC_CHECK(filePattern.isValid());
128-
}
129-
130129
Internal::DiffFormats DiffAndLogHighlighterPrivate::analyzeLine(const QString &text) const
131130
{
132131
// Do not match on git "--- a/" as a deleted line, check
@@ -146,7 +145,6 @@ Internal::DiffFormats DiffAndLogHighlighterPrivate::analyzeLine(const QString &t
146145

147146
void DiffAndLogHighlighterPrivate::updateOtherFormats()
148147
{
149-
Q_Q(DiffAndLogHighlighter);
150148
m_addedTrailingWhiteSpaceFormat =
151149
invertedColorFormat(q->formatForCategory(Internal::DiffInFormat));
152150

@@ -155,11 +153,8 @@ void DiffAndLogHighlighterPrivate::updateOtherFormats()
155153
// --- DiffAndLogHighlighter
156154
DiffAndLogHighlighter::DiffAndLogHighlighter(const QRegExp &filePattern, const QRegExp &changePattern) :
157155
TextEditor::SyntaxHighlighter(static_cast<QTextDocument *>(0)),
158-
d_ptr(new DiffAndLogHighlighterPrivate(filePattern, changePattern))
156+
d(new DiffAndLogHighlighterPrivate(this, filePattern, changePattern))
159157
{
160-
d_ptr->q_ptr = this;
161-
Q_D(DiffAndLogHighlighter);
162-
163158
static QVector<TextEditor::TextStyle> categories;
164159
if (categories.isEmpty()) {
165160
categories << TextEditor::C_TEXT
@@ -175,6 +170,7 @@ DiffAndLogHighlighter::DiffAndLogHighlighter(const QRegExp &filePattern, const Q
175170

176171
DiffAndLogHighlighter::~DiffAndLogHighlighter()
177172
{
173+
delete d;
178174
}
179175

180176
// Check trailing spaces
@@ -194,7 +190,6 @@ static inline int trimmedLength(const QString &in)
194190
*/
195191
void DiffAndLogHighlighter::highlightBlock(const QString &text)
196192
{
197-
Q_D(DiffAndLogHighlighter);
198193
if (text.isEmpty())
199194
return;
200195

@@ -274,7 +269,6 @@ void DiffAndLogHighlighter::highlightBlock(const QString &text)
274269

275270
void DiffAndLogHighlighter::setFontSettings(const TextEditor::FontSettings &fontSettings)
276271
{
277-
Q_D(DiffAndLogHighlighter);
278272
SyntaxHighlighter::setFontSettings(fontSettings);
279273
d->updateOtherFormats();
280274
}

0 commit comments

Comments
 (0)