summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYoann Laissus <yoann.laissus@gmail.com>2011-05-15 14:40:17 +0200
committerYoann Laissus <yoann.laissus@gmail.com>2011-05-15 14:40:17 +0200
commitebfe1e6f68e5e2b65693822f2b07ad6674dc0031 (patch)
tree3cedcb979627c87f7e61f78dd8d8872ce1b4fc8f
parentOpen source code by loading the page HTML instead of requesting (another time... (diff)
downloadrekonq-ebfe1e6f68e5e2b65693822f2b07ad6674dc0031.tar.xz
- Fix bookmark conflict between Rekonq and Konqueror
- New way to copy rekonq default bookmarks so no problem with konqueror anymore BUG: 273134
-rw-r--r--src/bookmarks/bookmarkprovider.cpp63
-rw-r--r--src/bookmarks/bookmarkprovider.h1
2 files changed, 41 insertions, 23 deletions
diff --git a/src/bookmarks/bookmarkprovider.cpp b/src/bookmarks/bookmarkprovider.cpp
index cef6eaeb..fc351320 100644
--- a/src/bookmarks/bookmarkprovider.cpp
+++ b/src/bookmarks/bookmarkprovider.cpp
@@ -54,31 +54,20 @@ BookmarkProvider::BookmarkProvider(QObject *parent)
, m_owner(0)
, m_actionCollection(new KActionCollection(this))
{
- // NOTE
- // This hackish code is needed to continue sharing bookmarks with konqueror,
- // until we can (hopefully) start using an akonadi resource.
- //
- // The cleanest code has a subdole bug inside does not allowing people to start
- // using rekonq and then using konqueror. So if konqueror bk file has not just been created,
- // bk are stored in rekonq dir and then they will be lost when you start using konqi
-
- KUrl bookfile = KUrl("~/.kde/share/apps/konqueror/bookmarks.xml"); // share konqueror bookmarks
- if (!QFile::exists(bookfile.path()))
+ m_manager = KBookmarkManager::userBookmarksManager();
+ const QString bookmarksFile = KStandardDirs::locateLocal("data", QString::fromLatin1("konqueror/bookmarks.xml"));
+
+ if (!QFile::exists(bookmarksFile))
{
- bookfile = KUrl("~/.kde4/share/apps/konqueror/bookmarks.xml");
- if (!QFile::exists(bookfile.path()))
- {
- QString bookmarksDefaultPath = KStandardDirs::locate("appdata" , "defaultbookmarks.xbel");
- QFile bkms(bookmarksDefaultPath);
- QString bookmarksPath = KStandardDirs::locateLocal("appdata", "bookmarks.xml", true);
- bookmarksPath.replace("rekonq", "konqueror");
- bkms.copy(bookmarksPath);
- bookfile = KUrl(bookmarksPath);
- }
- }
+ kDebug() << "copying of defaultbookmarks.xbel ...";
+
+ QString bookmarksDefaultPath = KStandardDirs::locate("appdata" , "defaultbookmarks.xbel");
+ KBookmarkManager *tempManager = KBookmarkManager::managerForExternalFile(bookmarksDefaultPath);
- m_manager = KBookmarkManager::managerForFile(bookfile.path(), "rekonq");
- m_manager->setEditorOptions("", true);
+ copyBookmarkGroup(tempManager->root(), rootGroup());
+ m_manager->emitChanged();
+ delete tempManager;
+ }
connect(m_manager, SIGNAL(changed(const QString &, const QString &)),
this, SLOT(slotBookmarksChanged()));
@@ -303,3 +292,31 @@ KBookmark BookmarkProvider::bookmarkForUrl(const KBookmark &bookmark, const KUrl
return found;
}
+
+
+void BookmarkProvider::copyBookmarkGroup(const KBookmarkGroup &groupToCopy, KBookmarkGroup destGroup)
+{
+ KBookmark bookmark = groupToCopy.first();
+ while (!bookmark.isNull())
+ {
+ if (bookmark.isGroup())
+ {
+ KBookmarkGroup newDestGroup = destGroup.createNewFolder(bookmark.text());
+ if (bookmark.toGroup().isToolbarGroup())
+ {
+ newDestGroup.internalElement().setAttribute("toolbar", "yes");
+ newDestGroup.setIcon("bookmark-toolbar");
+ }
+ copyBookmarkGroup(bookmark.toGroup(), newDestGroup);
+ }
+ else if (bookmark.isSeparator())
+ {
+ destGroup.createNewSeparator();
+ }
+ else
+ {
+ destGroup.addBookmark(bookmark.text(), bookmark.url());
+ }
+ bookmark = groupToCopy.next(bookmark);
+ }
+}
diff --git a/src/bookmarks/bookmarkprovider.h b/src/bookmarks/bookmarkprovider.h
index 4af97ef7..fe49eaee 100644
--- a/src/bookmarks/bookmarkprovider.h
+++ b/src/bookmarks/bookmarkprovider.h
@@ -144,6 +144,7 @@ Q_SIGNALS:
private:
void find(QList<KBookmark> *list, const KBookmark &bookmark, const QString &text);
KBookmark bookmarkForUrl(const KBookmark &bookmark, const KUrl &url);
+ void copyBookmarkGroup(const KBookmarkGroup &groupToCopy, KBookmarkGroup destGroup);
KBookmarkManager *m_manager;
BookmarkOwner *m_owner;