Ipod capacity checks (Was: extragear/multimedia/amarok/src/collection)

Seb Ruiz ruiz at kde.org
Thu Jul 16 23:40:41 CEST 2009


One big concern here that I was having during Akademy that I hadn't
brought up because I hadn't thought about it long enough.

usedCapacity() and totalCapacity() are used by the collection item
delegate when drawing/updating the view, and that calls to data() were
being used very liberally (possibly due to numerous redraws or the way
that an item delegate is implemented in Qt's mvc model)

So to my point: we need to be doing some more intelligent caching of
values here. Create and store the KDiskFreeSpaceInfo object as a
member of the class on initialisation rather than every time on
demand. This should dramatically speed up performance. Also, total
capacity is never going to change, so no need to recalculate that.

Futhermore, why have you now moved the capacity checks for the ipod
collection to IpodHandler? We discussed this at Akademy - in the mtp
case it makes sense (since the attributes are retrieved from the mtp
library). For Ipods, we are using solid which is totally unrelated to
libgpod. Keep the functionality on the Collection level (since this is
where the logical attributes exist). Also, I added very similar code
to MediaDeviceCollection, you've duplicated it.

Seb

2009/7/17 Alejandro Daniel Wainzinger <aikawarazuni at gmail.com>:
>
> +float
> +IpodHandler::usedCapacity() const
> +{
> +    Solid::Device device = Solid::Device( m_memColl->udi() );
> +    if( device.isValid() )
> +    {
> +        Solid::StorageAccess *storage = device.as<Solid::StorageAccess>();
> +        KDiskFreeSpaceInfo info = KDiskFreeSpaceInfo::freeSpaceInfo( storage->filePath() );
> +        return info.used();
> +
> +    }
> +
> +    else
> +    {
> +        return 0.0;
> +    }
> +}
> +
> +float
> +IpodHandler::totalCapacity() const
> +{
> +    Solid::Device device = Solid::Device( m_memColl->udi() );
> +    if( device.isValid() )
> +    {
> +        Solid::StorageAccess *storage = device.as<Solid::StorageAccess>();
> +        KDiskFreeSpaceInfo info = KDiskFreeSpaceInfo::freeSpaceInfo( storage->filePath() );
> +        return info.size();
> +    }
> +
> +    else
> +    {
> +        return 0.0;
> +    }
> +
> +}
> +



-- 
Seb Ruiz

http://www.sebruiz.net/
http://amarok.kde.org/


More information about the Amarok-devel mailing list