]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Clazy fix
authorMéven Car <meven@kde.org>
Tue, 29 Apr 2025 10:33:44 +0000 (12:33 +0200)
committerMéven Car <meven@kde.org>
Tue, 29 Apr 2025 10:33:44 +0000 (12:33 +0200)
19 files changed:
src/kitemviews/kitemlistwidget.cpp
src/kitemviews/kitemlistwidget.h
src/kitemviews/kstandarditemlistwidget.cpp
src/kitemviews/private/kitemlistsmoothscroller.cpp
src/search/bar.h
src/search/chip.h
src/search/popup.h
src/search/selectors/dateselector.h
src/search/selectors/filetypeselector.h
src/search/selectors/minimumratingselector.h
src/search/selectors/tagsselector.cpp
src/search/selectors/tagsselector.h
src/search/widgetmenu.cpp
src/settings/interface/folderstabssettingspage.cpp
src/statusbar/diskspaceusagemenu.cpp
src/tests/dolphinmainwindowtest.cpp
src/tests/kitemlistcontrollertest.cpp
src/views/dolphinview.cpp
src/views/dolphinviewactionhandler.cpp

index dac5ac296c4fa6f59eed834d6231145f594b2219..baf2445726d1e18255619306613ae7202551dda6 100644 (file)
@@ -98,6 +98,11 @@ QHash<QByteArray, QVariant> KItemListWidget::data() const
     return m_data;
 }
 
+QVariant KItemListWidget::value(const QByteArray &key) const
+{
+    return m_data.value(key);
+}
+
 void KItemListWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
 {
     Q_UNUSED(option)
index e254292c09bc39519747f9366b8ce34b570cbf5d..0e07d7ab559d155166cbf82fe4f5514db384e0ec 100644 (file)
@@ -52,8 +52,6 @@ class DOLPHIN_EXPORT KItemListWidget : public QGraphicsWidget
 {
     Q_OBJECT
 
-    Q_PROPERTY(int iconSize READ iconSize WRITE setIconSize)
-
 public:
     KItemListWidget(KItemListWidgetInformant *informant, QGraphicsItem *parent);
     ~KItemListWidget() override;
@@ -63,6 +61,7 @@ public:
 
     void setData(const QHash<QByteArray, QVariant> &data, const QSet<QByteArray> &roles = QSet<QByteArray>());
     QHash<QByteArray, QVariant> data() const;
+    QVariant value(const QByteArray &key) const;
 
     /**
      * Draws the hover-rectangle if the item is hovered. Overwrite this method
@@ -251,8 +250,6 @@ private:
     void drawItemStyleOption(QPainter *painter, QWidget *widget, QStyle::State styleState);
 
 private:
-    Q_PROPERTY(qreal hoverOpacity READ hoverOpacity WRITE setHoverOpacity)
-
     KItemListWidgetInformant *m_informant;
     int m_index;
     bool m_selected;
index 729411c11b04817f39b9461d43c3858b2ed55068..566c4dec2ad356d909bcbcd725cc564eb7f16231 100644 (file)
@@ -647,7 +647,7 @@ void KStandardItemListWidget::startActivateSoonAnimation(int timeUntilActivation
     m_activateSoonAnimation->setEndValue(1.0);
     m_activateSoonAnimation->setDuration(timeUntilActivation);
 
-    const QVariant originalIconName{data()["iconName"]};
+    const QVariant originalIconName{value("iconName")};
     connect(m_activateSoonAnimation, &QVariantAnimation::valueChanged, this, [originalIconName, this](const QVariant &value) {
         auto progress = value.toFloat();
 
@@ -682,7 +682,7 @@ void KStandardItemListWidget::startActivateSoonAnimation(int timeUntilActivation
 
 bool KStandardItemListWidget::isIconControlledByActivateSoonAnimation() const
 {
-    return m_activateSoonAnimation && data()["iconName"] == "folder-open";
+    return m_activateSoonAnimation && value("iconName") == "folder-open";
 }
 
 KItemListWidgetInformant *KStandardItemListWidget::createInformant()
@@ -1121,7 +1121,6 @@ void KStandardItemListWidget::updatePixmapCache()
                 // use a generic icon as fallback
                 iconName = QStringLiteral("unknown");
             }
-            const QStringList overlays = values["iconOverlays"].toStringList();
             const bool hasFocus = scene()->views()[0]->parentWidget()->hasFocus();
             m_pixmap = pixmapForIcon(iconName,
                                      QSize(maxIconWidth, maxIconHeight),
index 0e75460441abe4ba6c29bd5343d3384e0a2ab82e..14a280e33f7005a05829711ad6489fa622eddc5f 100644 (file)
@@ -29,7 +29,7 @@ KItemListSmoothScroller::KItemListSmoothScroller(QScrollBar *scrollBar, QObject
     KConfigGroup configGroup(globalConfig, QStringLiteral("KDE"));
     updateAnimationDuration(configGroup.readEntry("SmoothScroll", true));
 
-    QDBusConnection::sessionBus().connect(QStringLiteral(""),
+    QDBusConnection::sessionBus().connect(QString(),
                                           QStringLiteral("/SmoothScroll"),
                                           QStringLiteral("org.kde.SmoothScroll"),
                                           QStringLiteral("notifyChange"),
index e681b8a6e81147698f90ff13e1c398074b7a2efa..e8a401748b047aebccfe514bf15785d99fac8f51 100644 (file)
@@ -141,7 +141,7 @@ private Q_SLOTS:
      * @see UpdatableStateInterface::updateStateToMatch().
      * @see commitCurrentConfiguration().
      */
-    void slotConfigurationChanged(const DolphinQuery &searchConfiguration);
+    void slotConfigurationChanged(const Search::DolphinQuery &searchConfiguration);
 
     /**
      * Changes the m_searchConfiguration in response to the user editing the search term. If no further changes to the search term happen within a time limit,
index 94e51968dbf7931c3961e4446a16e187dced3bab..8cd1fce245748586ee4308b4e621f23716338c2f 100644 (file)
@@ -41,7 +41,7 @@ public:
 
 Q_SIGNALS:
     /** Is emitted whenever settings have changed and a new search might be necessary. */
-    void configurationChanged(const DolphinQuery &dolphinQuery);
+    void configurationChanged(const Search::DolphinQuery &dolphinQuery);
 
 protected:
     void paintEvent(QPaintEvent *event) override;
index 423c9dde60774c38724fa218f10f08eaa1e08c3e..5ebcc51a33687be1919fa027f94392c7af2ffa0b 100644 (file)
@@ -45,7 +45,7 @@ public:
 
 Q_SIGNALS:
     /** Is emitted whenever settings have changed and a new search might be necessary. */
-    void configurationChanged(const DolphinQuery &dolphinQuery);
+    void configurationChanged(const Search::DolphinQuery &dolphinQuery);
 
     /**
      * Requests for @p message with the given @p messageType to be shown to the user in a non-modal way.
index 99cecec06a2371ef9766971cd35a2fd7593fff22..860c6510003f1b36e605b6e6f592d53ce8c7a032 100644 (file)
@@ -28,7 +28,7 @@ public:
 
 Q_SIGNALS:
     /** Is emitted whenever settings have changed and a new search might be necessary. */
-    void configurationChanged(const DolphinQuery &dolphinQuery);
+    void configurationChanged(const Search::DolphinQuery &dolphinQuery);
 
 private:
     void updateState(const std::shared_ptr<const DolphinQuery> &dolphinQuery) override;
index bfc827344179a1d83a994db20449a8c7c5c3d79c..10e9ea5e540e6e94a201b0374a6cc4c3b4b37148 100644 (file)
@@ -26,7 +26,7 @@ public:
 
 Q_SIGNALS:
     /** Is emitted whenever settings have changed and a new search might be necessary. */
-    void configurationChanged(const DolphinQuery &dolphinQuery);
+    void configurationChanged(const Search::DolphinQuery &dolphinQuery);
 
 private:
     void updateState(const std::shared_ptr<const DolphinQuery> &dolphinQuery) override;
index 02364cd1a69ab6bb3852a4f22f0a19728532081b..f1c14cf6c452f084496f94ac1ed3724669ec9cbc 100644 (file)
@@ -31,7 +31,7 @@ public:
 
 Q_SIGNALS:
     /** Is emitted whenever settings have changed and a new search might be necessary. */
-    void configurationChanged(const DolphinQuery &dolphinQuery);
+    void configurationChanged(const Search::DolphinQuery &dolphinQuery);
 
 private:
     void updateState(const std::shared_ptr<const DolphinQuery> &dolphinQuery) override;
index 95d7ff52aa4cd026c9415abf1eaf2ea66c8c37e2..d6efb908158bbc4a46b5dc195d9f85034b129365 100644 (file)
@@ -133,7 +133,8 @@ void TagsSelector::updateMenu(const std::shared_ptr<const DolphinQuery> &dolphin
         menu()->hide(); // The menu needs to be hidden now, then updated, and then shown again.
     }
     // Delete all existing actions in the menu
-    for (QAction *action : menu()->actions()) {
+    const auto actions = menu()->actions();
+    for (QAction *action : actions) {
         action->deleteLater();
     }
     menu()->clear();
@@ -180,7 +181,8 @@ void TagsSelector::updateState(const std::shared_ptr<const DolphinQuery> &dolphi
         setIcon(QIcon{}); // No icon for the empty state
         setText(i18nc("@action:button Required tags for search results: None", "None"));
     }
-    for (const auto &tag : dolphinQuery->requiredTags()) {
+    const auto tags = dolphinQuery->requiredTags();
+    for (const auto &tag : tags) {
         tagsList()->addTag(tag); // We add it just in case this tag is not (or no longer) available on the system. This way the UI always works as expected.
     }
     if (menu()->isVisible()) {
index 386cbb92444dc6c380d3e36d97f42f880d1634ef..9aeba908fd56bad6771f7ab3aa4941c9398c20b3 100644 (file)
@@ -27,7 +27,7 @@ public:
 
 Q_SIGNALS:
     /** Is emitted whenever settings have changed and a new search might be necessary. */
-    void configurationChanged(const DolphinQuery &dolphinQuery);
+    void configurationChanged(const Search::DolphinQuery &dolphinQuery);
 
 private:
     /**
index 701a0ce9cb33ecd5423c230b89dba6a1e6f207ce..5624e2dfce56dd3d1872ee778fe41ef149847e7c 100644 (file)
@@ -41,7 +41,7 @@ void WidgetMenu::mouseReleaseEvent(QMouseEvent *event)
 
 void WidgetMenu::resizeToFitContents()
 {
-    auto *widgetAction = static_cast<QWidgetAction *>(actions().first());
+    auto *widgetAction = static_cast<QWidgetAction *>(actions().constFirst());
     auto focusedChildWidget = QApplication::focusWidget();
     if (!widgetAction->defaultWidget()->isAncestorOf(focusedChildWidget)) {
         focusedChildWidget = nullptr;
@@ -60,7 +60,7 @@ void WidgetMenu::resizeToFitContents()
 void WidgetMenu::showEvent(QShowEvent *event)
 {
     if (!event->spontaneous()) {
-        auto widgetAction = static_cast<QWidgetAction *>(actions().first());
+        auto widgetAction = static_cast<QWidgetAction *>(actions().constFirst());
         widgetAction->defaultWidget()->setFocus();
     }
     QMenu::showEvent(event);
index c4bc0d7404b4db58e3b27f591817466822d892c5..0e6c1aaabde3fe5c28333e1907451c52054892b3 100644 (file)
@@ -248,7 +248,8 @@ void FoldersTabsSettingsPage::useCurrentLocation()
 {
 #ifndef IS_KCM
     DolphinMainWindow *mainWindow = nullptr;
-    for (const auto widget : QApplication::topLevelWidgets()) {
+    const auto topLevelsWidgets = QApplication::topLevelWidgets();
+    for (const auto widget : topLevelsWidgets) {
         mainWindow = qobject_cast<DolphinMainWindow *>(widget);
         if (mainWindow) {
             break;
index e750a70e6c9649404ce3ed327799515fb05f1655..ef5a005b6c09d3bde8ad6809f71c4fd839752b11 100644 (file)
@@ -130,8 +130,8 @@ void DiskSpaceUsageMenu::updateMenu()
 
 void DiskSpaceUsageMenu::showEvent(QShowEvent *event)
 {
-    if (!event->spontaneous()) {
-        auto widgetAction = qobject_cast<QWidgetAction *>(actions().first());
+    if (!event->spontaneous() && !actions().isEmpty()) {
+        auto widgetAction = qobject_cast<QWidgetAction *>(*actions().constBegin());
         if (widgetAction) {
             widgetAction->defaultWidget()->setFocus();
         }
index 4ae36e7e6b6d6c110528b6f76ae0a9338284c9a1..b3e52ce2385f545abd79bc73f734049fdf3ab785 100644 (file)
@@ -154,20 +154,20 @@ void DolphinMainWindowTest::testSyncDesktopAndPhoneUi()
     do {
         QVERIFY2(desktopUiElement.tagName() == phoneUiElement.tagName(),
                  qPrintable(QStringLiteral("Node mismatch: dolphinui.rc/%1::%2 and dolphinuiforphones.rc/%3::%4")
-                                .arg(desktopUiElement.parentNode().toElement().tagName())
-                                .arg(desktopUiElement.tagName())
-                                .arg(phoneUiElement.parentNode().toElement().tagName())
-                                .arg(phoneUiElement.tagName())));
+                                .arg(desktopUiElement.parentNode().toElement().tagName(),
+                                     desktopUiElement.tagName(),
+                                     phoneUiElement.parentNode().toElement().tagName(),
+                                     phoneUiElement.tagName())));
         QCOMPARE(desktopUiElement.text(), phoneUiElement.text());
         const auto desktopUiElementAttributes = desktopUiElement.attributes();
         const auto phoneUiElementAttributes = phoneUiElement.attributes();
         for (int i = 0; i < desktopUiElementAttributes.count(); i++) {
             QVERIFY2(phoneUiElementAttributes.count() >= i,
                      qPrintable(QStringLiteral("Attribute mismatch: dolphinui.rc/%1::%2 has more attributes than dolphinuiforphones.rc/%3::%4")
-                                    .arg(desktopUiElement.parentNode().toElement().tagName())
-                                    .arg(desktopUiElement.tagName())
-                                    .arg(phoneUiElement.parentNode().toElement().tagName())
-                                    .arg(phoneUiElement.tagName())));
+                                    .arg(desktopUiElement.parentNode().toElement().tagName(),
+                                         desktopUiElement.tagName(),
+                                         phoneUiElement.parentNode().toElement().tagName(),
+                                         phoneUiElement.tagName())));
             if (exceptions.count(desktopUiElementAttributes.item(i).nodeName())) {
                 continue;
             }
@@ -177,12 +177,11 @@ void DolphinMainWindowTest::testSyncDesktopAndPhoneUi()
         }
         QVERIFY2(desktopUiElementAttributes.count() == phoneUiElementAttributes.count(),
                  qPrintable(QStringLiteral("Attribute mismatch: dolphinui.rc/%1::%2 has fewer attributes than dolphinuiforphones.rc/%3::%4. %5 < %6")
-                                .arg(desktopUiElement.parentNode().toElement().tagName())
-                                .arg(desktopUiElement.tagName())
-                                .arg(phoneUiElement.parentNode().toElement().tagName())
-                                .arg(phoneUiElement.tagName())
-                                .arg(phoneUiElementAttributes.count())
-                                .arg(desktopUiElementAttributes.count())));
+                                .arg(desktopUiElement.parentNode().toElement().tagName(),
+                                     desktopUiElement.tagName(),
+                                     phoneUiElement.parentNode().toElement().tagName(),
+                                     phoneUiElement.tagName())
+                                .arg(phoneUiElementAttributes.count(), desktopUiElementAttributes.count())));
 
         desktopUiElement = nextUiElement(desktopUiElement);
         phoneUiElement = nextUiElement(phoneUiElement);
index b05f4b23d755eae06a716f86591f24672a6137c2..e9e1e66c2e4174dc4be6b1a60ef729ec9bc6a45e 100644 (file)
@@ -505,7 +505,6 @@ void KItemListControllerTest::testKeyboardNavigationMultiSelection_data()
     const Qt::Key previousRowKey = Qt::Key_Up;
 
     const Qt::LayoutDirection layoutDirection = Qt::LeftToRight;
-    const KItemListController::SelectionBehavior &selectionBehavior = KItemListController::MultiSelection;
     const bool groupingEnabled = false;
 
     QList<QPair<KeyPress, ViewState>> testList;
index ee7ac51d26c270b359d6edf85c8bb1047b517810..0afa27d738220f179bd6eb6bbec5da58d5fe0d35 100644 (file)
@@ -1883,7 +1883,7 @@ void DolphinView::selectNextItem()
             Q_ASSERT_X(false, "DolphinView", "Selecting the next item failed.");
             return;
         }
-        const auto lastSelectedIndex = m_model->index(selectedItems().last());
+        const auto lastSelectedIndex = m_model->index(*selectedItems().constEnd());
         if (lastSelectedIndex < 0) {
             Q_ASSERT_X(false, "DolphinView", "Selecting the next item failed.");
             return;
index 079cd22fd600a9e602053ec00b4bbe24180b8e86..ce698a1785259953aab5a3ad429658e8f9731971 100644 (file)
@@ -364,7 +364,8 @@ void DolphinViewActionHandler::createActions(SelectionMode::ActionTextHelper *ac
     viewSettings->setText(i18nc("@action:intoolbar", "View Settings"));
     viewSettings->setWhatsThis(
         xi18nc("@info:whatsthis View Settings Toolbutton", "This cycles through all view modes. The dropdown menu contains various view-related actions."));
-    for (QAction *action : viewModeActions->actions()) {
+    const auto actions = viewModeActions->actions();
+    for (QAction *action : actions) {
         viewSettings->addAction(action);
     }
     viewSettings->addSeparator();