summaryrefslogtreecommitdiff
path: root/src/bookmarks
diff options
context:
space:
mode:
Diffstat (limited to 'src/bookmarks')
-rw-r--r--src/bookmarks/bookmarkcontextmenu.cpp7
-rw-r--r--src/bookmarks/bookmarksmanager.cpp44
-rw-r--r--src/bookmarks/bookmarksmanager.h5
-rw-r--r--src/bookmarks/bookmarkstreemodel.cpp12
4 files changed, 58 insertions, 10 deletions
diff --git a/src/bookmarks/bookmarkcontextmenu.cpp b/src/bookmarks/bookmarkcontextmenu.cpp
index 96668003..019d9eb9 100644
--- a/src/bookmarks/bookmarkcontextmenu.cpp
+++ b/src/bookmarks/bookmarkcontextmenu.cpp
@@ -268,8 +268,11 @@ void BookmarkContextMenu::newBookmarkGroup()
{
KBookmark newBk;
newBk = dialog->createNewFolder("New folder", selected.parentGroup());
- selected.parentGroup().moveBookmark(newBk, selected);
- manager()->emitChanged(newBk.parentGroup());
+ if (!newBk.isNull())
+ {
+ selected.parentGroup().moveBookmark(newBk, selected);
+ manager()->emitChanged(newBk.parentGroup());
+ }
}
}
else
diff --git a/src/bookmarks/bookmarksmanager.cpp b/src/bookmarks/bookmarksmanager.cpp
index 792baaeb..bba9dd77 100644
--- a/src/bookmarks/bookmarksmanager.cpp
+++ b/src/bookmarks/bookmarksmanager.cpp
@@ -388,13 +388,15 @@ BookmarkProvider::~BookmarkProvider()
void BookmarkProvider::setupBookmarkBar(BookmarkToolBar *toolbar)
{
+ if (m_bookmarkToolBars.contains(toolbar))
+ return;
+
kDebug() << "new bookmark bar...";
-
+
m_bookmarkToolBars.append(toolbar);
toolbar->setContextMenuPolicy(Qt::CustomContextMenu);
connect(toolbar, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenu(const QPoint &)));
- slotBookmarksChanged("", "");
kDebug() << "new bookmark bar... DONE!";
}
@@ -591,3 +593,41 @@ void BookmarkProvider::slotPanelChanged()
panel->startLoadFoldedState();
}
}
+
+
+KBookmark BookmarkProvider::bookmarkForUrl(const KUrl &url)
+{
+ KBookmark found;
+
+ KBookmarkGroup root = rootGroup();
+ if (root.isNull())
+ {
+ return found;
+ }
+
+ return bookmarkForUrl(root, url);
+}
+
+
+KBookmark BookmarkProvider::bookmarkForUrl(const KBookmark &bookmark, const KUrl &url)
+{
+ KBookmark found;
+
+ if (bookmark.isGroup())
+ {
+ KBookmarkGroup group = bookmark.toGroup();
+ KBookmark bookmark = group.first();
+
+ while (!bookmark.isNull() && found.isNull())
+ {
+ found = bookmarkForUrl(bookmark, url);
+ bookmark = group.next(bookmark);
+ }
+ }
+ else if (!bookmark.isSeparator() && bookmark.url() == url)
+ {
+ found = bookmark;
+ }
+
+ return found;
+}
diff --git a/src/bookmarks/bookmarksmanager.h b/src/bookmarks/bookmarksmanager.h
index 72ea1c3c..eeb5391d 100644
--- a/src/bookmarks/bookmarksmanager.h
+++ b/src/bookmarks/bookmarksmanager.h
@@ -271,6 +271,8 @@ public:
void registerBookmarkPanel(BookmarksPanel *panel);
void removeBookmarkPanel(BookmarksPanel *panel);
+ KBookmark bookmarkForUrl(const KUrl &url);
+
signals:
/**
* @short This signal is emitted when an url has to be loaded
@@ -305,6 +307,9 @@ private slots:
private:
QList<KBookmark> find(QList<KBookmark> list, const KBookmark &bookmark, QString text);
+ QString titleForBookmarkUrl(const KBookmark &bookmark, const QString &url);
+ KBookmark bookmarkForUrl(const KBookmark &bookmark, const KUrl &url);
+
KBookmarkManager *m_manager;
BookmarkOwner *m_owner;
KActionCollection *m_actionCollection;
diff --git a/src/bookmarks/bookmarkstreemodel.cpp b/src/bookmarks/bookmarkstreemodel.cpp
index 7063bf9b..299efaf0 100644
--- a/src/bookmarks/bookmarkstreemodel.cpp
+++ b/src/bookmarks/bookmarkstreemodel.cpp
@@ -406,15 +406,15 @@ bool BookmarksTreeModel::dropMimeData(const QMimeData *data, Qt::DropAction acti
if (parent.isValid())
root = bookmarkForIndex(parent).toGroup();
- if (!destIndex.isValid())
+ if (destIndex.isValid() && row != -1)
{
- root.deleteBookmark(bookmark);
- root.addBookmark(bookmark);
- }
+ root.moveBookmark(bookmark, root.previous(dropDestBookmark));
- else if (row != 1)
+ }
+ else
{
- root.moveBookmark(bookmark, root.previous(dropDestBookmark));
+ root.deleteBookmark(bookmark);
+ root.addBookmark(bookmark);
}
Application::bookmarkProvider()->bookmarkManager()->emitChanged();