@@ -113,30 +113,31 @@ bool QgsAttributesTree::dropMimeData( QTreeWidgetItem * parent, int index, const
113
113
{
114
114
QByteArray itemData = data->data ( " application/x-qabstractitemmodeldatalist" );
115
115
QDataStream stream ( &itemData, QIODevice::ReadOnly );
116
- int r, c;
117
- QMap<int , QVariant> roleDataMap;
118
- stream >> r >> c >> roleDataMap;
116
+ int row, col;
119
117
120
- QString itemType = roleDataMap.value ( Qt::UserRole ).toString ();
121
- QString itemName = roleDataMap.value ( Qt::DisplayRole ).toString ();
122
-
123
- if ( itemType == " field" ) //
118
+ while ( !stream.atEnd () )
124
119
{
125
- if ( parent )
126
- {
127
- addItem ( parent, itemName );
128
- bDropSuccessful = true ;
129
- }
130
- else // Should never happen as we ignore drops of fields onto the root element in dragMoveEvent, but actually does happen. Qt?
120
+ QMap<int , QVariant> roleDataMap;
121
+ stream >> row >> col >> roleDataMap;
122
+
123
+ if ( col == 1 )
131
124
{
132
- // addItem( invisibleRootItem(), itemName );
133
- // bDropSuccessful = true;
125
+ /* do something with the data */
126
+
127
+ QString itemName = roleDataMap.value ( Qt::DisplayRole ).toString ();
128
+
129
+ if ( parent )
130
+ {
131
+ addItem ( parent, itemName );
132
+ bDropSuccessful = true ;
133
+ }
134
+ else // Should never happen as we ignore drops of fields onto the root element in dragMoveEvent, but actually does happen. Qt?
135
+ {
136
+ // addItem( invisibleRootItem(), itemName );
137
+ // bDropSuccessful = true;
138
+ }
134
139
}
135
140
}
136
- else
137
- {
138
- bDropSuccessful = QTreeWidget::dropMimeData ( parent, index , data, Qt::MoveAction );
139
- }
140
141
}
141
142
142
143
return bDropSuccessful;
@@ -150,30 +151,9 @@ void QgsAttributesTree::dropEvent( QDropEvent *event )
150
151
if ( event->source () == this )
151
152
{
152
153
event->setDropAction ( Qt::MoveAction );
153
- QTreeWidget::dropEvent ( event );
154
154
}
155
- else
156
- {
157
- // Qt::DropAction dropAction;
158
- QByteArray itemData = event->mimeData ()->data ( " application/x-qabstractitemmodeldatalist" );
159
- QDataStream stream ( &itemData, QIODevice::ReadOnly );
160
- int r, c, rDummy, cDummy;
161
- QMap<int , QVariant> roleDataMap, newRoleDataMap, roleDataMapDummy;
162
- stream >> rDummy >> cDummy >> roleDataMapDummy >> r >> c >> roleDataMap; // fieldName is in second column
163
-
164
- QString fieldName = roleDataMap.value ( Qt::DisplayRole ).toString ();
165
- newRoleDataMap.insert ( Qt::UserRole , " field" );
166
- newRoleDataMap.insert ( Qt::DisplayRole , fieldName );
167
155
168
- QMimeData * mimeData = new QMimeData ();
169
- QByteArray mdata;
170
- QDataStream newStream ( &mdata, QIODevice::WriteOnly );
171
- newStream << r << c << newRoleDataMap;
172
- mimeData->setData ( QString ( " application/x-qabstractitemmodeldatalist" ), mdata );
173
- QDropEvent newEvent = QDropEvent ( event->pos (), Qt::CopyAction , mimeData, event->mouseButtons (), event->keyboardModifiers () );
174
-
175
- QTreeWidget::dropEvent ( &newEvent );
176
- }
156
+ QTreeWidget::dropEvent ( event );
177
157
}
178
158
179
159
QgsFieldsProperties::QgsFieldsProperties ( QgsVectorLayer *layer, QWidget* parent )
0 commit comments