Browse Source

Change date representation to ISO. Allow combined date time edits. Fixes #119

Neal Wilson 10 years ago
parent
commit
c9f84a56ac
1 changed files with 32 additions and 3 deletions
  1. 32
    3
      src/typica.w

+ 32
- 3
src/typica.w View File

5288
 void addCalendarToLayout(QDomElement element, QStack<QWidget *> *,@|
5288
 void addCalendarToLayout(QDomElement element, QStack<QWidget *> *,@|
5289
                          QStack<QLayout *> *layoutStack)
5289
                          QStack<QLayout *> *layoutStack)
5290
 {
5290
 {
5291
-	QDateEdit *widget = new QDateEdit;
5292
-	widget->setCalendarPopup(true);
5291
+	QWidget *widget;
5292
+	if(element.hasAttribute("time"))
5293
+	{
5294
+		if(element.attribute("time") == "true")
5295
+		{
5296
+			QDateTimeEdit *edit = new QDateTimeEdit;
5297
+			edit->setDateTime(QDateTime::currentDateTime());
5298
+			edit->setCalendarPopup(true);
5299
+			edit->setDisplayFormat("yyyy-MM-dd hh:mm:ss");
5300
+			widget = qobject_cast<QWidget *>(edit);
5301
+		}
5302
+		else
5303
+		{
5304
+			QDateEdit *edit = new QDateEdit;
5305
+			edit->setDate(QDate::currentDate());
5306
+			edit->setCalendarPopup(true);
5307
+			edit->setDisplayFormat("yyyy-MM-dd");
5308
+			widget = qobject_cast<QWidget *>(edit);
5309
+		}
5310
+	}
5311
+	else
5312
+	{
5313
+		QDateEdit *edit = new QDateEdit;
5314
+		edit->setDate(QDate::currentDate());
5315
+		edit->setCalendarPopup(true);
5316
+		edit->setDisplayFormat("yyyy-MM-dd");
5317
+		widget = qobject_cast<QWidget *>(edit);
5318
+	}
5293
 	if(element.hasAttribute("id"))
5319
 	if(element.hasAttribute("id"))
5294
 	{
5320
 	{
5295
 		widget->setObjectName(element.attribute("id"));
5321
 		widget->setObjectName(element.attribute("id"));
5296
 	}
5322
 	}
5297
-	widget->setDate(QDate::currentDate());
5298
 	QBoxLayout *layout = qobject_cast<QBoxLayout *>(layoutStack->top());
5323
 	QBoxLayout *layout = qobject_cast<QBoxLayout *>(layoutStack->top());
5299
 	layout->addWidget(widget);
5324
 	layout->addWidget(widget);
5300
 }
5325
 }
5428
 {
5453
 {
5429
 	setQDateEditProperties(value, engine);
5454
 	setQDateEditProperties(value, engine);
5430
 }
5455
 }
5456
+else if(className == "QDateTimeEdit")
5457
+{
5458
+	setQDateTimeEditProperties(value, engine);
5459
+}
5431
 else if(className == "QFrame")
5460
 else if(className == "QFrame")
5432
 {
5461
 {
5433
 	setQFrameProperties(value, engine);
5462
 	setQFrameProperties(value, engine);

Loading…
Cancel
Save