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 {
25 UpArrow,
26 DownArrow
27 };
28
29 explicit ScrollIndicator(ArrowDirection direction);
30
31 [[nodiscard]] QRectF boundingRect() const override;
32 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
33
34 [[nodiscard]] ArrowDirection direction() const
35 {
36 return mDirection;
37 }
38
39private:
40 ArrowDirection mDirection;
41
42 static const int mWidth = 30;
43 static const int mHeight = 10;
44};
45
46/**
47 * Keeps information about a month cell.
48 */
50{
51public:
52 MonthCell(int id, QDate date, QGraphicsScene *scene);
53 ~MonthCell();
54
55 /**
56 This is used to get the height of the minimum height (vertical position)
57 in the month cells.
58 */
60
61 QHash<int, MonthItem *> mHeightHash;
62
63 [[nodiscard]] int firstFreeSpace();
64 void addMonthItem(MonthItem *manager, int height);
65
66 [[nodiscard]] int id() const
67 {
68 return mId;
69 }
70
71 [[nodiscard]] QDate date() const
72 {
73 return mDate;
74 }
75
76 [[nodiscard]] int x() const
77 {
78 return mId % 7;
79 }
80
81 [[nodiscard]] int y() const
82 {
83 return mId / 7;
84 }
85
86 static int topMargin();
87 // returns true if the cell contains events below the height @p height
88 bool hasEventBelow(int height);
89
90 // TODO : move this to a new GUI class (monthcell could be GraphicsItems)
91 ScrollIndicator *upArrow() const
92 {
93 return mUpArrow;
94 }
95
96 ScrollIndicator *downArrow() const
97 {
98 return mDownArrow;
99 }
100
101private:
102 int mId;
103 QDate mDate;
104
105 QGraphicsScene *mScene = nullptr;
106
107 ScrollIndicator *mUpArrow = nullptr;
108 ScrollIndicator *mDownArrow = nullptr;
109};
110
111/**
112 * A MonthGraphicsItem representing a part of an event. There should be
113 * one part per row = week
114 */
116{
119
120public:
122
123 explicit MonthGraphicsItem(MonthItem *manager);
124 ~MonthGraphicsItem() override;
125
126 /**
127 Change QGraphicsItem pos and boundingRect in the scene
128 according to the incidence start and end date.
129 */
130 void updateGeometry();
131
132 /**
133 Returns the associated MonthItem.
134 */
136 {
137 return mMonthItem;
138 }
139
140 /**
141 Returns the starting date of this item.
142 */
143 [[nodiscard]] QDate startDate() const;
144
145 /**
146 Returns the number of day this item spans on minus one
147 to be compatible with QDate::addDays().
148 */
149 [[nodiscard]] int daySpan() const;
150
151 /**
152 Computed from startDate() and daySpan().
153 */
154 [[nodiscard]] QDate endDate() const;
155
156 void setStartDate(QDate d);
157 void setDaySpan(int span);
158
159 /**
160 Returns true if this item is currently being moved (ie. the
161 associated MonthItem is being moved).
162 */
163 [[nodiscard]] bool isMoving() const;
164
165 /**
166 Returns true if this item is currently being resized (ie. the
167 associated MonthItem is being moved).
168 */
169 [[nodiscard]] bool isResizing() const;
170
171 /**
172 Returns true if this MonthGraphicsItem is the first one of the
173 MonthItem ones.
174 */
175 [[nodiscard]] bool isBeginItem() const;
176
177 /**
178 Returns true if this MonthGraphicsItem is the last one of the
179 MonthItem ones.
180 */
181 [[nodiscard]] bool isEndItem() const;
182
183 /**
184 Reimplemented from QGraphicsItem
185 */
186 QRectF boundingRect() const override;
187 void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override;
188 QPainterPath shape() const override;
189
190 [[nodiscard]] QString getToolTip() const;
191
192private:
193 // Shape of the item, see shape()
194 [[nodiscard]] QPainterPath widgetPath(bool border) const;
195
196 // See startDate()
197 QDate mStartDate;
198
199 // See daySpan()
200 int mDaySpan;
201
202 // The current item is part of a MonthItem
203 MonthItem *mMonthItem = nullptr;
204};
205}
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 Sat Dec 21 2024 16:57:55 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.