korganizer

kodaymatrix.h
1 /*
2  This file is part of KOrganizer.
3 
4  Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at>
5  Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
6  Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
7 
8  This program is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 2 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 
22  As a special exception, permission is given to link this program
23  with any edition of TQt, and distribute the resulting executable,
24  without including the source code for TQt in the source distribution.
25 */
26 #ifndef KODAYMATRIX_H
27 #define KODAYMATRIX_H
28 
29 #include <libkcal/incidencebase.h>
30 #include <libkcal/calendar.h>
31 
32 #include <tqframe.h>
33 #include <tqcolor.h>
34 #include <tqtooltip.h>
35 #include <tqmap.h>
36 
37 class TQDragEnterEvent;
38 class TQDragMoveEvent;
39 class TQDragLeaveEvent;
40 class TQDropEvent;
41 
42 class KODayMatrix;
43 
44 namespace KCal {
45 class Incidence;
46 class Calendar;
47 }
48 using namespace KCal;
49 
50 
56 class DynamicTip : public TQToolTip
57 {
58  public:
64  DynamicTip( TQWidget *parent );
65 
66  protected:
73  void maybeTip( const TQPoint &pos );
74 
75  private:
77  KODayMatrix *mMatrix;
78 };
79 
105 class KODayMatrix: public TQFrame, public KCal::Calendar::Observer
106 {
107  TQ_OBJECT
108 
109  public:
116  KODayMatrix( TQWidget *parent, const char *name );
117 
120  ~KODayMatrix();
121 
125  static TQPair<TQDate,TQDate> matrixLimits( const TQDate &month );
126 
131  void setCalendar( Calendar * );
132 
140  void updateView( const TQDate &actdate );
141 
146  void updateEvents();
147 
151  const TQDate& getDate( int offset );
152 
156  TQString getHolidayLabel( int offset );
157 
161  void addSelectedDaysTo( DateList & );
162 
167  void setSelectedDaysFrom( const TQDate &start, const TQDate &end );
168 
172  void clearSelection();
173 
177  bool isTodayVisible() const { return mToday >= 0; }
178 
185  bool isBeginningOfMonth() const { return mToday <= 8; }
186  bool isEndOfMonth() const { return mToday >= 27; }
187 
188  /* reimplmented from KCal::Calendar::Observer */
189  void calendarIncidenceAdded( Incidence *incidence );
190  void calendarIncidenceChanged( Incidence *incidence );
191  void calendarIncidenceDeleted( Incidence *incidence );
192 
193  void setUpdateNeeded();
194 
195  public slots:
199  void updateView();
200 
205  void recalculateToday();
206 
210  void resourcesChanged();
211 
212  signals:
218  void selected( const KCal::DateList &daylist );
219 
225  void incidenceDropped( Incidence *incidence, const TQDate &dt );
231  void incidenceDroppedMove( Incidence *oldincidence, const TQDate &dt );
232 
233  protected:
234  void paintEvent( TQPaintEvent *ev );
235 
236  void mousePressEvent( TQMouseEvent *e );
237 
238  void mouseReleaseEvent( TQMouseEvent *e );
239 
240  void mouseMoveEvent( TQMouseEvent *e );
241 
242  void dragEnterEvent( TQDragEnterEvent * );
243 
244  void dragMoveEvent( TQDragMoveEvent * );
245 
246  void dragLeaveEvent( TQDragLeaveEvent * );
247 
248  void dropEvent( TQDropEvent * );
249 
250  void resizeEvent( TQResizeEvent * );
251 
252  private:
258  int getDayIndexFrom( int x, int y );
259 
265  TQColor getShadedColor( const TQColor &color );
266 
269  static const int NUMDAYS;
270 
272  Calendar *mCalendar;
273 
275  TQDate mStartDate;
276 
278  TQString *mDayLabels;
279 
282  TQDate *mDays;
283 
287  int *mEvents;
288 
290  TQMap<int,TQString> mHolidays;
291 
293  int mToday;
294 
297  int mSelInit;
298 
301  static const int NOSELECTION;
302 
304  int mSelStart;
305 
307  int mSelEnd;
308 
310  DynamicTip* mToolTip;
311 
313  int mTodayMarginWidth;
314 
318  TQRect mDaySize;
319 
323  bool mPendingChanges;
324 };
325 
326 #endif
small helper class to dynamically show tooltips inside the day matrix.
Definition: kodaymatrix.h:57
Replacement for kdpdatebuton.cpp that used 42 widgets for the day matrix to be displayed.
Definition: kodaymatrix.h:106
void selected(const KCal::DateList &daylist)
emitted if the user selects a block of days with the mouse by dragging a rectangle inside the matrix
void incidenceDropped(Incidence *incidence, const TQDate &dt)
emitted if the user has dropped an incidence (event or todo) inside the matrix
bool isTodayVisible() const
Is today visible in the view? Keep this in sync with the values today (below) can take.
Definition: kodaymatrix.h:177
void incidenceDroppedMove(Incidence *oldincidence, const TQDate &dt)
emitted if the user has dropped an event inside the matrix and chose to move it instead of copy
bool isBeginningOfMonth() const
If today is visible, then we can find out if today is near the beginning or the end of the month.
Definition: kodaymatrix.h:185