mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +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>
|
||||
|
||||
KFilePlacesItem::KFilePlacesItem(KBookmarkManager *manager,
|
||||
const QString &address,
|
||||
KFilePlacesItem::KFilePlacesItem(const KBookmark &bookmark,
|
||||
const QString &udi)
|
||||
: m_isCdrom(false), m_isAccessible(false),
|
||||
m_trashIsEmpty(false), m_device(udi)
|
||||
{
|
||||
setBookmark(manager->findByAddress(address));
|
||||
setBookmark(bookmark);
|
||||
|
||||
if (udi.isEmpty() && m_bookmark.metaDataItem("ID").isEmpty()) {
|
||||
m_bookmark.setMetaDataItem("ID", generateNewId());
|
||||
|
@ -119,15 +118,10 @@ Solid::Device KFilePlacesItem::device() const
|
|||
|
||||
QVariant KFilePlacesItem::data(int role) const
|
||||
{
|
||||
QVariant returnData;
|
||||
|
||||
if (role!=KFilePlacesModel::HiddenRole && role!=Qt::BackgroundRole && isDevice()) {
|
||||
returnData = deviceData(role);
|
||||
} else {
|
||||
returnData = bookmarkData(role);
|
||||
return deviceData(role);
|
||||
}
|
||||
|
||||
return returnData;
|
||||
return bookmarkData(role);
|
||||
}
|
||||
|
||||
QVariant KFilePlacesItem::bookmarkData(int role) const
|
||||
|
|
|
@ -40,8 +40,7 @@ class KFilePlacesItem : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
KFilePlacesItem(KBookmarkManager *manager,
|
||||
const QString &address,
|
||||
KFilePlacesItem(const KBookmark &bookmark,
|
||||
const QString &udi = QString());
|
||||
~KFilePlacesItem();
|
||||
|
||||
|
|
|
@ -422,10 +422,10 @@ QList<KFilePlacesItem *> KFilePlacesModel::Private::loadBookmarkList()
|
|||
if ((udi.isEmpty() && allowedHere) || deviceAvailable) {
|
||||
KFilePlacesItem *item;
|
||||
if (deviceAvailable) {
|
||||
item = new KFilePlacesItem(bookmarkManager, bookmark.address(), udi);
|
||||
item = new KFilePlacesItem(bookmark, udi);
|
||||
// TODO: Update bookmark internal element
|
||||
} else {
|
||||
item = new KFilePlacesItem(bookmarkManager, bookmark.address());
|
||||
item = new KFilePlacesItem(bookmark);
|
||||
}
|
||||
connect(item, SIGNAL(itemChanged(QString)),
|
||||
q, SLOT(_k_itemChanged(QString)));
|
||||
|
@ -439,8 +439,7 @@ QList<KFilePlacesItem *> KFilePlacesModel::Private::loadBookmarkList()
|
|||
foreach (const QString &udi, devices) {
|
||||
bookmark = KFilePlacesItem::createDeviceBookmark(bookmarkManager, udi);
|
||||
if (!bookmark.isNull()) {
|
||||
KFilePlacesItem *item = new KFilePlacesItem(bookmarkManager,
|
||||
bookmark.address(), udi);
|
||||
KFilePlacesItem *item = new KFilePlacesItem(bookmark, udi);
|
||||
connect(item, SIGNAL(itemChanged(QString)),
|
||||
q, SLOT(_k_itemChanged(QString)));
|
||||
// TODO: Update bookmark internal element
|
||||
|
|
Loading…
Add table
Reference in a new issue