Added alternative way to notify FeedsView about changes.

This commit is contained in:
Martin Rotter 2013-12-18 14:15:34 +01:00
parent 15db836b46
commit 1e7bf0ef9e
3 changed files with 22 additions and 3 deletions

View File

@ -173,9 +173,28 @@ FeedsModelRootItem *FeedsModel::itemForIndex(const QModelIndex &index) {
}
}
void FeedsModel::changeLayout() {
void FeedsModel::changeLayout(QModelIndexList list) {
// TODO: Udělat analyzu pres cachegrind
// esli je lepsi tohle, nebo zakomentovana cast
// zakomentovana cast udela to ze view se dopta na všecky
// polozky
while (!list.isEmpty()) {
QModelIndex ix = list.takeLast();
emit dataChanged(index(ix.row(), 0, ix.parent()),
index(ix.row(), FDS_MODEL_COUNTS_INDEX, ix.parent()));
if (ix.parent().isValid()) {
list.append(ix.parent());
}
}
/*
emit layoutAboutToBeChanged();
// TODO: kouknout do dokumentace na signal layoutChanged,
// protoze ten signal layoutAboutToBeChanged by se měl volat PRED
// zmenou dat v modelu
emit layoutChanged();
*/
}
void FeedsModel::loadFromDatabase() {

View File

@ -52,7 +52,7 @@ class FeedsModel : public QAbstractItemModel {
public slots:
// Signals that ALL data of this model need
// to be reloaded by ALL attached views.
void changeLayout();
void changeLayout(QModelIndexList list);
protected:
// Loads feed/categories from the database.

View File

@ -34,7 +34,7 @@ void FeedsView::updateCountsOfSelectedFeeds() {
feed->updateCounts();
}
m_sourceModel->changeLayout();
m_sourceModel->changeLayout(mapped_rows);
}
void FeedsView::setupAppearance() {