Show calendar in (PreferencesPanel) at the widget upper for a clearer view + react on SelectionChanged signal

This commit is contained in:
Grégory Soutadé 2017-10-29 18:21:53 +01:00 committed by Grégory Soutadé
parent 397096680c
commit 8b0f386121
2 changed files with 11 additions and 2 deletions

View File

@ -30,9 +30,16 @@ void CalendarDelegate::OnCalendarClicked(const QDate &date)
closeEditor(qobject_cast<QWidget*>(sender()), QAbstractItemDelegate::SubmitModelCache);
}
void CalendarDelegate::OnCalendarSelectionChanged(void)
{
QCalendarWidget* calendar = qobject_cast<QCalendarWidget*>(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;
}

View File

@ -40,7 +40,8 @@ public:
private slots:
void OnCalendarClicked(const QDate &date);
void OnCalendarSelectionChanged(void);
private:
std::vector<Account>* _accounts;
bool _start;