diff --git a/src/app/qgsfieldsproperties.cpp b/src/app/qgsfieldsproperties.cpp index 9a16d91045a1..2377df7c803b 100644 --- a/src/app/qgsfieldsproperties.cpp +++ b/src/app/qgsfieldsproperties.cpp @@ -113,30 +113,31 @@ bool QgsAttributesTree::dropMimeData( QTreeWidgetItem * parent, int index, const { QByteArray itemData = data->data( "application/x-qabstractitemmodeldatalist" ); QDataStream stream( &itemData, QIODevice::ReadOnly ); - int r, c; - QMap roleDataMap; - stream >> r >> c >> roleDataMap; + int row, col; - QString itemType = roleDataMap.value( Qt::UserRole ).toString(); - QString itemName = roleDataMap.value( Qt::DisplayRole ).toString(); - - if ( itemType == "field" ) // + while ( !stream.atEnd() ) { - if ( parent ) - { - addItem( parent, itemName ); - bDropSuccessful = true; - } - else // Should never happen as we ignore drops of fields onto the root element in dragMoveEvent, but actually does happen. Qt? + QMap roleDataMap; + stream >> row >> col >> roleDataMap; + + if ( col == 1 ) { - // addItem( invisibleRootItem(), itemName ); - // bDropSuccessful = true; + /* do something with the data */ + + QString itemName = roleDataMap.value( Qt::DisplayRole ).toString(); + + if ( parent ) + { + addItem( parent, itemName ); + bDropSuccessful = true; + } + else // Should never happen as we ignore drops of fields onto the root element in dragMoveEvent, but actually does happen. Qt? + { + // addItem( invisibleRootItem(), itemName ); + // bDropSuccessful = true; + } } } - else - { - bDropSuccessful = QTreeWidget::dropMimeData( parent, index, data, Qt::MoveAction ); - } } return bDropSuccessful; @@ -150,30 +151,9 @@ void QgsAttributesTree::dropEvent( QDropEvent *event ) if ( event->source() == this ) { event->setDropAction( Qt::MoveAction ); - QTreeWidget::dropEvent( event ); } - else - { - // Qt::DropAction dropAction; - QByteArray itemData = event->mimeData()->data( "application/x-qabstractitemmodeldatalist" ); - QDataStream stream( &itemData, QIODevice::ReadOnly ); - int r, c, rDummy, cDummy; - QMap roleDataMap, newRoleDataMap, roleDataMapDummy; - stream >> rDummy >> cDummy >> roleDataMapDummy >> r >> c >> roleDataMap; // fieldName is in second column - - QString fieldName = roleDataMap.value( Qt::DisplayRole ).toString(); - newRoleDataMap.insert( Qt::UserRole , "field" ); - newRoleDataMap.insert( Qt::DisplayRole , fieldName ); - QMimeData * mimeData = new QMimeData(); - QByteArray mdata; - QDataStream newStream( &mdata, QIODevice::WriteOnly ); - newStream << r << c << newRoleDataMap; - mimeData->setData( QString( "application/x-qabstractitemmodeldatalist" ), mdata ); - QDropEvent newEvent = QDropEvent( event->pos(), Qt::CopyAction , mimeData, event->mouseButtons(), event->keyboardModifiers() ); - - QTreeWidget::dropEvent( &newEvent ); - } + QTreeWidget::dropEvent( event ); } QgsFieldsProperties::QgsFieldsProperties( QgsVectorLayer *layer, QWidget* parent ) diff --git a/src/app/qgsfieldsproperties.h b/src/app/qgsfieldsproperties.h index 7b9e5945384f..6971d2f457bb 100644 --- a/src/app/qgsfieldsproperties.h +++ b/src/app/qgsfieldsproperties.h @@ -34,8 +34,8 @@ class QgsAttributesList : public QTableWidget protected: // virtual void dragMoveEvent( QDragMoveEvent *event ); - //QMimeData *mimeData( const QList items ) const; - //Qt::DropActions supportedDropActions() const; + // QMimeData *mimeData( const QList items ) const; + // Qt::DropActions supportedDropActions() const; }; class QgsAttributesTree : public QTreeWidget