#include "dolphin_generalsettings.h"
#include <KBookmark>
-#include <KBookmarkGroup>
#include <KBookmarkManager>
-#include <KDebug>
+#include "dolphindebug.h"
#include <QIcon>
-#include <kprotocolinfo.h>
+#include <KProtocolInfo>
#include <KLocalizedString>
-#include <KComponentData>
#include <QStandardPaths>
#include <KUser>
-#include <KGlobal>
+#include <KAboutData>
#include "placesitem.h"
#include <QAction>
#include <QDate>
m_systemBookmarksIndexes(),
m_bookmarkedItems(),
m_hiddenItemToRemove(-1),
- m_saveBookmarksTimer(0),
m_updateBookmarksTimer(0),
m_storageSetupInProgress()
{
Baloo::IndexerConfig config;
m_fileIndexingEnabled = config.fileIndexingEnabled();
#endif
- const QString file = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kfileplaces/bookmarks.xml");
- m_bookmarkManager = KBookmarkManager::managerForFile(file, "kfilePlaces");
+ const QString file = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/user-places.xbel";
+ m_bookmarkManager = KBookmarkManager::managerForExternalFile(file);
createSystemBookmarks();
initializeAvailableDevices();
const int syncBookmarksTimeout = 100;
- m_saveBookmarksTimer = new QTimer(this);
- m_saveBookmarksTimer->setInterval(syncBookmarksTimeout);
- m_saveBookmarksTimer->setSingleShot(true);
- connect(m_saveBookmarksTimer, &QTimer::timeout, this, &PlacesItemModel::saveBookmarks);
-
m_updateBookmarksTimer = new QTimer(this);
m_updateBookmarksTimer->setInterval(syncBookmarksTimeout);
m_updateBookmarksTimer->setSingleShot(true);
connect(m_bookmarkManager, &KBookmarkManager::changed,
m_updateBookmarksTimer, static_cast<void(QTimer::*)()>(&QTimer::start));
- connect(m_bookmarkManager, &KBookmarkManager::bookmarksChanged,
- m_updateBookmarksTimer, static_cast<void(QTimer::*)()>(&QTimer::start));
}
PlacesItemModel::~PlacesItemModel()
{
- saveBookmarks();
qDeleteAll(m_bookmarkedItems);
m_bookmarkedItems.clear();
}
}
#ifdef PLACESITEMMODEL_DEBUG
- kDebug() << "Changed visibility of hidden items";
+ qCDebug(DolphinDebug) << "Changed visibility of hidden items";
showModelState();
#endif
}
m_bookmarkedItems.insert(bookmarkIndex, 0);
}
- triggerBookmarksSaving();
-
#ifdef PLACESITEMMODEL_DEBUG
- kDebug() << "Inserted item" << index;
+ qCDebug(DolphinDebug) << "Inserted item" << index;
showModelState();
#endif
}
Q_ASSERT(!m_bookmarkedItems[boomarkIndex]);
m_bookmarkedItems.removeAt(boomarkIndex);
- triggerBookmarksSaving();
-
#ifdef PLACESITEMMODEL_DEBUG
- kDebug() << "Removed item" << index;
+ qCDebug(DolphinDebug) << "Removed item" << index;
showModelState();
#endif
}
QTimer::singleShot(0, this, SLOT(hideItem()));
}
}
-
- triggerBookmarksSaving();
}
void PlacesItemModel::slotDeviceAdded(const QString& udi)
}
#ifdef PLACESITEMMODEL_DEBUG
- kDebug() << "Loaded bookmarks";
+ qCDebug(DolphinDebug) << "Loaded bookmarks";
showModelState();
#endif
}
const bool deviceAvailable = availableDevices.contains(udi);
const bool allowedHere = (appName.isEmpty()
- || appName == KGlobal::mainComponent().componentName()
- || appName == KGlobal::mainComponent().componentName() + AppNamePrefix)
+ || appName == KAboutData::applicationData().componentName()
+ || appName == KAboutData::applicationData().componentName() + AppNamePrefix)
&& (m_fileIndexingEnabled || (url.scheme() != QLatin1String("timeline") &&
url.scheme() != QLatin1String("search")));
// As long as the KFilePlacesView from kdelibs is available, the system-bookmarks
// for "Recently Saved" and "Search For" should be a setting available only
// in the Places Panel (see description of AppNamePrefix for more details).
- const QString appName = KGlobal::mainComponent().componentName() + AppNamePrefix;
+ const QString appName = KAboutData::applicationData().componentName() + AppNamePrefix;
bookmark.setMetaDataItem("OnlyInApp", appName);
}
"view-calendar-month",
I18N_NOOP2("KFile System Bookmarks", "Last Month")));
m_systemBookmarks.append(SystemBookmarkData(QUrl("search:/documents"),
- "folder-txt",
+ "folder-text",
I18N_NOOP2("KFile System Bookmarks", "Documents")));
m_systemBookmarks.append(SystemBookmarkData(QUrl("search:/images"),
- "folder-image",
+ "folder-images",
I18N_NOOP2("KFile System Bookmarks", "Images")));
m_systemBookmarks.append(SystemBookmarkData(QUrl("search:/audio"),
"folder-sound",
I18N_NOOP2("KFile System Bookmarks", "Audio Files")));
m_systemBookmarks.append(SystemBookmarkData(QUrl("search:/videos"),
- "folder-video",
+ "folder-videos",
I18N_NOOP2("KFile System Bookmarks", "Videos")));
}
// bookmark should still be remembered, so readd it again:
m_bookmarkManager->root().addBookmark(hiddenBookmark);
m_bookmarkManager->root().moveBookmark(hiddenBookmark, previousBookmark);
- triggerBookmarksSaving();
}
m_bookmarkedItems.insert(newIndex, hiddenItem);
}
}
-void PlacesItemModel::triggerBookmarksSaving()
-{
- if (m_saveBookmarksTimer) {
- m_saveBookmarksTimer->start();
- }
-}
-
QString PlacesItemModel::internalMimeType() const
{
return "application/x-dolphinplacesmodel-" +
QUrl PlacesItemModel::searchUrlForType(const QString& type)
{
Baloo::Query query;
- query.addType("File");
query.addType(type);
return query.toSearchUrl();
#ifdef PLACESITEMMODEL_DEBUG
void PlacesItemModel::showModelState()
{
- kDebug() << "=================================";
- kDebug() << "Model:";
- kDebug() << "hidden-index model-index text";
+ qCDebug(DolphinDebug) << "=================================";
+ qCDebug(DolphinDebug) << "Model:";
+ qCDebug(DolphinDebug) << "hidden-index model-index text";
int modelIndex = 0;
for (int i = 0; i < m_bookmarkedItems.count(); ++i) {
if (m_bookmarkedItems[i]) {
- kDebug() << i << "(Hidden) " << " " << m_bookmarkedItems[i]->dataValue("text").toString();
+ qCDebug(DolphinDebug) << i << "(Hidden) " << " " << m_bookmarkedItems[i]->dataValue("text").toString();
} else {
if (item(modelIndex)) {
- kDebug() << i << " " << modelIndex << " " << item(modelIndex)->dataValue("text").toString();
+ qCDebug(DolphinDebug) << i << " " << modelIndex << " " << item(modelIndex)->dataValue("text").toString();
} else {
- kDebug() << i << " " << modelIndex << " " << "(not available yet)";
+ qCDebug(DolphinDebug) << i << " " << modelIndex << " " << "(not available yet)";
}
++modelIndex;
}
}
- kDebug();
- kDebug() << "Bookmarks:";
+ qCDebug(DolphinDebug);
+ qCDebug(DolphinDebug) << "Bookmarks:";
int bookmarkIndex = 0;
KBookmarkGroup root = m_bookmarkManager->root();
const QString udi = bookmark.metaDataItem("UDI");
const QString text = udi.isEmpty() ? bookmark.text() : udi;
if (bookmark.metaDataItem("IsHidden") == QLatin1String("true")) {
- kDebug() << bookmarkIndex << "(Hidden)" << text;
+ qCDebug(DolphinDebug) << bookmarkIndex << "(Hidden)" << text;
} else {
- kDebug() << bookmarkIndex << " " << text;
+ qCDebug(DolphinDebug) << bookmarkIndex << " " << text;
}
bookmark = root.next(bookmark);