Clang-Tidy and Clazy fixes
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
@@ -63,11 +64,13 @@
|
||||
#include "core/stylehelper.h"
|
||||
#include "settings/appearancesettingspage.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
const int FancyTabWidget::IconSize_LargeSidebar = 40;
|
||||
const int FancyTabWidget::IconSize_SmallSidebar = 32;
|
||||
const int FancyTabWidget::TabSize_LargeSidebarMinWidth = 70;
|
||||
|
||||
class FancyTabBar: public QTabBar {
|
||||
class FancyTabBar: public QTabBar { // clazy:exclude=missing-qobject-macro
|
||||
|
||||
private:
|
||||
int mouseHoverTabIndex = -1;
|
||||
@@ -340,10 +343,9 @@ class FancyTabBar: public QTabBar {
|
||||
|
||||
};
|
||||
|
||||
class TabData : public QObject {
|
||||
|
||||
class TabData : public QObject { // clazy:exclude=missing-qobject-macro
|
||||
public:
|
||||
TabData(QWidget *widget_view, const QString name, const QIcon icon, const QString label, const int idx, QWidget *parent) :
|
||||
TabData(QWidget *widget_view, const QString &name, const QIcon &icon, const QString &label, const int idx, QWidget *parent) :
|
||||
QObject(parent),
|
||||
widget_view_(widget_view),
|
||||
name_(name), icon_(icon),
|
||||
@@ -417,7 +419,8 @@ void FancyTabWidget::currentTabChanged(const int idx) {
|
||||
// The adwaita style is causing the contents of the tabbar to be stretched from top to bottom with space between icons and text.
|
||||
// You can see this on the default Fedora (Gnome) installation.
|
||||
|
||||
class FancyTabWidgetProxyStyle : public QProxyStyle {
|
||||
class FancyTabWidgetProxyStyle : public QProxyStyle { // clazy:exclude=missing-qobject-macro
|
||||
|
||||
public:
|
||||
explicit FancyTabWidgetProxyStyle(QStyle *style) : QProxyStyle(style), common_style_(new QCommonStyle()) {}
|
||||
~FancyTabWidgetProxyStyle() override { common_style_->deleteLater(); }
|
||||
@@ -689,7 +692,7 @@ void FancyTabWidget::SetMode(FancyTabWidget::Mode mode) {
|
||||
updateGeometry();
|
||||
|
||||
// There appears to be a bug in QTabBar which causes tabSizeHint to be ignored thus the need for this second shot repaint
|
||||
QTimer::singleShot(1, this, &FancyTabWidget::tabBarUpdateGeometry);
|
||||
QTimer::singleShot(1ms, this, &FancyTabWidget::tabBarUpdateGeometry);
|
||||
|
||||
emit ModeChanged(mode);
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@ class QEvent;
|
||||
// Some KDE styles override the ScrollMode property of QAbstractItemViews.
|
||||
// This helper class forces the mode back to ScrollPerPixel.
|
||||
class ForceScrollPerPixel : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ForceScrollPerPixel(QAbstractItemView *item_view, QObject *parent = nullptr);
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ void FreeSpaceBar::paintEvent(QPaintEvent*) {
|
||||
|
||||
}
|
||||
|
||||
void FreeSpaceBar::DrawBar(QPainter *p, const QRect &r) {
|
||||
void FreeSpaceBar::DrawBar(QPainter *p, const QRect r) {
|
||||
|
||||
p->setRenderHint(QPainter::Antialiasing, true);
|
||||
|
||||
@@ -179,7 +179,7 @@ void FreeSpaceBar::DrawBar(QPainter *p, const QRect &r) {
|
||||
|
||||
}
|
||||
|
||||
void FreeSpaceBar::DrawText(QPainter *p, const QRect &r) {
|
||||
void FreeSpaceBar::DrawText(QPainter *p, const QRect r) {
|
||||
|
||||
QFont small_font(font());
|
||||
small_font.setPointSize(small_font.pointSize() - 1);
|
||||
|
||||
@@ -79,8 +79,8 @@ class FreeSpaceBar : public QWidget {
|
||||
|
||||
QString TextForSize(const QString &prefix, const qint64 size) const;
|
||||
|
||||
void DrawBar(QPainter *p, const QRect &r);
|
||||
void DrawText(QPainter *p, const QRect &r);
|
||||
void DrawBar(QPainter *p, const QRect r);
|
||||
void DrawText(QPainter *p, const QRect r);
|
||||
|
||||
private:
|
||||
qint64 free_;
|
||||
|
||||
@@ -94,7 +94,7 @@ int GroupedIconView::header_height() const {
|
||||
return default_header_height_;
|
||||
}
|
||||
|
||||
void GroupedIconView::DrawHeader(QPainter *painter, const QRect &rect, const QFont &font, const QPalette &palette, const QString &text) {
|
||||
void GroupedIconView::DrawHeader(QPainter *painter, const QRect rect, const QFont &font, const QPalette &palette, const QString &text) {
|
||||
|
||||
painter->save();
|
||||
|
||||
@@ -316,17 +316,22 @@ void GroupedIconView::paintEvent(QPaintEvent *e) {
|
||||
}
|
||||
|
||||
void GroupedIconView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) {
|
||||
|
||||
QVector<QModelIndex> indexes(IntersectingItems(rect.translated(horizontalOffset(), verticalOffset())));
|
||||
|
||||
QItemSelection selection;
|
||||
selection.reserve(indexes.count());
|
||||
|
||||
for (const QModelIndex &idx : indexes) {
|
||||
selection << QItemSelectionRange(idx);
|
||||
}
|
||||
|
||||
selectionModel()->select(selection, command);
|
||||
|
||||
}
|
||||
|
||||
QVector<QModelIndex> GroupedIconView::IntersectingItems(const QRect &rect) const {
|
||||
QVector<QModelIndex> GroupedIconView::IntersectingItems(const QRect rect) const {
|
||||
|
||||
QVector<QModelIndex> ret;
|
||||
|
||||
const int count = visual_rects_.count();
|
||||
@@ -337,6 +342,7 @@ QVector<QModelIndex> GroupedIconView::IntersectingItems(const QRect &rect) const
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
QRegion GroupedIconView::visualRegionForSelection(const QItemSelection &selection) const {
|
||||
|
||||
@@ -81,7 +81,7 @@ class GroupedIconView : public QListView {
|
||||
QModelIndex moveCursor(CursorAction action, Qt::KeyboardModifiers modifiers) override;
|
||||
void setModel(QAbstractItemModel *model) override;
|
||||
|
||||
static void DrawHeader(QPainter *painter, const QRect &rect, const QFont &font, const QPalette &palette, const QString &text);
|
||||
static void DrawHeader(QPainter *painter, const QRect rect, const QFont &font, const QPalette &palette, const QString &text);
|
||||
|
||||
protected:
|
||||
virtual int header_height() const;
|
||||
@@ -112,7 +112,7 @@ class GroupedIconView : public QListView {
|
||||
};
|
||||
|
||||
// Returns the items that are wholly or partially inside the rect.
|
||||
QVector<QModelIndex> IntersectingItems(const QRect &rect) const;
|
||||
QVector<QModelIndex> IntersectingItems(const QRect rect) const;
|
||||
|
||||
// Returns the index of the item above (d=-1) or below (d=+1) the given item.
|
||||
int IndexAboveOrBelow(int index, const int d) const;
|
||||
|
||||
@@ -62,6 +62,9 @@ class LineEditInterface {
|
||||
|
||||
protected:
|
||||
QWidget *widget_;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(LineEditInterface)
|
||||
};
|
||||
|
||||
class ExtendedEditor : public LineEditInterface {
|
||||
|
||||
@@ -142,7 +142,7 @@ bool LoginStateWidget::eventFilter(QObject *object, QEvent *event) {
|
||||
return QWidget::eventFilter(object, event);
|
||||
}
|
||||
|
||||
void LoginStateWidget::SetExpires(const QDate &expires) {
|
||||
void LoginStateWidget::SetExpires(const QDate expires) {
|
||||
|
||||
ui_->expires->setVisible(expires.isValid());
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ class LoginStateWidget : public QWidget {
|
||||
void SetAccountTypeText(const QString &text);
|
||||
void SetAccountTypeVisible(const bool visible);
|
||||
|
||||
void SetExpires(const QDate &expires);
|
||||
void SetExpires(const QDate expires);
|
||||
|
||||
signals:
|
||||
void LogoutClicked();
|
||||
|
||||
@@ -76,6 +76,7 @@ void MultiLoadingIndicator::UpdateText() {
|
||||
QList<TaskManager::Task> tasks = task_manager_->GetTasks();
|
||||
|
||||
QStringList strings;
|
||||
strings.reserve(tasks.count());
|
||||
for (const TaskManager::Task &task : tasks) {
|
||||
QString task_text(task.name);
|
||||
task_text[0] = task_text[0].toLower();
|
||||
@@ -108,6 +109,6 @@ void MultiLoadingIndicator::paintEvent(QPaintEvent*) {
|
||||
kHorizontalPadding + spinner_->sizeHint().width() + kSpacing, kVerticalPadding,
|
||||
width() - kHorizontalPadding * 2 - spinner_->sizeHint().width() - kSpacing,
|
||||
height() - kVerticalPadding * 2);
|
||||
p.drawText(text_rect, Qt::TextSingleLine | Qt::AlignLeft, fontMetrics().elidedText(text_, Qt::ElideRight, text_rect.width()));
|
||||
p.drawText(text_rect, Qt::TextSingleLine | Qt::AlignLeft, fontMetrics().elidedText(text_, Qt::ElideRight, text_rect.width())); // NOLINT(bugprone-suspicious-enum-usage)
|
||||
|
||||
}
|
||||
|
||||
@@ -40,7 +40,8 @@ THE SOFTWARE.
|
||||
|
||||
#include "core/iconloader.h"
|
||||
|
||||
class QSearchFieldPrivate : public QObject {
|
||||
class QSearchFieldPrivate : public QObject { // clazy:exclude=missing-qobject-macro
|
||||
|
||||
public:
|
||||
QSearchFieldPrivate(QSearchField *searchField, QLineEdit *lineedit, QToolButton *clearbutton)
|
||||
: QObject(searchField), lineedit_(lineedit), clearbutton_(clearbutton) {}
|
||||
|
||||
@@ -72,7 +72,7 @@ RatingPainter::RatingPainter() {
|
||||
}
|
||||
}
|
||||
|
||||
QRect RatingPainter::Contents(const QRect &rect) {
|
||||
QRect RatingPainter::Contents(const QRect rect) {
|
||||
|
||||
const int width = kStarSize * kStarCount;
|
||||
const int x = rect.x() + (rect.width() - width) / 2;
|
||||
@@ -81,7 +81,7 @@ QRect RatingPainter::Contents(const QRect &rect) {
|
||||
|
||||
}
|
||||
|
||||
double RatingPainter::RatingForPos(const QPoint &pos, const QRect &rect) {
|
||||
double RatingPainter::RatingForPos(const QPoint pos, const QRect rect) {
|
||||
|
||||
const QRect contents = Contents(rect);
|
||||
const double raw = double(pos.x() - contents.left()) / contents.width();
|
||||
@@ -95,7 +95,7 @@ double RatingPainter::RatingForPos(const QPoint &pos, const QRect &rect) {
|
||||
|
||||
}
|
||||
|
||||
void RatingPainter::Paint(QPainter *painter, const QRect &rect, double rating) const {
|
||||
void RatingPainter::Paint(QPainter *painter, const QRect rect, double rating) const {
|
||||
|
||||
QSize size(qMin(kStarSize * kStarCount, rect.width()), qMin(kStarSize, rect.height()));
|
||||
QPoint pos(rect.center() - QPoint(size.width() / 2, size.height() / 2));
|
||||
|
||||
@@ -32,10 +32,10 @@ class RatingPainter {
|
||||
|
||||
static const int kStarCount = 5;
|
||||
static const int kStarSize = 16;
|
||||
static QRect Contents(const QRect &rect);
|
||||
static double RatingForPos(const QPoint &pos, const QRect &rect);
|
||||
static QRect Contents(const QRect rect);
|
||||
static double RatingForPos(const QPoint pos, const QRect rect);
|
||||
|
||||
void Paint(QPainter *painter, const QRect &rect, double rating) const;
|
||||
void Paint(QPainter *painter, const QRect rect, double rating) const;
|
||||
|
||||
private:
|
||||
QPixmap stars_[kStarCount * 2 + 1];
|
||||
@@ -43,6 +43,7 @@ class RatingPainter {
|
||||
|
||||
class RatingWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(double rating READ rating WRITE set_rating)
|
||||
|
||||
public:
|
||||
|
||||
@@ -314,6 +314,9 @@ QByteArray StretchHeaderView::SaveState() const {
|
||||
QList<int> pixel_widths;
|
||||
QList<int> visual_indices;
|
||||
|
||||
pixel_widths.reserve(count());
|
||||
visual_indices.reserve(count());
|
||||
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
pixel_widths << sectionSize(i);
|
||||
visual_indices << logicalIndex(i);
|
||||
@@ -350,6 +353,10 @@ QByteArray StretchHeaderView::ResetState() {
|
||||
|
||||
QList<int> visual_indices;
|
||||
QList<int> pixel_widths;
|
||||
|
||||
visual_indices.reserve(count());
|
||||
pixel_widths.reserve(count());
|
||||
|
||||
for (int i = 0 ; i < count() ; ++i) {
|
||||
pixel_widths << 10;
|
||||
visual_indices << count();
|
||||
|
||||
@@ -189,7 +189,8 @@ bool TrackSlider::event(QEvent *e) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
|
||||
return QWidget::event(e);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ void TrackSliderPopup::SetSmallText(const QString &text) {
|
||||
UpdatePixmap();
|
||||
}
|
||||
|
||||
void TrackSliderPopup::SetPopupPosition(const QPoint &pos) {
|
||||
void TrackSliderPopup::SetPopupPosition(const QPoint pos) {
|
||||
pos_ = pos;
|
||||
UpdatePosition();
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ class TrackSliderPopup : public QWidget {
|
||||
public slots:
|
||||
void SetText(const QString &text);
|
||||
void SetSmallText(const QString &small_text);
|
||||
void SetPopupPosition(const QPoint &pos);
|
||||
void SetPopupPosition(const QPoint pos);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent*) override;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
#include <QApplication>
|
||||
#include <QWidget>
|
||||
#include <QMap>
|
||||
#include <QHash>
|
||||
#include <QString>
|
||||
#include <QStringBuilder>
|
||||
#include <QImage>
|
||||
@@ -181,7 +181,7 @@ void PrettySlider::mousePressEvent(QMouseEvent *e) {
|
||||
void PrettySlider::slideEvent(QMouseEvent *e) {
|
||||
|
||||
if (m_mode == Pretty) {
|
||||
QSlider::setValue(orientation() == Qt::Horizontal ? QStyle::sliderValueFromPosition(minimum(), maximum(), e->pos().x(), width() - 2) : QStyle::sliderValueFromPosition(minimum(), maximum(), e->pos().y(), height() - 2));
|
||||
SliderSlider::setValue(orientation() == Qt::Horizontal ? QStyle::sliderValueFromPosition(minimum(), maximum(), e->pos().x(), width() - 2) : QStyle::sliderValueFromPosition(minimum(), maximum(), e->pos().y(), height() - 2));
|
||||
}
|
||||
else {
|
||||
SliderSlider::slideEvent(e);
|
||||
@@ -289,7 +289,7 @@ void VolumeSlider::mousePressEvent(QMouseEvent *e) {
|
||||
|
||||
void VolumeSlider::contextMenuEvent(QContextMenuEvent *e) {
|
||||
|
||||
QMap<QAction*, int> values;
|
||||
QHash<QAction*, int> values;
|
||||
QMenu menu;
|
||||
menu.setTitle("Volume");
|
||||
values[menu.addAction("100%")] = 100;
|
||||
@@ -301,20 +301,20 @@ void VolumeSlider::contextMenuEvent(QContextMenuEvent *e) {
|
||||
|
||||
QAction *ret = menu.exec(mapToGlobal(e->pos()));
|
||||
if (ret) {
|
||||
QSlider::setValue(values[ret]);
|
||||
SliderSlider::setValue(values[ret]);
|
||||
emit sliderReleased(values[ret]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void VolumeSlider::slideEvent(QMouseEvent *e) {
|
||||
QSlider::setValue(QStyle::sliderValueFromPosition(minimum(), maximum(), e->pos().x(), width() - 2));
|
||||
SliderSlider::setValue(QStyle::sliderValueFromPosition(minimum(), maximum(), e->pos().x(), width() - 2));
|
||||
}
|
||||
|
||||
void VolumeSlider::wheelEvent(QWheelEvent *e) {
|
||||
|
||||
const uint step = e->angleDelta().y() / (e->angleDelta().x() == 0 ? 30 : -30);
|
||||
QSlider::setValue(QSlider::value() + step);
|
||||
SliderSlider::setValue(SliderSlider::value() + step);
|
||||
emit sliderReleased(value());
|
||||
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ class SliderSlider : public QSlider {
|
||||
|
||||
signals:
|
||||
// we emit this when the user has specifically changed the slider so connect to it if valueChanged() is too generic Qt also emits valueChanged(int)
|
||||
void sliderReleased(int);
|
||||
void sliderReleased(int); // clazy:exclude=overloaded-signal
|
||||
|
||||
protected:
|
||||
void wheelEvent(QWheelEvent*) override;
|
||||
|
||||
Reference in New Issue
Block a user