Skip to content
Permalink
Browse files

Change in qgisapp and fixed a test

  • Loading branch information
homann committed Sep 21, 2012
1 parent 1b09393 commit f059e6f89927d721132ff02f3abd254972292a23
Showing with 11 additions and 32 deletions.
  1. +8 −30 src/app/qgisapp.cpp
  2. +2 −1 src/gui/qgsscalecombobox.cpp
  3. +1 −1 tests/src/gui/testqgsscalecombobox.cpp
@@ -1468,15 +1468,16 @@ void QgisApp::createStatusBar()
mScaleEdit->setMaximumHeight( 20 );
mScaleEdit->setContentsMargins( 0, 0, 0, 0 );
// QRegExp validator( "\\d+\\.?\\d*:\\d+\\.?\\d*" );
QRegExp validator( "\\d+\\.?\\d*:\\d+\\.?\\d*|\\d+\\.?\\d*" );
mScaleEditValidator = new QRegExpValidator( validator, mScaleEdit );
mScaleEdit->setValidator( mScaleEditValidator );
// QRegExp validator( "\\d+\\.?\\d*:\\d+\\.?\\d*|\\d+\\.?\\d*" );
// mScaleEditValidator = new QRegExpValidator( validator, mScaleEdit );
// mScaleEdit->setValidator( mScaleEditValidator );
mScaleEdit->setWhatsThis( tr( "Displays the current map scale" ) );
mScaleEdit->setToolTip( tr( "Current map scale (formatted as x:y)" ) );

statusBar()->addPermanentWidget( mScaleEdit, 0 );
connect( mScaleEdit, SIGNAL( currentIndexChanged( const QString & ) ), this, SLOT( userScale() ) );
connect( mScaleEdit->lineEdit(), SIGNAL( editingFinished() ), this, SLOT( userScale() ) );
//connect( mScaleEdit, SIGNAL( currentIndexChanged( const QString & ) ), this, SLOT( userScale() ) );
//connect( mScaleEdit->lineEdit(), SIGNAL( editingFinished() ), this, SLOT( userScale() ) );
connect( mScaleEdit, SIGNAL( scaleChanged() ), this, SLOT( userScale() ) );

//stop rendering status bar widget
mStopRenderButton = new QToolButton( statusBar() );
@@ -5266,31 +5267,8 @@ void QgisApp::showScale( double theScale )

void QgisApp::userScale()
{
if ( mOldScale == mScaleEdit->currentText() )
{
return;
}

QStringList parts = mScaleEdit->currentText().split( ':' );
if ( parts.size() == 2 )
{
bool leftOk, rightOk;
double leftSide = parts.at( 0 ).toDouble( &leftOk );
double rightSide = parts.at( 1 ).toDouble( &rightOk );
if ( leftSide > 0.0 && leftOk && rightOk )
{
mMapCanvas->zoomScale( rightSide / leftSide );
}
}
else
{
bool rightOk;
double rightSide = parts.at( 0 ).toDouble( &rightOk );
if ( rightOk )
{
mMapCanvas->zoomScale( rightSide );
}
}
// Why has MapCanvas the scale inversed?
mMapCanvas->zoomScale( 1.0 / mScaleEdit->scale() );
}

void QgisApp::userCenter()
@@ -117,6 +117,7 @@ double QgsScaleComboBox::scale()
void QgsScaleComboBox::fixupScale()
{
double newScale;
double oldScale = mScale;
bool ok;
QStringList txtList;

@@ -129,7 +130,7 @@ void QgsScaleComboBox::fixupScale()
// or reset to the old
setEditText( toString( mScale ) );

if ( ok )
if ( oldScale != mScale )
{
emit scaleChanged();
}
@@ -102,7 +102,7 @@ void TestQgsScaleComboBox::slot_test()
QTest::keyClicks( l, QLocale::system().toString( 0.02 ) );
QTest::keyClick( l, Qt::Key_Return );
QCOMPARE( spyFixup.count(), 2 ); // Qt emits twice!?
QCOMPARE( spyScaleChanged.count(), 2 ); // Qt emits twice!?
QCOMPARE( spyScaleChanged.count(), 1 );
}

void TestQgsScaleComboBox::cleanup()

0 comments on commit f059e6f

Please sign in to comment.
You can’t perform that action at this time.