mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-24 02:42:48 +00:00
kdeui: implement setter and getter for KCalendarWidget to use a specifiec KCalendarSystem
maybe temporary tho but for now the minimum and maximum date will be that of the KCalendarSystem Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
8f8865db62
commit
3c697cf8ce
2 changed files with 51 additions and 2 deletions
|
@ -35,16 +35,53 @@ static void setupCalendarWidget(KCalendarWidget *kcalendarwidget, const QDate &d
|
|||
|
||||
kcalendarwidget->setLocale(calendarlocale);
|
||||
kcalendarwidget->setSelectedDate(date);
|
||||
kcalendarwidget->setCalendar(KGlobal::locale()->calendar());
|
||||
}
|
||||
|
||||
class KCalendarWidgetPrivate
|
||||
{
|
||||
public:
|
||||
KCalendarWidgetPrivate();
|
||||
|
||||
const KCalendarSystem *calendar;
|
||||
};
|
||||
|
||||
KCalendarWidgetPrivate::KCalendarWidgetPrivate()
|
||||
: calendar(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
KCalendarWidget::KCalendarWidget(QWidget *parent)
|
||||
: QCalendarWidget(parent)
|
||||
: QCalendarWidget(parent),
|
||||
d(new KCalendarWidgetPrivate())
|
||||
{
|
||||
setupCalendarWidget(this, QDate::currentDate());
|
||||
}
|
||||
|
||||
KCalendarWidget::KCalendarWidget(const QDate &date, QWidget *parent)
|
||||
: QCalendarWidget(parent)
|
||||
: QCalendarWidget(parent),
|
||||
d(new KCalendarWidgetPrivate())
|
||||
{
|
||||
setupCalendarWidget(this, date);
|
||||
}
|
||||
|
||||
KCalendarWidget::~KCalendarWidget()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
const KCalendarSystem* KCalendarWidget::calendar() const
|
||||
{
|
||||
return d->calendar;
|
||||
}
|
||||
|
||||
void KCalendarWidget::setCalendar(const KCalendarSystem *calendar)
|
||||
{
|
||||
d->calendar = calendar;
|
||||
if (!calendar) {
|
||||
kWarning() << "Attempting to set KCalendarWidget calendar to null";
|
||||
return;
|
||||
}
|
||||
setMinimumDate(calendar->earliestValidDate());
|
||||
setMaximumDate(calendar->latestValidDate());
|
||||
}
|
||||
|
|
|
@ -22,11 +22,15 @@
|
|||
#include <kdeui_export.h>
|
||||
|
||||
#include <QCalendarWidget>
|
||||
#include <kcalendarsystem.h>
|
||||
|
||||
class KCalendarWidgetPrivate;
|
||||
|
||||
/*!
|
||||
Class to pick a date.
|
||||
|
||||
@since 4.23
|
||||
@warning the API is subject to change
|
||||
*/
|
||||
class KDEUI_EXPORT KCalendarWidget: public QCalendarWidget
|
||||
{
|
||||
|
@ -34,6 +38,14 @@ class KDEUI_EXPORT KCalendarWidget: public QCalendarWidget
|
|||
public:
|
||||
KCalendarWidget(QWidget *parent = nullptr);
|
||||
KCalendarWidget(const QDate &date, QWidget *parent = nullptr);
|
||||
~KCalendarWidget();
|
||||
|
||||
const KCalendarSystem* calendar() const;
|
||||
void setCalendar(const KCalendarSystem *calendar);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(KCalendarWidget);
|
||||
KCalendarWidgetPrivate *d;
|
||||
};
|
||||
|
||||
#endif // KCALENDARWIDGET_H
|
||||
|
|
Loading…
Add table
Reference in a new issue