summaryrefslogtreecommitdiffstats
path: root/tdeui/kdatetimewidget.cpp
blob: 1aa9332beb29cc4a4321689aac27653dc7a06bea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <tqlayout.h>

#include "kdatewidget.h"
#include "kdebug.h"
#include "kdialog.h"
#include "ktimewidget.h"

#include "kdatetimewidget.h"

class KDateTimeWidget::KDateTimeWidgetPrivate
{
public:
  KDateWidget * dateWidget;
  KTimeWidget * timeWidget;
};

KDateTimeWidget::KDateTimeWidget(TQWidget * parent, const char * name)
  : TQWidget(parent, name)
{
  init();
}

KDateTimeWidget::KDateTimeWidget(const TQDateTime & datetime,
			     TQWidget * parent, const char * name)
  : TQWidget(parent, name)
{
  init();

  setDateTime(datetime);
}

KDateTimeWidget::~KDateTimeWidget()
{
  delete d;
}

void KDateTimeWidget::init()
{
  d = new KDateTimeWidgetPrivate;

  TQHBoxLayout *layout = new TQHBoxLayout(this, 0, KDialog::spacingHint());
  layout->setAutoAdd(true);

  d->dateWidget = new KDateWidget(this);
  d->timeWidget = new KTimeWidget(this);

  connect(d->dateWidget, TQ_SIGNAL(changed(TQDate)),
          TQ_SLOT(slotValueChanged()));
  connect(d->timeWidget, TQ_SIGNAL(valueChanged(const TQTime &)),
          TQ_SLOT(slotValueChanged()));
}

void KDateTimeWidget::setDateTime(const TQDateTime & datetime)
{
  d->dateWidget->setDate(datetime.date());
  d->timeWidget->setTime(datetime.time());
}

TQDateTime KDateTimeWidget::dateTime() const
{
  return TQDateTime(d->dateWidget->date(), d->timeWidget->time());
}

void KDateTimeWidget::slotValueChanged()
{
  TQDateTime datetime(d->dateWidget->date(),
                     d->timeWidget->time());

  kdDebug() << "slotValueChanged(): " << datetime << "\n";

  emit valueChanged(datetime);
}

#include "kdatetimewidget.moc"