Skip to content
Permalink
Browse files

De-duplicate code when adding scales to the list of scales.

  • Loading branch information
SebDieBln committed Dec 8, 2015
1 parent 44fae1a commit 7671626843703763557d8713adfc3e5e58f2b306
Showing with 15 additions and 16 deletions.
  1. +13 −16 src/app/qgsoptions.cpp
  2. +2 −0 src/app/qgsoptions.h
@@ -689,10 +689,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) :
QStringList myScalesList = myPaths.split( ',' );
Q_FOREACH ( const QString& scale, myScalesList )
{
QListWidgetItem* newItem = new QListWidgetItem( mListGlobalScales );
newItem->setText( scale );
newItem->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable );
mListGlobalScales->addItem( newItem );
addScaleToScaleList( scale );
}
}

@@ -1922,10 +1919,7 @@ void QgsOptions::on_pbnAddScale_clicked()

if ( myScale != -1 )
{
QListWidgetItem* newItem = new QListWidgetItem( mListGlobalScales );
newItem->setText( QString( "1:%1" ).arg( myScale ) );
newItem->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable );
mListGlobalScales->addItem( newItem );
QListWidgetItem* newItem = addScaleToScaleList( QString( "1:%1" ).arg( myScale ) );
mListGlobalScales->setCurrentItem( newItem );
}
}
@@ -1944,10 +1938,7 @@ void QgsOptions::on_pbnDefaultScaleValues_clicked()
QStringList myScalesList = PROJECT_SCALES.split( ',' );
Q_FOREACH ( const QString& scale, myScalesList )
{
QListWidgetItem* newItem = new QListWidgetItem( mListGlobalScales );
newItem->setText( scale );
newItem->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable );
mListGlobalScales->addItem( newItem );
addScaleToScaleList( scale );
}
}

@@ -1969,10 +1960,7 @@ void QgsOptions::on_pbnImportScales_clicked()

Q_FOREACH ( const QString& scale, myScales )
{
QListWidgetItem* newItem = new QListWidgetItem( mListGlobalScales );
newItem->setText( scale );
newItem->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable );
mListGlobalScales->addItem( newItem );
addScaleToScaleList( scale );
}
}

@@ -2161,3 +2149,12 @@ void QgsOptions::on_mButtonExportColors_clicked()
return;
}
}

QListWidgetItem* QgsOptions::addScaleToScaleList( const QString &newScale )
{
QListWidgetItem* newItem = new QListWidgetItem();
newItem->setText( newScale );
newItem->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable );
mListGlobalScales->addItem( newItem );
return newItem;
}
@@ -214,6 +214,8 @@ class APP_EXPORT QgsOptions : public QgsOptionsDialogBase, private Ui::QgsOption

void saveDefaultDatumTransformations();

QListWidgetItem* addScaleToScaleList( const QString &newScale );

protected:
QgisAppStyleSheet* mStyleSheetBuilder;
QMap<QString, QVariant> mStyleSheetNewOpts;

0 comments on commit 7671626

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