[ConfigModel] Emit dataChanged when a ConfigCategory changes

Differential Revision: https://phabricator.kde.org/D4543
This commit is contained in:
Kai Uwe Broulik 2017-02-10 12:24:59 +01:00
parent cee709d054
commit 5becf5bc11

View File

@ -135,6 +135,21 @@ void ConfigModelPrivate::appendCategory(ConfigCategory *c)
{
q->beginInsertRows(QModelIndex(), categories.size(), categories.size());
categories.append(c);
auto emitChange = [this, c] {
const int row = categories.indexOf(c);
if (row > -1) {
QModelIndex modelIndex = q->index(row);
emit q->dataChanged(modelIndex, modelIndex);
}
};
QObject::connect(c, &ConfigCategory::nameChanged, q, emitChange);
QObject::connect(c, &ConfigCategory::iconChanged, q, emitChange);
QObject::connect(c, &ConfigCategory::sourceChanged, q, emitChange);
QObject::connect(c, &ConfigCategory::pluginNameChanged, q, emitChange);
QObject::connect(c, &ConfigCategory::visibleChanged, q, emitChange);
q->endInsertRows();
emit q->countChanged();
}