Skip to content
Permalink
Browse files

Set combo box maximum for precision <= type length

  • Loading branch information
mhugent committed Mar 14, 2013
1 parent 4af91c4 commit 69c656e5f9c2859cb226ca2cb08bfda8cfd78f7d
Showing with 20 additions and 7 deletions.
  1. +18 −7 src/app/qgsaddattrdialog.cpp
  2. +2 −0 src/app/qgsaddattrdialog.h
@@ -63,14 +63,25 @@ void QgsAddAttrDialog::on_mTypeBox_currentIndexChanged( int idx )
mLength->setValue( mLength->minimum() );
if ( mLength->value() > mLength->maximum() )
mLength->setValue( mLength->maximum() );
setPrecisionMinMax();
}

void QgsAddAttrDialog::on_mLength_editingFinished()
{
setPrecisionMinMax();
}

mPrec->setMinimum( mTypeBox->itemData( idx, Qt::UserRole + 4 ).toInt() );
mPrec->setMaximum( mTypeBox->itemData( idx, Qt::UserRole + 5 ).toInt() );
mPrec->setVisible( mPrec->minimum() < mPrec->maximum() );
if ( mPrec->value() < mPrec->minimum() )
mPrec->setValue( mPrec->minimum() );
if ( mPrec->value() > mPrec->maximum() )
mPrec->setValue( mPrec->maximum() );
void QgsAddAttrDialog::setPrecisionMinMax()
{
int idx = mTypeBox->currentIndex();
int minPrecType = mTypeBox->itemData( idx, Qt::UserRole + 4 ).toInt();
int maxPrecType = mTypeBox->itemData( idx, Qt::UserRole + 5 ).toInt();
mPrec->setVisible( minPrecType < maxPrecType );
if ( mPrec->isVisible() )
{
mPrec->setMinimum( minPrecType );
mPrec->setMaximum( qMin( maxPrecType, mLength->value() ) );
}
}

void QgsAddAttrDialog::accept()
@@ -37,11 +37,13 @@ class QgsAddAttrDialog: public QDialog, private Ui::QgsAddAttrDialogBase

public slots:
void on_mTypeBox_currentIndexChanged( int idx );
void on_mLength_editingFinished();
void accept();

private:
QString mLayerType;

void setPrecisionMinMax();
};

#endif

0 comments on commit 69c656e

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