1 /* 2 This file is part of KOrganizer. 3 4 SPDX-FileCopyrightText: 2001, 2003 Cornelius Schumacher <schumacher@kde.org> 5 SPDX-FileCopyrightText: 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> 6 7 SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0 8 */ 9 10 #pragma once 11 12 #include <Akonadi/Calendar/ETMCalendar> 13 #include <KCalendarCore/IncidenceBase> //for DateList typedef 14 #include <QDate> 15 #include <QFrame> 16 17 class KODayMatrix; 18 class NavigatorBar; 19 20 namespace Akonadi 21 { 22 class Item; 23 } 24 25 class QLabel; 26 27 class KDateNavigator : public QFrame 28 { 29 Q_OBJECT 30 public: 31 explicit KDateNavigator(QWidget *parent = nullptr); 32 ~KDateNavigator() override; 33 34 /** 35 Associate date navigator with a calendar. It is used by KODayMatrix. 36 */ 37 void setCalendar(const Akonadi::ETMCalendar::Ptr &); 38 39 void setBaseDate(const QDate &); 40 selectedDates()41 Q_REQUIRED_RESULT KCalendarCore::DateList selectedDates() const 42 { 43 return mSelectedDates; 44 } 45 46 Q_REQUIRED_RESULT QSizePolicy sizePolicy() const; 47 navigatorBar()48 NavigatorBar *navigatorBar() const 49 { 50 return mNavigatorBar; 51 } 52 53 Q_REQUIRED_RESULT QDate startDate() const; 54 Q_REQUIRED_RESULT QDate endDate() const; 55 void setHighlightMode(bool highlightEvents, bool highlightTodos, bool highlightJournals) const; 56 57 /** 58 Returns the current displayed month. 59 It's a QDate instead of uint so it can be easily feed to KCalendarSystem's 60 functions. 61 */ 62 Q_REQUIRED_RESULT QDate month() const; 63 64 public Q_SLOTS: 65 void selectDates(const KCalendarCore::DateList &); 66 void selectPreviousMonth(); 67 void selectNextMonth(); 68 void updateView(); 69 void updateConfig(); 70 void updateDayMatrix(); 71 void updateToday(); 72 void setUpdateNeeded(); 73 74 Q_SIGNALS: 75 void datesSelected(const KCalendarCore::DateList &); 76 void incidenceDropped(const Akonadi::Item &, const QDate &); 77 void incidenceDroppedMove(const Akonadi::Item &, const QDate &); 78 void newEventSignal(const QDate &); 79 void newTodoSignal(const QDate &); 80 void newJournalSignal(const QDate &); 81 void weekClicked(const QDate &week, const QDate &month); 82 83 void goPrevious(); 84 void goNext(); 85 void nextMonthClicked(); 86 void prevMonthClicked(); 87 void nextYearClicked(); 88 void prevYearClicked(); 89 90 void monthSelected(int month); 91 void yearSelected(int year); 92 93 protected: 94 void updateDates(); 95 96 void wheelEvent(QWheelEvent *) override; 97 98 bool eventFilter(QObject *, QEvent *) override; 99 100 void setShowWeekNums(bool enabled); 101 102 private: 103 void selectMonthHelper(int monthDifference); 104 NavigatorBar *const mNavigatorBar; 105 106 QLabel *mHeadings[7]; 107 QLabel *mWeeknos[7]; 108 109 KODayMatrix *mDayMatrix = nullptr; 110 111 KCalendarCore::DateList mSelectedDates; 112 QDate mBaseDate; 113 Akonadi::ETMCalendar::Ptr mCalendar; 114 115 // Disabling copy constructor and assignment operator 116 KDateNavigator(const KDateNavigator &); 117 KDateNavigator &operator=(const KDateNavigator &); 118 }; 119 120