Commit bb8270ba authored by Tobias Hunger's avatar Tobias Hunger

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's avatarOrgad Shaneh <orgads@gmail.com>
parent 96ca2e57
...@@ -51,43 +51,31 @@ namespace VcsBase { ...@@ -51,43 +51,31 @@ namespace VcsBase {
class BaseAnnotationHighlighterPrivate class BaseAnnotationHighlighterPrivate
{ {
BaseAnnotationHighlighter *q_ptr;
Q_DECLARE_PUBLIC(BaseAnnotationHighlighter)
public: public:
enum Formats { enum Formats {
BackgroundFormat // C_TEXT BackgroundFormat // C_TEXT
}; };
BaseAnnotationHighlighterPrivate(); BaseAnnotationHighlighterPrivate(BaseAnnotationHighlighter *q_) : q(q_) { }
void updateOtherFormats(); void updateOtherFormats();
ChangeNumberFormatMap m_changeNumberMap; ChangeNumberFormatMap m_changeNumberMap;
QColor m_background; QColor m_background;
BaseAnnotationHighlighter *const q;
}; };
BaseAnnotationHighlighterPrivate::BaseAnnotationHighlighterPrivate()
: q_ptr(0)
{
}
void BaseAnnotationHighlighterPrivate::updateOtherFormats() void BaseAnnotationHighlighterPrivate::updateOtherFormats()
{ {
Q_Q(BaseAnnotationHighlighter);
m_background = q->formatForCategory(BackgroundFormat).brushProperty(QTextFormat::BackgroundBrush).color(); m_background = q->formatForCategory(BackgroundFormat).brushProperty(QTextFormat::BackgroundBrush).color();
q->setChangeNumbers(m_changeNumberMap.keys().toSet()); q->setChangeNumbers(m_changeNumberMap.keys().toSet());
} }
BaseAnnotationHighlighter::BaseAnnotationHighlighter(const ChangeNumbers &changeNumbers, BaseAnnotationHighlighter::BaseAnnotationHighlighter(const ChangeNumbers &changeNumbers,
QTextDocument *document) : QTextDocument *document) :
TextEditor::SyntaxHighlighter(document), TextEditor::SyntaxHighlighter(document),
d_ptr(new BaseAnnotationHighlighterPrivate()) d(new BaseAnnotationHighlighterPrivate(this))
{ {
d_ptr->q_ptr = this;
Q_D(BaseAnnotationHighlighter);
static QVector<TextEditor::TextStyle> categories; static QVector<TextEditor::TextStyle> categories;
if (categories.isEmpty()) if (categories.isEmpty())
categories << TextEditor::C_TEXT; categories << TextEditor::C_TEXT;
...@@ -100,11 +88,11 @@ BaseAnnotationHighlighter::BaseAnnotationHighlighter(const ChangeNumbers &change ...@@ -100,11 +88,11 @@ BaseAnnotationHighlighter::BaseAnnotationHighlighter(const ChangeNumbers &change
BaseAnnotationHighlighter::~BaseAnnotationHighlighter() BaseAnnotationHighlighter::~BaseAnnotationHighlighter()
{ {
delete d;
} }
void BaseAnnotationHighlighter::setChangeNumbers(const ChangeNumbers &changeNumbers) void BaseAnnotationHighlighter::setChangeNumbers(const ChangeNumbers &changeNumbers)
{ {
Q_D(BaseAnnotationHighlighter);
d->m_changeNumberMap.clear(); d->m_changeNumberMap.clear();
if (!changeNumbers.isEmpty()) { if (!changeNumbers.isEmpty()) {
// Assign a color gradient to annotation change numbers. Give // Assign a color gradient to annotation change numbers. Give
...@@ -125,7 +113,6 @@ void BaseAnnotationHighlighter::setChangeNumbers(const ChangeNumbers &changeNumb ...@@ -125,7 +113,6 @@ void BaseAnnotationHighlighter::setChangeNumbers(const ChangeNumbers &changeNumb
void BaseAnnotationHighlighter::highlightBlock(const QString &text) void BaseAnnotationHighlighter::highlightBlock(const QString &text)
{ {
Q_D(BaseAnnotationHighlighter);
if (text.isEmpty() || d->m_changeNumberMap.empty()) if (text.isEmpty() || d->m_changeNumberMap.empty())
return; return;
const QString change = changeNumber(text); const QString change = changeNumber(text);
...@@ -136,7 +123,6 @@ void BaseAnnotationHighlighter::highlightBlock(const QString &text) ...@@ -136,7 +123,6 @@ void BaseAnnotationHighlighter::highlightBlock(const QString &text)
void BaseAnnotationHighlighter::setFontSettings(const TextEditor::FontSettings &fontSettings) void BaseAnnotationHighlighter::setFontSettings(const TextEditor::FontSettings &fontSettings)
{ {
Q_D(BaseAnnotationHighlighter);
SyntaxHighlighter::setFontSettings(fontSettings); SyntaxHighlighter::setFontSettings(fontSettings);
d->updateOtherFormats(); d->updateOtherFormats();
} }
......
...@@ -23,8 +23,7 @@ ...@@ -23,8 +23,7 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef BASEANNOTATIONHIGHLIGHTER_H #pragma once
#define BASEANNOTATIONHIGHLIGHTER_H
#include "vcsbase_global.h" #include "vcsbase_global.h"
...@@ -36,27 +35,26 @@ class BaseAnnotationHighlighterPrivate; ...@@ -36,27 +35,26 @@ class BaseAnnotationHighlighterPrivate;
class VCSBASE_EXPORT BaseAnnotationHighlighter : public TextEditor::SyntaxHighlighter class VCSBASE_EXPORT BaseAnnotationHighlighter : public TextEditor::SyntaxHighlighter
{ {
Q_OBJECT Q_OBJECT
Q_DECLARE_PRIVATE(BaseAnnotationHighlighter)
public: public:
typedef QSet<QString> ChangeNumbers; typedef QSet<QString> ChangeNumbers;
explicit BaseAnnotationHighlighter(const ChangeNumbers &changeNumbers, explicit BaseAnnotationHighlighter(const ChangeNumbers &changeNumbers,
QTextDocument *document = 0); QTextDocument *document = 0);
virtual ~BaseAnnotationHighlighter(); ~BaseAnnotationHighlighter() override;
void setChangeNumbers(const ChangeNumbers &changeNumbers); void setChangeNumbers(const ChangeNumbers &changeNumbers);
virtual void highlightBlock(const QString &text); virtual void highlightBlock(const QString &text) override;
virtual void setFontSettings(const TextEditor::FontSettings &fontSettings); virtual void setFontSettings(const TextEditor::FontSettings &fontSettings) override;
private: private:
// Implement this to return the change number of a line // Implement this to return the change number of a line
virtual QString changeNumber(const QString &block) const = 0; virtual QString changeNumber(const QString &block) const = 0;
QScopedPointer<BaseAnnotationHighlighterPrivate> d_ptr; BaseAnnotationHighlighterPrivate *const d;
friend class BaseAnnotationHighlighterPrivate;
}; };
} // namespace VcsBase } // namespace VcsBase
#endif // BASEANNOTATIONHIGHLIGHTER_H
...@@ -23,8 +23,7 @@ ...@@ -23,8 +23,7 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef BASEVCSEDITORFACTORY_H #pragma once
#define BASEVCSEDITORFACTORY_H
#include "vcsbase_global.h" #include "vcsbase_global.h"
...@@ -48,6 +47,3 @@ public: ...@@ -48,6 +47,3 @@ public:
}; };
} // namespace VcsBase } // namespace VcsBase
#endif // BASEVCSEDITORFACTORY_H
...@@ -37,10 +37,6 @@ VcsSubmitEditorFactory::VcsSubmitEditorFactory ...@@ -37,10 +37,6 @@ VcsSubmitEditorFactory::VcsSubmitEditorFactory
addMimeType(parameters->mimeType); addMimeType(parameters->mimeType);
} }
VcsSubmitEditorFactory::~VcsSubmitEditorFactory()
{
}
Core::IEditor *VcsSubmitEditorFactory::createEditor() Core::IEditor *VcsSubmitEditorFactory::createEditor()
{ {
return m_editorCreator(); return m_editorCreator();
......
...@@ -23,8 +23,7 @@ ...@@ -23,8 +23,7 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef BASEVCSSUBMITEDITORFACTORY_H #pragma once
#define BASEVCSSUBMITEDITORFACTORY_H
#include "vcsbase_global.h" #include "vcsbase_global.h"
...@@ -46,14 +45,11 @@ public: ...@@ -46,14 +45,11 @@ public:
typedef std::function<VcsBaseSubmitEditor *()> EditorCreator; typedef std::function<VcsBaseSubmitEditor *()> EditorCreator;
VcsSubmitEditorFactory(const VcsBaseSubmitEditorParameters *parameters, const EditorCreator &editorCreator); VcsSubmitEditorFactory(const VcsBaseSubmitEditorParameters *parameters, const EditorCreator &editorCreator);
~VcsSubmitEditorFactory();
Core::IEditor *createEditor(); Core::IEditor *createEditor() override;
private: private:
EditorCreator m_editorCreator; EditorCreator m_editorCreator;
}; };
} // namespace VcsBase } // namespace VcsBase
#endif // BASEVCSSUBMITEDITORFACTORY_H
...@@ -23,8 +23,7 @@ ...@@ -23,8 +23,7 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef CLEANDIALOG_H #pragma once
#define CLEANDIALOG_H
#include "vcsbase_global.h" #include "vcsbase_global.h"
...@@ -44,19 +43,19 @@ class VCSBASE_EXPORT CleanDialog : public QDialog ...@@ -44,19 +43,19 @@ class VCSBASE_EXPORT CleanDialog : public QDialog
public: public:
explicit CleanDialog(QWidget *parent = 0); explicit CleanDialog(QWidget *parent = 0);
~CleanDialog(); ~CleanDialog() override;
void setFileList(const QString &workingDirectory, const QStringList &files, const QStringList &ignoredFiles); void setFileList(const QString &workingDirectory, const QStringList &files,
const QStringList &ignoredFiles);
public slots: public slots:
void accept(); void accept() override;
private slots: private:
void slotDoubleClicked(const QModelIndex &); void slotDoubleClicked(const QModelIndex &);
void selectAllItems(bool checked); void selectAllItems(bool checked);
void updateSelectAllCheckBox(); void updateSelectAllCheckBox();
private:
QStringList checkedFiles() const; QStringList checkedFiles() const;
bool promptToDelete(); bool promptToDelete();
void addFile(const QString &workingDirectory, QString fileName, bool checked); void addFile(const QString &workingDirectory, QString fileName, bool checked);
...@@ -65,5 +64,3 @@ private: ...@@ -65,5 +64,3 @@ private:
}; };
} // namespace VcsBase } // namespace VcsBase
#endif // CLEANDIALOG_H
...@@ -23,8 +23,7 @@ ...@@ -23,8 +23,7 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef COMMONSETTINGSPAGE_H #pragma once
#define COMMONSETTINGSPAGE_H
#include "commonvcssettings.h" #include "commonvcssettings.h"
...@@ -44,15 +43,14 @@ class CommonSettingsWidget : public QWidget ...@@ -44,15 +43,14 @@ class CommonSettingsWidget : public QWidget
public: public:
explicit CommonSettingsWidget(QWidget *parent = 0); explicit CommonSettingsWidget(QWidget *parent = 0);
~CommonSettingsWidget(); ~CommonSettingsWidget() override;
CommonVcsSettings settings() const; CommonVcsSettings settings() const;
void setSettings(const CommonVcsSettings &s); void setSettings(const CommonVcsSettings &s);
private slots: private:
void updatePath(); void updatePath();
private:
Ui::CommonSettingsPage *m_ui; Ui::CommonSettingsPage *m_ui;
}; };
...@@ -63,9 +61,9 @@ class CommonOptionsPage : public VcsBaseOptionsPage ...@@ -63,9 +61,9 @@ class CommonOptionsPage : public VcsBaseOptionsPage
public: public:
explicit CommonOptionsPage(QObject *parent = 0); explicit CommonOptionsPage(QObject *parent = 0);
QWidget *widget(); QWidget *widget() override;
void apply(); void apply() override;
void finish(); void finish() override;
CommonVcsSettings settings() const { return m_settings; } CommonVcsSettings settings() const { return m_settings; }
...@@ -79,5 +77,3 @@ private: ...@@ -79,5 +77,3 @@ private:
} // namespace Internal } // namespace Internal
} // namespace VcsBase } // namespace VcsBase
#endif // COMMONSETTINGSPAGE_H
...@@ -23,8 +23,7 @@ ...@@ -23,8 +23,7 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef COMMONVCSSETTINGS_H #pragma once
#define COMMONVCSSETTINGS_H
#include <QString> #include <QString>
...@@ -66,5 +65,3 @@ QDebug operator<<(QDebug, const CommonVcsSettings &); ...@@ -66,5 +65,3 @@ QDebug operator<<(QDebug, const CommonVcsSettings &);
} // namespace Internal } // namespace Internal
} // namespace VcsBase } // namespace VcsBase
#endif // COMMONVCSSETTINGS_H
...@@ -97,14 +97,25 @@ static inline QTextCharFormat invertedColorFormat(const QTextCharFormat &in) ...@@ -97,14 +97,25 @@ static inline QTextCharFormat invertedColorFormat(const QTextCharFormat &in)
// --- DiffAndLogHighlighterPrivate // --- DiffAndLogHighlighterPrivate
class DiffAndLogHighlighterPrivate class DiffAndLogHighlighterPrivate
{ {
DiffAndLogHighlighter *q_ptr;
Q_DECLARE_PUBLIC(DiffAndLogHighlighter)
public: public:
DiffAndLogHighlighterPrivate(const QRegExp &filePattern, const QRegExp &changePattern); DiffAndLogHighlighterPrivate(DiffAndLogHighlighter *q_, const QRegExp &filePattern,
const QRegExp &changePattern) :
q(q_),
m_filePattern(filePattern),
m_changePattern(changePattern),
m_locationIndicator(QLatin1String("@@")),
m_diffInIndicator(QLatin1Char('+')),
m_diffOutIndicator(QLatin1Char('-')),
m_foldingState(Internal::StartOfFile)
{
QTC_CHECK(filePattern.isValid());
}
Internal::DiffFormats analyzeLine(const QString &block) const; Internal::DiffFormats analyzeLine(const QString &block) const;
void updateOtherFormats(); void updateOtherFormats();
DiffAndLogHighlighter *const q;
mutable QRegExp m_filePattern; mutable QRegExp m_filePattern;
mutable QRegExp m_changePattern; mutable QRegExp m_changePattern;
const QString m_locationIndicator; const QString m_locationIndicator;
...@@ -115,18 +126,6 @@ public: ...@@ -115,18 +126,6 @@ public:
Internal::FoldingState m_foldingState; Internal::FoldingState m_foldingState;
}; };
DiffAndLogHighlighterPrivate::DiffAndLogHighlighterPrivate(const QRegExp &filePattern, const QRegExp &changePattern) :
q_ptr(0),
m_filePattern(filePattern),
m_changePattern(changePattern),
m_locationIndicator(QLatin1String("@@")),
m_diffInIndicator(QLatin1Char('+')),
m_diffOutIndicator(QLatin1Char('-')),
m_foldingState(Internal::StartOfFile)
{
QTC_CHECK(filePattern.isValid());
}
Internal::DiffFormats DiffAndLogHighlighterPrivate::analyzeLine(const QString &text) const Internal::DiffFormats DiffAndLogHighlighterPrivate::analyzeLine(const QString &text) const
{ {
// Do not match on git "--- a/" as a deleted line, check // Do not match on git "--- a/" as a deleted line, check
...@@ -146,7 +145,6 @@ Internal::DiffFormats DiffAndLogHighlighterPrivate::analyzeLine(const QString &t ...@@ -146,7 +145,6 @@ Internal::DiffFormats DiffAndLogHighlighterPrivate::analyzeLine(const QString &t
void DiffAndLogHighlighterPrivate::updateOtherFormats() void DiffAndLogHighlighterPrivate::updateOtherFormats()
{ {
Q_Q(DiffAndLogHighlighter);
m_addedTrailingWhiteSpaceFormat = m_addedTrailingWhiteSpaceFormat =
invertedColorFormat(q->formatForCategory(Internal::DiffInFormat)); invertedColorFormat(q->formatForCategory(Internal::DiffInFormat));
...@@ -155,11 +153,8 @@ void DiffAndLogHighlighterPrivate::updateOtherFormats() ...@@ -155,11 +153,8 @@ void DiffAndLogHighlighterPrivate::updateOtherFormats()
// --- DiffAndLogHighlighter // --- DiffAndLogHighlighter
DiffAndLogHighlighter::DiffAndLogHighlighter(const QRegExp &filePattern, const QRegExp &changePattern) : DiffAndLogHighlighter::DiffAndLogHighlighter(const QRegExp &filePattern, const QRegExp &changePattern) :
TextEditor::SyntaxHighlighter(static_cast<QTextDocument *>(0)), TextEditor::SyntaxHighlighter(static_cast<QTextDocument *>(0)),
d_ptr(new DiffAndLogHighlighterPrivate(filePattern, changePattern)) d(new DiffAndLogHighlighterPrivate(this, filePattern, changePattern))
{ {
d_ptr->q_ptr = this;
Q_D(DiffAndLogHighlighter);
static QVector<TextEditor::TextStyle> categories; static QVector<TextEditor::TextStyle> categories;
if (categories.isEmpty()) { if (categories.isEmpty()) {
categories << TextEditor::C_TEXT categories << TextEditor::C_TEXT
...@@ -175,6 +170,7 @@ DiffAndLogHighlighter::DiffAndLogHighlighter(const QRegExp &filePattern, const Q ...@@ -175,6 +170,7 @@ DiffAndLogHighlighter::DiffAndLogHighlighter(const QRegExp &filePattern, const Q
DiffAndLogHighlighter::~DiffAndLogHighlighter() DiffAndLogHighlighter::~DiffAndLogHighlighter()
{ {
delete d;
} }
// Check trailing spaces // Check trailing spaces
...@@ -194,7 +190,6 @@ static inline int trimmedLength(const QString &in) ...@@ -194,7 +190,6 @@ static inline int trimmedLength(const QString &in)
*/ */
void DiffAndLogHighlighter::highlightBlock(const QString &text) void DiffAndLogHighlighter::highlightBlock(const QString &text)
{ {
Q_D(DiffAndLogHighlighter);
if (text.isEmpty()) if (text.isEmpty())
return; return;
...@@ -274,7 +269,6 @@ void DiffAndLogHighlighter::highlightBlock(const QString &text) ...@@ -274,7 +269,6 @@ void DiffAndLogHighlighter::highlightBlock(const QString &text)
void DiffAndLogHighlighter::setFontSettings(const TextEditor::FontSettings &fontSettings) void DiffAndLogHighlighter::setFontSettings(const TextEditor::FontSettings &fontSettings)
{ {
Q_D(DiffAndLogHighlighter);
SyntaxHighlighter::setFontSettings(fontSettings); SyntaxHighlighter::setFontSettings(fontSettings);
d->updateOtherFormats(); d->updateOtherFormats();
} }
......
...@@ -23,8 +23,7 @@ ...@@ -23,8 +23,7 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef DIFFANDLOGHIGHLIGHTER_H #pragma once
#define DIFFANDLOGHIGHLIGHTER_H
#include "vcsbase_global.h" #include "vcsbase_global.h"
...@@ -45,19 +44,18 @@ class DiffAndLogHighlighterPrivate; ...@@ -45,19 +44,18 @@ class DiffAndLogHighlighterPrivate;
class VCSBASE_EXPORT DiffAndLogHighlighter : public TextEditor::SyntaxHighlighter class VCSBASE_EXPORT DiffAndLogHighlighter : public TextEditor::SyntaxHighlighter
{ {
Q_OBJECT Q_OBJECT
Q_DECLARE_PRIVATE(DiffAndLogHighlighter)
public: public:
explicit DiffAndLogHighlighter(const QRegExp &filePattern, const QRegExp &changePattern); explicit DiffAndLogHighlighter(const QRegExp &filePattern, const QRegExp &changePattern);
~DiffAndLogHighlighter(); ~DiffAndLogHighlighter() override;
void highlightBlock(const QString &text); void highlightBlock(const QString &text) override;
virtual void setFontSettings(const TextEditor::FontSettings &fontSettings); virtual void setFontSettings(const TextEditor::FontSettings &fontSettings) override;
private: private:
QScopedPointer<DiffAndLogHighlighterPrivate> d_ptr; friend class DiffAndLogHighlighterPrivate;
DiffAndLogHighlighterPrivate *const d;
}; };
} // namespace VcsBase } // namespace VcsBase
#endif // DIFFANDLOGHIGHLIGHTER_H
...@@ -23,8 +23,7 @@ ...@@ -23,8 +23,7 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef NICKNAMEDIALOG_H #pragma once
#define NICKNAMEDIALOG_H
#include <QDialog> #include <QDialog>
...@@ -46,7 +45,7 @@ class NickNameDialog : public QDialog ...@@ -46,7 +45,7 @@ class NickNameDialog : public QDialog
public: public:
explicit NickNameDialog(QStandardItemModel *model, QWidget *parent = 0); explicit NickNameDialog(QStandardItemModel *model, QWidget *parent = 0);
virtual ~NickNameDialog(); ~NickNameDialog() override;
QString nickName() const; QString nickName() const;
...@@ -59,11 +58,10 @@ public: ...@@ -59,11 +58,10 @@ public:
// Return a list for a completer on the field line edits // Return a list for a completer on the field line edits
static QStringList nickNameList(const QStandardItemModel *model); static QStringList nickNameList(const QStandardItemModel *model);
private slots: private:
void slotCurrentItemChanged(const QModelIndex &); void slotCurrentItemChanged(const QModelIndex &);
void slotActivated(const QModelIndex &); void slotActivated(const QModelIndex &);
private:
QPushButton *okButton() const; QPushButton *okButton() const;
Ui::NickNameDialog *m_ui;