[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [digikam/frameworks] libs/models: Optimize resetting of checked albums
From: Marcel Wiesweg <marcel.wiesweg () gmx ! de>
Date: 2015-09-11 16:48:54
Message-ID: E1ZaRVO-0003pi-OT () scm ! kde ! org
[Download RAW message or body]
Git commit efd576d5204bb13fe4b209944d621e9060c0480f by Marcel Wiesweg.
Committed on 11/09/2015 at 16:46.
Pushed by mwiesweg into branch 'frameworks'.
Optimize resetting of checked albums
No need to traverse all albums, only the checked ones.
M +11 -5 libs/models/abstractalbummodel.cpp
http://commits.kde.org/digikam/efd576d5204bb13fe4b209944d621e9060c0480f
diff --git a/libs/models/abstractalbummodel.cpp b/libs/models/abstractalbummodel.cpp
index 39280c5..3c3de19 100644
--- a/libs/models/abstractalbummodel.cpp
+++ b/libs/models/abstractalbummodel.cpp
@@ -841,6 +841,7 @@ class AbstractCheckableAlbumModel::Private
public:
Private()
+ : staticVectorContainingCheckStateRole(1, Qt::CheckStateRole)
{
extraFlags = 0;
rootIsCheckable = true;
@@ -851,6 +852,8 @@ public:
bool rootIsCheckable;
bool addExcludeTristate;
QHash<Album*, Qt::CheckState> checkedAlbums;
+
+ QVector<int> staticVectorContainingCheckStateRole;
};
AbstractCheckableAlbumModel::AbstractCheckableAlbumModel(Album::Type albumType, \
Album* const rootAlbum, @@ -970,14 +973,17 @@ QList<Album*> \
AbstractCheckableAlbumModel::partiallyCheckedAlbums() const
void AbstractCheckableAlbumModel::resetAllCheckedAlbums()
{
- QList<Album*> oldChecked = d->checkedAlbums.keys();
+ const QHash<Album*, Qt::CheckState> oldChecked = d->checkedAlbums;
d->checkedAlbums.clear();
- foreach(Album* const album, oldChecked)
+ for (QHash<Album*, Qt::CheckState>::const_iterator it = oldChecked.begin(); it \
!= oldChecked.end(); ++it) {
- QModelIndex index = indexForAlbum(album);
- emit dataChanged(index, index);
- emit checkStateChanged(album, Qt::Unchecked);
+ if (it.value() != Qt::Unchecked)
+ {
+ QModelIndex index = indexForAlbum(it.key());
+ emit dataChanged(index, index, d->staticVectorContainingCheckStateRole);
+ emit checkStateChanged(it.key(), Qt::Unchecked);
+ }
}
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic