Skip to content

Commit 69c656e

Browse files
committedMar 14, 2013
Set combo box maximum for precision <= type length
1 parent 4af91c4 commit 69c656e

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed
 

‎src/app/qgsaddattrdialog.cpp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,25 @@ void QgsAddAttrDialog::on_mTypeBox_currentIndexChanged( int idx )
6363
mLength->setValue( mLength->minimum() );
6464
if ( mLength->value() > mLength->maximum() )
6565
mLength->setValue( mLength->maximum() );
66+
setPrecisionMinMax();
67+
}
68+
69+
void QgsAddAttrDialog::on_mLength_editingFinished()
70+
{
71+
setPrecisionMinMax();
72+
}
6673

67-
mPrec->setMinimum( mTypeBox->itemData( idx, Qt::UserRole + 4 ).toInt() );
68-
mPrec->setMaximum( mTypeBox->itemData( idx, Qt::UserRole + 5 ).toInt() );
69-
mPrec->setVisible( mPrec->minimum() < mPrec->maximum() );
70-
if ( mPrec->value() < mPrec->minimum() )
71-
mPrec->setValue( mPrec->minimum() );
72-
if ( mPrec->value() > mPrec->maximum() )
73-
mPrec->setValue( mPrec->maximum() );
74+
void QgsAddAttrDialog::setPrecisionMinMax()
75+
{
76+
int idx = mTypeBox->currentIndex();
77+
int minPrecType = mTypeBox->itemData( idx, Qt::UserRole + 4 ).toInt();
78+
int maxPrecType = mTypeBox->itemData( idx, Qt::UserRole + 5 ).toInt();
79+
mPrec->setVisible( minPrecType < maxPrecType );
80+
if ( mPrec->isVisible() )
81+
{
82+
mPrec->setMinimum( minPrecType );
83+
mPrec->setMaximum( qMin( maxPrecType, mLength->value() ) );
84+
}
7485
}
7586

7687
void QgsAddAttrDialog::accept()

‎src/app/qgsaddattrdialog.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,13 @@ class QgsAddAttrDialog: public QDialog, private Ui::QgsAddAttrDialogBase
3737

3838
public slots:
3939
void on_mTypeBox_currentIndexChanged( int idx );
40+
void on_mLength_editingFinished();
4041
void accept();
4142

4243
private:
4344
QString mLayerType;
4445

46+
void setPrecisionMinMax();
4547
};
4648

4749
#endif

0 commit comments

Comments
 (0)
Please sign in to comment.