25 mComboBoxMinScale->setScale( 0.0000001 );
26 mComboBoxMaxScale->setScale( 1 );
27 connect( mCheckBoxMinScale, SIGNAL( toggled(
bool ) ),
this, SLOT( configureMinComboBox() ) );
28 connect( mCheckBoxMaxScale, SIGNAL( toggled(
bool ) ),
this, SLOT( configureMaxComboBox() ) );
29 connect( mComboBoxMinScale, SIGNAL( scaleChanged() ),
this, SLOT( configureMaxComboBox() ) );
30 connect( mComboBoxMaxScale, SIGNAL( scaleChanged() ),
this, SLOT( configureMinComboBox() ) );
35 mComboBoxMinScale->setScale( scale.
minScale > 0.0 ? scale.
minScale : 0.0000001 );
36 mCheckBoxMinScale->setChecked( scale.
minScale > 0.0 );
37 mComboBoxMinScale->setEnabled( scale.
minScale > 0.0 );
39 mCheckBoxMaxScale->setChecked( scale.
maxScale > 0.0 );
40 mComboBoxMaxScale->setEnabled( scale.
maxScale > 0.0 );
43 void QgsMapUnitScaleDialog::configureMinComboBox()
45 mComboBoxMinScale->setEnabled( mCheckBoxMinScale->isChecked() );
46 if ( mCheckBoxMinScale->isChecked() && mComboBoxMinScale->scale() > mComboBoxMaxScale->scale() )
48 mComboBoxMinScale->setScale( mComboBoxMaxScale->scale() );
52 void QgsMapUnitScaleDialog::configureMaxComboBox()
54 mComboBoxMaxScale->setEnabled( mCheckBoxMaxScale->isChecked() );
55 if ( mCheckBoxMaxScale->isChecked() && mComboBoxMaxScale->scale() < mComboBoxMinScale->scale() )
57 mComboBoxMaxScale->setScale( mComboBoxMinScale->scale() );
64 scale.
minScale = mCheckBoxMinScale->isChecked() ? mComboBoxMinScale->scale() : 0;
65 scale.
maxScale = mCheckBoxMaxScale->isChecked() ? mComboBoxMaxScale->scale() : 0;
77 mMapScaleButton->setVisible(
false );
78 mMapScaleButton->setToolTip(
tr(
"Adjust scaling range" ) );
83 connect( mUnitCombo, SIGNAL( currentIndexChanged(
int ) ),
this, SLOT( toggleUnitRangeButton() ) );
84 connect( mMapScaleButton, SIGNAL( clicked() ),
this, SLOT( showDialog() ) );
85 connect( mUnitCombo, SIGNAL( currentIndexChanged(
int ) ),
this, SIGNAL(
changed() ) );
91 mUnitCombo->addItems( units );
92 mMapUnitIdx = mapUnitIdx;
122 if ( mUnitCombo->count() == 0 )
125 QVariant currentData = mUnitCombo->itemData( mUnitCombo->currentIndex() );
137 mUnitCombo->setCurrentIndex( unitIndex );
143 int idx = mUnitCombo->findData(
QVariant((
int ) unit ) );
144 mUnitCombo->setCurrentIndex( idx == -1 ? 0 : idx );
147 void QgsUnitSelectionWidget::showDialog()
150 if ( mUnitScaleDialog->
exec() != QDialog::Accepted )
164 void QgsUnitSelectionWidget::toggleUnitRangeButton()
172 mMapScaleButton->setVisible( mMapUnitIdx != -1 && mUnitCombo->currentIndex() == mMapUnitIdx );
QgsMapUnitScale getMapUnitScale() const
Returns the map unit scale.
QString tr(const char *sourceText, const char *disambiguation, int n)
QgsMapUnitScaleDialog(QWidget *parent)
double maxScale
The maximum scale, or 0.0 if unset.
int toInt(bool *ok) const
void setMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale.
Dialog allowing the user to choose the minimum and maximum scale of an object in map units...
bool blockSignals(bool block)
bool contains(const T &value) const
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
double minScale
The minimum scale, or 0.0 if unset.