kdelibs/kdelibs-4.9.2-cache-solid-device-in-kfileplaces.patch

118 lines
4.2 KiB
Diff
Raw Normal View History

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