22 #include <QAbstractItemView>
32 setInsertPolicy( QComboBox::NoInsert );
34 connect(
this, SIGNAL( activated(
const QString & ) ),
this, SLOT(
fixupScale() ) );
35 connect( lineEdit(), SIGNAL( editingFinished() ),
this, SLOT(
fixupScale() ) );
45 QStringList myScalesList;
46 QString oldScale = currentText();
48 if ( scales.isEmpty() )
51 QString myScales = settings.value(
"Map/scales",
PROJECT_SCALES ).toString();
52 if ( !myScales.isEmpty() )
54 myScalesList = myScales.split(
"," );
59 QStringList::const_iterator scaleIt = scales.constBegin();
60 for ( ; scaleIt != scales.constEnd(); ++scaleIt )
62 myScalesList.append( *scaleIt );
69 for (
int i = 0; i < myScalesList.size(); ++i )
71 parts = myScalesList[ i ] .split(
':' );
72 denominator = QLocale::system().toDouble( parts[1], &ok );
75 myScalesList[ i ] =
toString( 1.0 / denominator );
81 addItems( myScalesList );
83 blockSignals(
false );
90 if ( !currentText().contains(
':' ) )
94 QStringList parts = currentText().split(
':' );
98 long currScale = parts.at( 1 ).toLong( &ok );
99 long nextScale, delta;
100 for (
int i = 0; i < count(); i++ )
102 parts = itemText( i ).split(
':' );
103 nextScale = parts.at( 1 ).toLong( &ok );
104 delta = qAbs( currScale - nextScale );
112 blockSignals(
true );
113 view()->setCurrentIndex( model()->
index( idx, 0 ) );
114 blockSignals(
false );
129 double newScale =
toDouble( scaleTxt, &ok );
162 bool ok, userSetScale;
163 QStringList txtList = currentText().split(
':' );
164 txtList.size() == 2 ? userSetScale =
false : userSetScale = true ;
167 newScale =
toDouble( currentText(), &ok );
170 if ( ok && ( newScale != oldScale ) )
173 if ( userSetScale && newScale >= 1.0 )
196 return QString(
"%1:1" ).arg( QLocale::system().
toString( qRound( scale ) ) );
200 return QString(
"1:%1" ).arg( QLocale::system().
toString( qRound( 1.0 / scale ) ) );
207 QString scaleTxt( scaleString );
209 double scale = QLocale::system().toDouble( scaleTxt, &ok );
218 QStringList txtList = scaleTxt.split(
':' );
219 if ( 2 == txtList.size() )
223 int x = QLocale::system().toInt( txtList[ 0 ], &okX );
224 int y = QLocale::system().toInt( txtList[ 1 ], &okY );
228 scale = ( double )x / (
double )y;