9#include "dateeditwidget.h"
12#include <KDatePickerPopup>
14#include <KLocalizedString>
15#include <QContextMenuEvent>
20DateView::DateView(
QWidget *parent)
23 setPlaceholderText(
i18nc(
"@info:placeholder",
"Click to add date"));
29 if (
text().isEmpty()) {
39void DateView::emitSignal()
44DateEditWidget::DateEditWidget(Type type,
QWidget *parent)
49 layout->setContentsMargins({});
52 layout->addWidget(mView);
56 mClearButton->setIcon(
QIcon::fromTheme(QStringLiteral(
"edit-clear-locationbar-rtl")));
58 mClearButton->setIcon(
QIcon::fromTheme(QStringLiteral(
"edit-clear-locationbar-ltr")));
60 layout->addWidget(mClearButton);
66 mSelectButton->setIcon(
QIcon::fromTheme(QStringLiteral(
"view-calendar-day")));
69 mSelectButton->setIcon(
QIcon::fromTheme(QStringLiteral(
"view-calendar-birthday")));
72 mSelectButton->setIcon(
QIcon::fromTheme(QStringLiteral(
"view-calendar-wedding-anniversary")));
76 layout->addWidget(mSelectButton);
77 setFocusProxy(mSelectButton);
81 mSelectButton->setMenu(mMenu);
85 connect(mView, &DateView::resetDate,
this, &DateEditWidget::resetDate);
90DateEditWidget::~DateEditWidget() =
default;
92void DateEditWidget::setDate(
const QDate &date)
95 mMenu->setDate(mDate);
99QDate DateEditWidget::date()
const
104void DateEditWidget::setReadOnly(
bool readOnly)
106 mReadOnly = readOnly;
108 mSelectButton->setEnabled(!readOnly);
109 mClearButton->setEnabled(!readOnly);
112void DateEditWidget::dateSelected(
const QDate &date)
118void DateEditWidget::resetDate()
124void DateEditWidget::updateView()
126 if (mDate.isValid()) {
127 mView->setText(QLocale().
toString(mDate));
128 mClearButton->show();
130 mView->setText(QString());
131 mClearButton->hide();
135#include "moc_dateeditwidget.cpp"
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
char * toString(const EngineQuery &query)
QIcon fromTheme(const QString &name)
virtual bool event(QEvent *e)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)