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 
34 class KNoScrollListBox;
35 
36 class KOMonthCellToolTip : public TQToolTip
37 {
38  public:
39  KOMonthCellToolTip (TQWidget* parent, Calendar *calendar, const TQDate &date, KNoScrollListBox* lv );
40 
41  protected:
42  void maybeTip( const TQPoint & pos);
43 
44  private:
45  Calendar *mCalendar;
46  TQDate mDate;
47  KNoScrollListBox* eventlist;
48 };
49 
50 
51 class KNoScrollListBox: public TQListBox
52 {
53  TQ_OBJECT
54 
55  public:
56  KNoScrollListBox(TQWidget *parent=0, const char *name=0);
57  ~KNoScrollListBox() {}
58 
59  void setBackground( bool primary, bool workday );
60 
61  signals:
62  void shiftDown();
63  void shiftUp();
64  void rightClick();
65 
66  protected slots:
67  void keyPressEvent(TQKeyEvent *);
68  void keyReleaseEvent(TQKeyEvent *);
69  void mousePressEvent(TQMouseEvent *);
70  void resizeEvent(TQResizeEvent *);
71  void contentsMouseDoubleClickEvent( TQMouseEvent * e );
72 
73  private:
74  bool mSqueezing;
75 };
76 
77 
78 class MonthViewItem: public TQListBoxItem
79 {
80  public:
81  MonthViewItem( Incidence *, const TQDateTime &qd, const TQString & title );
82 
83  void setEvent(bool on) { mEvent = on; }
84  void setTodo(bool on) { mTodo = on; }
85  void setTodoDone(bool on) { mTodoDone = on; }
86  void setRecur(bool on) { mRecur = on; }
87  void setAlarm(bool on) { mAlarm = on; }
88  void setReply(bool on) { mReply = on; }
89 
90  void setPalette(const TQPalette &p) { mPalette = p; }
91  TQPalette palette() const { return mPalette; }
92 
93  Incidence *incidence() const { return mIncidence; }
94  TQDateTime incidenceDateTime() { return mDateTime; }
95 
96  void setResourceColor( TQColor& color ) { mResourceColor = color; }
97  TQColor &resourceColor() { return mResourceColor; }
98  protected:
99  virtual void paint(TQPainter *);
100  virtual int height(const TQListBox *) const;
101  virtual int width(const TQListBox *) const;
102  //Color of the resource
103  TQColor mResourceColor;
104  private:
105  bool mEvent;
106  bool mTodo;
107  bool mTodoDone;
108  bool mRecur;
109  bool mAlarm;
110  bool mReply;
111 
112  TQPixmap mEventPixmap;
113  TQPixmap mBirthdayPixmap;
114  TQPixmap mAnniversaryPixmap;
115  TQPixmap mTodoPixmap;
116  TQPixmap mTodoDonePixmap;
117  TQPixmap mAlarmPixmap;
118  TQPixmap mRecurPixmap;
119  TQPixmap mReplyPixmap;
120 
121  TQPalette mPalette;
122  TQDateTime mDateTime;
123 
124  Incidence *mIncidence;
125  TQColor catColor() const;
126 };
127 
128 
129 class KOMonthView;
130 
135 class MonthViewCell : public TQWidget
136 {
137  TQ_OBJECT
138 
139  public:
140  class CreateItemVisitor;
142 
144  void setDate( const TQDate & );
146  TQDate date() const;
147 
149  KOMonthView *monthView() { return mMonthView; }
150 
158  void setPrimary( bool primary );
162  bool isPrimary() const;
163 
165  void setHoliday( bool );
171  void setHolidayString( const TQString &name );
172 
173  void updateCell();
181  void addIncidence( Incidence *incidence, MonthViewCell::CreateItemVisitor&v, int multiDay = 0 );
186  void removeIncidence( Incidence * );
187 
188  void updateConfig();
189 
190  void enableScrollBars( bool );
191 
192  Incidence *selectedIncidence();
193  TQDate selectedIncidenceDate();
194 
195  void deselect();
196 
197  signals:
198  void defaultAction( Incidence * );
204  void newEventSignal( ResourceCalendar *res,const TQString &subResource,
205  const TQDate &date );
206 
207  public slots:
208  void select();
209 
210  protected:
211  void setFrameWidth();
212  void resizeEvent( TQResizeEvent * );
213 
214  protected slots:
215  void defaultAction( TQListBoxItem * );
216  void contextMenu( TQListBoxItem * );
217 
218  private:
219  KOMonthView *mMonthView;
220 
221  TQDate mDate;
222  bool mPrimary;
223  bool mHoliday;
224  TQString mHolidayString;
225 
226  TQLabel *mLabel;
227  KNoScrollListBox *mItemList;
228 
229  bool isSelected;
230 
231  TQSize mLabelSize;
232 // TQPalette mOriginalPalette;
233  TQPalette mHolidayPalette;
234  TQPalette mStandardPalette;
235  TQPalette mTodayPalette;
236 };
237 
246 {
247  TQ_OBJECT
248 
249  public:
250  KOMonthView(Calendar *cal, TQWidget *parent = 0, const char *name = 0 );
251  ~KOMonthView();
252 
254  virtual int maxDatesHint();
255 
257  virtual int currentDateCount();
258 
260  virtual Incidence::List selectedIncidences();
261 
263  virtual DateList selectedIncidenceDates();
264 
265  virtual TQDateTime selectionStart();
266 
267  virtual TQDateTime selectionEnd();
268 
269  virtual bool eventDurationHint(TQDateTime &startDt, TQDateTime &endDt, bool &allDay);
270 
271  public slots:
272  virtual void updateView();
273  virtual void updateConfig();
274  virtual void showDates(const TQDate &start, const TQDate &end);
275  virtual void showIncidences( const Incidence::List &incidenceList, const TQDate &date );
276 
277  void changeIncidenceDisplay(Incidence *, int);
278  void changeIncidenceDisplayAdded(Incidence *, MonthViewCell::CreateItemVisitor&);
279 
280  void clearSelection();
281 
282  void showEventContextMenu( Calendar *, Incidence *, const TQDate & );
283  void showGeneralContextMenu();
284 
285  void setSelectedCell( MonthViewCell * );
286 
287  protected slots:
288  void processSelectionChange();
289 
290  protected:
291  void resizeEvent(TQResizeEvent *);
292 
293  void viewChanged();
294  void updateDayLabels();
295 
296  private:
297  void showLabel( bool show );
298 
299  class GetDateVisitor;
300  int mDaysPerWeek;
301  int mNumWeeks;
302  int mNumCells;
303  int mWeekStartDay;
304 
305  TQPtrVector<MonthViewCell> mCells;
306  TQMap<TQDate,MonthViewCell *> mDateToCell;
307  TQPtrVector<TQLabel> mDayLabels;
308 
309  bool mShortDayLabels;
310  int mWidthLongDayLabel;
311 
312  TQDate mStartDate;
313  TQDate mSelectedDate;
314 
315  MonthViewCell *mSelectedCell;
316 
317  KOEventPopupMenu *mEventContextMenu;
318  TQLabel *mLabel;
319 };
320 
321 #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:246
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:136
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.
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.
KOMonthView * monthView()
Definition: komonthview.h:149
void setDate(const TQDate &)
Sets the date of the cell.