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

List:       kde-commits
Subject:    [amarok] src/core-impl/collections/umscollection: Add de-init for
From:       Bart Cerneels <bart.cerneels () kde ! org>
Date:       2011-10-19 9:53:00
Message-ID: 20111019095300.7DC5DA60C6 () git ! kde ! org
[Download RAW message or body]

Git commit 206dd21c7958626eb0d0c1f360a9ba8bd5d20477 by Bart Cerneels.
Committed on 19/10/2011 at 11:52.
Pushed by shanachie into branch 'master'.

Add de-init for UMS collection.

Collection will still exist, but just as a placeholder.

M  +32   -19   src/core-impl/collections/umscollection/UmsCollection.cpp
M  +4    -0    src/core-impl/collections/umscollection/UmsCollection.h

http://commits.kde.org/amarok/206dd21c7958626eb0d0c1f360a9ba8bd5d20477

diff --git a/src/core-impl/collections/umscollection/UmsCollection.cpp \
b/src/core-impl/collections/umscollection/UmsCollection.cpp index f156e70..1d2ce9c \
                100644
--- a/src/core-impl/collections/umscollection/UmsCollection.cpp
+++ b/src/core-impl/collections/umscollection/UmsCollection.cpp
@@ -143,6 +143,7 @@ UmsCollection::UmsCollection( Solid::Device device )
     : Collection()
     , m_device( device )
     , m_mc( new MemoryCollection() )
+    , m_initialized( false )
     , m_autoConnect( false )
     , m_vfatSafe( true )
     , m_asciiOnly( false )
@@ -157,17 +158,6 @@ UmsCollection::UmsCollection( Solid::Device device )
     connect( storageAccess, SIGNAL(accessibilityChanged( bool, QString )),
              SLOT(slotAccessibilityChanged( bool, QString )) );
 
-    if( storageAccess->isAccessible() )
-        init();
-}
-
-void
-UmsCollection::init()
-{
-    Solid::StorageAccess *storageAccess = m_device.as<Solid::StorageAccess>();
-    m_mountPoint = storageAccess->filePath();
-    debug() << "Mounted at: " << m_mountPoint;
-
     m_configureAction = new QAction( KIcon( "configure" ), i18n( "&Configure %1", \
prettyName() ),  this );
     m_configureAction->setProperty( "popupdropper_svg_id", "configure" );
@@ -182,6 +172,23 @@ UmsCollection::init()
     m_ejectAction->setProperty( "popupdropper_svg_id", "eject" );
     connect( m_ejectAction, SIGNAL( triggered() ), SLOT( slotEject() ) );
 
+    if( storageAccess->isAccessible() )
+        init();
+}
+
+UmsCollection::~UmsCollection()
+{
+    DEBUG_BLOCK
+}
+
+void
+UmsCollection::init()
+{
+    Solid::StorageAccess *storageAccess = m_device.as<Solid::StorageAccess>();
+    m_mountPoint = storageAccess->filePath();
+    debug() << "Mounted at: " << m_mountPoint;
+
+    //read .is_audio_player from filesystem
     KUrl playerFilePath( m_mountPoint );
     playerFilePath.addPath( s_settingsFileName );
     QFile playerFile( playerFilePath.toLocalFile() );
@@ -264,13 +271,17 @@ UmsCollection::init()
         }
     }
 
+    m_initialized = true;
+
     if( m_autoConnect )
         slotParseTracks();
 }
 
-UmsCollection::~UmsCollection()
+void
+UmsCollection::deInit()
 {
-    DEBUG_BLOCK
+    m_initialized = false;
+    m_mc.clear();
 }
 
 bool
@@ -382,7 +393,7 @@ UmsCollection::hasCapabilityInterface( \
Capabilities::Capability::Type type ) con  }
 }
 
-Capabilities::Capability*
+Capabilities::Capability *
 UmsCollection::createCapabilityInterface( Capabilities::Capability::Type type )
 {
     switch( type )
@@ -390,9 +401,12 @@ UmsCollection::createCapabilityInterface( \
Capabilities::Capability::Type type )  case Capabilities::Capability::Actions:
         {
             QList< QAction* > actions;
-            actions << m_parseAction;
-            actions << m_configureAction;
-            actions << m_ejectAction;
+            if( m_initialized )
+            {
+                actions << m_parseAction;
+                actions << m_configureAction;
+                actions << m_ejectAction;
+            }
             return new Capabilities::ActionsCapability( actions );
         }
         default:
@@ -440,8 +454,7 @@ UmsCollection::slotAccessibilityChanged( bool accessible, const \
QString &udi )  if( accessible )
         init();
     else
-        //TODO: de-init so the entry remains valid
-        emit remove();
+        deInit();
 }
 
 void
diff --git a/src/core-impl/collections/umscollection/UmsCollection.h \
b/src/core-impl/collections/umscollection/UmsCollection.h index 4628c72..46eeb24 \
                100644
--- a/src/core-impl/collections/umscollection/UmsCollection.h
+++ b/src/core-impl/collections/umscollection/UmsCollection.h
@@ -121,7 +121,10 @@ class UmsCollection : public Collection
         void slotDirectoryScanned( CollectionScanner::Directory *dir );
 
     private:
+        /** enable the collection after the volume got mounted */
         void init();
+        /** disable the collection, but don't remove it yet so it stays in the \
collection view */ +        void deInit();
 
         //static variables relating to the on-disk configuration file
         static QString s_settingsFileName;
@@ -138,6 +141,7 @@ class UmsCollection : public Collection
 
         Solid::Device m_device;
         QSharedPointer<MemoryCollection> m_mc;
+        bool m_initialized;
 
         bool m_autoConnect;
         QString m_mountPoint;


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

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