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

Alejandro Wainzinger aikawarazuni at gmail.com
Fri Jul 17 07:32:13 CEST 2009


To check if there's enough space to make a copy of tracks to the
device, we have to know the capacity and space usage of the device.
To put this into the collection and have the handler ask the
collection for it seemed a bit odd.  The caching of the
KDiskFreeSpaceInfo object makes sense though, and also the caching of
the call to full capacity.

On Thu, Jul 16, 2009 at 11:40 PM, Seb Ruiz<ruiz at kde.org> wrote:
> 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/
> _______________________________________________
> Amarok-devel mailing list
> Amarok-devel at kde.org
> https://mail.kde.org/mailman/listinfo/amarok-devel
>


More information about the Amarok-devel mailing list