From d20fd5620b04db5b23b2e3218467239b64bd3a49 Mon Sep 17 00:00:00 2001
From: Nicolas Fella <nicolas.fella@gmx.de>
Date: Wed, 6 Nov 2024 16:10:36 +0100
Subject: [PATCH] [activities] Remove d-ptr

It's unneeded since this is not API and it only complicates things
---
 .../fileitemplugin/FileItemLinkingPlugin.cpp  | 36 +++++------
 .../fileitemplugin/FileItemLinkingPlugin.h    | 44 ++++++++++++-
 .../FileItemLinkingPluginActionLoader.cpp     |  1 -
 .../FileItemLinkingPluginActionLoader.h       |  1 -
 .../fileitemplugin/FileItemLinkingPlugin_p.h  | 61 -------------------
 5 files changed, 56 insertions(+), 87 deletions(-)
 delete mode 100644 activities/fileitemplugin/FileItemLinkingPlugin_p.h

diff --git a/activities/fileitemplugin/FileItemLinkingPlugin.cpp b/activities/fileitemplugin/FileItemLinkingPlugin.cpp
index 8b378dea2..0ed80a7f9 100644
--- a/activities/fileitemplugin/FileItemLinkingPlugin.cpp
+++ b/activities/fileitemplugin/FileItemLinkingPlugin.cpp
@@ -6,10 +6,8 @@
 
 #include "FileItemLinkingPlugin.h"
 #include "FileItemLinkingPluginActionLoader.h"
-#include "FileItemLinkingPlugin_p.h"
 
 #include <KFileItemListProperties>
-#include <utils/d_ptr_implementation.h>
 #include <utils/qsqlquery_iterator.h>
 
 #include <QCursor>
@@ -33,21 +31,14 @@
 
 K_PLUGIN_CLASS_WITH_JSON(FileItemLinkingPlugin, "kactivitymanagerd_fileitem_linking_plugin.json")
 
-// Private
-
-FileItemLinkingPlugin::Private::Private()
-{
-    connect(&activities, &KActivities::Consumer::serviceStatusChanged, this, &Private::activitiesServiceStatusChanged);
-}
-
-void FileItemLinkingPlugin::Private::activitiesServiceStatusChanged(KActivities::Consumer::ServiceStatus status)
+void FileItemLinkingPlugin::activitiesServiceStatusChanged(KActivities::Consumer::ServiceStatus status)
 {
     if (status != KActivities::Consumer::Unknown) {
         loadAllActions();
     }
 }
 
-void FileItemLinkingPlugin::Private::rootActionHovered()
+void FileItemLinkingPlugin::rootActionHovered()
 {
     if (status != Status::LoadingBlocked) {
         return;
@@ -56,7 +47,7 @@ void FileItemLinkingPlugin::Private::rootActionHovered()
     loadAllActions();
 }
 
-void FileItemLinkingPlugin::Private::actionTriggered()
+void FileItemLinkingPlugin::actionTriggered()
 {
     QAction *action = dynamic_cast<QAction *>(sender());
 
@@ -75,7 +66,7 @@ void FileItemLinkingPlugin::Private::actionTriggered()
     }
 }
 
-QAction *FileItemLinkingPlugin::Private::basicAction(QWidget *parentWidget)
+QAction *FileItemLinkingPlugin::basicAction(QWidget *parentWidget)
 {
     if (root) {
         return root;
@@ -90,14 +81,14 @@ QAction *FileItemLinkingPlugin::Private::basicAction(QWidget *parentWidget)
     rootMenu = new QMenu(parentWidget);
     rootMenu->addAction(new QAction(i18n("Loading..."), this));
 
-    connect(root, &QAction::hovered, this, &Private::rootActionHovered);
+    connect(root, &QAction::hovered, this, &FileItemLinkingPlugin::rootActionHovered);
 
     root->setMenu(rootMenu);
 
     return root;
 }
 
-void FileItemLinkingPlugin::Private::loadAllActions()
+void FileItemLinkingPlugin::loadAllActions()
 {
     if (status != Status::ShouldLoad || activities.serviceStatus() == KActivities::Consumer::Unknown) {
         return;
@@ -116,13 +107,13 @@ void FileItemLinkingPlugin::Private::loadAllActions()
 
         static FileItemLinkingPluginActionStaticInit init;
 
-        connect(loader, &FileItemLinkingPluginActionLoader::result, this, &Private::setActions, Qt::QueuedConnection);
+        connect(loader, &FileItemLinkingPluginActionLoader::result, this, &FileItemLinkingPlugin::setActions, Qt::QueuedConnection);
 
         loader->start();
     }
 }
 
-void FileItemLinkingPlugin::Private::setActions(const ActionList &actions)
+void FileItemLinkingPlugin::setActions(const ActionList &actions)
 {
     if (!rootMenu) {
         return;
@@ -144,7 +135,7 @@ void FileItemLinkingPlugin::Private::setActions(const ActionList &actions)
 
             rootMenu->addAction(action);
 
-            connect(action, &QAction::triggered, this, &Private::actionTriggered);
+            connect(action, &QAction::triggered, this, &FileItemLinkingPlugin::actionTriggered);
 
         } else {
             auto action = new QAction(actionInfo.title, nullptr);
@@ -166,11 +157,12 @@ FileItemLinkingPluginActionStaticInit::FileItemLinkingPluginActionStaticInit()
 FileItemLinkingPlugin::FileItemLinkingPlugin(QObject *parent, const QVariantList &)
     : KAbstractFileItemActionPlugin(parent)
 {
+    connect(&activities, &KActivities::Consumer::serviceStatusChanged, this, &FileItemLinkingPlugin::activitiesServiceStatusChanged);
 }
 
 FileItemLinkingPlugin::~FileItemLinkingPlugin()
 {
-    d->setActions({});
+    setActions({});
 }
 
 QList<QAction *> FileItemLinkingPlugin::actions(const KFileItemListProperties &fileItemInfos, QWidget *parentWidget)
@@ -186,10 +178,10 @@ QList<QAction *> FileItemLinkingPlugin::actions(const KFileItemListProperties &f
         return {};
     }
 
-    d->items = fileItemInfos;
+    items = fileItemInfos;
 
-    return {d->basicAction(parentWidget)};
+    return {basicAction(parentWidget)};
 }
 
 #include "FileItemLinkingPlugin.moc"
-#include "moc_FileItemLinkingPlugin_p.cpp"
+#include "moc_FileItemLinkingPlugin.cpp"
diff --git a/activities/fileitemplugin/FileItemLinkingPlugin.h b/activities/fileitemplugin/FileItemLinkingPlugin.h
index 279bdf069..9cdcdabf9 100644
--- a/activities/fileitemplugin/FileItemLinkingPlugin.h
+++ b/activities/fileitemplugin/FileItemLinkingPlugin.h
@@ -8,18 +8,36 @@
 #define FILE_ITEM_LINKING_PLUGIN_H
 
 #include <KAbstractFileItemActionPlugin>
+#include <KFileItemListProperties>
+
+#include <PlasmaActivities/Consumer>
+#include <PlasmaActivities/Info>
 
 #include <QAction>
 #include <QList>
+#include <QPointer>
 #include <QVariant>
 
-#include <utils/d_ptr.h>
+struct Action {
+    QString title;
+    QString icon;
+    QString activity;
+    bool link;
+};
+typedef QList<Action> ActionList;
+
+class FileItemLinkingPluginActionStaticInit
+{
+public:
+    FileItemLinkingPluginActionStaticInit();
+};
 
 /**
  * FileItemLinkingPlugin
  */
 class FileItemLinkingPlugin : public KAbstractFileItemActionPlugin
 {
+    Q_OBJECT
 public:
     FileItemLinkingPlugin(QObject *parent, const QVariantList &);
     ~FileItemLinkingPlugin() override;
@@ -27,7 +45,29 @@ public:
     QList<QAction *> actions(const KFileItemListProperties &fileItemInfos, QWidget *parentWidget) override;
 
 private:
-    D_PTR;
+    QPointer<QAction> root;
+    QMenu *rootMenu = nullptr;
+    KFileItemListProperties items;
+
+    QAction *basicAction(QWidget *parentWidget);
+
+    KActivities::Consumer activities;
+
+public Q_SLOTS:
+    void activitiesServiceStatusChanged(KActivities::Consumer::ServiceStatus status);
+    void rootActionHovered();
+    void setActions(const ActionList &actions);
+
+    void actionTriggered();
+    void loadAllActions();
+
+private:
+    enum class Status {
+        LoadingBlocked,
+        ShouldLoad,
+        Loaded
+    };
+    Status status = Status::LoadingBlocked;
 };
 
 #endif // FILE_ITEM_LINKING_PLUGIN_H
diff --git a/activities/fileitemplugin/FileItemLinkingPluginActionLoader.cpp b/activities/fileitemplugin/FileItemLinkingPluginActionLoader.cpp
index b16ef8ecd..416dfa18c 100644
--- a/activities/fileitemplugin/FileItemLinkingPluginActionLoader.cpp
+++ b/activities/fileitemplugin/FileItemLinkingPluginActionLoader.cpp
@@ -7,7 +7,6 @@
 #include "FileItemLinkingPluginActionLoader.h"
 
 #include <KFileItemListProperties>
-#include <utils/d_ptr_implementation.h>
 #include <utils/qsqlquery_iterator.h>
 
 #include <QCursor>
diff --git a/activities/fileitemplugin/FileItemLinkingPluginActionLoader.h b/activities/fileitemplugin/FileItemLinkingPluginActionLoader.h
index 9f1967444..f62acd416 100644
--- a/activities/fileitemplugin/FileItemLinkingPluginActionLoader.h
+++ b/activities/fileitemplugin/FileItemLinkingPluginActionLoader.h
@@ -8,7 +8,6 @@
 #define FILE_ITEM_LINKING_PLUGIN_ACTION_LOADER_H
 
 #include "FileItemLinkingPlugin.h"
-#include "FileItemLinkingPlugin_p.h"
 
 #include <QThread>
 
diff --git a/activities/fileitemplugin/FileItemLinkingPlugin_p.h b/activities/fileitemplugin/FileItemLinkingPlugin_p.h
deleted file mode 100644
index 3b8df1b9a..000000000
--- a/activities/fileitemplugin/FileItemLinkingPlugin_p.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- *   SPDX-FileCopyrightText: 2012-2016 Ivan Cukic <ivan.cukic@kde.org>
- *
- *   SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
- */
-
-#ifndef FILE_ITEM_LINKING_PLUGIN_P_H
-#define FILE_ITEM_LINKING_PLUGIN_P_H
-
-#include "FileItemLinkingPlugin.h"
-
-#include <QPointer>
-
-#include <KFileItemListProperties>
-
-#include <PlasmaActivities/Consumer>
-#include <PlasmaActivities/Info>
-
-struct Action {
-    QString title;
-    QString icon;
-    QString activity;
-    bool link;
-};
-typedef QList<Action> ActionList;
-
-class FileItemLinkingPlugin::Private : public QObject
-{
-    Q_OBJECT
-
-public:
-    Private();
-
-    QPointer<QAction> root;
-    QMenu *rootMenu = nullptr;
-    KFileItemListProperties items;
-
-    QAction *basicAction(QWidget *parentWidget);
-
-    KActivities::Consumer activities;
-
-public Q_SLOTS:
-    void activitiesServiceStatusChanged(KActivities::Consumer::ServiceStatus status);
-    void rootActionHovered();
-    void setActions(const ActionList &actions);
-
-    void actionTriggered();
-    void loadAllActions();
-
-private:
-    enum class Status { LoadingBlocked, ShouldLoad, Loaded };
-    Status status = Status::LoadingBlocked;
-};
-
-class FileItemLinkingPluginActionStaticInit
-{
-public:
-    FileItemLinkingPluginActionStaticInit();
-};
-
-#endif // FILE_ITEM_LINKING_PLUGIN_P_H
-- 
GitLab