]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Fix a bunch of clazy warnings
authorMéven Car <meven@kde.org>
Mon, 28 Aug 2023 12:39:00 +0000 (14:39 +0200)
committerMéven Car <meven.car@kdemail.net>
Tue, 29 Aug 2023 07:18:51 +0000 (07:18 +0000)
16 files changed:
src/dolphincontextmenu.cpp
src/dolphinmainwindow.cpp
src/dolphinpart.h
src/dolphintabwidget.h
src/kitemviews/kitemlistcontroller.h
src/kitemviews/kitemlistview.h
src/kitemviews/private/kitemlistheaderwidget.cpp
src/kitemviews/private/kitemlistrubberband.h
src/search/dolphinquery.cpp
src/selectionmode/backgroundcolorhelper.cpp
src/selectionmode/bottombarcontentscontainer.cpp
src/settings/contextmenu/contextmenusettingspage.cpp
src/settings/viewmodes/viewsettingstab.h
src/views/dolphinitemlistview.cpp
src/views/dolphinview.cpp
src/views/dolphinview.h

index 99db5584c3ecab87747dc1c03ebaae23799ebbea..705f8e4a5b3c64cc1b81accf4edb32640c257714 100644 (file)
@@ -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 <KActionCollection>
 #include <KFileItemListProperties>
index 637cd55afb838ce5d01ebce1844ecd8d0fff91c8..e3373efe29e045275fbb39d44ab8320331bbf8be 100644 (file)
@@ -1144,7 +1144,8 @@ void DolphinMainWindow::openTerminalHere()
 {
     QList<QUrl> 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);
     }
 }
index 94f83d0ef4730f2d0f6214f54899acdb441169d9..af0acb171ef5406d0549a3d5f9103aa8ce689928 100644 (file)
@@ -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)
 
index 75c6e3471aa45e285db393fce451870750dd95f9..5bc708b380b1024544202a1aba90cd5427794180 100644 (file)
@@ -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.
index 122ef836d05aa964657443c119f49cd6f0dd7c05..0576fc7fd60742872eb0d83b55d3244240e378f9 100644 (file)
@@ -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 };
index 6c3d3648d091ce526f54cb935f76916a0f5e02c5..ff51af92243d4deb75a0d35714891fe41028a758 100644 (file)
@@ -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);
index 850f49406ac30f2966e01ef2a53d0c718b0f1ae5..82e5dde97754535b6d9e5e2d7e33e7bca72f7dc4 100644 (file)
@@ -136,7 +136,7 @@ void KItemListHeaderWidget::setSidePadding(qreal width)
 {
     if (m_sidePadding != width) {
         m_sidePadding = width;
-        sidePaddingChanged(width);
+        Q_EMIT sidePaddingChanged(width);
         update();
     }
 }
index fd1416b565b7dadc130108d601f69e75f842c789..64ce9ba29e86b91e64e42c824bdfee069a3ed237 100644 (file)
@@ -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);
index f9e5da84f53c620015f7ed1282d2995d1f4eb4c8..ed2a6a766b98a6d988aa23b721629e5e5c73654f 100644 (file)
@@ -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;
index 74f5bda1a9c23c41774dd4cb364b84adffe892aa..fa3e55ac4d1b1efe84a32a02002519bb422bb7b1 100644 (file)
@@ -46,7 +46,7 @@ void BackgroundColorHelper::controlBackgroundColor(QWidget *widget)
 BackgroundColorHelper::BackgroundColorHelper()
 {
     updateBackgroundColor();
-    QObject::connect(qApp, &QGuiApplication::paletteChanged, [=]() {
+    QObject::connect(qApp, &QGuiApplication::paletteChanged, qApp, [=]() {
         slotPaletteChanged();
     });
 }
index d53d2e4b97950e62c613da60d4ef78c524f315a0..d571b0302ab3785eba85cc26b7fb63f2280162f6 100644 (file)
@@ -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.
index fa3d0b256a1374bc28bd840a73661b883c9bd8d1..ea780550abe1ab436a3a31806ae99e969b1e6397 100644 (file)
@@ -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"
index fd4cc85a74fc1a4b25e149140373a963c982175a..5181e801832d76b76365900351a487278adc0911 100644 (file)
@@ -32,9 +32,6 @@ public:
     void applySettings() override;
     void restoreDefaults() override;
 
-Q_SIGNALS:
-    void changed();
-
 private Q_SLOTS:
 
     void slotDefaultSliderMoved(int value);
index 0efea844c7157ad6026542aa9ca9809fab4282ce..418c9bfe8d636c02d6f245040bb61ecf6e8d64cd 100644 (file)
@@ -22,7 +22,7 @@ DolphinItemListView::DolphinItemListView(QGraphicsWidget *parent)
     : KFileItemListView(parent)
     , m_zoomLevel(0)
 {
-    updateFont();
+    DolphinItemListView::updateFont();
     updateGridSize();
 }
 
index d0d524196b5eb374a6077d06949cacd6f0c0c4e1..a91d76358aecf434704aaeb44ca0888f9ec75bf9 100644 (file)
@@ -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();
index f851724c238a8bccda45dd703dcb90f798e51d8c..05b9e009c058eb4b33ceaea44c29962c97bc941b 100644 (file)
@@ -824,6 +824,8 @@ private Q_SLOTS:
 
     void slotTwoClicksRenamingTimerTimeout();
 
+    void onDirectoryLoadingCompleted();
+
 private:
     void loadDirectory(const QUrl &url, bool reload = false);