QDebug operator<<( QDebug d, const CollectionStatistics& s ) { return d << "CollectionStatistics:" << endl << " count:" << s.count() << endl << " unread count:" << s.unreadCount() << endl << " size:" << s.size(); }
void getCountRecursive( const QModelIndex &index, qint64 &totalSize ) const { Collection collection = qvariant_cast<Collection>( index.data( EntityTreeModel::CollectionRole ) ); // Do not assert on invalid collections, since a collection may be deleted // in the meantime and deleted collections are invalid. if ( collection.isValid() ) { CollectionStatistics statistics = collection.statistics(); totalSize += qMax( 0LL, statistics.size() ); if ( index.model()->hasChildren( index ) ) { const int rowCount = index.model()->rowCount( index ); for ( int row = 0; row < rowCount; row++ ) { static const int column = 0; getCountRecursive( index.model()->index( row, column, index ), totalSize ); } } } }