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 );
68 addItems( myScalesList );
70 blockSignals(
false );
77 if ( !currentText().contains(
':' ) )
81 QStringList parts = currentText().split(
':' );
85 long currScale = parts.at( 1 ).toLong( &ok );
86 long nextScale, delta;
87 for (
int i = 0; i < count(); i++ )
89 parts = itemText( i ).split(
':' );
90 nextScale = parts.at( 1 ).toLong( &ok );
91 delta = qAbs( currScale - nextScale );
100 view()->setCurrentIndex( model()->index( idx, 0 ) );
101 blockSignals(
false );
116 double newScale =
toDouble( scaleTxt, &ok );
149 bool ok, userSetScale;
150 QStringList txtList = currentText().split(
':' );
151 txtList.size() == 2 ? userSetScale =
false : userSetScale = true ;
154 newScale =
toDouble( currentText(), &ok );
157 if ( ok && ( newScale != oldScale ) )
160 if ( userSetScale && newScale >= 1.0 )
183 return QString(
"%1:1" ).arg( qRound( scale ) );
187 return QString(
"1:%1" ).arg( qRound( 1.0 / scale ) );
194 QString scaleTxt( scaleString );
196 double scale = QLocale::system().toDouble( scaleTxt, &ok );
205 QStringList txtList = scaleTxt.split(
':' );
206 if ( 2 == txtList.size() )
210 int x = QLocale::system().toInt( txtList[ 0 ], &okX );
211 int y = QLocale::system().toInt( txtList[ 1 ], &okY );
215 scale = ( double )x / (
double )y;