[Kstars-devel] KDE/kdeedu/kstars/kstars/widgets

Jason Harris kstars at 30doradus.org
Sun Aug 24 23:59:39 CEST 2008


SVN commit 851910 by harris:

Fixing bug #169744 (Catalog fields can't be modified because drag events not 
working).

Well, the drag events work now, but it's difficult to predict what the order of 
items will be when you drop an item.  It's supposed to insert the item in the 
correct place based on the cursor's position, but it looks like there are some 
problems.  I'll leave the bug open until this is working as well as it did in 
3.5.x...

CCBUG: 169744
CCMAIL: kstars-devel at kde.org



 M  +20 -7     draglistbox.cpp  
 M  +1 -0      draglistbox.h  


--- trunk/KDE/kdeedu/kstars/kstars/widgets/draglistbox.cpp #851909:851910
@@ -28,24 +28,37 @@
 DragListBox::DragListBox( QWidget *parent, const char *name )
         : KListWidget( parent ) {
 
-    if ( name )
+    if ( name ) {
         setObjectName( name );
+    }
     setAcceptDrops( true );
     leftButtonDown = false;
 }
 
 DragListBox::~DragListBox() {}
 
+bool DragListBox::contains( const QString &s ) const {
+    QList<QListWidgetItem*> foundList = findItems( s, Qt::MatchExactly );
+    if ( foundList.isEmpty() ) return false;
+    else return true;
+}
+
 void DragListBox::dragEnterEvent( QDragEnterEvent *evt )
 {
-    if ( evt->mimeData()->hasText() )
+    if ( evt->mimeData()->hasText() ) {
         evt->acceptProposedAction();
+    } else {
+        evt->ignore();
+    }
 }
 
-bool DragListBox::contains( const QString &s ) const {
-    QList<QListWidgetItem*> foundList = findItems( s, Qt::MatchExactly );
-    if ( foundList.isEmpty() ) return false;
-    else return true;
+void DragListBox::dragMoveEvent( QDragMoveEvent *evt )
+{
+    if ( evt->mimeData()->hasText() ) {
+        evt->acceptProposedAction();
+    } else {
+        evt->ignore();
+    }
 }
 
 void DragListBox::dropEvent( QDropEvent *evt ) {
@@ -102,7 +115,7 @@
         mimeData->setText( currentItem()->text() );
         drag->setMimeData( mimeData );
 
-        Qt::DropAction dropAction = drag->start();
+        Qt::DropAction dropAction = drag->exec();
         evt->accept();
     }
 }
--- trunk/KDE/kdeedu/kstars/kstars/widgets/draglistbox.h #851909:851910
@@ -48,6 +48,7 @@
     bool contains( const QString &s ) const;
 
     void dragEnterEvent( QDragEnterEvent *evt );
+    void dragMoveEvent( QDragMoveEvent *evt );
     void dropEvent( QDropEvent *evt );
     void mousePressEvent( QMouseEvent *evt );
     void mouseMoveEvent( QMouseEvent * );


More information about the Kstars-devel mailing list