Eventviews

agendaview.h
1/*
2 SPDX-FileCopyrightText: 2000, 2001, 2003 Cornelius Schumacher <schumacher@kde.org>
3 SPDX-FileCopyrightText: 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
4 SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.net>
5 SPDX-FileContributor: Kevin Krammer <krake@kdab.com>
6 SPDX-FileContributor: Sergio Martins <sergio@kdab.com>
7
8 SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0
9*/
10#pragma once
11
12#include "eventview.h"
13#include "eventviews_export.h"
14#include "viewcalendar.h"
15
16#include <KCalendarCore/Todo>
17
18#include <memory>
19
20class KConfig;
21
22class QSplitter;
23
24namespace EventViews
25{
26namespace CalendarDecoration
27{
28class Decoration;
29}
30
31class TimeLabels;
32class TimeLabelsZone;
33
34class Agenda;
35class AgendaItem;
36class AgendaView;
37
38class EventIndicatorPrivate;
39
40class EventIndicator : public QWidget
41{
43public:
44 enum Location {
45 Top,
46 Bottom
47 };
48 explicit EventIndicator(Location loc = Top, QWidget *parent = nullptr);
49 ~EventIndicator() override;
50
51 void changeColumns(int columns);
52
53 void enableColumn(int column, bool enable);
54
55protected:
56 void paintEvent(QPaintEvent *event) override;
57 bool eventFilter(QObject *, QEvent *) override;
58
59private:
60 std::unique_ptr<EventIndicatorPrivate> const d;
61};
62
63class AgendaViewPrivate;
64
65/**
66 AgendaView is the agenda-like view that displays events in a single
67 or multi-day view.
68*/
69class EVENTVIEWS_EXPORT AgendaView : public EventView
70{
71 Q_OBJECT
72public:
73 explicit AgendaView(const PrefsPtr &preferences, QDate start, QDate end, bool isInteractive, bool isSideBySide = false, QWidget *parent = nullptr);
74
75 explicit AgendaView(QDate start, QDate end, bool isInteractive, bool isSideBySide = false, QWidget *parent = nullptr);
76
77 ~AgendaView() override;
78
79 enum {
80 MAX_DAY_COUNT = 42 // (6 * 7)
81 };
82
83 void addCalendar(const Akonadi::CollectionCalendar::Ptr &calendar) override;
84 void removeCalendar(const Akonadi::CollectionCalendar::Ptr &calendar) override;
85
86 /** Returns number of currently shown dates. */
87 [[nodiscard]] int currentDateCount() const override;
88
89 /** returns the currently selected events */
90 [[nodiscard]] Akonadi::Item::List selectedIncidences() const override;
91
92 /** returns the currently selected incidence's dates */
93 [[nodiscard]] KCalendarCore::DateList selectedIncidenceDates() const override;
94
95 /** return the default start/end date/time for new events */
96 bool eventDurationHint(QDateTime &startDt, QDateTime &endDt, bool &allDay) const override;
97
98 /** start-datetime of selection */
99 [[nodiscard]] QDateTime selectionStart() const override;
100
101 /** end-datetime of selection */
102 [[nodiscard]] QDateTime selectionEnd() const override;
103
104 /** returns true if selection is for whole day */
105 [[nodiscard]] bool selectedIsAllDay() const;
106
107 /** make selected start/end invalid */
108 void deleteSelectedDateTime();
109
110 /** returns if only a single cell is selected, or a range of cells */
111 [[nodiscard]] bool selectedIsSingleCell() const;
112
113 /* reimp from EventView */
114 virtual void addCalendar(const ViewCalendar::Ptr &cal);
115
116 QSplitter *splitter() const;
117
118 // FIXME: we already have startDateTime() and endDateTime() in the base class
119
120 /** First shown day */
121 [[nodiscard]] QDate startDate() const;
122 /** Last shown day */
123 [[nodiscard]] QDate endDate() const;
124
125 /** Update event belonging to agenda item
126 If the incidence is multi-day, item is the first one
127 */
128 void updateEventDates(AgendaItem *item, bool addIncidence, Akonadi::Collection::Id collectionId);
129
130 [[nodiscard]] QList<bool> busyDayMask() const;
131
132 /**
133 * Return calendar object for a concrete incidence.
134 * this function is able to use multiple calendars
135 * TODO: replace EventsView::calendar()
136 */
137 virtual KCalendarCore::Calendar::Ptr calendar2(const KCalendarCore::Incidence::Ptr &incidence) const;
138 virtual KCalendarCore::Calendar::Ptr calendar2(const QString &incidenceIdentifier) const;
139
140 void showDates(const QDate &start, const QDate &end, const QDate &preferredMonth = QDate()) override;
141
142 void showIncidences(const Akonadi::Item::List &incidenceList, const QDate &date) override;
143
144 void clearSelection() override;
145
146 void startDrag(const Akonadi::Item &);
147
148 void readSettings();
149 void readSettings(const KConfig *);
150 void writeSettings(KConfig *);
151
152 void enableAgendaUpdate(bool enable);
153 void setIncidenceChanger(Akonadi::IncidenceChanger *changer) override;
154
155 void zoomInHorizontally(QDate date = QDate());
156 void zoomOutHorizontally(QDate date = QDate());
157
158 void zoomInVertically();
159 void zoomOutVertically();
160
161 void zoomView(const int delta, QPoint pos, const Qt::Orientation orient = Qt::Horizontal);
162
163 void clearTimeSpanSelection();
164
165 // Used by the timelabelszone
166 void updateTimeBarWidth();
167 /** Create labels for the selected dates. */
168 void createDayLabels(bool force);
169
170 void createTimeBarHeaders();
171
172 void setChanges(EventView::Changes) override;
173
174 void setTitle(const QString &title);
175
176Q_SIGNALS:
177 void showNewEventPopupSignal();
178 void showIncidencePopupSignal(const Akonadi::CollectionCalendar::Ptr &, const Akonadi::Item &, const QDate &);
179 void zoomViewHorizontally(const QDate &, int count);
180
181 void timeSpanSelectionChanged();
182
183protected:
184 /** Fill agenda using the current set value for the start date */
185 void fillAgenda();
186
187 void connectAgenda(Agenda *agenda, Agenda *otherAgenda);
188
189 /**
190 Set the masks on the agenda widgets indicating, which days are holidays.
191 */
192 void setHolidayMasks();
193
194 void removeIncidence(const KCalendarCore::Incidence::Ptr &inc);
195
196public Q_SLOTS:
197 void updateView() override;
198 void updateConfig() override;
199 /** reschedule the todo to the given x- and y- coordinates.
200 Third parameter determines all-day (no time specified) */
201 void slotIncidencesDropped(const KCalendarCore::Incidence::List &incidences, const QPoint &, bool);
202 void slotIncidencesDropped(const QList<QUrl> &incidences, const QPoint &, bool);
203 void startDrag(const KCalendarCore::Incidence::Ptr &);
204
205protected Q_SLOTS:
206 void updateEventIndicatorTop(int newY);
207 void updateEventIndicatorBottom(int newY);
208
209 /** Updates data for selected timespan */
210 void newTimeSpanSelected(const QPoint &start, const QPoint &end);
211 /** Updates data for selected timespan for all day event*/
212 void newTimeSpanSelectedAllDay(const QPoint &start, const QPoint &end);
213 /**
214 Updates the event indicators after a certain incidence was modified or
215 removed.
216 */
217 void updateEventIndicators();
218 void scheduleUpdateEventIndicators();
219
220 void alignAgendas();
221
222protected:
223 void showEvent(QShowEvent *showEvent) override;
224 bool eventFilter(QObject *object, QEvent *event) override;
225
226private:
227 void slotIncidenceSelected(const KCalendarCore::Incidence::Ptr &incidence, QDate date);
228 void slotShowIncidencePopup(const KCalendarCore::Incidence::Ptr &incidence, QDate date);
229 void slotEditIncidence(const KCalendarCore::Incidence::Ptr &incidence);
230 void slotShowIncidence(const KCalendarCore::Incidence::Ptr &incidence);
231 void slotDeleteIncidence(const KCalendarCore::Incidence::Ptr &incidence);
232
233 void init(QDate start, QDate end);
234 bool filterByCollectionSelection(const KCalendarCore::Incidence::Ptr &incidence);
235 void setupTimeLabel(TimeLabels *timeLabel);
236 bool displayIncidence(const KCalendarCore::Incidence::Ptr &incidence, bool createSelected);
237
238 friend class TimeLabelsZone;
239 friend class MultiAgendaViewPrivate;
240 friend class MultiAgendaView;
241 Agenda *agenda() const;
242 Agenda *allDayAgenda() const;
243
244 friend class AgendaViewPrivate;
245 std::unique_ptr<AgendaViewPrivate> const d;
246};
247}
This class describes the widgets that represent the various calendar items in the agenda view.
Definition agendaitem.h:61
AgendaView is the agenda-like view that displays events in a single or multi-day view.
Definition agendaview.h:70
EventView is the abstract base class from which all other calendar views for event data are derived.
Definition eventview.h:69
Shows one agenda for every resource side-by-side.
Q_SCRIPTABLE Q_NOREPLY void start()
Namespace EventViews provides facilities for displaying incidences, including events,...
Definition agenda.h:33
Q_OBJECTQ_OBJECT
QObject * parent() const const
Orientation
virtual bool event(QEvent *event) override
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:07:11 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.