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 b36c7c7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/gui/symbology/qgscategorizedsymbolrendererwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Qt::ItemFlags QgsCategorizedSymbolRendererModel::flags( const QModelIndex &index
return Qt::ItemIsDropEnabled;
}

Qt::ItemFlags flags = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsUserCheckable;
Qt::ItemFlags flags = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsUserCheckable;
if ( index.column() == 1 )
{
const QgsRendererCategory category = mRenderer->categories().value( index.row() );
Expand Down Expand Up @@ -398,8 +398,8 @@ 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 )
Q_UNUSED( parent )
if ( action != Qt::MoveAction )
return true;

Expand All @@ -417,7 +417,8 @@ bool QgsCategorizedSymbolRendererModel::dropMimeData( const QMimeData *data, Qt:
rows.append( r );
}

int to = parent.row();
int to = row;

// to is -1 if dragged outside items, i.e. below any item,
// then move to the last position
if ( to == -1 )
Expand Down
7 changes: 4 additions & 3 deletions src/gui/symbology/qgsgraduatedsymbolrendererwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ Qt::ItemFlags QgsGraduatedSymbolRendererModel::flags( const QModelIndex &index )
return Qt::ItemIsDropEnabled;
}

Qt::ItemFlags flags = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsUserCheckable;
Qt::ItemFlags flags = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsUserCheckable;

if ( index.column() == 2 )
{
Expand Down Expand Up @@ -306,8 +306,8 @@ 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 )
Q_UNUSED( parent )
if ( action != Qt::MoveAction )
return true;

Expand All @@ -325,7 +325,8 @@ bool QgsGraduatedSymbolRendererModel::dropMimeData( const QMimeData *data, Qt::D
rows.append( r );
}

int to = parent.row();
int to = 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 b36c7c7

Please sign in to comment.