summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2010-08-23 00:04:32 +0200
committerAndrea Diamantini <adjam7@gmail.com>2010-08-23 00:04:32 +0200
commit370ddeb53aa8386816a5ac3fc3a8998a99de55e8 (patch)
treef5325ac2f83fdd27ac7519ff11bd61489c5db878 /src
parentMerge commit 'refs/merge-requests/184' of git://gitorious.org/rekonq/mainline... (diff)
parentForget to commit some changes (diff)
downloadrekonq-370ddeb53aa8386816a5ac3fc3a8998a99de55e8.tar.xz
Merge commit 'refs/merge-requests/185' of git://gitorious.org/rekonq/mainline into m185
Diffstat (limited to 'src')
-rw-r--r--src/bookmarks/bookmarkstoolbar.cpp58
1 files changed, 38 insertions, 20 deletions
diff --git a/src/bookmarks/bookmarkstoolbar.cpp b/src/bookmarks/bookmarkstoolbar.cpp
index 8d35cb8a..68529bd1 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,
@@ -321,33 +321,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))
@@ -358,18 +363,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));