mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-24 02:42:48 +00:00
kfile: KFilePlacesItem optimizations
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
ad277e865d
commit
7394efdc83
3 changed files with 8 additions and 16 deletions
|
@ -34,13 +34,12 @@
|
||||||
|
|
||||||
#include <QtCore/QDateTime>
|
#include <QtCore/QDateTime>
|
||||||
|
|
||||||
KFilePlacesItem::KFilePlacesItem(KBookmarkManager *manager,
|
KFilePlacesItem::KFilePlacesItem(const KBookmark &bookmark,
|
||||||
const QString &address,
|
|
||||||
const QString &udi)
|
const QString &udi)
|
||||||
: m_isCdrom(false), m_isAccessible(false),
|
: m_isCdrom(false), m_isAccessible(false),
|
||||||
m_trashIsEmpty(false), m_device(udi)
|
m_trashIsEmpty(false), m_device(udi)
|
||||||
{
|
{
|
||||||
setBookmark(manager->findByAddress(address));
|
setBookmark(bookmark);
|
||||||
|
|
||||||
if (udi.isEmpty() && m_bookmark.metaDataItem("ID").isEmpty()) {
|
if (udi.isEmpty() && m_bookmark.metaDataItem("ID").isEmpty()) {
|
||||||
m_bookmark.setMetaDataItem("ID", generateNewId());
|
m_bookmark.setMetaDataItem("ID", generateNewId());
|
||||||
|
@ -119,15 +118,10 @@ Solid::Device KFilePlacesItem::device() const
|
||||||
|
|
||||||
QVariant KFilePlacesItem::data(int role) const
|
QVariant KFilePlacesItem::data(int role) const
|
||||||
{
|
{
|
||||||
QVariant returnData;
|
|
||||||
|
|
||||||
if (role!=KFilePlacesModel::HiddenRole && role!=Qt::BackgroundRole && isDevice()) {
|
if (role!=KFilePlacesModel::HiddenRole && role!=Qt::BackgroundRole && isDevice()) {
|
||||||
returnData = deviceData(role);
|
return deviceData(role);
|
||||||
} else {
|
|
||||||
returnData = bookmarkData(role);
|
|
||||||
}
|
}
|
||||||
|
return bookmarkData(role);
|
||||||
return returnData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant KFilePlacesItem::bookmarkData(int role) const
|
QVariant KFilePlacesItem::bookmarkData(int role) const
|
||||||
|
|
|
@ -40,8 +40,7 @@ class KFilePlacesItem : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
KFilePlacesItem(KBookmarkManager *manager,
|
KFilePlacesItem(const KBookmark &bookmark,
|
||||||
const QString &address,
|
|
||||||
const QString &udi = QString());
|
const QString &udi = QString());
|
||||||
~KFilePlacesItem();
|
~KFilePlacesItem();
|
||||||
|
|
||||||
|
|
|
@ -422,10 +422,10 @@ QList<KFilePlacesItem *> KFilePlacesModel::Private::loadBookmarkList()
|
||||||
if ((udi.isEmpty() && allowedHere) || deviceAvailable) {
|
if ((udi.isEmpty() && allowedHere) || deviceAvailable) {
|
||||||
KFilePlacesItem *item;
|
KFilePlacesItem *item;
|
||||||
if (deviceAvailable) {
|
if (deviceAvailable) {
|
||||||
item = new KFilePlacesItem(bookmarkManager, bookmark.address(), udi);
|
item = new KFilePlacesItem(bookmark, udi);
|
||||||
// TODO: Update bookmark internal element
|
// TODO: Update bookmark internal element
|
||||||
} else {
|
} else {
|
||||||
item = new KFilePlacesItem(bookmarkManager, bookmark.address());
|
item = new KFilePlacesItem(bookmark);
|
||||||
}
|
}
|
||||||
connect(item, SIGNAL(itemChanged(QString)),
|
connect(item, SIGNAL(itemChanged(QString)),
|
||||||
q, SLOT(_k_itemChanged(QString)));
|
q, SLOT(_k_itemChanged(QString)));
|
||||||
|
@ -439,8 +439,7 @@ QList<KFilePlacesItem *> KFilePlacesModel::Private::loadBookmarkList()
|
||||||
foreach (const QString &udi, devices) {
|
foreach (const QString &udi, devices) {
|
||||||
bookmark = KFilePlacesItem::createDeviceBookmark(bookmarkManager, udi);
|
bookmark = KFilePlacesItem::createDeviceBookmark(bookmarkManager, udi);
|
||||||
if (!bookmark.isNull()) {
|
if (!bookmark.isNull()) {
|
||||||
KFilePlacesItem *item = new KFilePlacesItem(bookmarkManager,
|
KFilePlacesItem *item = new KFilePlacesItem(bookmark, udi);
|
||||||
bookmark.address(), udi);
|
|
||||||
connect(item, SIGNAL(itemChanged(QString)),
|
connect(item, SIGNAL(itemChanged(QString)),
|
||||||
q, SLOT(_k_itemChanged(QString)));
|
q, SLOT(_k_itemChanged(QString)));
|
||||||
// TODO: Update bookmark internal element
|
// TODO: Update bookmark internal element
|
||||||
|
|
Loading…
Add table
Reference in a new issue