diff options
Diffstat (limited to 'src/bookmarks')
-rw-r--r-- | src/bookmarks/bookmarkscontextmenu.cpp | 18 | ||||
-rw-r--r-- | src/bookmarks/bookmarkstoolbar.cpp | 59 |
2 files changed, 54 insertions, 23 deletions
diff --git a/src/bookmarks/bookmarkscontextmenu.cpp b/src/bookmarks/bookmarkscontextmenu.cpp index a473966a..da986fd2 100644 --- a/src/bookmarks/bookmarkscontextmenu.cpp +++ b/src/bookmarks/bookmarkscontextmenu.cpp @@ -69,10 +69,22 @@ void BookmarksContextMenu::addBookmarkActions() void BookmarksContextMenu::addFolderActions() { - if (!bookmark().toGroup().first().isNull()) + KBookmarkGroup group = bookmark().toGroup(); + + if (!group.first().isNull()) { - addAction(bmOwner->action(BookmarkOwner::OPEN_FOLDER)); - addSeparator(); + KBookmark child = group.first(); + + while (child.isGroup() || child.isSeparator()) + { + child = group.next(child); + } + + if (!child.isNull()) + { + addAction(bmOwner->action(BookmarkOwner::OPEN_FOLDER)); + addSeparator(); + } } addAction(bmOwner->action(BookmarkOwner::BOOKMARK_PAGE)); diff --git a/src/bookmarks/bookmarkstoolbar.cpp b/src/bookmarks/bookmarkstoolbar.cpp index bc307965..ddb70a65 100644 --- a/src/bookmarks/bookmarkstoolbar.cpp +++ b/src/bookmarks/bookmarkstoolbar.cpp @@ -38,7 +38,7 @@ // Qt Includes #include <QtGui/QFrame> -#include <QActionEvent> +#include <QtGui/QActionEvent> BookmarkMenu::BookmarkMenu(KBookmarkManager *manager, @@ -124,6 +124,7 @@ void BookmarkMenu::refill() void BookmarkMenu::addOpenFolderInTabs() { + // TODO: Needs to be ported to the new BookmarkOwner API KAction *action; KBookmarkGroup group = manager()->findByAddress(parentAddress()).toGroup(); @@ -336,33 +337,38 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) else if (event->type() == QEvent::Drop) { QDropEvent *dropEvent = static_cast<QDropEvent*>(event); - if (dropEvent->mimeData()->hasFormat("application/rekonq-bookmark")) + QByteArray addresses = dropEvent->mimeData()->data("application/rekonq-bookmark"); + KBookmark bookmark = Application::bookmarkProvider()->bookmarkManager()->findByAddress(QString::fromLatin1(addresses.data())); + + if (!dropEvent->mimeData()->hasFormat("application/rekonq-bookmark") && !bookmark.isNull()) { - QByteArray addresses = dropEvent->mimeData()->data("application/rekonq-bookmark"); - KBookmark bookmark = Application::bookmarkProvider()->bookmarkManager()->findByAddress(QString::fromLatin1(addresses.data())); + return QObject::eventFilter(watched, event); + } - QAction *destAction = toolBar()->actionAt(dropEvent->pos()); - if (destAction && destAction == m_dropAction) + QAction *destAction = toolBar()->actionAt(dropEvent->pos()); + if (destAction && destAction == m_dropAction) + { + if (toolBar()->actions().indexOf(m_dropAction) > 0) { - if (toolBar()->actions().indexOf(m_dropAction) > 0) - { - destAction = toolBar()->actions().at(toolBar()->actions().indexOf(m_dropAction) - 1); - } - else - { - destAction = toolBar()->actions().at(1); - } + destAction = toolBar()->actions().at(toolBar()->actions().indexOf(m_dropAction) - 1); } + else + { + destAction = toolBar()->actions().at(1); + } + } + KBookmarkGroup root = Application::bookmarkProvider()->rootGroup(); + + if (destAction) + { KBookmarkActionInterface *destBookmarkAction = dynamic_cast<KBookmarkActionInterface *>(destAction); QWidget *widgetAction = toolBar()->widgetForAction(destAction); - if (!bookmark.isNull() && destBookmarkAction && !destBookmarkAction->bookmark().isNull() + if (destBookmarkAction && !destBookmarkAction->bookmark().isNull() && widgetAction && bookmark.address() != destBookmarkAction->bookmark().address()) { - KBookmarkGroup root = Application::bookmarkProvider()->rootGroup(); KBookmark destBookmark = destBookmarkAction->bookmark(); - // To fix an issue with panel's drags root.deleteBookmark(bookmark); if ((dropEvent->pos().x() - widgetAction->pos().x()) > (widgetAction->width() / 2)) @@ -373,18 +379,31 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) { root.moveBookmark(bookmark, destBookmark.parentGroup().previous(destBookmark)); } - Application::bookmarkProvider()->bookmarkManager()->emitChanged(); - dropEvent->accept(); } } + else + { + root.deleteBookmark(bookmark); + if (QCursor::pos().x() < toolBar()->widgetForAction(toolBar()->actions().first())->pos().x()) + { + root.moveBookmark(bookmark, KBookmark()); + } + else + { + root.addBookmark(bookmark); + } + + Application::bookmarkProvider()->bookmarkManager()->emitChanged(); + } + dropEvent->accept(); } } else { // Drag handling if (event->type() == QEvent::MouseButtonPress) - {//QMessageBox::information(NULL, "", ""); + { QPoint pos = toolBar()->mapFromGlobal(QCursor::pos()); KBookmarkActionInterface* action = dynamic_cast<KBookmarkActionInterface *>(toolBar()->actionAt(pos)); |