2
This file is part of KOrganizer.
4
Copyright (c) 2008 Bruno Virlet <bruno.virlet@gmail.com>
5
Copyright (c) 2008 Thomas Thrainer <tom_t@gmx.at>
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2 of the License, or
10
(at your option) any later version.
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
17
You should have received a copy of the GNU General Public License along
18
with this program; if not, write to the Free Software Foundation, Inc.,
19
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21
As a special exception, permission is given to link this program
22
with any edition of Qt, and distribute the resulting executable,
23
without including the source code for Qt in the source distribution.
26
#ifndef MONTHGRAPHICSITEMS_H
27
#define MONTHGRAPHICSITEMS_H
30
#include <QGraphicsItem>
35
class QStyleOptionGraphicsItem;
43
* Graphics items which indicates that the view can be scrolled to display
46
class ScrollIndicator : public QGraphicsItem
54
ScrollIndicator( ArrowDirection direction );
56
QRectF boundingRect() const;
57
void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget );
59
ArrowDirection direction() { return mDirection; }
62
ArrowDirection mDirection;
64
static const int mWidth = 30;
65
static const int mHeight = 10;
69
* Keeps information about a month cell.
74
MonthCell( int id, QDate date, QGraphicsScene *scene );
78
This is used to get the height of the minimum height (vertical position)
81
QList<MonthItem *> mMonthItemList;
83
QHash<int, MonthItem *> mHeightHash;
86
void addMonthItem( MonthItem *manager, int height );
88
int id() const { return mId; }
89
QDate date() const { return mDate; }
99
static int topMargin();
100
// returns true if the cell contains events below the height @p height
101
bool hasEventBelow( int height );
103
// TODO : move this to a new GUI class (monthcell could be GraphicsItems)
104
ScrollIndicator *upArrow() { return mUpArrow; }
105
ScrollIndicator *downArrow() { return mDownArrow; }
111
QGraphicsScene *mScene;
113
ScrollIndicator *mUpArrow;
114
ScrollIndicator *mDownArrow;
118
* A MonthGraphicsItem representing a part of an event. There should be
119
* one part per row = week
121
class MonthGraphicsItem : public QObject, public QGraphicsItem
124
Q_INTERFACES(QGraphicsItem)
127
typedef QList<MonthGraphicsItem *> List;
129
MonthGraphicsItem( MonthItem *manager );
130
~MonthGraphicsItem();
133
Change QGraphicsItem pos and boundingRect in the scene
134
according to the incidence start and end date.
136
void updateGeometry();
139
Returns the associated MonthItem.
141
MonthItem *monthItem() const { return mMonthItem; }
144
Returns the starting date of this item.
146
QDate startDate() const;
149
Returns the number of day this item spans on minus one
150
to be compatible with QDate::addDays().
155
Computed from startDate() and daySpan().
157
QDate endDate() const;
159
void setStartDate( const QDate &d );
160
void setDaySpan( int span );
163
Returns true if this item is currently being moved (ie. the
164
associated MonthItem is being moved).
166
bool isMoving() const;
169
Returns true if this item is currently being resized (ie. the
170
associated MonthItem is being moved).
172
bool isResizing() const;
175
Returns true if this MonthGraphicsItem is the first one of the
178
bool isBeginItem() const;
181
Returns true if this MonthGraphicsItem is the last one of the
184
bool isEndItem() const;
187
Reimplemented from QGraphicsItem
189
virtual QRectF boundingRect() const;
190
virtual void paint( QPainter *, const QStyleOptionGraphicsItem *, QWidget * );
191
virtual QPainterPath shape() const;
194
// Shape of the item, see shape()
195
QPainterPath widgetPath( bool border ) const;
203
// The current item is part of a MonthItem
204
MonthItem *mMonthItem;
209
#endif //MONTHGRAPHICSITEMS_H