Pārlūkot izejas kodu

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

Neal Wilson 10 gadus atpakaļ
vecāks
revīzija
c9f84a56ac
1 mainītis faili ar 32 papildinājumiem un 3 dzēšanām
  1. 32
    3
      src/typica.w

+ 32
- 3
src/typica.w Parādīt failu

@@ -5288,13 +5288,38 @@ editor. This one provides a calendar.
5288 5288
 void addCalendarToLayout(QDomElement element, QStack<QWidget *> *,@|
5289 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 5319
 	if(element.hasAttribute("id"))
5294 5320
 	{
5295 5321
 		widget->setObjectName(element.attribute("id"));
5296 5322
 	}
5297
-	widget->setDate(QDate::currentDate());
5298 5323
 	QBoxLayout *layout = qobject_cast<QBoxLayout *>(layoutStack->top());
5299 5324
 	layout->addWidget(widget);
5300 5325
 }
@@ -5428,6 +5453,10 @@ else if(className == "QDateEdit")
5428 5453
 {
5429 5454
 	setQDateEditProperties(value, engine);
5430 5455
 }
5456
+else if(className == "QDateTimeEdit")
5457
+{
5458
+	setQDateTimeEditProperties(value, engine);
5459
+}
5431 5460
 else if(className == "QFrame")
5432 5461
 {
5433 5462
 	setQFrameProperties(value, engine);

Notiek ielāde…
Atcelt
Saglabāt