summaryrefslogtreecommitdiffstats
path: root/kcontrol/crypto/kdatetimedlg.cpp
blob: b5cfe00a92ffaf93fed017f1e1278251d3f7b15e (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/**
 * kdatetimedlg.cpp
 *
 * Copyright (c) 2001 George Staikos <[email protected]>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published
 *  by the Free Software Foundation; either version 2.1 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "kdatetimedlg.h"
#include <tqlayout.h>
#include <tqlabel.h>
#include <tdelocale.h>
#include <kdebug.h>
#include <kdatepicker.h>
#include <kpushbutton.h>
#include <knuminput.h>
#include <kstdguiitem.h>

KDateTimeDlg::KDateTimeDlg(TQWidget *parent, const char *name)
                             : KDialog(parent, name, true) {
TQGridLayout *grid = new TQGridLayout(this, 9, 6, marginHint(), spacingHint());

   setCaption(i18n("Date & Time Selector"));

   _date = new KDatePicker(this);
   grid->addMultiCellWidget(_date, 0, 5, 0, 5);

   grid->addWidget(new TQLabel(i18n("Hour:"), this), 7, 0);
   _hours = new KIntNumInput(this);
   _hours->setRange(0, 23, 1, false);
   grid->addWidget(_hours, 7, 1);

   grid->addWidget(new TQLabel(i18n("Minute:"), this), 7, 2);
   _mins = new KIntNumInput(this);
   _mins->setRange(0, 59, 1, false);
   grid->addWidget(_mins, 7, 3);

   grid->addWidget(new TQLabel(i18n("Second:"), this), 7, 4);
   _secs = new KIntNumInput(this);
   _secs->setRange(0, 59, 1, false);
   grid->addWidget(_secs, 7, 5);

   _ok = new KPushButton(KStdGuiItem::ok(), this);
   grid->addWidget(_ok, 8, 4);
   connect(_ok, TQT_SIGNAL(clicked()), TQT_SLOT(accept()));

   _cancel = new KPushButton(KStdGuiItem::cancel(), this);
   grid->addWidget(_cancel, 8, 5);
   connect(_cancel, TQT_SIGNAL(clicked()), TQT_SLOT(reject()));

}


KDateTimeDlg::~KDateTimeDlg() {

}


TQDate KDateTimeDlg::getDate() {
   return _date->date();
}


TQTime KDateTimeDlg::getTime() {
TQTime rc(_hours->value(), _mins->value(), _secs->value());
return rc;
}


TQDateTime KDateTimeDlg::getDateTime() {
TQDateTime qdt;
TQTime qtime(_hours->value(), _mins->value(), _secs->value());

   qdt.setDate(_date->date());
   qdt.setTime(qtime);

return qdt;
}


void KDateTimeDlg::setDate(const TQDate& qdate) {
   _date->setDate(qdate);
}


void KDateTimeDlg::setTime(const TQTime& qtime) {
   _hours->setValue(qtime.hour());
   _mins->setValue(qtime.minute());
   _secs->setValue(qtime.second());
}


void KDateTimeDlg::setDateTime(const TQDateTime& qdatetime) {
   _date->setDate(qdatetime.date());
   _hours->setValue(qdatetime.time().hour());
   _mins->setValue(qdatetime.time().minute());
   _secs->setValue(qdatetime.time().second());
}


#include "kdatetimedlg.moc"