[kdelibs] Cache udisks devices in open/save dialog (#868530)

Daniel Vrátil dvratil at fedoraproject.org
Thu Oct 25 14:46:53 UTC 2012


commit b012e5922f16d82963e7968ffb5fb20e320fe5ea
Author: Dan Vrátil <dvratil at redhat.com>
Date:   Thu Oct 25 16:40:57 2012 +0200

    Cache udisks devices in open/save dialog (#868530)

 ...s-4.9.2-cache-solid-device-in-kfileplaces.patch |  117 ++++++++++++++++++++
 kdelibs.spec                                       |   11 ++-
 2 files changed, 127 insertions(+), 1 deletions(-)
---
diff --git a/kdelibs-4.9.2-cache-solid-device-in-kfileplaces.patch b/kdelibs-4.9.2-cache-solid-device-in-kfileplaces.patch
new file mode 100644
index 0000000..ce09b5e
--- /dev/null
+++ b/kdelibs-4.9.2-cache-solid-device-in-kfileplaces.patch
@@ -0,0 +1,117 @@
+diff --git a/kfile/kfileplacesitem.cpp b/kfile/kfileplacesitem.cpp
+index 3ada0c3..52bbef1 100644
+--- a/kfile/kfileplacesitem.cpp
++++ b/kfile/kfileplacesitem.cpp
+@@ -36,7 +36,8 @@
+ KFilePlacesItem::KFilePlacesItem(KBookmarkManager *manager,
+                                  const QString &address,
+                                  const QString &udi)
+-    : m_manager(manager), m_lister(0), m_folderIsEmpty(true), m_device(udi)
++    : m_manager(manager), m_lister(0), m_folderIsEmpty(true), m_isCdrom(false),
++      m_isAccessible(false), m_device(udi)
+ {
+     setBookmark(m_manager->findByAddress(address));
+ 
+@@ -58,8 +59,11 @@ KFilePlacesItem::KFilePlacesItem(KBookmarkManager *manager,
+         m_disc = m_device.as<Solid::OpticalDisc>();
+         if (m_access) {
+             connect(m_access, SIGNAL(accessibilityChanged(bool,QString)),
+-                    this, SLOT(onAccessibilityChanged()));
++                    this, SLOT(onAccessibilityChanged(bool)));
++	    onAccessibilityChanged(m_access->isAccessible());
+         }
++        m_iconPath = m_device.icon();
++	m_emblems = m_device.emblems();
+     }
+ }
+ 
+@@ -171,7 +175,7 @@ QVariant KFilePlacesItem::deviceData(int role) const
+         case Qt::DisplayRole:
+             return d.description();
+         case Qt::DecorationRole:
+-            return KIcon(d.icon(), 0, d.emblems());
++            return KIcon(m_iconPath, 0, m_emblems);
+         case KFilePlacesModel::UrlRole:
+             if (m_access) {
+                 return QUrl(KUrl(m_access->filePath()));
+@@ -183,7 +187,7 @@ QVariant KFilePlacesItem::deviceData(int role) const
+             }
+         case KFilePlacesModel::SetupNeededRole:
+             if (m_access) {
+-                return !m_access->isAccessible();
++                return !m_isAccessible;
+             } else {
+                 return QVariant();
+             }
+@@ -203,16 +207,7 @@ QVariant KFilePlacesItem::deviceData(int role) const
+             }
+ 
+         case KFilePlacesModel::CapacityBarRecommendedRole:
+-        {
+-            bool accessible = m_access && m_access->isAccessible();
+-            bool isCdrom =
+-                ((m_device.is<Solid::StorageDrive>()
+-                        && m_device.as<Solid::StorageDrive>()->driveType() == Solid::StorageDrive::CdromDrive)
+-                || (m_device.parent().is<Solid::StorageDrive>()
+-                        && m_device.parent().as<Solid::StorageDrive>()->driveType() == Solid::StorageDrive::CdromDrive));
+-
+-            return accessible && !isCdrom;
+-        }
++	    return m_isAccessible && !m_isCdrom;
+ 
+         default:
+             return QVariant();
+@@ -291,8 +286,15 @@ QString KFilePlacesItem::generateNewId()
+ //         + '/' + QString::number(qrand());
+ }
+ 
+-void KFilePlacesItem::onAccessibilityChanged()
++void KFilePlacesItem::onAccessibilityChanged(bool isAccessible)
+ {
++    m_isAccessible = isAccessible;
++    m_isCdrom = ((m_device.is<Solid::StorageDrive>()
++                        && m_device.as<Solid::StorageDrive>()->driveType() == Solid::StorageDrive::CdromDrive)
++                || (m_device.parent().is<Solid::StorageDrive>()
++                        && m_device.parent().as<Solid::StorageDrive>()->driveType() == Solid::StorageDrive::CdromDrive));
++    m_emblems = m_device.emblems();
++
+     emit itemChanged(id());
+ }
+ 
+diff --git a/kfile/kfileplacesitem_p.h b/kfile/kfileplacesitem_p.h
+index 3c6bd30..dec3e64 100644
+--- a/kfile/kfileplacesitem_p.h
++++ b/kfile/kfileplacesitem_p.h
+@@ -24,6 +24,7 @@
+ #include <QtCore/QObject>
+ #include <QtCore/QPointer>
+ #include <QtCore/QModelIndex>
++#include <QtCore/QStringList>
+ #include <kbookmark.h>
+ #include <solid/device.h>
+ 
+@@ -69,7 +70,7 @@ Q_SIGNALS:
+     void itemChanged(const QString &id);
+ 
+ private Q_SLOTS:
+-    void onAccessibilityChanged();
++    void onAccessibilityChanged(bool);
+     void onListerCompleted();
+ 
+ private:
+@@ -85,11 +86,15 @@ private:
+     KBookmark m_bookmark;
+     KDirLister *m_lister;
+     bool m_folderIsEmpty;
++    bool m_isCdrom;
++    bool m_isAccessible;
+     QString m_text;
+     mutable Solid::Device m_device;
+     mutable QPointer<Solid::StorageAccess> m_access;
+     mutable QPointer<Solid::StorageVolume> m_volume;
+     mutable QPointer<Solid::OpticalDisc> m_disc;
++    QString m_iconPath;
++    QStringList m_emblems;
+ };
+ 
+ #endif
diff --git a/kdelibs.spec b/kdelibs.spec
index 6fb7b73..6e3e0f0 100644
--- a/kdelibs.spec
+++ b/kdelibs.spec
@@ -25,7 +25,7 @@
 
 Summary: KDE Libraries
 Version: 4.9.2
-Release: 7%{?dist}
+Release: 8%{?dist}
 
 Name: kdelibs
 Epoch: 6
@@ -157,6 +157,10 @@ Patch57: kdelibs-4.9.2-revert-kde#108510-kde#183534.patch
 Patch58: kdelibs-cmake_python3.patch
 
 ## upstream
+# cache solid device icon so that it does not poll udisks2 constantly (rhbz#868530)
+# see https://git.reviewboard.kde.org/r/107030/
+Patch100: kdelibs-4.9.2-cache-solid-device-in-kfileplaces.patch
+
 
 ## security fix
 # Not Upstreamed? why not ? -- Rex
@@ -330,6 +334,7 @@ sed -i -e "s|@@VERSION_RELEASE@@|%{version}-%{release}|" kio/kio/kprotocolmanage
 %patch58 -p1 -b .cmake_python3
 
 # upstream patches
+%patch100 -p1 -b .cache-solid-device-icon
 
 # security fixes
 %patch200 -p1 -b .CVE-2009-2702
@@ -585,6 +590,10 @@ rm -rf %{buildroot}
 
 
 %changelog
+* Thu Oct 25 2012 Dan Vrátil <dvratil at redhat.com> 6:4.9.2-8
+- Resolves #868530 - cache information about solid device in 'Places'
+  panel in  open/save dialog
+
 * Wed Oct 24 2012 Rex Dieter <rdieter at fedoraproject.org> 6:4.9.2-7
 - rebuild (libjpeg-turbo v8)
 


More information about the scm-commits mailing list