Skip to content
Permalink
Browse files
Add support for QCalendarWidget in custom forms
  • Loading branch information
NathanW2 committed Jan 10, 2013
1 parent 464de26 commit 4ddcb3eaac812a69ff8fdd323c26e477a033e449
Showing with 19 additions and 2 deletions.
  1. +19 −2 src/gui/qgsattributeeditor.cpp
@@ -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 )
@@ -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();
}
@@ -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 )
{

0 comments on commit 4ddcb3e

Please sign in to comment.