[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdepim/KDE/4.11] calendarviews/agenda: Fix DnD when dropping onto another item instead of the view.
From:       Sergio Martins <iamsergio () gmail ! com>
Date:       2013-09-30 17:24:07
Message-ID: E1VQhCZ-0005av-Sb () scm ! kde ! org
[Download RAW message or body]

Git commit 1da97ef37c2d7dc9dbb94fdbbbb0718705df1511 by Sergio Martins.
Committed on 30/09/2013 at 17:20.
Pushed by smartins into branch 'KDE/4.11'.

Fix DnD when dropping onto another item instead of the view.

The drop event's pos() is relative to the drop target but the code
was expecting view coordinates.

map to view coordinates.

M  +8    -2    calendarviews/agenda/agenda.cpp

http://commits.kde.org/kdepim/1da97ef37c2d7dc9dbb94fdbbbb0718705df1511

diff --git a/calendarviews/agenda/agenda.cpp b/calendarviews/agenda/agenda.cpp
index f278829..aa18eef 100644
--- a/calendarviews/agenda/agenda.cpp
+++ b/calendarviews/agenda/agenda.cpp
@@ -555,7 +555,7 @@ bool Agenda::eventFilter ( QObject *object, QEvent *event )
   }
 }
 
-bool Agenda::eventFilter_drag( QObject *, QDropEvent *de )
+bool Agenda::eventFilter_drag( QObject *obj, QDropEvent *de )
 {
 #ifndef QT_NO_DRAGANDDROP
   const QMimeData *md = de->mimeData();
@@ -591,7 +591,13 @@ bool Agenda::eventFilter_drag( QObject *, QDropEvent *de )
 
     de->setDropAction( Qt::MoveAction );
 
-    const QPoint gridPosition = contentsToGrid( de->pos() );
+    QWidget *dropTarget = qobject_cast<QWidget*>( obj );
+    QPoint dropPosition = de->pos();
+    if ( dropTarget && dropTarget != this ) {
+      dropPosition = dropTarget->mapTo( this, dropPosition );
+    }
+
+    const QPoint gridPosition = contentsToGrid( dropPosition );
     if ( !incidenceUrls.isEmpty() ) {
       emit droppedIncidences( incidenceUrls, gridPosition, d->mAllDayMode );
     } else {
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic