@@ -104,6 +104,25 @@ Categories::onCountChanged()
107+void Categories::onRowCountChanged()
109+ QAbstractItemModel* model = qobject_cast<QAbstractItemModel*>(sender());
110+ // find the corresponding category index
111+ for (auto iter = m_overriddenCategories.begin(); iter != m_overriddenCategories.end(); ++iter) {
112+ if (iter.value() == model) {
113+ for (int i = 0; i < rowCount(); i++) {
114+ auto id = data(index(i), RoleCategoryId).toString();
115+ if (id != iter.key()) continue;
117+ roles.append(RoleCount);
118+ QModelIndex changedIndex = index(i);
119+ Q_EMIT dataChanged(changedIndex, changedIndex, roles);
108Categories::onEmitCountChanged()
127Categories::onEmitCountChanged()
@@ -127,6 +146,8 @@ void Categories::overrideResults(const QString& categoryId, QAbstractItemModel*
128 m_overriddenCategories[categoryId] = model;
147 m_overriddenCategories[categoryId] = model;
129 // TODO: change the parent of the model?
148 // TODO: change the parent of the model?
149+ connect(model, &QAbstractItemModel::rowsInserted, this, &Categories::onRowCountChanged);
150+ connect(model, &QAbstractItemModel::rowsRemoved, this, &Categories::onRowCountChanged);
131 // emit the dataChanged signal if the category is already in the model
152 // emit the dataChanged signal if the category is already in the model
132 for (int i = 0; i < rowCount(); i++) {
153 for (int i = 0; i < rowCount(); i++) {