Skip to content

Commit

Permalink
Add groupbox support to attribute editor
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed Jan 12, 2013
1 parent a0628bf commit 971c7b8
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions src/gui/qgsattributeeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,12 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
case QgsVectorLayer::CheckBox:
{
QCheckBox *cb = 0;
QGroupBox *gb = 0;
if ( editor )
{
gb = qobject_cast<QGroupBox *>( editor );
cb = qobject_cast<QCheckBox*>( editor );
}
else
cb = new QCheckBox( parent );

Expand All @@ -427,6 +431,11 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
myWidget = cb;
break;
}
else if ( gb )
{
myWidget = gb;
break;
}
}

// fall-through
Expand Down Expand Up @@ -744,16 +753,23 @@ bool QgsAttributeEditor::retrieveValue( QWidget *widget, QgsVectorLayer *vl, int
text = ckb->isChecked() ? states.first : states.second;
}

QGroupBox *gb = qobject_cast<QGroupBox *>( widget );
if ( gb )
{
QPair<QString, QString> states = vl->checkedState( idx );
text = gb->isChecked() ? states.first : states.second;
}

QCalendarWidget *cw = qobject_cast<QCalendarWidget *>( widget );
if ( cw )
{
text = cw->selectedDate().toString( Qt::ISODate );
}

le = widget->findChild<QLineEdit *>();
// QCalendarWidget has a internal QLineEdit which returns the date
// so we need to skip this if we have a QCalendarWidget
if ( !cw && le )
// QCalendarWidget and QGroupBox have an internal QLineEdit which returns the year
// part of the date so we need to skip this if we have a QCalendarWidget
if ( !cw && !gb && le )
{
text = le->text();
}
Expand Down Expand Up @@ -898,6 +914,14 @@ bool QgsAttributeEditor::setValue( QWidget *editor, QgsVectorLayer *vl, int idx,

case QgsVectorLayer::CheckBox:
{
QGroupBox *gb = qobject_cast<QGroupBox *>( editor );
if ( gb )
{
QPair<QString, QString> states = vl->checkedState( idx );
gb->setChecked( value == states.first );
break;
}

QCheckBox *cb = qobject_cast<QCheckBox *>( editor );
if ( cb )
{
Expand Down

0 comments on commit 971c7b8

Please sign in to comment.