Commit ddf978ad authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Fix Bug 233414 - Folder size of collapsed folders does not include

subfolder size
Show subfolder size in tooltip
FIXED-IN: 4.9
BUG: 233414
parent e7fa822d
......@@ -49,6 +49,24 @@ class StatisticsProxyModel::Private
{
}
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 );
}
}
}
}
int sourceColumnCount( const QModelIndex &parent )
{
return mParent->sourceModel()->columnCount( mParent->mapToSource( parent ) );
......@@ -100,11 +118,21 @@ class StatisticsProxyModel::Private
}
}
qint64 currentFolderSize( collection.statistics().size() );
tipInfo += QString::fromLatin1(
" <strong>%1</strong>: %2<br>\n"
).arg( i18n( "Storage Size" ) ).arg( KIO::convertSize( (KIO::filesize_t)( collection.statistics().size() ) ) );
).arg( i18n( "Storage Size" ) ).arg( KIO::convertSize( (KIO::filesize_t)( currentFolderSize ) ) );
qint64 totalSize = 0;
getCountRecursive( index, totalSize );
totalSize -= currentFolderSize;
if (totalSize > 0 ) {
tipInfo += QString::fromLatin1(
"<strong>%1</strong>: %2<br>"
).arg( i18n("Subfolder Storage Size") ).arg( KIO::convertSize( (KIO::filesize_t)( totalSize ) ) );
}
QString iconName = CollectionUtils::defaultIconName( collection );
if ( collection.hasAttribute<EntityDisplayAttribute>() &&
!collection.attribute<EntityDisplayAttribute>()->iconName().isEmpty() ) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment