Changeset View
Changeset View
Standalone View
Standalone View
src/browsers/CollectionTreeItemModel.cpp
Show All 36 Lines | |||||
37 | #include <QTimer> | 37 | #include <QTimer> | ||
38 | #include <QMap> | 38 | #include <QMap> | ||
39 | 39 | | |||
40 | CollectionTreeItemModel::CollectionTreeItemModel( const QList<CategoryId::CatMenuId> &levelType ) | 40 | CollectionTreeItemModel::CollectionTreeItemModel( const QList<CategoryId::CatMenuId> &levelType ) | ||
41 | : CollectionTreeItemModelBase() | 41 | : CollectionTreeItemModelBase() | ||
42 | { | 42 | { | ||
43 | m_rootItem = new CollectionTreeItem( this ); | 43 | m_rootItem = new CollectionTreeItem( this ); | ||
44 | CollectionManager *collMgr = CollectionManager::instance(); | 44 | CollectionManager *collMgr = CollectionManager::instance(); | ||
45 | connect( collMgr, SIGNAL(collectionAdded(Collections::Collection*)), this, SLOT(collectionAdded(Collections::Collection*)), Qt::QueuedConnection ); | 45 | connect( collMgr, &CollectionManager::collectionAdded, this, &CollectionTreeItemModel::collectionAdded, Qt::QueuedConnection ); | ||
46 | connect( collMgr, SIGNAL(collectionRemoved(QString)), this, SLOT(collectionRemoved(QString)) ); | 46 | connect( collMgr, &CollectionManager::collectionRemoved, this, &CollectionTreeItemModel::collectionRemoved ); | ||
47 | 47 | | |||
48 | QList<Collections::Collection *> collections = CollectionManager::instance()->viewableCollections(); | 48 | QList<Collections::Collection *> collections = CollectionManager::instance()->viewableCollections(); | ||
49 | foreach( Collections::Collection *coll, collections ) | 49 | foreach( Collections::Collection *coll, collections ) | ||
50 | { | 50 | { | ||
51 | connect( coll, SIGNAL(updated()), this, SLOT(slotFilter()) ) ; | 51 | connect( coll, &Collections::Collection::updated, this, &CollectionTreeItemModel::slotFilterWithoutAutoExpand ); | ||
52 | m_collections.insert( coll->collectionId(), CollectionRoot( coll, new CollectionTreeItem( coll, m_rootItem, this ) ) ); | 52 | m_collections.insert( coll->collectionId(), CollectionRoot( coll, new CollectionTreeItem( coll, m_rootItem, this ) ) ); | ||
53 | } | 53 | } | ||
54 | 54 | | |||
55 | setLevels( levelType ); | 55 | setLevels( levelType ); | ||
56 | } | 56 | } | ||
57 | 57 | | |||
58 | Qt::ItemFlags | 58 | Qt::ItemFlags | ||
59 | CollectionTreeItemModel::flags( const QModelIndex &idx ) const | 59 | CollectionTreeItemModel::flags( const QModelIndex &idx ) const | ||
▲ Show 20 Lines • Show All 126 Lines • ▼ Show 20 Line(s) | |||||
186 | } | 186 | } | ||
187 | 187 | | |||
188 | void | 188 | void | ||
189 | CollectionTreeItemModel::collectionAdded( Collections::Collection *newCollection ) | 189 | CollectionTreeItemModel::collectionAdded( Collections::Collection *newCollection ) | ||
190 | { | 190 | { | ||
191 | if( !newCollection ) | 191 | if( !newCollection ) | ||
192 | return; | 192 | return; | ||
193 | 193 | | |||
194 | connect( newCollection, SIGNAL(updated()), this, SLOT(slotFilter()) ) ; | 194 | connect( newCollection, &Collections::Collection::updated, this, &CollectionTreeItemModel::slotFilterWithoutAutoExpand ) ; | ||
195 | 195 | | |||
196 | QString collectionId = newCollection->collectionId(); | 196 | QString collectionId = newCollection->collectionId(); | ||
197 | if( m_collections.contains( collectionId ) ) | 197 | if( m_collections.contains( collectionId ) ) | ||
198 | return; | 198 | return; | ||
199 | 199 | | |||
200 | //inserts new collection at the end. | 200 | //inserts new collection at the end. | ||
201 | beginInsertRows( QModelIndex(), m_rootItem->childCount(), m_rootItem->childCount() ); | 201 | beginInsertRows( QModelIndex(), m_rootItem->childCount(), m_rootItem->childCount() ); | ||
202 | m_collections.insert( collectionId, CollectionRoot( newCollection, new CollectionTreeItem( newCollection, m_rootItem, this ) ) ); | 202 | m_collections.insert( collectionId, CollectionRoot( newCollection, new CollectionTreeItem( newCollection, m_rootItem, this ) ) ); | ||
203 | endInsertRows(); | 203 | endInsertRows(); | ||
204 | 204 | | |||
205 | if( m_collections.count() == 1 ) | 205 | if( m_collections.count() == 1 ) | ||
206 | QTimer::singleShot( 0, this, SLOT(requestCollectionsExpansion()) ); | 206 | QTimer::singleShot( 0, this, &CollectionTreeItemModel::requestCollectionsExpansion ); | ||
207 | } | 207 | } | ||
208 | 208 | | |||
209 | void | 209 | void | ||
210 | CollectionTreeItemModel::collectionRemoved( const QString &collectionId ) | 210 | CollectionTreeItemModel::collectionRemoved( const QString &collectionId ) | ||
211 | { | 211 | { | ||
212 | int count = m_rootItem->childCount(); | 212 | int count = m_rootItem->childCount(); | ||
213 | for( int i = 0; i < count; i++ ) | 213 | for( int i = 0; i < count; i++ ) | ||
214 | { | 214 | { | ||
Show All 32 Lines |