From: Peter Penz Date: Sat, 7 Jun 2008 12:14:29 +0000 (+0000) Subject: Fixed the following Information Panel issues: X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/2848f1fb5a0e265150bc11c1e7e3ae5d50057007 Fixed the following Information Panel issues: * 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 --- diff --git a/src/infosidebarpage.cpp b/src/infosidebarpage.cpp index 07827fd1d..fdfa230a2 100644 --- a/src/infosidebarpage.cpp +++ b/src/infosidebarpage.cpp @@ -21,12 +21,13 @@ #include +#include +#include #include #include #include #include #include -#include #include #include #include @@ -47,8 +48,6 @@ #include "metatextlabel.h" #include "pixmapviewer.h" -#include - 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; } diff --git a/src/infosidebarpage.h b/src/infosidebarpage.h index bfbaf0e45..b6575751b 100644 --- a/src/infosidebarpage.h +++ b/src/infosidebarpage.h @@ -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 };