Eventviews

monthgraphicsitems.h
1/*
2 SPDX-FileCopyrightText: 2008 Bruno Virlet <bruno.virlet@gmail.com>
3 SPDX-FileCopyrightText: 2008 Thomas Thrainer <tom_t@gmx.at>
4
5 SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0
6*/
7
8#pragma once
9
10#include <QDate>
11#include <QGraphicsItem>
12
13namespace EventViews
14{
15class MonthItem;
16
17/**
18 * Graphics items which indicates that the view can be scrolled to display
19 * more events.
20 */
22{
23public:
24 enum ArrowDirection { UpArrow, DownArrow };
25
26 explicit ScrollIndicator(ArrowDirection direction);
27
28 [[nodiscard]] QRectF boundingRect() const override;
29 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
30
31 [[nodiscard]] ArrowDirection direction() const
32 {
33 return mDirection;
34 }
35
36private:
37 ArrowDirection mDirection;
38
39 static const int mWidth = 30;
40 static const int mHeight = 10;
41};
42
43/**
44 * Keeps information about a month cell.
45 */
47{
48public:
49 MonthCell(int id, QDate date, QGraphicsScene *scene);
50 ~MonthCell();
51
52 /**
53 This is used to get the height of the minimum height (vertical position)
54 in the month cells.
55 */
57
58 QHash<int, MonthItem *> mHeightHash;
59
60 [[nodiscard]] int firstFreeSpace();
61 void addMonthItem(MonthItem *manager, int height);
62
63 [[nodiscard]] int id() const
64 {
65 return mId;
66 }
67
68 [[nodiscard]] QDate date() const
69 {
70 return mDate;
71 }
72
73 [[nodiscard]] int x() const
74 {
75 return mId % 7;
76 }
77
78 [[nodiscard]] int y() const
79 {
80 return mId / 7;
81 }
82
83 static int topMargin();
84 // returns true if the cell contains events below the height @p height
85 bool hasEventBelow(int height);
86
87 // TODO : move this to a new GUI class (monthcell could be GraphicsItems)
88 ScrollIndicator *upArrow() const
89 {
90 return mUpArrow;
91 }
92
93 ScrollIndicator *downArrow() const
94 {
95 return mDownArrow;
96 }
97
98private:
99 int mId;
100 QDate mDate;
101
102 QGraphicsScene *mScene = nullptr;
103
104 ScrollIndicator *mUpArrow = nullptr;
105 ScrollIndicator *mDownArrow = nullptr;
106};
107
108/**
109 * A MonthGraphicsItem representing a part of an event. There should be
110 * one part per row = week
111 */
113{
116
117public:
119
120 explicit MonthGraphicsItem(MonthItem *manager);
121 ~MonthGraphicsItem() override;
122
123 /**
124 Change QGraphicsItem pos and boundingRect in the scene
125 according to the incidence start and end date.
126 */
127 void updateGeometry();
128
129 /**
130 Returns the associated MonthItem.
131 */
133 {
134 return mMonthItem;
135 }
136
137 /**
138 Returns the starting date of this item.
139 */
140 [[nodiscard]] QDate startDate() const;
141
142 /**
143 Returns the number of day this item spans on minus one
144 to be compatible with QDate::addDays().
145 */
146 [[nodiscard]] int daySpan() const;
147
148 /**
149 Computed from startDate() and daySpan().
150 */
151 [[nodiscard]] QDate endDate() const;
152
153 void setStartDate(QDate d);
154 void setDaySpan(int span);
155
156 /**
157 Returns true if this item is currently being moved (ie. the
158 associated MonthItem is being moved).
159 */
160 [[nodiscard]] bool isMoving() const;
161
162 /**
163 Returns true if this item is currently being resized (ie. the
164 associated MonthItem is being moved).
165 */
166 [[nodiscard]] bool isResizing() const;
167
168 /**
169 Returns true if this MonthGraphicsItem is the first one of the
170 MonthItem ones.
171 */
172 [[nodiscard]] bool isBeginItem() const;
173
174 /**
175 Returns true if this MonthGraphicsItem is the last one of the
176 MonthItem ones.
177 */
178 [[nodiscard]] bool isEndItem() const;
179
180 /**
181 Reimplemented from QGraphicsItem
182 */
183 QRectF boundingRect() const override;
184 void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override;
185 QPainterPath shape() const override;
186
187 [[nodiscard]] QString getToolTip() const;
188
189private:
190 // Shape of the item, see shape()
191 [[nodiscard]] QPainterPath widgetPath(bool border) const;
192
193 // See startDate()
194 QDate mStartDate;
195
196 // See daySpan()
197 int mDaySpan;
198
199 // The current item is part of a MonthItem
200 MonthItem *mMonthItem = nullptr;
201};
202}
Keeps information about a month cell.
QList< MonthItem * > mMonthItemList
This is used to get the height of the minimum height (vertical position) in the month cells.
A MonthGraphicsItem representing a part of an event.
QDate startDate() const
Returns the starting date of this item.
QDate endDate() const
Computed from startDate() and daySpan().
bool isMoving() const
Returns true if this item is currently being moved (ie.
MonthItem * monthItem() const
Returns the associated MonthItem.
void updateGeometry()
Change QGraphicsItem pos and boundingRect in the scene according to the incidence start and end date.
QRectF boundingRect() const override
Reimplemented from QGraphicsItem.
bool isBeginItem() const
Returns true if this MonthGraphicsItem is the first one of the MonthItem ones.
bool isEndItem() const
Returns true if this MonthGraphicsItem is the last one of the MonthItem ones.
int daySpan() const
Returns the number of day this item spans on minus one to be compatible with QDate::addDays().
bool isResizing() const
Returns true if this item is currently being resized (ie.
A month item manages different MonthGraphicsItems.
Definition monthitem.h:27
Graphics items which indicates that the view can be scrolled to display more events.
Namespace EventViews provides facilities for displaying incidences, including events,...
Definition agenda.h:33
Q_INTERFACES(...)
Q_OBJECTQ_OBJECT
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:12:29 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.