Skip to content
Permalink
Browse files
add old/new scale comparison and emit scaleChanged only if new scale …
…is different than old.
  • Loading branch information
amitkulz authored and mhugent committed Feb 28, 2013
1 parent b5dc778 commit f1a85a58a591e45c6dd3c1faa9a218f01cf75955
Showing 1 changed file with 15 additions and 10 deletions.
@@ -146,26 +146,31 @@ void QgsScaleComboBox::fixupScale()
{
double newScale;
double oldScale = mScale;
bool ok;
QStringList txtList;
bool ok, userSetScale;
QStringList txtList = currentText().split( ':' );
txtList.size() == 2 ? userSetScale = false : userSetScale = true ;

// QgsDebugMsg( QString( "entered with oldScale: %1" ).arg( oldScale ) );
newScale = toDouble( currentText(), &ok );
if ( ok )

// Valid string representation
if ( ok && (newScale != oldScale))
{
// Valid string representation
if ( newScale != oldScale )
// if a user types scale = 2345, we transform to 1:2345
if(userSetScale)
{
mScale = 1 / newScale;
}
else
{
// Scale has change, update.
// QgsDebugMsg( QString( "New scale OK!: %1" ).arg( newScale ) );
mScale = newScale;
setScale( mScale );
emit scaleChanged();
}
setScale( mScale );
emit scaleChanged();
}
else
{
// Invalid string representation
// Invalid string representation or same scale
// Reset to the old
setScale( mScale );
}

1 comment on commit f1a85a5

@alexbruy
Copy link
Contributor

@alexbruy alexbruy commented on f1a85a5 Mar 1, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, this commit breaks test for scalecombox

Please sign in to comment.