Skip to content

Commit

Permalink
Set combo box maximum for precision <= type length
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Mar 14, 2013
1 parent 4af91c4 commit 69c656e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/app/qgsaddattrdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsaddattrdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.