[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: extragear/multimedia/amarok/src/collection/ipodcollection/handler
From: Alejandro Daniel Wainzinger <aikawarazuni () gmail ! com>
Date: 2009-07-17 11:32:11
Message-ID: 1247830331.534600.13409.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 998297 by awainzinger:
Cache capacity/used space for iPod.
M +19 -24 IpodHandler.cpp
M +10 -0 IpodHandler.h
--- trunk/extragear/multimedia/amarok/src/collection/ipodcollection/handler/IpodHandler.cpp \
#998296:998297 @@ -72,6 +72,7 @@
: MediaDeviceHandler( mc )
//, m_memColl( mc )
, m_masterPlaylist( 0 )
+ , m_capacity( 0.0 )
, m_jobcounter( 0 )
, m_autoConnect( false )
, m_mountPoint( mountPoint )
@@ -312,6 +313,21 @@
qsrand( QTime::currentTime().msec() ); // random number used for folder number \
generation
+ // Get storage access for getting device space capacity/usage
+
+ Solid::Device device = Solid::Device( m_memColl->udi() );
+ if ( device.isValid() )
+ {
+ Solid::StorageAccess *storage = device.as<Solid::StorageAccess>();
+ m_filepath = storage->filePath();
+ m_capacity = KDiskFreeSpaceInfo::freeSpaceInfo( m_filepath ).size();
+ }
+ else
+ {
+ m_filepath = "";
+ m_capacity = 0.0;
+ }
+
debug() << "Succeeded: " << m_success;
m_memColl->slotAttemptConnectionDone( m_success );
@@ -1343,37 +1359,16 @@
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();
-
- }
-
+ if ( !m_filepath.isEmpty() )
+ return KDiskFreeSpaceInfo::freeSpaceInfo( m_filepath ).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;
- }
-
+ return m_capacity;
}
/// Sets
--- trunk/extragear/multimedia/amarok/src/collection/ipodcollection/handler/IpodHandler.h \
#998296:998297 @@ -39,6 +39,7 @@
#include "mediadevicecollection_export.h"
+#include <KDiskFreeSpaceInfo>
#include <KIO/Job>
#include "kjob.h"
#include <ctime> // for kjob.h
@@ -50,6 +51,10 @@
#include <QMultiMap>
#include <QMutex>
+namespace Solid {
+ class StorageAccess;
+}
+
class QString;
class QMutex;
@@ -281,6 +286,11 @@
GList *m_currtracklist;
Itdb_Track *m_currtrack;
+ // For space checks
+
+ QString m_filepath;
+ float m_capacity;
+
// for playlist parsing
GList *m_currplaylistlist;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic