22 #include "dateeditwidget.h"
24 #include "kdatepickerpopup_p.h"
26 #include <kdatepicker.h>
29 #include <klocalizedstring.h>
31 #include <QContextMenuEvent>
32 #include <QHBoxLayout>
34 #include <QToolButton>
36 DateView::DateView(
QWidget *parent)
39 setTextInteractionFlags(Qt::TextSelectableByMouse);
40 setFrameShape(QFrame::StyledPanel);
41 setFrameShadow(QFrame::Sunken);
46 if (text().isEmpty()) {
51 menu.
addAction(i18n(
"Remove"),
this, SLOT(emitSignal()));
56 void DateView::emitSignal()
61 DateEditWidget::DateEditWidget(Type type,
QWidget *parent)
72 if (layoutDirection() == Qt::LeftToRight) {
75 mClearButton->setIcon(KIcon(
QLatin1String(
"edit-clear-locationbar-ltr")));
83 mSelectButton->setIcon(KIcon(
QLatin1String(
"view-calendar-day")));
86 mSelectButton->setIcon(KIcon(
QLatin1String(
"view-calendar-birthday")));
89 mSelectButton->setIcon(KIcon(
QLatin1String(
"view-calendar-wedding-anniversary")));
94 setFocusProxy(mSelectButton);
95 setFocusPolicy(Qt::StrongFocus);
98 mSelectButton->setMenu(mMenu);
100 connect(mClearButton, SIGNAL(clicked()), SLOT(resetDate()));
101 connect(mMenu, SIGNAL(dateChanged(
QDate)), SLOT(dateSelected(
QDate)));
102 connect(mView, SIGNAL(resetDate()), SLOT(resetDate()));
107 DateEditWidget::~DateEditWidget()
111 void DateEditWidget::setDate(
const QDate &date)
118 QDate DateEditWidget::date()
const
123 void DateEditWidget::setReadOnly(
bool readOnly)
125 mReadOnly = readOnly;
127 mSelectButton->setEnabled(!readOnly);
128 mClearButton->setEnabled(!readOnly);
131 void DateEditWidget::dateSelected(
const QDate &date)
137 void DateEditWidget::resetDate()
143 void DateEditWidget::updateView()
145 if (mDate.isValid()) {
146 mView->setText(KGlobal::locale()->formatDate(mDate));
147 mClearButton->show();
150 mClearButton->hide();
void setMargin(int margin)
bool setDate(int year, int month, int day)