[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    Re: extragear/multimedia/amarok/src/collection/mediadevicecollection
From:       Alejandro Wainzinger <aikawarazuni () gmail ! com>
Date:       2009-07-19 17:01:21
Message-ID: fce735e0907191001n7f0d68c9ja35bfa134f626252 () mail ! gmail ! com
[Download RAW message or body]

Currently, the used capacity isn't cached in the handler, since it can
change between calls, it gets the latest each time.  Just the max
capacity is being cached.

On Sun, Jul 19, 2009 at 2:43 PM, Seb Ruiz<ruiz@kde.org> wrote:
> As I discovered today, it's a bad idea to cache the used capacity -
> because the visualisation won't get updated after adding/removing
> tracks to a device. We could consider "invalidating" the used capacity
> cache after an add/remove, but this would magnify our complexity and
> also not respond to changes outside of Amarok.
> 
> 2009/7/19 Alejandro Daniel Wainzinger <aikawarazuni@gmail.com>:
> > SVN commit 999101 by awainzinger:
> > 
> > Don't duplicate capacity code in collection.
> > 
> > M  +4 -16     MediaDeviceCollection.cpp
> > M  +12 -0     handler/MediaDeviceHandler.cpp
> > M  +3 -0      handler/MediaDeviceHandler.h
> > 
> > 
> > --- trunk/extragear/multimedia/amarok/src/collection/mediadevicecollection/MediaDeviceCollection.cpp \
> > #999100:999101 @@ -140,19 +140,8 @@
> > void
> > MediaDeviceCollection::initCapacities()
> > {
> > -    Solid::Device device = Solid::Device( m_udi );
> > -    if( device.isValid() )
> > -    {
> > -        Solid::StorageAccess *storage = device.as<Solid::StorageAccess>();
> > -        KDiskFreeSpaceInfo info = KDiskFreeSpaceInfo::freeSpaceInfo( \
> >                 storage->filePath() );
> > -        m_usedCapacity = info.used();
> > -        m_totalCapacity = info.size();
> > -    }
> > -    else
> > -    {
> > -        m_usedCapacity = 0;
> > -        m_totalCapacity = 0;
> > -    }
> > +    m_usedCapacity = m_handler->usedcapacity();
> > +    m_totalCapacity = m_handler->totalcapacity();
> > }
> > 
> > QueryMaker*
> > @@ -263,9 +252,8 @@
> > float
> > MediaDeviceCollection::usedCapacity() const
> > {
> > -    if( m_totalCapacity < 0 )
> > -        const_cast<MediaDeviceCollection*>(this)->initCapacities();
> > -    return m_usedCapacity;
> > +    if( m_totalCapacity >= 0 )
> > +        return m_usedCapacity;
> > }
> > 
> > float
> > --- trunk/extragear/multimedia/amarok/src/collection/mediadevicecollection/handler/MediaDeviceHandler.cpp \
> > #999100:999101 @@ -1041,6 +1041,18 @@
> > return ( m_rc->totalCapacity() - m_rc->usedCapacity() );
> > }
> > 
> > +float
> > +MediaDeviceHandler::usedcapacity() const
> > +{
> > +    return m_rc->usedCapacity();
> > +}
> > +
> > +float
> > +MediaDeviceHandler::totalcapacity() const
> > +{
> > +    return m_rc->totalCapacity();
> > +}
> > +
> > /** Observer Methods **/
> > void
> > MediaDeviceHandler::metadataChanged( TrackPtr track )
> > --- trunk/extragear/multimedia/amarok/src/collection/mediadevicecollection/handler/MediaDeviceHandler.h \
> > #999100:999101 @@ -188,6 +188,9 @@
> > 
> > virtual void prepareToPlay( Meta::MediaDeviceTrackPtr &track ) { Q_UNUSED( track \
> > ) } // called by @param track 
> > +    virtual float usedcapacity() const;
> > +    virtual float totalcapacity() const;
> > +
> > // HACK: Used for device-specific actions, such as initialize for iPod
> > 
> > virtual QList<PopupDropperAction *> collectionActions() { return \
> > QList<PopupDropperAction*> (); } 
> 
> 
> 
> --
> Seb Ruiz
> 
> http://www.sebruiz.net/
> http://amarok.kde.org/
> 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic