[utilities/kdebugsettings] src: Prepare to save elements

Laurent Montel <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 62d35532346e4890d552fed5b5c9b6ca4ba0ca65 by Laurent Montel.
Committed on 18/07/2026 at 15:39.
Pushed by mlaurent into branch 'master'.

Prepare to save elements

M  +18   -0    src/core/loggingmanager.cpp
M  +2    -0    src/core/loggingmanager.h
M  +19   -0    src/core/model/kdeapplicationloggingcategoryproxymodel.cpp
M  +2    -0    src/core/model/kdeapplicationloggingcategoryproxymodel.h
M  +5    -4    src/quickapps/contents/ui/KDEApplicationRulesPage.qml

https://invent.kde.org/utilities/kdebugsettings/-/commit/62d35532346e4890d552fed5b5c9b6ca4ba0ca65

diff --git a/src/core/loggingmanager.cpp b/src/core/loggingmanager.cpp
index 921026a2..bf6546f4 100644
--- a/src/core/loggingmanager.cpp
+++ b/src/core/loggingmanager.cpp
@@ -6,6 +6,7 @@
 */
 
 #include "loggingmanager.h"
+#include "jobs/saverulesjob.h"
 
 LoggingManager::LoggingManager(QObject *parent)
     : QObject{parent}
@@ -58,6 +59,23 @@ void LoggingManager::updateLoggingCategories()
     mQtKdeCategoryModel->setLoggingCategories(qtKdeCategories);
 }
 
+bool LoggingManager::saveRules(const QString &path, bool forceSavingAllRules)
+{
+#if 0 /// TODO
+    SaveRulesJob job;
+    job.setFileName(path);
+    job.setListCustom(customCategoryModel()->loggingCategories());
+    job.setListKde(mKdeApplicationSettingsPage->rules(forceSavingAllRules));
+    if (!job.start()) {
+        KMessageBox::error(this, i18n("\'%1\' cannot be opened. Please verify it.", path));
+        return false;
+    }
+    return true;
+#endif
+    // TODO
+    return false;
+}
+
 KDebugSettingsLoadingCategories LoggingManager::loggings() const
 {
     return mLoggings;
diff --git a/src/core/loggingmanager.h b/src/core/loggingmanager.h
index 1a33c905..39435f4f 100644
--- a/src/core/loggingmanager.h
+++ b/src/core/loggingmanager.h
@@ -44,6 +44,8 @@ public:
     void readQtLoggingFile();
     void updateLoggingCategories();
 
+    [[nodiscard]] bool saveRules(const QString &path, bool forceSavingAllRules);
+
 private:
     LIBKDEBUGSETTINGSCORE_NO_EXPORT explicit LoggingManager(QObject *parent = nullptr);
     CustomLoggingCategoryModel *const mCustomCategoryModel;
diff --git a/src/core/model/kdeapplicationloggingcategoryproxymodel.cpp b/src/core/model/kdeapplicationloggingcategoryproxymodel.cpp
index 56949887..2854001e 100644
--- a/src/core/model/kdeapplicationloggingcategoryproxymodel.cpp
+++ b/src/core/model/kdeapplicationloggingcategoryproxymodel.cpp
@@ -14,6 +14,25 @@ KDEApplicationLoggingCategoryProxyModel::KDEApplicationLoggingCategoryProxyModel
 
 KDEApplicationLoggingCategoryProxyModel::~KDEApplicationLoggingCategoryProxyModel() = default;
 
+bool KDEApplicationLoggingCategoryProxyModel::setCategoryType(int proxyRow, int type)
+{
+    if (proxyRow < 0 || proxyRow >= rowCount()) {
+        return false;
+    }
+
+    const QModelIndex proxyIndex = index(proxyRow, KDEApplicationLoggingCategoryModel::LoggingTypeRole);
+    if (!proxyIndex.isValid()) {
+        return false;
+    }
+
+    const QModelIndex sourceIndex = mapToSource(proxyIndex);
+    if (!sourceIndex.isValid() || !sourceModel()) {
+        return false;
+    }
+
+    return sourceModel()->setData(sourceIndex, QVariant::fromValue(static_cast<LoggingCategory::LoggingType>(type)), Qt::EditRole);
+}
+
 bool KDEApplicationLoggingCategoryProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
 {
     if (mFilterText.isEmpty()) {
diff --git a/src/core/model/kdeapplicationloggingcategoryproxymodel.h b/src/core/model/kdeapplicationloggingcategoryproxymodel.h
index 04746b56..6f1933cc 100644
--- a/src/core/model/kdeapplicationloggingcategoryproxymodel.h
+++ b/src/core/model/kdeapplicationloggingcategoryproxymodel.h
@@ -15,6 +15,8 @@ public:
     explicit KDEApplicationLoggingCategoryProxyModel(QObject *parent = nullptr);
     ~KDEApplicationLoggingCategoryProxyModel() override;
 
+    Q_INVOKABLE bool setCategoryType(int proxyRow, int type);
+
     [[nodiscard]] QString filterText() const;
     void setFilterText(const QString &newFilterText);
 
diff --git a/src/quickapps/contents/ui/KDEApplicationRulesPage.qml b/src/quickapps/contents/ui/KDEApplicationRulesPage.qml
index e77169e8..d1276629 100644
--- a/src/quickapps/contents/ui/KDEApplicationRulesPage.qml
+++ b/src/quickapps/contents/ui/KDEApplicationRulesPage.qml
@@ -50,6 +50,9 @@ Kirigami.ScrollablePage {
                 QQC2.ComboBox {
                     Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
 
+                    // Keep the delegate row index distinct from ComboBox activation index.
+                    property int rowIndex: index
+
                     model: CategoryTypeProxyModel {
                         sourceModel: LoggingManager.categoryTypeModel
                         showOffType: true
@@ -57,10 +60,8 @@ Kirigami.ScrollablePage {
                     textRole: "display"
                     valueRole: "categoryType"
                     currentIndex: LoggingManager.categoryTypeModel.indexOfCategory(listviewRules.model.categoryType)
-                    onActivated: {
-                        console.debug("Not implemented yet")
-
-                        // TODO
+                    onActivated: () => {
+                        listviewRules.model.setCategoryType(rowIndex, currentValue)
                     }
                 }
             }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.