mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
kio: remove unused feature to show bookmark folders in toolbars
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
c8119cf861
commit
2778dbed9c
4 changed files with 7 additions and 108 deletions
|
@ -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<KUrl> KBookmarkGroup::groupUrlList() const
|
||||
{
|
||||
QList<KUrl> urlList;
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -44,7 +44,7 @@ class KBookmarkManagerPrivate;
|
|||
* <folder folded="no">
|
||||
* <title>Title of this folder</title>
|
||||
* <bookmark icon="kde" href="http://www.kde.org"><title>KDE Web Site</title></bookmark>
|
||||
* <folder toolbar="yes">
|
||||
* <folder>
|
||||
* <title>My own bookmarks</title>
|
||||
* <bookmark href="http://www.koffice.org"><title>KOffice Web Site</title></bookmark>
|
||||
* <separator/>
|
||||
|
@ -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();
|
||||
|
|
Loading…
Add table
Reference in a new issue