2 This file is part of KOrganizer.
4 Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org>
5 Copyright (C) 2004 Reinhold Kainhofer <reinhold@kainhofer.com>
7 Copyright (C) 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.net>
8 Author: Sergio Martins <sergio@kdab.com>
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License along
21 with this program; if not, write to the Free Software Foundation, Inc.,
22 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 As a special exception, permission is given to link this program
25 with any edition of Qt, and distribute the resulting executable,
26 without including the source code for Qt in the source distribution.
29 #ifndef KORG_DATENAVIGATORCONTAINER_H
30 #define KORG_DATENAVIGATORCONTAINER_H
32 #include <Akonadi/Calendar/ETMCalendar>
38 class DateNavigatorContainer
: public QFrame
42 explicit DateNavigatorContainer(QWidget
*parent
= Q_NULLPTR
);
43 ~DateNavigatorContainer();
46 Associate date navigator with a calendar. It is used by KODayMatrix.
48 void setCalendar(const Akonadi::ETMCalendar::Ptr
&);
50 QSize
minimumSizeHint() const Q_DECL_OVERRIDE
;
51 QSize
sizeHint() const Q_DECL_OVERRIDE
;
52 void setHighlightMode(bool highlightEvents
,
54 bool highlightJournals
) const;
55 void setUpdateNeeded();
58 Returns the month of the specified KDateNavigator.
59 The first navigatorIndex is 0.
60 Returns a QDate instead of uint so it can be easily feed to KCalendarSystem's
62 An invalid QDate() is returned if the index is too big or too small.
64 QDate
monthOfNavigator(int navigatorIndex
= 0) const;
68 preferredMonth is useful when the datelist crosses months, if different
69 from -1, it has the month that the kdatenavigator should show in case
72 void selectDates(const KCalCore::DateList
&, const QDate
&preferredMonth
= QDate());
76 void updateDayMatrix();
83 void datesSelected(const KCalCore::DateList
&, const QDate
&preferredMonth
);
84 void incidenceDropped(const Akonadi::Item
&, const QDate
&);
85 void incidenceDroppedMove(const Akonadi::Item
&, const QDate
&);
86 void newEventSignal(const QDate
&);
87 void newTodoSignal(const QDate
&);
88 void newJournalSignal(const QDate
&);
91 * @param preferredMonth Holds the month that should be selected when the
92 * week crosses months. It's a QDate instead of uint so it can be easily
93 * fed to KCalendarSystem's functions.
95 void weekClicked(const QDate
&week
, const QDate
&preferredMonth
);
100 void nextYearClicked();
101 void prevYearClicked();
103 /** Signals that the previous month button has been clicked.
105 @param currentMonth The month displayed on the first KDateNavigator.
106 DateNavigator doesn't know anything abouts months, it just has
107 a list of selected dates, so we must send this.
108 @param selectionLowerLimit The first date of the first KDateNavigator.
109 @param selectionUpperLimit The last date of the last KDateNavigator.
111 void prevMonthClicked(const QDate
¤tMonth
,
112 const QDate
&selectionLowerLimit
,
113 const QDate
&selectionUpperLimit
);
115 void nextMonthClicked(const QDate
¤tMonth
,
116 const QDate
&selectionLowerLimit
,
117 const QDate
&selectionUpperLimit
);
119 void monthSelected(int month
);
121 void yearSelected(int year
);
124 void resizeEvent(QResizeEvent
*) Q_DECL_OVERRIDE
;
125 void setBaseDates(const QDate
&start
);
126 void connectNavigatorView(KDateNavigator
*v
);
130 * Resizes all the child elements after the size of the widget changed.
131 * This slot is called by a QTimer::singleShot from resizeEvent.
132 * This makes the UI seem more responsive, since the other parts
133 * of the splitter are resized earlier now.
135 void resizeAllContents();
138 void handleDatesSelectedSignal(const KCalCore::DateList
&);
139 void handleWeekClickedSignal(const QDate
&, const QDate
&);
142 /* Returns the first day of the first KDateNavigator, and the last day
143 of the last KDateNavigator.
145 @param monthOffset If you have two KDateNavigators displaying
146 January and February and want to know the boundaries of,
147 for e.g. displaying February and March, use monthOffset = 1.
149 QPair
<QDate
, QDate
> dateLimits(int monthOffset
= 0) const;
152 * Returns the first KDateNavigator that displays date, or 0 if
153 * no KDateNavigator displays it.
155 KDateNavigator
*firstNavigatorForDate(const QDate
&date
) const;
157 KDateNavigator
*mNavigatorView
;
159 Akonadi::ETMCalendar::Ptr mCalendar
;
161 QList
<KDateNavigator
*> mExtraViews
;
163 int mHorizontalCount
;
166 bool mIgnoreNavigatorUpdates
;