@@ -45,7 +45,7 @@ QgsColorSchemeList::QgsColorSchemeList( QWidget *parent , QgsColorScheme *scheme
45
45
setAcceptDrops ( true );
46
46
setDragDropMode ( QTreeView::DragDrop );
47
47
setDropIndicatorShown ( true );
48
- setDefaultDropAction ( Qt::MoveAction );
48
+ setDefaultDropAction ( Qt::CopyAction );
49
49
}
50
50
51
51
QgsColorSchemeList::~QgsColorSchemeList ()
@@ -414,7 +414,7 @@ Qt::DropActions QgsColorSchemeModel::supportedDropActions() const
414
414
{
415
415
if ( mScheme ->isEditable () )
416
416
{
417
- return Qt::MoveAction | Qt::CopyAction ;
417
+ return Qt::CopyAction | Qt::MoveAction ;
418
418
}
419
419
else
420
420
{
@@ -450,7 +450,7 @@ QMimeData* QgsColorSchemeModel::mimeData( const QModelIndexList &indexes ) const
450
450
colorList << qMakePair ( mColors [( *indexIt ).row ()].first , mColors [( *indexIt ).row ()].second );
451
451
}
452
452
453
- QMimeData* mimeData = QgsSymbolLayerV2Utils::colorListToMimeData ( colorList, false );
453
+ QMimeData* mimeData = QgsSymbolLayerV2Utils::colorListToMimeData ( colorList );
454
454
return mimeData;
455
455
}
456
456
@@ -482,9 +482,31 @@ bool QgsColorSchemeModel::dropMimeData( const QMimeData *data, Qt::DropAction ac
482
482
return false ;
483
483
}
484
484
485
+ // any existing colors? if so, remove them first
486
+ QgsNamedColorList::const_iterator colorIt = droppedColors.constBegin ();
487
+ for ( ; colorIt != droppedColors.constEnd (); ++colorIt )
488
+ {
489
+ // dest color
490
+ QPair< QColor, QString > color = qMakePair (( *colorIt ).first , !( *colorIt ).second .isEmpty () ? ( *colorIt ).second : QgsSymbolLayerV2Utils::colorToName (( *colorIt ).first ) );
491
+ // if color already exists, remove it
492
+ int existingIndex = mColors .indexOf ( color );
493
+ if ( existingIndex >= 0 )
494
+ {
495
+ if ( existingIndex < beginRow )
496
+ {
497
+ // color is before destination row, so decrease destination row to account for removal
498
+ beginRow--;
499
+ }
500
+
501
+ beginRemoveRows ( parent, existingIndex, existingIndex );
502
+ mColors .removeAt ( existingIndex );
503
+ endRemoveRows ();
504
+ }
505
+ }
506
+
485
507
// insert dropped colors
486
508
insertRows ( beginRow, droppedColors.length (), QModelIndex () );
487
- QgsNamedColorList::const_iterator colorIt = droppedColors.constBegin ();
509
+ colorIt = droppedColors.constBegin ();
488
510
for ( ; colorIt != droppedColors.constEnd (); ++colorIt )
489
511
{
490
512
QModelIndex colorIdx = index ( beginRow, 0 , QModelIndex () );
0 commit comments