[utilities/kdebugsettings] src: Emit signal when customloggingcategorymodel value changed
Laurent Montel <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 5bfe5e180b320ff8964b7c3f5badaa4de5e128f6 by Laurent Montel.
Committed on 30/07/2026 at 11:51.
Pushed by mlaurent into branch 'master'.
Emit signal when customloggingcategorymodel value changed
M +1 -0 src/core/loggingmanager.cpp
M +3 -0 src/core/loggingmanager.h
M +7 -1 src/core/model/customloggingcategorymodel.cpp
M +3 -0 src/core/model/customloggingcategorymodel.h
M +4 -0 src/kcm/kcmdebugsettingsqml.cpp
https://invent.kde.org/utilities/kdebugsettings/-/commit/5bfe5e180b320ff8964b7c3f5badaa4de5e128f6
diff --git a/src/core/loggingmanager.cpp b/src/core/loggingmanager.cpp
index 32ffd6d8..0a33bafc 100644
--- a/src/core/loggingmanager.cpp
+++ b/src/core/loggingmanager.cpp
@@ -21,6 +21,7 @@ LoggingManager::LoggingManager(QObject *parent)
mCustomLoggingCategoryProxyModel->setSourceModel(mCustomCategoryModel);
mLoggings.readQtLoggingFile();
updateLoggingCategories();
+ connect(mCustomCategoryModel, &CustomLoggingCategoryModel::customLoggingChanged, this, &LoggingManager::customLoggingChanged);
}
CustomLoggingCategoryProxyModel *LoggingManager::customLoggingCategoryProxyModel() const
diff --git a/src/core/loggingmanager.h b/src/core/loggingmanager.h
index 324f74c9..8d4521ef 100644
--- a/src/core/loggingmanager.h
+++ b/src/core/loggingmanager.h
@@ -53,6 +53,9 @@ public:
[[nodiscard]] CustomLoggingCategoryProxyModel *customLoggingCategoryProxyModel() const;
+Q_SIGNALS:
+ void customLoggingChanged();
+
private:
LIBKDEBUGSETTINGSCORE_NO_EXPORT explicit LoggingManager(QObject *parent = nullptr);
CustomLoggingCategoryModel *const mCustomCategoryModel;
diff --git a/src/core/model/customloggingcategorymodel.cpp b/src/core/model/customloggingcategorymodel.cpp
index 3547d738..071c137d 100644
--- a/src/core/model/customloggingcategorymodel.cpp
+++ b/src/core/model/customloggingcategorymodel.cpp
@@ -73,6 +73,7 @@ void CustomLoggingCategoryModel::updateCategory(int row, const QString &category
cat.loggingType = type;
const QModelIndex modelIndex = index(row, 0);
Q_EMIT dataChanged(modelIndex, modelIndex);
+ Q_EMIT customLoggingChanged();
}
QVariant CustomLoggingCategoryModel::data(const QModelIndex &index, int role) const
@@ -130,6 +131,7 @@ void CustomLoggingCategoryModel::removeCategory(int row)
beginRemoveRows(QModelIndex(), row, row);
mLoggingCategories.removeAt(row);
endRemoveRows();
+ Q_EMIT customLoggingChanged();
}
void CustomLoggingCategoryModel::removeCategory(const LoggingCategory::List &categories)
@@ -144,6 +146,7 @@ void CustomLoggingCategoryModel::removeCategory(const LoggingCategory::List &cat
}
}
endResetModel();
+ Q_EMIT customLoggingChanged();
}
void CustomLoggingCategoryModel::addCategory(const QString &categoryName, bool enabled, LoggingCategory::LoggingType type)
@@ -152,7 +155,9 @@ void CustomLoggingCategoryModel::addCategory(const QString &categoryName, bool e
category.categoryName = categoryName;
category.enabled = enabled;
category.loggingType = type;
- if (!addCategory(category)) { }
+ if (addCategory(category)) {
+ Q_EMIT customLoggingChanged();
+ }
}
bool CustomLoggingCategoryModel::addCategory(const LoggingCategory &category)
@@ -184,6 +189,7 @@ void CustomLoggingCategoryModel::insertCategories(const LoggingCategory::List &c
beginInsertRows(QModelIndex(), mLoggingCategories.count(), mLoggingCategories.count() + categories.count() - 1);
mLoggingCategories.append(categories);
endInsertRows();
+ Q_EMIT customLoggingChanged();
}
}
diff --git a/src/core/model/customloggingcategorymodel.h b/src/core/model/customloggingcategorymodel.h
index 50b7f606..229a0bf4 100644
--- a/src/core/model/customloggingcategorymodel.h
+++ b/src/core/model/customloggingcategorymodel.h
@@ -54,6 +54,9 @@ public:
Q_INVOKABLE void addCategory(const QString &categoryName, bool enabled, LoggingCategory::LoggingType type);
Q_INVOKABLE void updateCategory(int row, const QString &categoryName, bool enabled, LoggingCategory::LoggingType type);
+Q_SIGNALS:
+ void customLoggingChanged();
+
private:
LoggingCategory::List mLoggingCategories;
QHash<int, QByteArray> mRoleNames;
diff --git a/src/kcm/kcmdebugsettingsqml.cpp b/src/kcm/kcmdebugsettingsqml.cpp
index ef052860..41f3ae0b 100644
--- a/src/kcm/kcmdebugsettingsqml.cpp
+++ b/src/kcm/kcmdebugsettingsqml.cpp
@@ -24,6 +24,10 @@ KCMDebugSettingsQml::KCMDebugSettingsQml(QObject *parent, const KPluginMetaData
qmlRegisterType<CategoryTypeProxyModel>("org.kde.kdebugsettings", 1, 0, "CategoryTypeProxyModel");
qmlRegisterType<CustomLoggingCategoryProxyModel>("org.kde.kdebugsettings", 1, 0, "CustomLoggingCategoryProxyModel");
qmlRegisterType<KDEApplicationLoggingCategoryProxyModel>("org.kde.kdebugsettings", 1, 0, "KDEApplicationLoggingCategoryProxyModel");
+
+ connect(&LoggingManager::self(), &LoggingManager::customLoggingChanged, this, [this]() {
+ setNeedsSave(true);
+ });
}
KCMDebugSettingsQml::~KCMDebugSettingsQml() = default;