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 {
class BaseAnnotationHighlighterPrivate
{
BaseAnnotationHighlighter *q_ptr;
Q_DECLARE_PUBLIC(BaseAnnotationHighlighter)
public:
enum Formats {
BackgroundFormat // C_TEXT
};
BaseAnnotationHighlighterPrivate();
BaseAnnotationHighlighterPrivate(BaseAnnotationHighlighter *q_) : q(q_) { }
void updateOtherFormats();
ChangeNumberFormatMap m_changeNumberMap;
QColor m_background;
BaseAnnotationHighlighter *const q;
};
BaseAnnotationHighlighterPrivate::BaseAnnotationHighlighterPrivate()
: q_ptr(0)
{
}
void BaseAnnotationHighlighterPrivate::updateOtherFormats()
{
Q_Q(BaseAnnotationHighlighter);
m_background = q->formatForCategory(BackgroundFormat).brushProperty(QTextFormat::BackgroundBrush).color();
q->setChangeNumbers(m_changeNumberMap.keys().toSet());
}
BaseAnnotationHighlighter::BaseAnnotationHighlighter(const ChangeNumbers &changeNumbers,
QTextDocument *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;
if (categories.isEmpty())
categories << TextEditor::C_TEXT;
......@@ -100,11 +88,11 @@ BaseAnnotationHighlighter::BaseAnnotationHighlighter(const ChangeNumbers &change
BaseAnnotationHighlighter::~BaseAnnotationHighlighter()
{
delete d;
}
void BaseAnnotationHighlighter::setChangeNumbers(const ChangeNumbers &changeNumbers)
{
Q_D(BaseAnnotationHighlighter);
d->m_changeNumberMap.clear();
if (!changeNumbers.isEmpty()) {
// Assign a color gradient to annotation change numbers. Give
......@@ -125,7 +113,6 @@ void BaseAnnotationHighlighter::setChangeNumbers(const ChangeNumbers &changeNumb
void BaseAnnotationHighlighter::highlightBlock(const QString &text)
{
Q_D(BaseAnnotationHighlighter);
if (text.isEmpty() || d->m_changeNumberMap.empty())
return;
const QString change = changeNumber(text);
......@@ -136,7 +123,6 @@ void BaseAnnotationHighlighter::highlightBlock(const QString &text)
void BaseAnnotationHighlighter::setFontSettings(const TextEditor::FontSettings &fontSettings)
{
Q_D(BaseAnnotationHighlighter);
SyntaxHighlighter::setFontSettings(fontSettings);
d->updateOtherFormats();
}
......
......@@ -23,8 +23,7 @@
**
****************************************************************************/
#ifndef BASEANNOTATIONHIGHLIGHTER_H
#define BASEANNOTATIONHIGHLIGHTER_H
#pragma once
#include "vcsbase_global.h"
......@@ -36,27 +35,26 @@ class BaseAnnotationHighlighterPrivate;
class VCSBASE_EXPORT BaseAnnotationHighlighter : public TextEditor::SyntaxHighlighter
{
Q_OBJECT
Q_DECLARE_PRIVATE(BaseAnnotationHighlighter)
public:
typedef QSet<QString> ChangeNumbers;
explicit BaseAnnotationHighlighter(const ChangeNumbers &changeNumbers,
QTextDocument *document = 0);
virtual ~BaseAnnotationHighlighter();
~BaseAnnotationHighlighter() override;
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:
// Implement this to return the change number of a line
virtual QString changeNumber(const QString &block) const = 0;
QScopedPointer<BaseAnnotationHighlighterPrivate> d_ptr;
BaseAnnotationHighlighterPrivate *const d;
friend class BaseAnnotationHighlighterPrivate;
};
} // namespace VcsBase
#endif // BASEANNOTATIONHIGHLIGHTER_H
......@@ -23,8 +23,7 @@
**
****************************************************************************/
#ifndef BASEVCSEDITORFACTORY_H
#define BASEVCSEDITORFACTORY_H
#pragma once
#include "vcsbase_global.h"
......@@ -48,6 +47,3 @@ public:
};
} // namespace VcsBase
#endif // BASEVCSEDITORFACTORY_H
......@@ -37,10 +37,6 @@ VcsSubmitEditorFactory::VcsSubmitEditorFactory
addMimeType(parameters->mimeType);
}
VcsSubmitEditorFactory::~VcsSubmitEditorFactory()
{
}
Core::IEditor *VcsSubmitEditorFactory::createEditor()
{
return m_editorCreator();
......
......@@ -23,8 +23,7 @@
**
****************************************************************************/
#ifndef BASEVCSSUBMITEDITORFACTORY_H
#define BASEVCSSUBMITEDITORFACTORY_H
#pragma once
#include "vcsbase_global.h"
......@@ -46,14 +45,11 @@ public:
typedef std::function<VcsBaseSubmitEditor *()> EditorCreator;
VcsSubmitEditorFactory(const VcsBaseSubmitEditorParameters *parameters, const EditorCreator &editorCreator);
~VcsSubmitEditorFactory();
Core::IEditor *createEditor();
Core::IEditor *createEditor() override;
private:
EditorCreator m_editorCreator;
};
} // namespace VcsBase
#endif // BASEVCSSUBMITEDITORFACTORY_H
......@@ -23,8 +23,7 @@
**
****************************************************************************/
#ifndef CLEANDIALOG_H
#define CLEANDIALOG_H
#pragma once
#include "vcsbase_global.h"
......@@ -44,19 +43,19 @@ class VCSBASE_EXPORT CleanDialog : public QDialog
public:
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:
void accept();
void accept() override;
private slots:
private:
void slotDoubleClicked(const QModelIndex &);
void selectAllItems(bool checked);
void updateSelectAllCheckBox();
private:
QStringList checkedFiles() const;
bool promptToDelete();
void addFile(const QString &workingDirectory, QString fileName, bool checked);
......@@ -65,5 +64,3 @@ private:
};
} // namespace VcsBase
#endif // CLEANDIALOG_H
......@@ -23,8 +23,7 @@
**
****************************************************************************/
#ifndef COMMONSETTINGSPAGE_H
#define COMMONSETTINGSPAGE_H
#pragma once
#include "commonvcssettings.h"
......@@ -44,15 +43,14 @@ class CommonSettingsWidget : public QWidget
public:
explicit CommonSettingsWidget(QWidget *parent = 0);
~CommonSettingsWidget();
~CommonSettingsWidget() override;
CommonVcsSettings settings() const;
void setSettings(const CommonVcsSettings &s);
private slots:
private:
void updatePath();
private:
Ui::CommonSettingsPage *m_ui;
};
......@@ -63,9 +61,9 @@ class CommonOptionsPage : public VcsBaseOptionsPage
public:
explicit CommonOptionsPage(QObject *parent = 0);
QWidget *widget();
void apply();
void finish();
QWidget *widget() override;
void apply() override;
void finish() override;
CommonVcsSettings settings() const { return m_settings; }
......@@ -79,5 +77,3 @@ private:
} // namespace Internal
} // namespace VcsBase
#endif // COMMONSETTINGSPAGE_H
......@@ -23,8 +23,7 @@
**
****************************************************************************/
#ifndef COMMONVCSSETTINGS_H
#define COMMONVCSSETTINGS_H
#pragma once
#include <QString>
......@@ -66,5 +65,3 @@ QDebug operator<<(QDebug, const CommonVcsSettings &);
} // namespace Internal
} // namespace VcsBase
#endif // COMMONVCSSETTINGS_H
......@@ -97,14 +97,25 @@ static inline QTextCharFormat invertedColorFormat(const QTextCharFormat &in)
// --- DiffAndLogHighlighterPrivate
class DiffAndLogHighlighterPrivate
{
DiffAndLogHighlighter *q_ptr;
Q_DECLARE_PUBLIC(DiffAndLogHighlighter)
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;
void updateOtherFormats();
DiffAndLogHighlighter *const q;
mutable QRegExp m_filePattern;
mutable QRegExp m_changePattern;
const QString m_locationIndicator;
......@@ -115,18 +126,6 @@ public:
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
{
// Do not match on git "--- a/" as a deleted line, check
......@@ -146,7 +145,6 @@ Internal::DiffFormats DiffAndLogHighlighterPrivate::analyzeLine(const QString &t
void DiffAndLogHighlighterPrivate::updateOtherFormats()
{
Q_Q(DiffAndLogHighlighter);
m_addedTrailingWhiteSpaceFormat =
invertedColorFormat(q->formatForCategory(Internal::DiffInFormat));
......@@ -155,11 +153,8 @@ void DiffAndLogHighlighterPrivate::updateOtherFormats()
// --- DiffAndLogHighlighter
DiffAndLogHighlighter::DiffAndLogHighlighter(const QRegExp &filePattern, const QRegExp &changePattern) :
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;
if (categories.isEmpty()) {
categories << TextEditor::C_TEXT
......@@ -175,6 +170,7 @@ DiffAndLogHighlighter::DiffAndLogHighlighter(const QRegExp &filePattern, const Q
DiffAndLogHighlighter::~DiffAndLogHighlighter()
{
delete d;
}
// Check trailing spaces
......@@ -194,7 +190,6 @@ static inline int trimmedLength(const QString &in)
*/
void DiffAndLogHighlighter::highlightBlock(const QString &text)
{
Q_D(DiffAndLogHighlighter);
if (text.isEmpty())
return;
......@@ -274,7 +269,6 @@ void DiffAndLogHighlighter::highlightBlock(const QString &text)
void DiffAndLogHighlighter::setFontSettings(const TextEditor::FontSettings &fontSettings)
{
Q_D(DiffAndLogHighlighter);
SyntaxHighlighter::setFontSettings(fontSettings);
d->updateOtherFormats();
}
......
......@@ -23,8 +23,7 @@
**
****************************************************************************/
#ifndef DIFFANDLOGHIGHLIGHTER_H
#define DIFFANDLOGHIGHLIGHTER_H
#pragma once
#include "vcsbase_global.h"
......@@ -45,19 +44,18 @@ class DiffAndLogHighlighterPrivate;
class VCSBASE_EXPORT DiffAndLogHighlighter : public TextEditor::SyntaxHighlighter
{
Q_OBJECT
Q_DECLARE_PRIVATE(DiffAndLogHighlighter)
public:
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:
QScopedPointer<DiffAndLogHighlighterPrivate> d_ptr;
friend class DiffAndLogHighlighterPrivate;
DiffAndLogHighlighterPrivate *const d;
};
} // namespace VcsBase
#endif // DIFFANDLOGHIGHLIGHTER_H
......@@ -23,8 +23,7 @@
**
****************************************************************************/
#ifndef NICKNAMEDIALOG_H
#define NICKNAMEDIALOG_H
#pragma once
#include <QDialog>
......@@ -46,7 +45,7 @@ class NickNameDialog : public QDialog
public:
explicit NickNameDialog(QStandardItemModel *model, QWidget *parent = 0);
virtual ~NickNameDialog();
~NickNameDialog() override;
QString nickName() const;
......@@ -59,11 +58,10 @@ public:
// Return a list for a completer on the field line edits
static QStringList nickNameList(const QStandardItemModel *model);
private slots:
private:
void slotCurrentItemChanged(const QModelIndex &);
void slotActivated(const QModelIndex &);
private:
QPushButton *okButton() const;
Ui::NickNameDialog *m_ui;
......@@ -73,5 +71,3 @@ private:
} // namespace Internal
} // namespace VcsBase
#endif // NICKNAMEDIALOG_H
......@@ -23,8 +23,7 @@
**
****************************************************************************/
#ifndef SUBMITEDITORFILE_H
#define SUBMITEDITORFILE_H
#pragma once
#include "vcsbasesubmiteditor.h"
......@@ -60,8 +59,5 @@ private:
VcsBaseSubmitEditor *m_editor;
};
} // namespace Internal
} // namespace VcsBase
#endif // SUBMITEDITORFILE_H
......@@ -23,8 +23,7 @@
**
****************************************************************************/
#ifndef SUBMITEDITORWIDGET_H
#define SUBMITEDITORWIDGET_H
#pragma once
#include "vcsbase_global.h"
......@@ -54,7 +53,7 @@ class VCSBASE_EXPORT SubmitEditorWidget : public QWidget
public:
SubmitEditorWidget();
~SubmitEditorWidget();
~SubmitEditorWidget() override;
// Register/Unregister actions that are managed by ActionManager with this widget.
// The submit action should have Core::Command::CA_UpdateText set as its text will
......@@ -101,18 +100,15 @@ public:
void setUpdateInProgress(bool value);
bool updateInProgress() const;
public slots:
void updateSubmitAction();
signals:
void diffSelected(const QList<int> &);
void fileSelectionChanged(bool someFileSelected);
void submitActionTextChanged(const QString &);
void submitActionEnabledChanged(bool);
private slots:
void updateCheckAllComboBox();
void checkAllToggled();
void checkAll();
void uncheckAll();
protected:
virtual QString cleanupDescription(const QString &) const;
virtual QString commitName() const;
......@@ -124,10 +120,12 @@ protected:
protected slots:
void descriptionTextChanged();
public slots:
void updateSubmitAction();
private:
void updateCheckAllComboBox();
void checkAllToggled();
void checkAll();
void uncheckAll();
private slots:
void triggerDiffSelected();
void diffActivated(const QModelIndex &index);
void diffActivatedDelayed();
......@@ -136,7 +134,6 @@ private slots:
void editorCustomContextMenuRequested(const QPoint &);
void fileListCustomContextMenuRequested(const QPoint & pos);
private:
bool hasSelection() const;
int checkedFilesCount() const;
void wrapDescription();
......@@ -146,5 +143,3 @@ private:
};
} // namespace VcsBase
#endif // SUBMITEDITORWIDGET_H
......@@ -23,8 +23,7 @@
**
****************************************************************************/
#ifndef SUBMITFIELDWIDGET_H
#define SUBMITFIELDWIDGET_H
#pragma once
#include "vcsbase_global.h"
......@@ -47,7 +46,7 @@ class VCSBASE_EXPORT SubmitFieldWidget : public QWidget
public:
explicit SubmitFieldWidget(QWidget *parent = 0);
virtual ~SubmitFieldWidget();
~SubmitFieldWidget() override;
QStringList fields() const;
void setFields(const QStringList&);
......@@ -70,12 +69,11 @@ public:
signals:
void browseButtonClicked(int pos, const QString &field);
private slots:
private:
void slotRemove();
void slotComboIndexChanged(int);
void slotBrowseButtonClicked();
private:
void removeField(int index);
bool comboIndexChange(int fieldNumber, int index);
void createField(const QString &f);
......@@ -84,5 +82,3 @@ private:
};
} // namespace VcsBase
#endif // SUBMITFIELDWIDGET_H
......@@ -23,8 +23,7 @@
**
****************************************************************************/
#ifndef VCSBASEGLOBAL_H
#define VCSBASEGLOBAL_H
#pragma once
#include <qglobal.h>
......@@ -33,5 +32,3 @@
#else
# define VCSBASE_EXPORT Q_DECL_IMPORT
#endif
#endif // VCSBASEGLOBAL_H
......@@ -23,8 +23,7 @@
**
****************************************************************************/
#ifndef VCSBASECLIENT_H
#define VCSBASECLIENT_H
#pragma once
#include "vcsbase_global.h"
......@@ -46,7 +45,7 @@ namespace Core { class Id; }
namespace Utils {
struct SynchronousProcessResponse;
class ExitCodeInterpreter;
}
} // namespace Utils
namespace VcsBase {
......@@ -64,7 +63,7 @@ class VCSBASE_EXPORT VcsBaseClientImpl : public QObject
public:
explicit VcsBaseClientImpl(VcsBaseClientSettings *settings);
~VcsBaseClientImpl();
~VcsBaseClientImpl() override;
VcsBaseClientSettings &settings() const;
......@@ -137,14 +136,14 @@ public:
class VCSBASE_EXPORT StatusItem
{
public:
StatusItem() {}
StatusItem() = default;
StatusItem(const QString &s, const QString &f);
QString flags;
QString file;
};
explicit VcsBaseClient(VcsBaseClientSettings *settings);
~VcsBaseClient();
~VcsBaseClient() override;
virtual bool synchronousCreateRepository(const QString &workingDir,
const QStringList &extraOptions = QStringList());
virtual bool synchronousClone(const QString &workingDir,
......@@ -164,9 +163,9 @@ public:
virtual bool synchronousPush(const QString &workingDir,
const QString &dstLocation,
const QStringList &extraOptions = QStringList());
virtual void annotate(const QString &workingDir, const QString &file,
void annotate(const QString &workingDir, const QString &file,
const QString &revision = QString(), int lineNumber = -1,
const QStringList &extraOptions = QStringList());
const QStringList &extraOptions = QStringList()) override;
virtual void diff(const QString &workingDir, const QStringList &files = QStringList(),
const QStringList &extraOptions = QStringList());
virtual void log(const QString &workingDir, const QStringList &files = QStringList(),
......@@ -241,5 +240,3 @@ private:
};
} //namespace VcsBase
#endif // VCSBASECLIENT_H