Skip to content

Commit 83759f1

Browse files
committedJun 17, 2019
Correctly ignore unwanted drag events in QgsMapLayerComboBox
1 parent 72af468 commit 83759f1

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed
 

‎src/gui/qgsmaplayercombobox.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,10 @@ QgsMapLayer *QgsMapLayerComboBox::compatibleMapLayerFromMimeData( const QMimeDat
164164
void QgsMapLayerComboBox::dragEnterEvent( QDragEnterEvent *event )
165165
{
166166
if ( !( event->possibleActions() & Qt::CopyAction ) )
167+
{
168+
event->ignore();
167169
return;
170+
}
168171

169172
if ( compatibleMapLayerFromMimeData( event->mimeData() ) )
170173
{
@@ -174,23 +177,33 @@ void QgsMapLayerComboBox::dragEnterEvent( QDragEnterEvent *event )
174177
mDragActive = true;
175178
update();
176179
}
180+
else
181+
{
182+
event->ignore();
183+
}
177184
}
178185

179186
void QgsMapLayerComboBox::dragLeaveEvent( QDragLeaveEvent *event )
180187
{
181-
QComboBox::dragLeaveEvent( event );
182188
if ( mDragActive )
183189
{
184190
event->accept();
185191
mDragActive = false;
186192
update();
187193
}
194+
else
195+
{
196+
event->ignore();
197+
}
188198
}
189199

190200
void QgsMapLayerComboBox::dropEvent( QDropEvent *event )
191201
{
192202
if ( !( event->possibleActions() & Qt::CopyAction ) )
203+
{
204+
event->ignore();
193205
return;
206+
}
194207

195208
if ( QgsMapLayer *layer = compatibleMapLayerFromMimeData( event->mimeData() ) )
196209
{
@@ -201,6 +214,10 @@ void QgsMapLayerComboBox::dropEvent( QDropEvent *event )
201214

202215
setLayer( layer );
203216
}
217+
else
218+
{
219+
event->ignore();
220+
}
204221
mDragActive = false;
205222
update();
206223
}

0 commit comments

Comments
 (0)
Please sign in to comment.