1 /***************************************************************************
2 * Copyright (C) 2012 by Peter Penz <peter.penz19@gmail.com> *
4 * Based on KFilePlacesModel from kdelibs: *
5 * Copyright (C) 2007 Kevin Ottens <ervin@kde.org> *
6 * Copyright (C) 2007 David Faure <faure@kde.org> *
8 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
13 * This program is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
18 * You should have received a copy of the GNU General Public License *
19 * along with this program; if not, write to the *
20 * Free Software Foundation, Inc., *
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
22 ***************************************************************************/
24 #include "placesitemmodel.h"
25 #include "placesitemsignalhandler.h"
27 #include "dolphin_generalsettings.h"
30 #include <KBookmarkManager>
31 #include "dolphindebug.h"
33 #include <KProtocolInfo>
34 #include <KLocalizedString>
35 #include <QStandardPaths>
37 #include "placesitem.h"
42 #include <KUrlMimeData>
43 #include <KFilePlacesModel>
45 #include <Solid/Device>
46 #include <Solid/DeviceNotifier>
47 #include <Solid/OpticalDisc>
48 #include <Solid/OpticalDrive>
49 #include <Solid/StorageAccess>
50 #include <Solid/StorageDrive>
52 #include <views/dolphinview.h>
53 #include <views/viewproperties.h>
56 // Hence a prefix to the application-name of the stored bookmarks is
57 // added, which is only read by PlacesItemModel.
58 const char AppNamePrefix
[] = "-places-panel";
61 PlacesItemModel::PlacesItemModel(QObject
* parent
) :
62 KStandardItemModel(parent
),
63 m_hiddenItemsShown(false),
64 m_deviceToTearDown(nullptr),
65 m_storageSetupInProgress(),
66 m_sourceModel(new KFilePlacesModel(this))
69 initializeDefaultViewProperties();
71 connect(m_sourceModel
.data(), &KFilePlacesModel::rowsInserted
, this, &PlacesItemModel::onSourceModelRowsInserted
);
72 connect(m_sourceModel
.data(), &KFilePlacesModel::rowsAboutToBeRemoved
, this, &PlacesItemModel::onSourceModelRowsAboutToBeRemoved
);
73 connect(m_sourceModel
.data(), &KFilePlacesModel::dataChanged
, this, &PlacesItemModel::onSourceModelDataChanged
);
74 connect(m_sourceModel
.data(), &KFilePlacesModel::rowsAboutToBeMoved
, this, &PlacesItemModel::onSourceModelRowsAboutToBeMoved
);
75 connect(m_sourceModel
.data(), &KFilePlacesModel::rowsMoved
, this, &PlacesItemModel::onSourceModelRowsMoved
);
78 PlacesItemModel::~PlacesItemModel()
82 void PlacesItemModel::createPlacesItem(const QString
& text
,
84 const QString
& iconName
,
87 m_sourceModel
->addPlace(text
, url
, iconName
, {}, mapToSource(after
));
90 PlacesItem
* PlacesItemModel::placesItem(int index
) const
92 return dynamic_cast<PlacesItem
*>(item(index
));
95 int PlacesItemModel::hiddenCount() const
97 return m_sourceModel
->hiddenCount();
100 void PlacesItemModel::setHiddenItemsShown(bool show
)
102 if (m_hiddenItemsShown
== show
) {
106 m_hiddenItemsShown
= show
;
109 for (int r
= 0, rMax
= m_sourceModel
->rowCount(); r
< rMax
; r
++) {
110 const QModelIndex index
= m_sourceModel
->index(r
, 0);
111 if (!m_sourceModel
->isHidden(index
)) {
114 addItemFromSourceModel(index
);
117 for (int r
= 0, rMax
= m_sourceModel
->rowCount(); r
< rMax
; r
++) {
118 const QModelIndex index
= m_sourceModel
->index(r
, 0);
119 if (m_sourceModel
->isHidden(index
)) {
120 removeItemByIndex(index
);
125 #ifdef PLACESITEMMODEL_DEBUG
126 qCDebug(DolphinDebug
) << "Changed visibility of hidden items";
131 bool PlacesItemModel::hiddenItemsShown() const
133 return m_hiddenItemsShown
;
136 int PlacesItemModel::closestItem(const QUrl
& url
) const
138 return mapFromSource(m_sourceModel
->closestItem(url
));
141 // look for the correct position for the item based on source model
142 void PlacesItemModel::insertSortedItem(PlacesItem
* item
)
148 const KBookmark iBookmark
= item
->bookmark();
149 const QString iBookmarkId
= bookmarkId(iBookmark
);
150 QModelIndex sourceIndex
;
153 for(int r
= 0, rMax
= m_sourceModel
->rowCount(); r
< rMax
; r
++) {
154 sourceIndex
= m_sourceModel
->index(r
, 0);
156 if (bookmarkId(m_sourceModel
->bookmarkForIndex(sourceIndex
)) == iBookmarkId
) {
160 if (!m_sourceModel
->isHidden(sourceIndex
)) {
165 m_indexMap
.insert(pos
, sourceIndex
);
166 insertItem(pos
, item
);
169 void PlacesItemModel::onItemInserted(int index
)
171 KStandardItemModel::onItemInserted(index
);
172 #ifdef PLACESITEMMODEL_DEBUG
173 qCDebug(DolphinDebug
) << "Inserted item" << index
;
178 void PlacesItemModel::onItemRemoved(int index
, KStandardItem
* removedItem
)
180 m_indexMap
.removeAt(index
);
182 KStandardItemModel::onItemRemoved(index
, removedItem
);
183 #ifdef PLACESITEMMODEL_DEBUG
184 qCDebug(DolphinDebug
) << "Removed item" << index
;
189 void PlacesItemModel::onItemChanged(int index
, const QSet
<QByteArray
>& changedRoles
)
191 const QModelIndex sourceIndex
= mapToSource(index
);
192 const PlacesItem
*changedItem
= placesItem(mapFromSource(sourceIndex
));
194 if (!changedItem
|| !sourceIndex
.isValid()) {
195 qWarning() << "invalid item changed signal";
199 if (changedRoles
.contains("isHidden")) {
200 m_sourceModel
->setPlaceHidden(sourceIndex
, changedItem
->isHidden());
203 KStandardItemModel::onItemChanged(index
, changedRoles
);
206 QAction
* PlacesItemModel::ejectAction(int index
) const
208 const PlacesItem
* item
= placesItem(index
);
209 if (item
&& item
->device().is
<Solid::OpticalDisc
>()) {
210 return new QAction(QIcon::fromTheme(QStringLiteral("media-eject")), i18nc("@item", "Eject"), nullptr);
216 QAction
* PlacesItemModel::teardownAction(int index
) const
218 const PlacesItem
* item
= placesItem(index
);
223 Solid::Device device
= item
->device();
224 const bool providesTearDown
= device
.is
<Solid::StorageAccess
>() &&
225 device
.as
<Solid::StorageAccess
>()->isAccessible();
226 if (!providesTearDown
) {
230 Solid::StorageDrive
* drive
= device
.as
<Solid::StorageDrive
>();
232 drive
= device
.parent().as
<Solid::StorageDrive
>();
235 bool hotPluggable
= false;
236 bool removable
= false;
238 hotPluggable
= drive
->isHotpluggable();
239 removable
= drive
->isRemovable();
244 if (device
.is
<Solid::OpticalDisc
>()) {
245 text
= i18nc("@item", "Release");
246 } else if (removable
|| hotPluggable
) {
247 text
= i18nc("@item", "Safely Remove");
248 iconName
= QStringLiteral("media-eject");
250 text
= i18nc("@item", "Unmount");
251 iconName
= QStringLiteral("media-eject");
254 if (iconName
.isEmpty()) {
255 return new QAction(text
, nullptr);
258 return new QAction(QIcon::fromTheme(iconName
), text
, nullptr);
261 void PlacesItemModel::requestEject(int index
)
263 const PlacesItem
* item
= placesItem(index
);
265 Solid::OpticalDrive
* drive
= item
->device().parent().as
<Solid::OpticalDrive
>();
267 connect(drive
, &Solid::OpticalDrive::ejectDone
,
268 this, &PlacesItemModel::slotStorageTearDownDone
);
271 const QString label
= item
->text();
272 const QString message
= i18nc("@info", "The device '%1' is not a disk and cannot be ejected.", label
);
273 emit
errorMessage(message
);
278 void PlacesItemModel::requestTearDown(int index
)
280 const PlacesItem
* item
= placesItem(index
);
282 Solid::StorageAccess
*tmp
= item
->device().as
<Solid::StorageAccess
>();
284 m_deviceToTearDown
= tmp
;
285 // disconnect the Solid::StorageAccess::teardownRequested
286 // to prevent emitting PlacesItemModel::storageTearDownExternallyRequested
287 // after we have emitted PlacesItemModel::storageTearDownRequested
288 disconnect(tmp
, &Solid::StorageAccess::teardownRequested
,
289 item
->signalHandler(), &PlacesItemSignalHandler::onTearDownRequested
);
290 emit
storageTearDownRequested(tmp
->filePath());
295 bool PlacesItemModel::storageSetupNeeded(int index
) const
297 const PlacesItem
* item
= placesItem(index
);
298 return item
? item
->storageSetupNeeded() : false;
301 void PlacesItemModel::requestStorageSetup(int index
)
303 const PlacesItem
* item
= placesItem(index
);
308 Solid::Device device
= item
->device();
309 const bool setup
= device
.is
<Solid::StorageAccess
>()
310 && !m_storageSetupInProgress
.contains(device
.as
<Solid::StorageAccess
>())
311 && !device
.as
<Solid::StorageAccess
>()->isAccessible();
313 Solid::StorageAccess
* access
= device
.as
<Solid::StorageAccess
>();
315 m_storageSetupInProgress
[access
] = index
;
317 connect(access
, &Solid::StorageAccess::setupDone
,
318 this, &PlacesItemModel::slotStorageSetupDone
);
324 QMimeData
* PlacesItemModel::createMimeData(const KItemSet
& indexes
) const
329 QDataStream
stream(&itemData
, QIODevice::WriteOnly
);
331 for (int index
: indexes
) {
332 const QUrl itemUrl
= placesItem(index
)->url();
333 if (itemUrl
.isValid()) {
339 QMimeData
* mimeData
= new QMimeData();
340 if (!urls
.isEmpty()) {
341 mimeData
->setUrls(urls
);
343 // #378954: prevent itemDropEvent() drops if there isn't a source url.
344 mimeData
->setData(blacklistItemDropEventMimeType(), QByteArrayLiteral("true"));
346 mimeData
->setData(internalMimeType(), itemData
);
351 bool PlacesItemModel::supportsDropping(int index
) const
353 return index
>= 0 && index
< count();
356 void PlacesItemModel::dropMimeDataBefore(int index
, const QMimeData
* mimeData
)
358 if (mimeData
->hasFormat(internalMimeType())) {
359 // The item has been moved inside the view
360 QByteArray itemData
= mimeData
->data(internalMimeType());
361 QDataStream
stream(&itemData
, QIODevice::ReadOnly
);
365 m_sourceModel
->movePlace(oldIndex
, index
);
366 } else if (mimeData
->hasFormat(QStringLiteral("text/uri-list"))) {
367 // One or more items must be added to the model
368 const QList
<QUrl
> urls
= KUrlMimeData::urlsFromMimeData(mimeData
);
369 for (int i
= urls
.count() - 1; i
>= 0; --i
) {
370 const QUrl
& url
= urls
[i
];
372 QString text
= url
.fileName();
373 if (text
.isEmpty()) {
377 if ((url
.isLocalFile() && !QFileInfo(url
.toLocalFile()).isDir())
378 || url
.scheme() == QLatin1String("trash")) {
379 // Only directories outside the trash are allowed
383 createPlacesItem(text
, url
, QString(), qMax(0, index
- 1));
386 // will save bookmark alteration and fix sort if that is broken by the drag/drop operation
390 void PlacesItemModel::addItemFromSourceModel(const QModelIndex
&index
)
392 const KBookmark bookmark
= m_sourceModel
->bookmarkForIndex(index
);
393 Q_ASSERT(!bookmark
.isNull());
394 PlacesItem
*item
= new PlacesItem(bookmark
);
395 updateItem(item
, index
);
396 insertSortedItem(item
);
398 if (m_sourceModel
->isDevice(index
)) {
399 connect(item
->signalHandler(), &PlacesItemSignalHandler::tearDownExternallyRequested
,
400 this, &PlacesItemModel::storageTearDownExternallyRequested
);
404 void PlacesItemModel::removeItemByIndex(const QModelIndex
&sourceIndex
)
406 QString id
= bookmarkId(m_sourceModel
->bookmarkForIndex(sourceIndex
));
408 for (int i
= 0, iMax
= count(); i
< iMax
; ++i
) {
409 if (bookmarkId(placesItem(i
)->bookmark()) == id
) {
416 QString
PlacesItemModel::bookmarkId(const KBookmark
&bookmark
) const
418 QString id
= bookmark
.metaDataItem(QStringLiteral("UDI"));
420 id
= bookmark
.metaDataItem(QStringLiteral("ID"));
425 void PlacesItemModel::initializeDefaultViewProperties() const
427 for(int i
= 0, iMax
= m_sourceModel
->rowCount(); i
< iMax
; i
++) {
428 const QModelIndex index
= m_sourceModel
->index(i
, 0);
429 const PlacesItem
*item
= placesItem(mapFromSource(index
));
434 // Create default view-properties for all "Search For" and "Recently Saved" bookmarks
435 // in case the user has not already created custom view-properties for a corresponding
437 const bool createDefaultViewProperties
= item
->isSearchOrTimelineUrl() && !GeneralSettings::self()->globalViewProps();
438 if (createDefaultViewProperties
) {
439 const QUrl itemUrl
= item
->url();
440 ViewProperties
props(KFilePlacesModel::convertedUrl(itemUrl
));
441 if (!props
.exist()) {
442 const QString path
= itemUrl
.path();
443 if (path
== QLatin1String("/documents")) {
444 props
.setViewMode(DolphinView::DetailsView
);
445 props
.setPreviewsShown(false);
446 props
.setVisibleRoles({"text", "path"});
447 } else if (path
== QLatin1String("/images")) {
448 props
.setViewMode(DolphinView::IconsView
);
449 props
.setPreviewsShown(true);
450 props
.setVisibleRoles({"text", "imageSize"});
451 } else if (path
== QLatin1String("/audio")) {
452 props
.setViewMode(DolphinView::DetailsView
);
453 props
.setPreviewsShown(false);
454 props
.setVisibleRoles({"text", "artist", "album"});
455 } else if (path
== QLatin1String("/videos")) {
456 props
.setViewMode(DolphinView::IconsView
);
457 props
.setPreviewsShown(true);
458 props
.setVisibleRoles({"text"});
459 } else if (itemUrl
.scheme() == QLatin1String("timeline")) {
460 props
.setViewMode(DolphinView::DetailsView
);
461 props
.setVisibleRoles({"text", "modificationtime"});
469 void PlacesItemModel::updateItem(PlacesItem
*item
, const QModelIndex
&index
)
471 item
->setGroup(index
.data(KFilePlacesModel::GroupRole
).toString());
472 item
->setIcon(index
.data(KFilePlacesModel::IconNameRole
).toString());
475 void PlacesItemModel::slotStorageTearDownDone(Solid::ErrorType error
, const QVariant
& errorData
)
477 if (error
&& errorData
.isValid()) {
478 emit
errorMessage(errorData
.toString());
480 m_deviceToTearDown
->disconnect();
481 m_deviceToTearDown
= nullptr;
484 void PlacesItemModel::slotStorageSetupDone(Solid::ErrorType error
,
485 const QVariant
& errorData
,
490 const int index
= m_storageSetupInProgress
.take(sender());
491 const PlacesItem
* item
= placesItem(index
);
496 if (error
!= Solid::NoError
) {
497 if (errorData
.isValid()) {
498 emit
errorMessage(i18nc("@info", "An error occurred while accessing '%1', the system responded: %2",
500 errorData
.toString()));
502 emit
errorMessage(i18nc("@info", "An error occurred while accessing '%1'",
505 emit
storageSetupDone(index
, false);
507 emit
storageSetupDone(index
, true);
511 void PlacesItemModel::onSourceModelRowsInserted(const QModelIndex
&parent
, int first
, int last
)
513 for (int i
= first
; i
<= last
; i
++) {
514 const QModelIndex index
= m_sourceModel
->index(i
, 0, parent
);
515 addItemFromSourceModel(index
);
519 void PlacesItemModel::onSourceModelRowsAboutToBeRemoved(const QModelIndex
&parent
, int first
, int last
)
521 for(int r
= first
; r
<= last
; r
++) {
522 const QModelIndex index
= m_sourceModel
->index(r
, 0, parent
);
523 int oldIndex
= mapFromSource(index
);
524 if (oldIndex
!= -1) {
525 removeItem(oldIndex
);
530 void PlacesItemModel::onSourceModelRowsAboutToBeMoved(const QModelIndex
&parent
, int start
, int end
, const QModelIndex
&destination
, int row
)
532 Q_UNUSED(destination
);
535 for(int r
= start
; r
<= end
; r
++) {
536 const QModelIndex sourceIndex
= m_sourceModel
->index(r
, 0, parent
);
538 removeItem(mapFromSource(sourceIndex
));
542 void PlacesItemModel::onSourceModelRowsMoved(const QModelIndex
&parent
, int start
, int end
, const QModelIndex
&destination
, int row
)
544 Q_UNUSED(destination
);
547 const int blockSize
= (end
- start
) + 1;
549 for (int r
= start
; r
<= end
; r
++) {
550 // insert the moved item in the new position
551 const int targetRow
= row
+ (start
- r
) - (r
< row
? blockSize
: 0);
552 const QModelIndex targetIndex
= m_sourceModel
->index(targetRow
, 0, destination
);
554 const KBookmark bookmark
= m_sourceModel
->bookmarkForIndex(targetIndex
);
555 PlacesItem
*item
= new PlacesItem(bookmark
);
556 updateItem(item
, targetIndex
);
558 insertSortedItem(item
);
562 void PlacesItemModel::onSourceModelDataChanged(const QModelIndex
&topLeft
, const QModelIndex
&bottomRight
, const QVector
<int> &roles
)
566 for (int r
= topLeft
.row(); r
<= bottomRight
.row(); r
++) {
567 const QModelIndex sourceIndex
= m_sourceModel
->index(r
, 0);
568 const KBookmark bookmark
= m_sourceModel
->bookmarkForIndex(sourceIndex
);
569 PlacesItem
*placeItem
= itemFromBookmark(bookmark
);
571 if (placeItem
&& (!m_hiddenItemsShown
&& m_sourceModel
->isHidden(sourceIndex
))) {
572 //hide item if it became invisible
573 removeItem(index(placeItem
));
577 if (!placeItem
&& (m_hiddenItemsShown
|| !m_sourceModel
->isHidden(sourceIndex
))) {
578 //show item if it became visible
579 addItemFromSourceModel(sourceIndex
);
583 if (placeItem
&& !m_sourceModel
->isDevice(sourceIndex
)) {
584 placeItem
->setText(bookmark
.text());
585 placeItem
->setIcon(sourceIndex
.data(KFilePlacesModel::IconNameRole
).toString());
586 placeItem
->setUrl(m_sourceModel
->url(sourceIndex
));
587 placeItem
->bookmark().setMetaDataItem(QStringLiteral("OnlyInApp"),
588 bookmark
.metaDataItem(QStringLiteral("OnlyInApp")));
593 void PlacesItemModel::loadBookmarks()
595 for(int r
= 0, rMax
= m_sourceModel
->rowCount(); r
< rMax
; r
++) {
596 const QModelIndex sourceIndex
= m_sourceModel
->index(r
, 0);
597 KBookmark bookmark
= m_sourceModel
->bookmarkForIndex(sourceIndex
);
598 if (acceptBookmark(bookmark
) &&
599 (m_hiddenItemsShown
|| !m_sourceModel
->isHidden(sourceIndex
))) {
600 addItemFromSourceModel(sourceIndex
);
604 #ifdef PLACESITEMMODEL_DEBUG
605 qCDebug(DolphinDebug
) << "Loaded bookmarks";
610 bool PlacesItemModel::acceptBookmark(const KBookmark
& bookmark
) const
612 const QString udi
= bookmark
.metaDataItem(QStringLiteral("UDI"));
613 const QUrl url
= bookmark
.url();
614 const QString appName
= bookmark
.metaDataItem(QStringLiteral("OnlyInApp"));
615 const bool allowedHere
= (appName
.isEmpty()
616 || appName
== KAboutData::applicationData().componentName()
617 || appName
== KAboutData::applicationData().componentName() + AppNamePrefix
);
619 return (udi
.isEmpty() && allowedHere
);
622 void PlacesItemModel::clear() {
623 KStandardItemModel::clear();
626 void PlacesItemModel::proceedWithTearDown()
628 Q_ASSERT(m_deviceToTearDown
);
630 connect(m_deviceToTearDown
, &Solid::StorageAccess::teardownDone
,
631 this, &PlacesItemModel::slotStorageTearDownDone
);
632 m_deviceToTearDown
->teardown();
635 void PlacesItemModel::deleteItem(int index
)
637 QModelIndex sourceIndex
= mapToSource(index
);
638 Q_ASSERT(sourceIndex
.isValid());
639 m_sourceModel
->removePlace(sourceIndex
);
642 void PlacesItemModel::refresh()
644 m_sourceModel
->refresh();
647 void PlacesItemModel::hideItem(int index
)
649 PlacesItem
* shownItem
= placesItem(index
);
654 shownItem
->setHidden(true);
657 QString
PlacesItemModel::internalMimeType() const
659 return "application/x-dolphinplacesmodel-" +
660 QString::number((qptrdiff
)this);
663 int PlacesItemModel::groupedDropIndex(int index
, const PlacesItem
* item
) const
667 int dropIndex
= index
;
668 const QString group
= item
->group();
670 const int itemCount
= count();
672 dropIndex
= itemCount
;
675 // Search nearest previous item with the same group
676 int previousIndex
= -1;
677 for (int i
= dropIndex
- 1; i
>= 0; --i
) {
678 if (placesItem(i
)->group() == group
) {
684 // Search nearest next item with the same group
686 for (int i
= dropIndex
; i
< count(); ++i
) {
687 if (placesItem(i
)->group() == group
) {
693 // Adjust the drop-index to be inserted to the
694 // nearest item with the same group.
695 if (previousIndex
>= 0 && nextIndex
>= 0) {
696 dropIndex
= (dropIndex
- previousIndex
< nextIndex
- dropIndex
) ?
697 previousIndex
+ 1 : nextIndex
;
698 } else if (previousIndex
>= 0) {
699 dropIndex
= previousIndex
+ 1;
700 } else if (nextIndex
>= 0) {
701 dropIndex
= nextIndex
;
707 bool PlacesItemModel::equalBookmarkIdentifiers(const KBookmark
& b1
, const KBookmark
& b2
)
709 const QString udi1
= b1
.metaDataItem(QStringLiteral("UDI"));
710 const QString udi2
= b2
.metaDataItem(QStringLiteral("UDI"));
711 if (!udi1
.isEmpty() && !udi2
.isEmpty()) {
714 return b1
.metaDataItem(QStringLiteral("ID")) == b2
.metaDataItem(QStringLiteral("ID"));
718 int PlacesItemModel::mapFromSource(const QModelIndex
&index
) const
720 if (!index
.isValid()) {
724 return m_indexMap
.indexOf(index
);
727 bool PlacesItemModel::isDir(int index
) const
733 QModelIndex
PlacesItemModel::mapToSource(int row
) const
735 return m_indexMap
.value(row
);
738 PlacesItem
*PlacesItemModel::itemFromBookmark(const KBookmark
&bookmark
) const
740 const QString id
= bookmarkId(bookmark
);
741 for (int i
= 0, iMax
= count(); i
< iMax
; i
++) {
742 PlacesItem
*item
= placesItem(i
);
743 const KBookmark itemBookmark
= item
->bookmark();
744 if (bookmarkId(itemBookmark
) == id
) {
751 #ifdef PLACESITEMMODEL_DEBUG
752 void PlacesItemModel::showModelState()
754 qCDebug(DolphinDebug
) << "=================================";
755 qCDebug(DolphinDebug
) << "Model:";
756 qCDebug(DolphinDebug
) << "hidden-index model-index text";
758 for (int i
= 0; i
< m_bookmarkedItems
.count(); ++i
) {
759 if (m_bookmarkedItems
[i
]) {
760 qCDebug(DolphinDebug
) << i
<< "(Hidden) " << " " << m_bookmarkedItems
[i
]->dataValue("text").toString();
762 if (item(modelIndex
)) {
763 qCDebug(DolphinDebug
) << i
<< " " << modelIndex
<< " " << item(modelIndex
)->dataValue("text").toString();
765 qCDebug(DolphinDebug
) << i
<< " " << modelIndex
<< " " << "(not available yet)";
771 qCDebug(DolphinDebug
);
772 qCDebug(DolphinDebug
) << "Bookmarks:";
774 int bookmarkIndex
= 0;
775 KBookmarkGroup root
= m_bookmarkManager
->root();
776 KBookmark bookmark
= root
.first();
777 while (!bookmark
.isNull()) {
778 const QString udi
= bookmark
.metaDataItem("UDI");
779 const QString text
= udi
.isEmpty() ? bookmark
.text() : udi
;
780 if (bookmark
.metaDataItem("IsHidden") == QLatin1String("true")) {
781 qCDebug(DolphinDebug
) << bookmarkIndex
<< "(Hidden)" << text
;
783 qCDebug(DolphinDebug
) << bookmarkIndex
<< " " << text
;
786 bookmark
= root
.next(bookmark
);