From 8b0f386121f99ab8b0c1774057feec5445801402 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Sun, 29 Oct 2017 18:21:53 +0100 Subject: [PATCH] Show calendar in (PreferencesPanel) at the widget upper for a clearer view + react on SelectionChanged signal --- src/view/grid/CalendarDelegate.cpp | 10 +++++++++- src/view/grid/CalendarDelegate.hpp | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/view/grid/CalendarDelegate.cpp b/src/view/grid/CalendarDelegate.cpp index 116cd01..1877f66 100644 --- a/src/view/grid/CalendarDelegate.cpp +++ b/src/view/grid/CalendarDelegate.cpp @@ -30,9 +30,16 @@ void CalendarDelegate::OnCalendarClicked(const QDate &date) closeEditor(qobject_cast(sender()), QAbstractItemDelegate::SubmitModelCache); } +void CalendarDelegate::OnCalendarSelectionChanged(void) +{ + QCalendarWidget* calendar = qobject_cast(sender()); + _date = calendar->selectedDate(); + commitData(calendar); +} + QWidget * CalendarDelegate::createEditor (QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index ) const { - QCalendarWidget* calendar = new QCalendarWidget(parent); + QCalendarWidget* calendar = new QCalendarWidget(parent->parentWidget()->parentWidget()); calendar->setGridVisible(false); calendar->setFirstDayOfWeek(Qt::Monday); @@ -41,6 +48,7 @@ QWidget * CalendarDelegate::createEditor (QWidget * parent, const QStyleOptionVi calendar->setMinimumHeight(200); connect(calendar, SIGNAL(clicked (const QDate&)), this, SLOT(OnCalendarClicked(const QDate&))); + connect(calendar, SIGNAL(selectionChanged (void)), this, SLOT(OnCalendarSelectionChanged(void))); return calendar; } diff --git a/src/view/grid/CalendarDelegate.hpp b/src/view/grid/CalendarDelegate.hpp index 1750c03..c84dec6 100644 --- a/src/view/grid/CalendarDelegate.hpp +++ b/src/view/grid/CalendarDelegate.hpp @@ -40,7 +40,8 @@ public: private slots: void OnCalendarClicked(const QDate &date); - + void OnCalendarSelectionChanged(void); + private: std::vector* _accounts; bool _start;