korganizer

koagendaview.h
1 /*
2  This file is part of KOrganizer.
3 
4  Copyright (c) 2000,2001,2003 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 #ifndef KOAGENDAVIEW_H
26 #define KOAGENDAVIEW_H
27 
28 #include <tqscrollview.h>
29 #include <tqlabel.h>
30 
31 #include <libkcal/calendar.h>
32 
33 #include "calprinter.h"
34 #include "calendarview.h"
35 
36 #include "agendaview.h"
37 
38 class TQHBox;
39 class TQPushButton;
40 class TQBoxLayout;
41 
42 class KOAgenda;
43 class KOAgendaItem;
44 class TimeLabels;
45 class TDEConfig;
46 
47 namespace KOrg {
48  class IncidenceChangerBase;
49 }
50 
51 class EventIndicator : public TQFrame
52 {
53  TQ_OBJECT
54 
55  public:
56  enum Location { Top, Bottom };
57  EventIndicator( Location loc = Top, TQWidget *parent = 0,
58  const char *name = 0 );
59  virtual ~EventIndicator();
60 
61  void changeColumns( int columns );
62 
63  void enableColumn( int column, bool enable );
64 
65  protected:
66  void drawContents( TQPainter * );
67 
68  private:
69  int mColumns;
70  Location mLocation;
71  TQPixmap mPixmap;
72  TQMemArray<bool> mEnabled;
73 };
74 
75 class KOAlternateLabel : public TQLabel
76 {
77  TQ_OBJECT
78 
79  public:
80  KOAlternateLabel( const TQString &shortlabel, const TQString &longlabel,
81  const TQString &extensivelabel = TQString(),
82  TQWidget *parent = 0, const char *name = 0 );
83  ~KOAlternateLabel();
84 
85  virtual TQSize minimumSizeHint() const;
86 
87  enum TextType { Short = 0, Long = 1, Extensive = 2 };
88  TextType largestFittingTextType() const;
89  void setFixedType( TextType type );
90 
91  public slots:
92  void useShortText();
93  void useLongText();
94  void useExtensiveText();
95  void useDefaultText();
96 
97  protected:
98  virtual void resizeEvent( TQResizeEvent * );
99  virtual void squeezeTextToLabel();
100  bool mTextTypeFixed;
101  TQString mShortText, mLongText, mExtensiveText;
102 };
103 
109 {
110  TQ_OBJECT
111 
112  public:
113  KOAgendaView( Calendar *cal,
114  CalendarView *calendarView,
115  TQWidget *parent = 0,
116  const char *name = 0,
117  bool isSideBySide = false );
118  virtual ~KOAgendaView();
119 
121  virtual int maxDatesHint();
122 
124  virtual int currentDateCount();
125 
127  virtual Incidence::List selectedIncidences();
128 
130  virtual DateList selectedIncidenceDates();
131 
133  virtual bool eventDurationHint(TQDateTime &startDt, TQDateTime &endDt, bool &allDay);
134 
136  void clearView();
137 
138  KOrg::CalPrinterBase::PrintType printType();
139 
141  TQDateTime selectionStart() { return mTimeSpanBegin; }
143  TQDateTime selectionEnd() { return mTimeSpanEnd; }
145  bool selectedIsAllDay() { return mTimeSpanInAllDay; }
147  void deleteSelectedDateTime();
149  bool selectedIsSingleCell();
150 
151  void setTypeAheadReceiver( TQObject * );
152 
153  KOAgenda* agenda() const { return mAgenda; }
154  TQSplitter* splitter() const { return mSplitterAgenda; }
155  TQFrame *dayLabels() const { return mDayLabels; }
156 
157  /* reimplmented from KCal::Calendar::Observer */
158  void calendarIncidenceAdded( Incidence *incidence );
159  void calendarIncidenceChanged( Incidence *incidence );
160  void calendarIncidenceDeleted( Incidence *incidence );
161 
162  public slots:
163  virtual void updateView();
164  virtual void updateConfig();
165  virtual void showDates( const TQDate &start, const TQDate &end );
166  virtual void showIncidences( const Incidence::List &incidenceList, const TQDate &date );
167 
168  void insertIncidence( Incidence *incidence, const TQDate &curDate );
169  void changeIncidenceDisplayAdded( Incidence *incidence );
170  void changeIncidenceDisplay( Incidence *incidence, int mode );
171 
172  void clearSelection();
173 
174  void startDrag( Incidence * );
175 
176  void readSettings();
177  void readSettings( TDEConfig * );
178  void writeSettings( TDEConfig * );
179 
180  void setContentsPos( int y );
181 
182  void setExpandedButton( bool expanded );
183 
184  void finishTypeAhead();
185 
187  void slotTodoDropped( Todo *, const TQPoint &, bool );
188 
189  void enableAgendaUpdate( bool enable );
190  void setIncidenceChanger( KOrg::IncidenceChangerBase *changer );
191 
192  void zoomInHorizontally( const TQDate& date=TQDate() );
193  void zoomOutHorizontally( const TQDate& date=TQDate() );
194 
195  void zoomInVertically( );
196  void zoomOutVertically( );
197 
198  void zoomView( const int delta, const TQPoint &pos,
199 
200  const TQt::Orientation orient=TQt::Horizontal );
201 
202  void clearTimeSpanSelection();
203 
204  void resourcesChanged();
205 
206  signals:
207  void toggleExpand();
208  void zoomViewHorizontally(const TQDate &, int count );
209 
210  void timeSpanSelectionChanged();
211 
212  protected:
214  void fillAgenda( const TQDate &startDate );
215 
217  void fillAgenda();
218 
219  void connectAgenda( KOAgenda*agenda, TQPopupMenu*popup, KOAgenda* otherAgenda );
220 
222  void createDayLabels( bool force );
223 
227  void setHolidayMasks();
228 
229  void removeIncidence( Incidence * );
234  void updateEventIndicators();
235 
236  void updateTimeBarWidth();
237 
238  virtual void resizeEvent( TQResizeEvent *resizeEvent );
239 
240  protected slots:
242  void updateEventDates( KOAgendaItem *item );
244  void doUpdateItem();
245 
246  void updateEventIndicatorTop( int newY );
247  void updateEventIndicatorBottom( int newY );
248 
250  void newTimeSpanSelected( const TQPoint &start, const TQPoint &end );
252  void newTimeSpanSelectedAllDay( const TQPoint &start, const TQPoint &end );
253 
254  void updateDayLabelSizes();
255 
256  private:
257  bool filterByResource( Incidence *incidence );
258  void displayIncidence( Incidence *incidence );
259 
260  private:
261  // view widgets
262  TQFrame *mDayLabels;
263  TQHBox *mDayLabelsFrame;
264  TQBoxLayout *mLayoutDayLabels;
265  TQPtrList<KOAlternateLabel> mDateDayLabels;
266  TQFrame *mAllDayFrame;
267  KOAgenda *mAllDayAgenda;
268  KOAgenda *mAgenda;
269  TimeLabels *mTimeLabels;
270  TQWidget *mDummyAllDayLeft;
271  TQSplitter *mSplitterAgenda;
272  TQPushButton *mExpandButton;
273 
274  DateList mSelectedDates; // List of dates to be displayed
275  DateList mSaveSelectedDates; // Save the list of dates between updateViews
276  int mViewType;
277 
278  KOEventPopupMenu *mAgendaPopup;
279  KOEventPopupMenu *mAllDayAgendaPopup;
280 
281  EventIndicator *mEventIndicatorTop;
282  EventIndicator *mEventIndicatorBottom;
283 
284  TQMemArray<int> mMinY;
285  TQMemArray<int> mMaxY;
286 
287  TQMemArray<bool> mHolidayMask;
288 
289  TQPixmap mExpandedPixmap;
290  TQPixmap mNotExpandedPixmap;
291 
292  TQDateTime mTimeSpanBegin;
293  TQDateTime mTimeSpanEnd;
294  bool mTimeSpanInAllDay;
295  bool mAllowAgendaUpdate;
296 
297  Incidence *mUpdateItem;
298 
299  bool mIsSideBySide;
300  bool mPendingChanges;
301 
302  // the current date is inserted into mSelectedDates in the constructor
303  // however whe should only show events when setDates is called, otherwise
304  // we see day view with current date for a few milisecs, then we see something else
305  // because someone called setDates with the real dates that should be displayed.
306  // Other solution would be not initializing mSelectedDates in the ctor, but that requires
307  // lots of changes in koagenda.cpp and koagendaview.cpp
308  bool mAreDatesInitialized;
309 };
310 
311 #endif
This is the main calendar widget.
Definition: calendarview.h:82
KOAgendaView is the agenda-like view used to display events in a single one or multi-day view.
Definition: koagendaview.h:109
bool selectedIsSingleCell()
returns if only a single cell is selected, or a range of cells
void doUpdateItem()
update just the display of the given incidence, called by a single-shot timer
void newTimeSpanSelectedAllDay(const TQPoint &start, const TQPoint &end)
Updates data for selected timespan for all day event.
void fillAgenda()
Fill agenda using the current set value for the start date.
TQDateTime selectionEnd()
end-datetime of selection
Definition: koagendaview.h:143
virtual int maxDatesHint()
Returns maximum number of days supported by the koagendaview.
void clearView()
Remove all events from view.
void createDayLabels(bool force)
Create labels for the selected dates.
void updateEventIndicators()
Updates the event indicators after a certain incidence was modified or removed.
void setHolidayMasks()
Set the masks on the agenda widgets indicating, which days are holidays.
TQDateTime selectionStart()
start-datetime of selection
Definition: koagendaview.h:141
void updateEventDates(KOAgendaItem *item)
Update event belonging to agenda item.
virtual DateList selectedIncidenceDates()
returns the currently selected events
void newTimeSpanSelected(const TQPoint &start, const TQPoint &end)
Updates data for selected timespan.
virtual int currentDateCount()
Returns number of currently shown dates.
void slotTodoDropped(Todo *, const TQPoint &, bool)
reschedule the todo to the given x- and y- coordinates.
virtual bool eventDurationHint(TQDateTime &startDt, TQDateTime &endDt, bool &allDay)
return the default start/end date/time for new events
void deleteSelectedDateTime()
make selected start/end invalid
virtual Incidence::List selectedIncidences()
returns the currently selected events
bool selectedIsAllDay()
returns true if selection is for whole day
Definition: koagendaview.h:145
Base class for single/multi agenda views.
Definition: agendaview.h:28