From 2778dbed9c77624b83f80e371bddfd057760df09 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Thu, 8 Jun 2023 16:11:21 +0300 Subject: [PATCH] kio: remove unused feature to show bookmark folders in toolbars Signed-off-by: Ivailo Monev --- kio/bookmarks/kbookmark.cc | 21 ---------- kio/bookmarks/kbookmark.h | 9 ---- kio/bookmarks/kbookmarkmanager.cc | 68 ++----------------------------- kio/bookmarks/kbookmarkmanager.h | 17 ++------ 4 files changed, 7 insertions(+), 108 deletions(-) diff --git a/kio/bookmarks/kbookmark.cc b/kio/bookmarks/kbookmark.cc index a0f10ef7..dcdd6cba 100644 --- a/kio/bookmarks/kbookmark.cc +++ b/kio/bookmarks/kbookmark.cc @@ -238,27 +238,6 @@ void KBookmarkGroup::deleteBookmark(const KBookmark &bk) element.removeChild(bk.element); } -bool KBookmarkGroup::isToolbarGroup() const -{ - return (element.attribute("toolbar") == "yes"); -} - -QDomElement KBookmarkGroup::findToolbar() const -{ - if (element.attribute("toolbar") == "yes") { - return element; - } - for (QDomElement e = element.firstChildElement("folder"); !e.isNull(); - e = e.nextSiblingElement("folder") ) - { - QDomElement result = KBookmarkGroup(e).findToolbar(); - if (!result.isNull()) { - return result; - } - } - return QDomElement(); -} - QList KBookmarkGroup::groupUrlList() const { QList urlList; diff --git a/kio/bookmarks/kbookmark.h b/kio/bookmarks/kbookmark.h index dc30dc8e..96df4255 100644 --- a/kio/bookmarks/kbookmark.h +++ b/kio/bookmarks/kbookmark.h @@ -392,15 +392,6 @@ public: */ void deleteBookmark(const KBookmark &bk); - /** - * @return true if this is the toolbar group - */ - bool isToolbarGroup() const; - /** - * @internal - */ - QDomElement findToolbar() const; - /** * @return the list of urls of bookmarks at top level of the group */ diff --git a/kio/bookmarks/kbookmarkmanager.cc b/kio/bookmarks/kbookmarkmanager.cc index d2b7162e..825fedec 100644 --- a/kio/bookmarks/kbookmarkmanager.cc +++ b/kio/bookmarks/kbookmarkmanager.cc @@ -128,7 +128,6 @@ public: } mutable QDomDocument m_doc; - mutable QDomDocument m_toolbarDoc; QString m_bookmarksFile; QString m_dbusObjectName; mutable bool m_docIsLoaded; @@ -302,7 +301,6 @@ QDomDocument KBookmarkManager::internalDocument() const { if (!d->m_docIsLoaded) { parse(); - d->m_toolbarDoc.clear(); } return d->m_doc; } @@ -354,32 +352,14 @@ void KBookmarkManager::parse() const d->m_map.setNeedsUpdate(); } -bool KBookmarkManager::save(bool toolbarCache) const +bool KBookmarkManager::save() const { - return saveAs(d->m_bookmarksFile, toolbarCache); + return saveAs(d->m_bookmarksFile); } -bool KBookmarkManager::saveAs(const QString &filename, bool toolbarCache) const +bool KBookmarkManager::saveAs(const QString &filename) const { - kDebug(7043) << "save as" << filename << toolbarCache; - - // Save the bookmark toolbar folder for quick loading - // but only when it will actually make things quicker - const QString cacheFilename = filename + QLatin1String(".tbcache"); - if(toolbarCache && !root().isToolbarGroup()) { - KSaveFile cacheFile(cacheFilename); - if (cacheFile.open()) { - QString str; - QTextStream stream(&str, QIODevice::WriteOnly); - stream << root().findToolbar(); - const QByteArray cstr = str.toUtf8(); - cacheFile.write(cstr.data(), cstr.length()); - cacheFile.finalize(); - } - } else { - // remove any (now) stale cache - QFile::remove(cacheFilename); - } + kDebug(7043) << "save as" << filename; KSaveFile file(filename); if (file.open()) { @@ -422,46 +402,6 @@ KBookmarkGroup KBookmarkManager::root() const return KBookmarkGroup(internalDocument().documentElement()); } -KBookmarkGroup KBookmarkManager::toolbar() -{ - // kDebug(7043) << "toolbar begin"; - // Only try to read from a toolbar cache if the full document isn't loaded - if (!d->m_docIsLoaded) { - kDebug(7043) << "trying toolbar cache"; - const QString cacheFilename = d->m_bookmarksFile + QLatin1String(".tbcache"); - QFileInfo bmInfo(d->m_bookmarksFile); - QFileInfo cacheInfo(cacheFilename); - if (d->m_toolbarDoc.isNull() && - QFile::exists(cacheFilename) && - bmInfo.lastModified() < cacheInfo.lastModified()) - { - kDebug(7043) << "reading file toolbar cache"; - QFile file(cacheFilename); - if (file.open(QIODevice::ReadOnly)) { - d->m_toolbarDoc = QDomDocument("cache"); - d->m_toolbarDoc.setContent(&file); - kDebug(7043) << "toolbar cache opened"; - } - } - if (!d->m_toolbarDoc.isNull()) { - kDebug(7043) << "returning toolbar element"; - QDomElement elem = d->m_toolbarDoc.firstChild().toElement(); - return KBookmarkGroup(elem); - } - } - - // Fallback to the normal way if there is no cache or if the bookmark file - // is already loaded - QDomElement elem = root().findToolbar(); - if (elem.isNull()) { - // Root is the bookmark toolbar if none has been set. - // Make it explicit to speed up invocations of findToolbar() - root().internalElement().setAttribute("toolbar", "yes"); - return root(); - } - return KBookmarkGroup(elem); -} - KBookmark KBookmarkManager::findByAddress(const QString &address) { // kDebug(7043) << "findByAddress" << address; diff --git a/kio/bookmarks/kbookmarkmanager.h b/kio/bookmarks/kbookmarkmanager.h index 8c91360c..b26c860a 100644 --- a/kio/bookmarks/kbookmarkmanager.h +++ b/kio/bookmarks/kbookmarkmanager.h @@ -44,7 +44,7 @@ class KBookmarkManagerPrivate; * * Title of this folder * KDE Web Site - * + * * My own bookmarks * KOffice Web Site * @@ -123,11 +123,10 @@ public: /** * Save the bookmarks to the given XML file on disk. * @param filename full path to the desired bookmarks file location - * @param toolbarCache if true save a cache of the toolbar folder, too * @return true if saving was successful */ // KDE5 TODO: Use an enum and not a bool - bool saveAs(const QString &filename, bool toolbarCache = true) const; + bool saveAs(const QString &filename) const; /** * Update access time stamps for a given url. @@ -159,14 +158,6 @@ public: */ KBookmarkGroup root() const; - /** - * This returns the root of the toolbar menu. - * In the XML, this is the group with the attribute toolbar=yes - * - * @return the toolbar group - */ - KBookmarkGroup toolbar(); - /** * @return the bookmark designated by @p address * @param address the address belonging to the bookmark you're looking for @@ -193,11 +184,9 @@ public: * You should use emitChanged() instead of this function, it saves * and notifies everyone that the file has changed. * Only use this if you don't want the emitChanged signal. - * @param toolbarCache if true save a cache of the toolbar folder, too * @return true if saving was successful */ - // KDE5 TODO: Use an enum and not a bool - bool save(bool toolbarCache = true) const; + bool save() const; void emitConfigChanged();