Skip to content

Commit

Permalink
add old/new scale comparison and emit scaleChanged only if new scale …
Browse files Browse the repository at this point in the history
…is different than old.
  • Loading branch information
amitkulz authored and mhugent committed Feb 28, 2013
1 parent b5dc778 commit f1a85a5
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/gui/qgsscalecombobox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down

1 comment on commit f1a85a5

@alexbruy
Copy link
Contributor

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.