summaryrefslogtreecommitdiff
path: root/client/widgets/datetime.cc
diff options
context:
space:
mode:
Diffstat (limited to 'client/widgets/datetime.cc')
-rw-r--r--client/widgets/datetime.cc107
1 files changed, 43 insertions, 64 deletions
diff --git a/client/widgets/datetime.cc b/client/widgets/datetime.cc
index 0b91a40..b97178f 100644
--- a/client/widgets/datetime.cc
+++ b/client/widgets/datetime.cc
@@ -26,87 +26,89 @@
*/
#include "datetime.h"
+#include <QDateTimeEdit>
+
#include "common.h"
DateTime::DateTime(QDomNode &node, MacroWindow *macrowindow)
- : QDateTimeEdit(), Widget(node, macrowindow)
+ : Widget(node, macrowindow)
{
+ datetimeedit = new QDateTimeEdit();
+ widget = datetimeedit;
+
changedByUser = true;
- setCommonAttributes(this, node);
+ setCommonAttributes(datetimeedit, node);
- setCalendarPopup(true);
+ datetimeedit->setCalendarPopup(true);
// setMinimumDateTime(QDateTime::fromTime_t(0));
- setMinimumDate(QDate(1900,1,1));
- setMinimumTime(QTime(0,0));
+ datetimeedit->setMinimumDate(QDate(1900,1,1));
+ datetimeedit->setMinimumTime(QTime(0,0));
QDomElement elem = node.toElement();
switch(elem.attribute("fuzziness", "5").toLong()) {
case 1:
- setDisplayFormat("yyyy");
+ datetimeedit->setDisplayFormat("yyyy");
break;
case 2:
- setDisplayFormat("MMMM yyyy");
+ datetimeedit->setDisplayFormat("MMMM yyyy");
break;
case 3:
- setDisplayFormat("dd MMMM yyyy");
+ datetimeedit->setDisplayFormat("dd MMMM yyyy");
break;
case 4:
- setDisplayFormat("dd MMMM yyyy hh");
+ datetimeedit->setDisplayFormat("dd MMMM yyyy hh");
break;
case 5:
- setDisplayFormat("dd MMMM yyyy hh:mm");
+ datetimeedit->setDisplayFormat("dd MMMM yyyy hh:mm");
break;
case 6:
- setDisplayFormat("dd MMMM yyyy hh:mm:ss");
+ datetimeedit->setDisplayFormat("dd MMMM yyyy hh:mm:ss");
break;
case 7:
default:
- setDisplayFormat("dd MMMM yyyy hh:mm:ss:zzz");
+ datetimeedit->setDisplayFormat("dd MMMM yyyy hh:mm:ss:zzz");
break;
}
/*
if(elem.hasAttribute("readonly")) {
- if(elem.attribute("readonly") == "true" || elem.attribute("readonly") == "1") {
+ if(elem.attribute("readonly") == "true" ||
+ elem.attribute("readonly") == "1") {
setReadOnly(true);
- } else if(elem.attribute("readonly") == "false" || elem.attribute("readonly") == "0") {
+ } else if(elem.attribute("readonly") == "false" ||
+ elem.attribute("readonly") == "0") {
setReadOnly(false);
} else {
- printf("Unknown value of readonly: %s\n", elem.attribute("readonly").toStdString().c_str());
+ printf("Unknown value of readonly: %s\n",
+ elem.attribute("readonly").toStdString().c_str());
}
}
*/
- connect(this, SIGNAL(dateTimeChanged(const QDateTime &)),
+ connect(datetimeedit, SIGNAL(dateTimeChanged(const QDateTime &)),
this, SLOT(changed(const QDateTime &)));
}
-void DateTime::changed(const QDateTime &)
+DateTime::~DateTime()
{
- QPalette palette;
-
- if(luaValidator()) {
- // valid string
- palette.setBrush(QPalette::Base, QBrush(QColor(255, 255, 255)));
- } else {
- // invalid string
- palette.setBrush(QPalette::Base, QBrush(QColor(200, 230, 200)));
- }
-
- setPalette(palette);
+ // delete datetimeedit;
+}
+void DateTime::changed(const QDateTime &)
+{
if(changedByUser) emit wasChanged();
+ eventOnChange();
}
-QString DateTime::getValue()
+QString DateTime::value()
{
- return QString::number(dateTime().toUTC().toTime_t());
+ return QString::number(datetimeedit->dateTime().toUTC().toTime_t());
}
void DateTime::setValue(QString value, QString source)
@@ -114,46 +116,23 @@ void DateTime::setValue(QString value, QString source)
changedByUser = false;
if(isUserSource(source)) emit wasChanged();
- setDateTime(QDateTime::fromTime_t(value.toUInt()));
+ datetimeedit->setDateTime(QDateTime::fromTime_t(value.toUInt()));
setInitialValue(value);
changedByUser = true;
}
-void DateTime::enable()
-{
- setEnabled(true);
-}
-
-void DateTime::disable()
-{
- setEnabled(false);
-}
-
-bool DateTime::isDisabled()
-{
- return isEnabled() == false;
-}
-
-void DateTime::connectFrom(const char *signal,
- const QObject *receiver, const char *method)
+void DateTime::setWdgValid(bool valid)
{
- connect(this, signal, receiver, method);
-}
-
-void DateTime::connectTo(const QObject *sender, const char *signal,
- const char *method)
-{
- connect(sender, signal, this, method);
-}
+ QPalette palette;
-bool DateTime::setKeyboardFocus()
-{
- setFocus();
- return true;
-}
+ if(valid) {
+ // valid string
+ palette.setBrush(QPalette::Base, QBrush(QColor(255, 255, 255)));
+ } else {
+ // invalid string
+ palette.setBrush(QPalette::Base, QBrush(QColor(200, 230, 200)));
+ }
-void DateTime::setVisibility(bool visible)
-{
- setVisible(visible);
+ datetimeedit->setPalette(palette);
}