From 079f903bc8691866b4aa3c3e41204a47e735c062 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9ven=20Car?= Date: Mon, 28 Aug 2023 14:39:00 +0200 Subject: [PATCH] Fix a bunch of clazy warnings --- src/dolphincontextmenu.cpp | 2 -- src/dolphinmainwindow.cpp | 5 ++-- src/dolphinpart.h | 2 +- src/dolphintabwidget.h | 4 +++- src/kitemviews/kitemlistcontroller.h | 7 ++---- src/kitemviews/kitemlistview.h | 4 ++-- .../private/kitemlistheaderwidget.cpp | 2 +- src/kitemviews/private/kitemlistrubberband.h | 2 +- src/search/dolphinquery.cpp | 2 +- src/selectionmode/backgroundcolorhelper.cpp | 2 +- .../bottombarcontentscontainer.cpp | 8 +++---- .../contextmenu/contextmenusettingspage.cpp | 1 - src/settings/viewmodes/viewsettingstab.h | 3 --- src/views/dolphinitemlistview.cpp | 2 +- src/views/dolphinview.cpp | 24 +++++++------------ src/views/dolphinview.h | 2 ++ 16 files changed, 31 insertions(+), 41 deletions(-) diff --git a/src/dolphincontextmenu.cpp b/src/dolphincontextmenu.cpp index 99db5584c..705f8e4a5 100644 --- a/src/dolphincontextmenu.cpp +++ b/src/dolphincontextmenu.cpp @@ -7,7 +7,6 @@ #include "dolphincontextmenu.h" #include "dolphin_contextmenusettings.h" -#include "dolphin_generalsettings.h" #include "dolphinmainwindow.h" #include "dolphinnewfilemenu.h" #include "dolphinplacesmodelsingleton.h" @@ -16,7 +15,6 @@ #include "global.h" #include "trash/dolphintrash.h" #include "views/dolphinview.h" -#include "views/viewmodecontroller.h" #include #include diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 637cd55af..e3373efe2 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -1144,7 +1144,8 @@ void DolphinMainWindow::openTerminalHere() { QList urls = {}; - for (const KFileItem &item : m_activeViewContainer->view()->selectedItems()) { + const auto selectedItems = m_activeViewContainer->view()->selectedItems(); + for (const KFileItem &item : selectedItems) { QUrl url = item.targetUrl(); if (item.isFile()) { url.setPath(QFileInfo(url.path()).absolutePath()); @@ -1174,7 +1175,7 @@ void DolphinMainWindow::openTerminalHere() } } - for (const QUrl &url : urls) { + for (const QUrl &url : std::as_const(urls)) { openTerminalJob(url); } } diff --git a/src/dolphinpart.h b/src/dolphinpart.h index 94f83d0ef..af0acb171 100644 --- a/src/dolphinpart.h +++ b/src/dolphinpart.h @@ -29,7 +29,7 @@ class DolphinPart : public KParts::ReadOnlyPart // Used by konqueror. Technically it means "we want undo enabled if // there are things in the undo history and the current part is a dolphin part". // Even though it's konqueror doing the undo... - Q_PROPERTY(bool supportsUndo READ supportsUndo) + Q_PROPERTY(bool supportsUndo READ supportsUndo CONSTANT) Q_PROPERTY(QString currentViewMode READ currentViewMode WRITE setCurrentViewMode) diff --git a/src/dolphintabwidget.h b/src/dolphintabwidget.h index 75c6e3471..5bc708b38 100644 --- a/src/dolphintabwidget.h +++ b/src/dolphintabwidget.h @@ -123,7 +123,9 @@ public Q_SLOTS: * Opens a new tab in the background showing the URL \a primaryUrl and the * optional URL \a secondaryUrl. */ - void openNewTab(const QUrl &primaryUrl, const QUrl &secondaryUrl = QUrl(), NewTabPosition position = NewTabPosition::FollowSetting); + void openNewTab(const QUrl &primaryUrl, + const QUrl &secondaryUrl = QUrl(), + DolphinTabWidget::NewTabPosition position = DolphinTabWidget::NewTabPosition::FollowSetting); /** * Opens each directory in \p dirs in a separate tab unless it is already open. diff --git a/src/kitemviews/kitemlistcontroller.h b/src/kitemviews/kitemlistcontroller.h index 122ef836d..0576fc7fd 100644 --- a/src/kitemviews/kitemlistcontroller.h +++ b/src/kitemviews/kitemlistcontroller.h @@ -49,11 +49,8 @@ class QTouchEvent; class DOLPHIN_EXPORT KItemListController : public QObject { Q_OBJECT - Q_PROPERTY(KItemModelBase *model READ model WRITE setModel) - Q_PROPERTY(KItemListView *view READ view WRITE setView) - Q_PROPERTY(SelectionBehavior selectionBehavior READ selectionBehavior WRITE setSelectionBehavior) - Q_PROPERTY(AutoActivationBehavior autoActivationBehavior READ autoActivationBehavior WRITE setAutoActivationBehavior) - Q_PROPERTY(MouseDoubleClickAction mouseDoubleClickAction READ mouseDoubleClickAction WRITE setMouseDoubleClickAction) + Q_PROPERTY(KItemModelBase *model READ model WRITE setModel NOTIFY modelChanged) + Q_PROPERTY(KItemListView *view READ view WRITE setView NOTIFY viewChanged) public: enum SelectionBehavior { NoSelection, SingleSelection, MultiSelection }; diff --git a/src/kitemviews/kitemlistview.h b/src/kitemviews/kitemlistview.h index 6c3d3648d..ff51af922 100644 --- a/src/kitemviews/kitemlistview.h +++ b/src/kitemviews/kitemlistview.h @@ -53,8 +53,8 @@ class DOLPHIN_EXPORT KItemListView : public QGraphicsWidget { Q_OBJECT - Q_PROPERTY(qreal scrollOffset READ scrollOffset WRITE setScrollOffset) - Q_PROPERTY(qreal itemOffset READ itemOffset WRITE setItemOffset) + Q_PROPERTY(qreal scrollOffset READ scrollOffset WRITE setScrollOffset NOTIFY scrollOffsetChanged) + Q_PROPERTY(qreal itemOffset READ itemOffset WRITE setItemOffset NOTIFY itemOffsetChanged) public: explicit KItemListView(QGraphicsWidget *parent = nullptr); diff --git a/src/kitemviews/private/kitemlistheaderwidget.cpp b/src/kitemviews/private/kitemlistheaderwidget.cpp index 850f49406..82e5dde97 100644 --- a/src/kitemviews/private/kitemlistheaderwidget.cpp +++ b/src/kitemviews/private/kitemlistheaderwidget.cpp @@ -136,7 +136,7 @@ void KItemListHeaderWidget::setSidePadding(qreal width) { if (m_sidePadding != width) { m_sidePadding = width; - sidePaddingChanged(width); + Q_EMIT sidePaddingChanged(width); update(); } } diff --git a/src/kitemviews/private/kitemlistrubberband.h b/src/kitemviews/private/kitemlistrubberband.h index fd1416b56..64ce9ba29 100644 --- a/src/kitemviews/private/kitemlistrubberband.h +++ b/src/kitemviews/private/kitemlistrubberband.h @@ -18,7 +18,7 @@ class DOLPHIN_EXPORT KItemListRubberBand : public QObject { Q_OBJECT - Q_PROPERTY(QPointF endPosition MEMBER m_endPos READ endPosition WRITE setEndPosition) + Q_PROPERTY(QPointF endPosition MEMBER m_endPos READ endPosition WRITE setEndPosition NOTIFY endPositionChanged) public: explicit KItemListRubberBand(QObject *parent = nullptr); diff --git a/src/search/dolphinquery.cpp b/src/search/dolphinquery.cpp index f9e5da84f..ed2a6a766 100644 --- a/src/search/dolphinquery.cpp +++ b/src/search/dolphinquery.cpp @@ -49,7 +49,7 @@ QStringList splitOutsideQuotes(const QString &text) // - Groups with two leading quotes must close both on them (filename:""abc xyz" tuv") // - Groups enclosed in quotes // - Words separated by spaces - const QRegularExpression subTermsRegExp("(\\S*?\"\"[^\"]+\"[^\"]+\"+|\\S*?\"[^\"]+\"+|(?<=\\s|^)\\S+(?=\\s|$))"); + static const QRegularExpression subTermsRegExp("(\\S*?\"\"[^\"]+\"[^\"]+\"+|\\S*?\"[^\"]+\"+|(?<=\\s|^)\\S+(?=\\s|$))"); auto subTermsMatchIterator = subTermsRegExp.globalMatch(text); QStringList textParts; diff --git a/src/selectionmode/backgroundcolorhelper.cpp b/src/selectionmode/backgroundcolorhelper.cpp index 74f5bda1a..fa3e55ac4 100644 --- a/src/selectionmode/backgroundcolorhelper.cpp +++ b/src/selectionmode/backgroundcolorhelper.cpp @@ -46,7 +46,7 @@ void BackgroundColorHelper::controlBackgroundColor(QWidget *widget) BackgroundColorHelper::BackgroundColorHelper() { updateBackgroundColor(); - QObject::connect(qApp, &QGuiApplication::paletteChanged, [=]() { + QObject::connect(qApp, &QGuiApplication::paletteChanged, qApp, [=]() { slotPaletteChanged(); }); } diff --git a/src/selectionmode/bottombarcontentscontainer.cpp b/src/selectionmode/bottombarcontentscontainer.cpp index d53d2e4b9..d571b0302 100644 --- a/src/selectionmode/bottombarcontentscontainer.cpp +++ b/src/selectionmode/bottombarcontentscontainer.cpp @@ -166,7 +166,7 @@ void BottomBarContentsContainer::addCopyContents() auto *copyButton = new QPushButton(this); // We claim to have PasteContents already so triggering the copy action next won't instantly hide the bottom bar. - connect(copyButton, &QAbstractButton::clicked, [this]() { + connect(copyButton, &QAbstractButton::clicked, this, [this]() { if (GeneralSettings::showPasteBarAfterCopying()) { m_contents = BottomBar::Contents::PasteContents; // prevents hiding } @@ -174,7 +174,7 @@ void BottomBarContentsContainer::addCopyContents() // Connect the copy action as a second step. m_mainAction = ActionWithWidget(m_actionCollection->action(KStandardAction::name(KStandardAction::Copy)), copyButton); // Finally connect the lambda that actually changes the contents to the PasteContents. - connect(copyButton, &QAbstractButton::clicked, [this]() { + connect(copyButton, &QAbstractButton::clicked, this, [this]() { if (GeneralSettings::showPasteBarAfterCopying()) { resetContents(BottomBar::Contents::PasteContents); // resetContents() needs to be connected last because // it instantly deletes the button and then the other slots won't be called. @@ -244,7 +244,7 @@ void BottomBarContentsContainer::addCutContents() auto *cutButton = new QPushButton(this); // We claim to have PasteContents already so triggering the cut action next won't instantly hide the bottom bar. - connect(cutButton, &QAbstractButton::clicked, [this]() { + connect(cutButton, &QAbstractButton::clicked, this, [this]() { if (GeneralSettings::showPasteBarAfterCopying()) { m_contents = BottomBar::Contents::PasteContents; // prevents hiding } @@ -252,7 +252,7 @@ void BottomBarContentsContainer::addCutContents() // Connect the cut action as a second step. m_mainAction = ActionWithWidget(m_actionCollection->action(KStandardAction::name(KStandardAction::Cut)), cutButton); // Finally connect the lambda that actually changes the contents to the PasteContents. - connect(cutButton, &QAbstractButton::clicked, [this]() { + connect(cutButton, &QAbstractButton::clicked, this, [this]() { if (GeneralSettings::showPasteBarAfterCopying()) { resetContents(BottomBar::Contents::PasteContents); // resetContents() needs to be connected last because // it instantly deletes the button and then the other slots won't be called. diff --git a/src/settings/contextmenu/contextmenusettingspage.cpp b/src/settings/contextmenu/contextmenusettingspage.cpp index fa3d0b256..ea780550a 100644 --- a/src/settings/contextmenu/contextmenusettingspage.cpp +++ b/src/settings/contextmenu/contextmenusettingspage.cpp @@ -7,7 +7,6 @@ #include "contextmenusettingspage.h" #include "dolphin_contextmenusettings.h" -#include "dolphin_generalsettings.h" #include "dolphin_versioncontrolsettings.h" #include "global.h" #include "settings/serviceitemdelegate.h" diff --git a/src/settings/viewmodes/viewsettingstab.h b/src/settings/viewmodes/viewsettingstab.h index fd4cc85a7..5181e8018 100644 --- a/src/settings/viewmodes/viewsettingstab.h +++ b/src/settings/viewmodes/viewsettingstab.h @@ -32,9 +32,6 @@ public: void applySettings() override; void restoreDefaults() override; -Q_SIGNALS: - void changed(); - private Q_SLOTS: void slotDefaultSliderMoved(int value); diff --git a/src/views/dolphinitemlistview.cpp b/src/views/dolphinitemlistview.cpp index 0efea844c..418c9bfe8 100644 --- a/src/views/dolphinitemlistview.cpp +++ b/src/views/dolphinitemlistview.cpp @@ -22,7 +22,7 @@ DolphinItemListView::DolphinItemListView(QGraphicsWidget *parent) : KFileItemListView(parent) , m_zoomLevel(0) { - updateFont(); + DolphinItemListView::updateFont(); updateGridSize(); } diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index d0d524196..a91d76358 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -1419,6 +1419,14 @@ void DolphinView::slotItemCreated(const QUrl &url) } } +void DolphinView::onDirectoryLoadingCompleted() +{ + // the model should now contain all the items created by the job + updateSelectionState(); + m_selectJobCreatedItems = false; + m_selectedUrls.clear(); +} + void DolphinView::slotJobResult(KJob *job) { if (job->error() && job->error() != KIO::ERR_USER_CANCELED) { @@ -1434,21 +1442,7 @@ void DolphinView::slotJobResult(KJob *job) updateSelectionState(); if (!m_selectedUrls.isEmpty()) { // not all urls were found, the model may not be up to date - // TODO KF6 replace with Qt::singleShotConnection - QMetaObject::Connection *const connection = new QMetaObject::Connection; - *connection = connect( - m_model, - &KFileItemModel::directoryLoadingCompleted, - this, - [this, connection]() { - // the model should now contain all the items created by the job - updateSelectionState(); - m_selectJobCreatedItems = false; - m_selectedUrls.clear(); - QObject::disconnect(*connection); - delete connection; - }, - Qt::UniqueConnection); + connect(m_model, &KFileItemModel::directoryLoadingCompleted, this, &DolphinView::onDirectoryLoadingCompleted, Qt::UniqueConnection); } else { m_selectJobCreatedItems = false; m_selectedUrls.clear(); diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h index f851724c2..05b9e009c 100644 --- a/src/views/dolphinview.h +++ b/src/views/dolphinview.h @@ -824,6 +824,8 @@ private Q_SLOTS: void slotTwoClicksRenamingTimerTimeout(); + void onDirectoryLoadingCompleted(); + private: void loadDirectory(const QUrl &url, bool reload = false);