Skip to content
Permalink
Browse files
Add groupbox support to attribute editor
  • Loading branch information
NathanW2 committed Jan 12, 2013
1 parent a0628bf commit 971c7b8b6ad3ae44b7432a569669f29173bf1eca
Showing with 27 additions and 3 deletions.
  1. +27 −3 src/gui/qgsattributeeditor.cpp
@@ -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 );

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

// fall-through
@@ -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();
}
@@ -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 )
{

0 comments on commit 971c7b8

Please sign in to comment.