Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add support for QCalendarWidget in custom forms
  • Loading branch information
NathanW2 committed Jan 10, 2013
1 parent 464de26 commit 4ddcb3e
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/gui/qgsattributeeditor.cpp
Expand Up @@ -560,6 +560,14 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
case QgsVectorLayer::FileName:
case QgsVectorLayer::Calendar:
{
QCalendarWidget *cw = qobject_cast<QCalendarWidget *>( editor );
if ( cw )
{
myWidget = cw;
break;
}


QPushButton *pb = 0;
QLineEdit *le = qobject_cast<QLineEdit *>( editor );
if ( le )
Expand Down Expand Up @@ -739,11 +747,13 @@ bool QgsAttributeEditor::retrieveValue( QWidget *widget, QgsVectorLayer *vl, int
QCalendarWidget *cw = qobject_cast<QCalendarWidget *>( widget );
if ( cw )
{
text = cw->selectedDate().toString();
text = cw->selectedDate().toString( Qt::ISODate );
}

le = widget->findChild<QLineEdit *>();
if ( le )
// QCalendarWidget has a internal QLineEdit which returns the date
// so we need to skip this if we have a QCalendarWidget
if ( !cw && le )
{
text = le->text();
}
Expand Down Expand Up @@ -941,6 +951,13 @@ bool QgsAttributeEditor::setValue( QWidget *editor, QgsVectorLayer *vl, int idx,
case QgsVectorLayer::FileName:
case QgsVectorLayer::Calendar:
{
QCalendarWidget *cw = qobject_cast<QCalendarWidget *>( editor );
if ( cw )
{
cw->setSelectedDate( value.toDate() );
break;
}

QLineEdit* le = qobject_cast<QLineEdit*>( editor );
if ( !le )
{
Expand Down

0 comments on commit 4ddcb3e

Please sign in to comment.