Skip to content

Commit

Permalink
Avoid adding duplicate scales to the scale list.
Browse files Browse the repository at this point in the history
  • Loading branch information
SebDieBln committed Dec 11, 2015
1 parent 9aff9c5 commit 33ea2a0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/app/qgsoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2152,7 +2152,11 @@ void QgsOptions::on_mButtonExportColors_clicked()

QListWidgetItem* QgsOptions::addScaleToScaleList( const QString &newScale )
{
QListWidgetItem* newItem = new QListWidgetItem();
QListWidgetItem* newItem;
newItem = mListGlobalScales->findItems( newScale, Qt::MatchExactly ).value( 0 );
if ( newItem )
return newItem;

int newDenominator = newScale.split( ":" ).value( 1 ).toInt();
int i;
for ( i = 0; i < mListGlobalScales->count(); i++ )
Expand All @@ -2161,7 +2165,7 @@ QListWidgetItem* QgsOptions::addScaleToScaleList( const QString &newScale )
if ( newDenominator > denominator )
break;
}
newItem->setText( newScale );
newItem = new QListWidgetItem( newScale );
newItem->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable );
mListGlobalScales->insertItem( i, newItem );
return newItem;
Expand Down

0 comments on commit 33ea2a0

Please sign in to comment.