]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Fixed the following Information Panel issues:
authorPeter Penz <peter.penz19@gmail.com>
Sat, 7 Jun 2008 12:14:29 +0000 (12:14 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Sat, 7 Jun 2008 12:14:29 +0000 (12:14 +0000)
* Trash icon is not updated when trash has been emptied or got filled.
* When renaming an item the old name will be shown in the Information Panel.
* When unmounting media, still the mounted icon is shown.

BUG: 161385
BUG: 153514
BUG: 154747
CCBUG: 159366

svn path=/trunk/KDE/kdebase/apps/; revision=818005

src/infosidebarpage.cpp
src/infosidebarpage.h

index 07827fd1dd7d44bfa3c83901948db2eed50e8ea0..fdfa230a21964f75fdda7116a5fdb0e081254d2a 100644 (file)
 
 #include <config-nepomuk.h>
 
+#include <kdialog.h>
+#include <kdirnotify.h>
 #include <kfileplacesmodel.h>
 #include <klocale.h>
 #include <kstandarddirs.h>
 #include <kio/previewjob.h>
 #include <kfileitem.h>
-#include <kdialog.h>
 #include <kglobalsettings.h>
 #include <kfilemetainfo.h>
 #include <kiconeffect.h>
@@ -47,8 +48,6 @@
 #include "metatextlabel.h"
 #include "pixmapviewer.h"
 
-#include <kdebug.h>
-
 InfoSidebarPage::InfoSidebarPage(QWidget* parent) :
     SidebarPage(parent),
     m_initialized(false),
@@ -242,6 +241,61 @@ void InfoSidebarPage::showPreview(const KFileItem& item,
     }
 }
 
+void InfoSidebarPage::slotFileRenamed(const QString& source, const QString& dest)
+{
+    if (m_shownUrl == KUrl(source)) {
+        // the currently shown file has been renamed, hence update the item information
+        // for the renamed file
+        KFileItem item(KFileItem::Unknown, KFileItem::Unknown, KUrl(dest));
+        requestDelayedItemInfo(item);
+    }
+}
+
+void InfoSidebarPage::slotFilesAdded(const QString& directory)
+{
+    if (m_shownUrl == KUrl(directory)) {
+        // If the 'trash' icon changes because the trash has been emptied or got filled,
+        // the signal filesAdded("trash:/") will be emitted.
+        KFileItem item(KFileItem::Unknown, KFileItem::Unknown, KUrl(directory));
+        requestDelayedItemInfo(item);
+    }
+}
+
+void InfoSidebarPage::slotFilesChanged(const QStringList& files)
+{
+    foreach (const QString& fileName, files) {
+        if (m_shownUrl == KUrl(fileName)) {
+            showItemInfo();
+            break;
+        }
+    }
+}
+
+void InfoSidebarPage::slotFilesRemoved(const QStringList& files)
+{
+    foreach (const QString& fileName, files) {
+        if (m_shownUrl == KUrl(fileName)) {
+            // the currently shown item has been removed, show
+            // the parent directory as fallback
+            m_shownUrl = url();
+            showItemInfo();
+            break;
+        }
+    }
+}
+
+void InfoSidebarPage::slotLeftDirectory(const QString& directory)
+{
+    if (m_shownUrl == KUrl(directory)) {
+        // The signal 'leftDirectory' is also emitted when a media
+        // has been unmounted. In this case no directory change will be
+        // done in Dolphin, but the Information Panel must be updated to
+        // indicate an invalid directory.
+        m_shownUrl = url();
+        showItemInfo();
+    }
+}
+
 bool InfoSidebarPage::applyPlace(const KUrl& url)
 {
     KFilePlacesModel* placesModel = DolphinSettings::instance().placesModel();
@@ -427,6 +481,14 @@ void InfoSidebarPage::init()
     layout->addStretch(1);
     setLayout(layout);
 
+    org::kde::KDirNotify* dirNotify = new org::kde::KDirNotify(QString(), QString(),
+                                                               QDBusConnection::sessionBus(), this);
+    connect(dirNotify, SIGNAL(FileRenamed(QString, QString)), SLOT(slotFileRenamed(QString, QString)));
+    connect(dirNotify, SIGNAL(FilesAdded(QString)), SLOT(slotFilesAdded(QString)));
+    connect(dirNotify, SIGNAL(FilesChanged(QStringList)), SLOT(slotFilesChanged(QStringList)));
+    connect(dirNotify, SIGNAL(FilesRemoved(QStringList)), SLOT(slotFilesRemoved(QStringList)));
+    connect(dirNotify, SIGNAL(leftDirectory(QString)), SLOT(slotLeftDirectory(QString)));
+
     m_initialized = true;
 }
 
index bfbaf0e453f7ce99b41c1ea543499baa891376d1..b6575751b4ad699005b0e5482b9c68751d3f8152 100644 (file)
@@ -105,6 +105,12 @@ private slots:
      */
     void showPreview(const KFileItem& item, const QPixmap& pixmap);
 
+    void slotFileRenamed(const QString& source, const QString& dest);
+    void slotFilesAdded(const QString& directory);
+    void slotFilesChanged(const QStringList& files);
+    void slotFilesRemoved(const QStringList& files);
+    void slotLeftDirectory(const QString& directory);
+
 private:
     enum { TimerDelay = 300 };