kdatetimewidget.cpp
#include <qlayout.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(QWidget * parent, const char * name)
: QWidget(parent, name)
{
init();
}
KDateTimeWidget::KDateTimeWidget(const QDateTime & datetime,
QWidget * parent, const char * name)
: QWidget(parent, name)
{
init();
setDateTime(datetime);
}
KDateTimeWidget::~KDateTimeWidget()
{
delete d;
}
void KDateTimeWidget::init()
{
d = new KDateTimeWidgetPrivate;
QHBoxLayout *layout = new QHBoxLayout(this, 0, KDialog::spacingHint());
layout->setAutoAdd(true);
d->dateWidget = new KDateWidget(this);
d->timeWidget = new KTimeWidget(this);
connect(d->dateWidget, SIGNAL(changed(QDate)),
SLOT(slotValueChanged()));
connect(d->timeWidget, SIGNAL(valueChanged(const QTime &)),
SLOT(slotValueChanged()));
}
void KDateTimeWidget::setDateTime(const QDateTime & datetime)
{
d->dateWidget->setDate(datetime.date());
d->timeWidget->setTime(datetime.time());
}
QDateTime KDateTimeWidget::dateTime() const
{
return QDateTime(d->dateWidget->date(), d->timeWidget->time());
}
void KDateTimeWidget::slotValueChanged()
{
QDateTime datetime(d->dateWidget->date(),
d->timeWidget->time());
kdDebug() << "slotValueChanged(): " << datetime << "\n";
emit valueChanged(datetime);
}
#include "kdatetimewidget.moc"
KTimeWidget
A time selection widget.
Definition: ktimewidget.h:37
kdDebug
kdbgstream kdDebug(int area=0)
KDateTimeWidget::dateTime
QDateTime dateTime() const
Returns the currently selected date and time.
KDateTimeWidget::setDateTime
void setDateTime(const QDateTime &datetime)
Changes the selected date and time to datetime.
Definition: kdatetimewidget.cpp:53
KDateTimeWidget::valueChanged
void valueChanged(const QDateTime &datetime)
Emitted whenever the date or time of the widget is changed, either with setDateTime() or via user sel...
KDateTimeWidget::~KDateTimeWidget
virtual ~KDateTimeWidget()
Destructs the date and time selection widget.
Definition: kdatetimewidget.cpp:32
KDialog::spacingHint
static int spacingHint()
Return the number of pixels you shall use between widgets inside a dialog according to the KDE standa...
Definition: kdialog.cpp:103
KDateWidget
A pushbutton to display or allow user selection of a date.
Definition: kdatewidget.h:36
KDateTimeWidget::KDateTimeWidget
KDateTimeWidget(QWidget *parent=0, const char *name=0)
Constructs a date and time selection widget.
Definition: kdatetimewidget.cpp:17

KDE Home | KDE Accessibility Home | Description of Access Keys