korganizer

komonthview.h
1/*
2 This file is part of KOrganizer.
3
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5 Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
6
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.
11
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.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
21 As a special exception, permission is given to link this program
22 with any edition of TQt, and distribute the resulting executable,
23 without including the source code for TQt in the source distribution.
24*/
25
26#ifndef _KOMONTHVIEW_H
27#define _KOMONTHVIEW_H
28
29#include <tqlistbox.h>
30#include <tqptrvector.h>
31#include <tqtooltip.h>
32#include "koeventview.h"
33
34class KNoScrollListBox;
35class MonthViewCell;
36
37class KOMonthCellToolTip : public TQToolTip
38{
39 public:
40 KOMonthCellToolTip (TQWidget* parent, Calendar *calendar, const TQDate &date, KNoScrollListBox* lv, MonthViewCell* cl);
41
42 protected:
43 void maybeTip( const TQPoint & pos);
44
45 private:
46 Calendar *mCalendar;
47 TQDate mDate;
48 KNoScrollListBox* eventlist;
49 MonthViewCell* cell;
50};
51
52
53class KNoScrollListBox: public TQListBox
54{
55 TQ_OBJECT
56
57 public:
58 KNoScrollListBox(TQWidget *parent=0, const char *name=0);
59 ~KNoScrollListBox() {}
60
61 void setBackground( bool primary, bool workday );
62
63 signals:
64 void shiftDown();
65 void shiftUp();
66 void rightClick();
67
68 protected slots:
69 void keyPressEvent(TQKeyEvent *);
70 void keyReleaseEvent(TQKeyEvent *);
71 void mousePressEvent(TQMouseEvent *);
72 void resizeEvent(TQResizeEvent *);
73 void contentsMouseDoubleClickEvent( TQMouseEvent * e );
74
75 private:
76 bool mSqueezing;
77};
78
79
80class MonthViewItem: public TQListBoxItem
81{
82 public:
83 MonthViewItem( Incidence *, const TQDateTime &qd, const TQString & title );
84
85 void setEvent(bool on) { mEvent = on; }
86 void setTodo(bool on) { mTodo = on; }
87 void setTodoDone(bool on) { mTodoDone = on; }
88 void setRecur(bool on) { mRecur = on; }
89 void setAlarm(bool on) { mAlarm = on; }
90 void setReply(bool on) { mReply = on; }
91
92 void setPalette(const TQPalette &p) { mPalette = p; }
93 TQPalette palette() const { return mPalette; }
94
95 Incidence *incidence() const { return mIncidence; }
96 TQDateTime incidenceDateTime() { return mDateTime; }
97
98 void setResourceColor( TQColor& color ) { mResourceColor = color; }
99 TQColor &resourceColor() { return mResourceColor; }
100 protected:
101 virtual void paint(TQPainter *);
102 virtual int height(const TQListBox *) const;
103 virtual int width(const TQListBox *) const;
104 //Color of the resource
105 TQColor mResourceColor;
106 private:
107 bool mEvent;
108 bool mTodo;
109 bool mTodoDone;
110 bool mRecur;
111 bool mAlarm;
112 bool mReply;
113
114 TQPixmap mEventPixmap;
115 TQPixmap mBirthdayPixmap;
116 TQPixmap mAnniversaryPixmap;
117 TQPixmap mTodoPixmap;
118 TQPixmap mTodoDonePixmap;
119 TQPixmap mAlarmPixmap;
120 TQPixmap mRecurPixmap;
121 TQPixmap mReplyPixmap;
122
123 TQPalette mPalette;
124 TQDateTime mDateTime;
125
126 Incidence *mIncidence;
127 TQColor catColor() const;
128};
129
130
131class KOMonthView;
132
137class MonthViewCell : public TQWidget
138{
139 TQ_OBJECT
140
141 public:
142 class CreateItemVisitor;
144
145 TQString holidayString( ) { return mHolidayString; }
146
148 void setDate( const TQDate & );
150 TQDate date() const;
151
153 KOMonthView *monthView() { return mMonthView; }
154
162 void setPrimary( bool primary );
166 bool isPrimary() const;
167
169 void setHoliday( bool );
175 void setHolidayString( const TQString &name );
176
177 void updateCell();
185 void addIncidence( Incidence *incidence, MonthViewCell::CreateItemVisitor&v, int multiDay = 0 );
190 void removeIncidence( Incidence * );
191
192 void updateConfig();
193
194 void enableScrollBars( bool );
195
196 Incidence *selectedIncidence();
197 TQDate selectedIncidenceDate();
198
199 void deselect();
200
201 signals:
202 void defaultAction( Incidence * );
208 void newEventSignal( ResourceCalendar *res,const TQString &subResource,
209 const TQDate &date );
210
211 public slots:
212 void select();
213
214 protected:
215 void setFrameWidth();
216 void resizeEvent( TQResizeEvent * );
217
218 protected slots:
219 void defaultAction( TQListBoxItem * );
220 void contextMenu( TQListBoxItem * );
221
222 private:
223 KOMonthView *mMonthView;
224
225 TQDate mDate;
226 bool mPrimary;
227 bool mHoliday;
228 TQString mHolidayString;
229
230 TQLabel *mLabel;
231 KNoScrollListBox *mItemList;
232
233 bool isSelected;
234
235 TQSize mLabelSize;
236// TQPalette mOriginalPalette;
237 TQPalette mHolidayPalette;
238 TQPalette mStandardPalette;
239 TQPalette mTodayPalette;
240};
241
250{
251 TQ_OBJECT
252
253 public:
254 KOMonthView(Calendar *cal, TQWidget *parent = 0, const char *name = 0 );
255 ~KOMonthView();
256
258 virtual int maxDatesHint();
259
261 virtual int currentDateCount();
262
264 virtual Incidence::List selectedIncidences();
265
267 virtual DateList selectedIncidenceDates();
268
269 virtual TQDateTime selectionStart();
270
271 virtual TQDateTime selectionEnd();
272
273 virtual bool eventDurationHint(TQDateTime &startDt, TQDateTime &endDt, bool &allDay);
274
275 public slots:
276 virtual void updateView();
277 virtual void updateConfig();
278 virtual void showDates(const TQDate &start, const TQDate &end);
279 virtual void showIncidences( const Incidence::List &incidenceList, const TQDate &date );
280
281 void changeIncidenceDisplay(Incidence *, int);
282 void changeIncidenceDisplayAdded(Incidence *, MonthViewCell::CreateItemVisitor&);
283
284 void clearSelection();
285
286 void showEventContextMenu( Calendar *, Incidence *, const TQDate & );
287 void showGeneralContextMenu();
288
289 void setSelectedCell( MonthViewCell * );
290
291 protected slots:
292 void processSelectionChange();
293
294 protected:
295 void resizeEvent(TQResizeEvent *);
296
297 void viewChanged();
298 void updateDayLabels();
299
300 private:
301 void showLabel( bool show );
302
303 class GetDateVisitor;
304 int mDaysPerWeek;
305 int mNumWeeks;
306 int mNumCells;
307 int mWeekStartDay;
308
309 TQPtrVector<MonthViewCell> mCells;
310 TQMap<TQDate,MonthViewCell *> mDateToCell;
311 TQPtrVector<TQLabel> mDayLabels;
312
313 bool mShortDayLabels;
314 int mWidthLongDayLabel;
315
316 TQDate mStartDate;
317 TQDate mSelectedDate;
318
319 MonthViewCell *mSelectedCell;
320
321 KOEventPopupMenu *mEventContextMenu;
322 TQLabel *mLabel;
323};
324
325#endif
KOEventView is the abstract base class from which all other calendar views for event data are derived...
Definition: koeventview.h:56
The class KOMonthView represents the monthly view in KOrganizer.
Definition: komonthview.h:250
virtual bool eventDurationHint(TQDateTime &startDt, TQDateTime &endDt, bool &allDay)
Set the default start/end date/time for new events.
virtual DateList selectedIncidenceDates()
Returns dates of the currently selected events.
virtual TQDateTime selectionEnd()
Returns the end of the selection, or an invalid TQDateTime if there is no selection or the view doesn...
virtual int currentDateCount()
Returns number of currently shown dates.
virtual Incidence::List selectedIncidences()
Returns the currently selected events.
virtual int maxDatesHint()
Returns maximum number of days supported by the komonthview.
virtual TQDateTime selectionStart()
Returns the start of the selection, or an invalid TQDateTime if there is no selection or the view doe...
This class represents one day in KOrganizer's month view.
Definition: komonthview.h:138
void setPrimary(bool primary)
Set this cell as primary if primary is true.
void removeIncidence(Incidence *)
Removes an incidence from the cell.
void setHolidayString(const TQString &name)
Sets the holiday name to this cell.
KOMonthView * monthView()
Definition: komonthview.h:153
void addIncidence(Incidence *incidence, MonthViewCell::CreateItemVisitor &v, int multiDay=0)
Adds an incidence to the cell.
void setHoliday(bool)
Make this cell show as a holiday.
TQDate date() const
bool isPrimary() const
void newEventSignal(ResourceCalendar *res, const TQString &subResource, const TQDate &date)
Notify the view manager that we want to create a new event, so an editor will pop up.
void setDate(const TQDate &)
Sets the date of the cell.