Skip to content

Commit

Permalink
[ux] In graduated and categorized symbol lists, make sure we don't ap…
Browse files Browse the repository at this point in the history
…pend to the end when dropping an item between other items (fix #50823)
  • Loading branch information
gacarrillor committed Feb 11, 2025
1 parent 2027519 commit ac7ec3b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/gui/symbology/qgscategorizedsymbolrendererwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,6 @@ QMimeData *QgsCategorizedSymbolRendererModel::mimeData( const QModelIndexList &i

bool QgsCategorizedSymbolRendererModel::dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent )
{
Q_UNUSED( row )
Q_UNUSED( column )
if ( action != Qt::MoveAction )
return true;
Expand All @@ -417,7 +416,10 @@ bool QgsCategorizedSymbolRendererModel::dropMimeData( const QMimeData *data, Qt:
rows.append( r );
}

int to = parent.row();
// row and parent.row() hold valid positions
// as long as the drop is done over items
int to = row != -1 ? row : parent.row();

// to is -1 if dragged outside items, i.e. below any item,
// then move to the last position
if ( to == -1 )
Expand Down
6 changes: 4 additions & 2 deletions src/gui/symbology/qgsgraduatedsymbolrendererwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ QMimeData *QgsGraduatedSymbolRendererModel::mimeData( const QModelIndexList &ind

bool QgsGraduatedSymbolRendererModel::dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent )
{
Q_UNUSED( row )
Q_UNUSED( column )
if ( action != Qt::MoveAction )
return true;
Expand All @@ -325,7 +324,10 @@ bool QgsGraduatedSymbolRendererModel::dropMimeData( const QMimeData *data, Qt::D
rows.append( r );
}

int to = parent.row();
// row and parent.row() hold valid positions
// as long as the drop is done over items
int to = row != -1 ? row : parent.row();

// to is -1 if dragged outside items, i.e. below any item,
// then move to the last position
if ( to == -1 )
Expand Down

0 comments on commit ac7ec3b

Please sign in to comment.