27 #include <tqscrollview.h>
29 #include <tqguardedptr.h>
30 #include <libkcal/incidencebase.h>
32 #include "calendarview.h"
42 class IncidenceChangerBase;
53 class MarcusBains :
public TQFrame
58 MarcusBains( KOAgenda *agenda = 0,
const char *name = 0 );
59 void updateLocationRecalc(
bool recalculate =
false );
60 virtual ~MarcusBains();
63 void updateLocation();
74 class KOAgenda :
public TQScrollView
79 KOAgenda (
int columns,
int rows,
int columnSize,
CalendarView *calendarView,
80 TQWidget *parent=0,
const char *name = 0, WFlags f = 0 );
82 KOAgenda (
int columns,
CalendarView *calendarView, TQWidget *parent = 0,
83 const char *name = 0, WFlags f = 0 );
87 TQDate selectedIncidenceDate()
const;
92 const TQString lastSelectedUid()
const;
94 virtual bool eventFilter ( TQObject *, TQEvent * );
96 TQPoint contentsToGrid (
const TQPoint &pos )
const;
97 TQPoint gridToContents (
const TQPoint &gpos )
const;
99 int timeToY (
const TQTime &time );
100 TQTime gyToTime (
int y );
102 TQMemArray<int> minContentsY();
103 TQMemArray<int> maxContentsY();
105 int visibleContentsYMin();
106 int visibleContentsYMax();
108 void setStartTime(
const TQTime &startHour );
110 KOAgendaItem *insertItem (
Incidence *incidence,
const TQDate &qd,
int X,
int YTop,
111 int YBottom,
int itemPos,
int itemCount );
112 KOAgendaItem *insertAllDayItem (
Incidence *event,
const TQDate &qd,
int XBegin,
114 void insertMultiItem (
Event *event,
const TQDate &qd,
int XBegin,
int XEnd,
115 int YTop,
int YBottom );
121 void removeIncidence(
Incidence *incidence );
123 void changeColumns(
int columns );
125 int columns() {
return mColumns; }
126 int rows() {
return mRows; }
128 double gridSpacingX()
const {
return mGridSpacingX; }
129 double gridSpacingY()
const {
return mGridSpacingY; }
136 virtual int minimumWidth()
const;
140 void checkScrollBoundaries();
142 void setHolidayMask( TQMemArray<bool> * );
144 void setDateList(
const DateList &selectedDates );
145 DateList dateList()
const;
147 void setTypeAheadReceiver( TQObject * );
148 TQObject *typeAheadReceiver()
const;
149 void finishTypeAhead();
151 void setCalendar(
Calendar*cal ) { mCalendar = cal; }
152 void setIncidenceChanger( IncidenceChangerBase *changer ) { mChanger = changer; }
158 void checkScrollBoundaries(
int );
163 void clearSelection();
170 void selectItem( KOAgendaItem * );
174 void selectItemByUID(
const TQString& uid );
175 bool removeAgendaItem( KOAgendaItem *item );
176 void showAgendaItem( KOAgendaItem *item );
180 void newTimeSpanSignal(
const TQPoint &,
const TQPoint & );
181 void newStartSelectSignal();
183 void showIncidenceSignal(
Incidence *,
const TQDate & );
184 void editIncidenceSignal(
Incidence *,
const TQDate & );
185 void deleteIncidenceSignal(
Incidence * );
187 void showNewEventPopupSignal();
189 void itemModified( KOAgendaItem *item );
190 void incidenceSelected(
Incidence *,
const TQDate & );
191 void startMultiModify(
const TQString & );
192 void endMultiModify();
194 void lowerYChanged(
int );
195 void upperYChanged(
int );
198 void droppedToDo(
Todo*todo,
const TQPoint &gpos,
bool allDay );
200 void enableAgendaUpdate(
bool enable );
201 void zoomView(
const int delta,
const TQPoint &pos,
const TQt::Orientation );
203 void mousePosSignal(
const TQPoint &pos);
207 void gridSpacingYChanged(
double );
210 enum MouseActionType { NOP, MOVE, SELECT,
211 RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT };
214 void drawContents( TQPainter *p,
int cx,
int cy,
int cw,
int ch );
215 int columnWidth(
int column );
216 virtual void resizeEvent ( TQResizeEvent * );
219 virtual bool eventFilter_mouse ( TQObject *, TQMouseEvent * );
220 #ifndef TQT_NO_WHEELEVENT
222 virtual bool eventFilter_wheel ( TQObject *, TQWheelEvent * );
225 virtual bool eventFilter_key ( TQObject *, TQKeyEvent * );
228 virtual bool eventFilter_drag( TQObject *, TQDropEvent * );
236 MouseActionType isInResizeArea(
bool horizontal,
const TQPoint &pos, KOAgendaItem *item );
239 bool ptInSelection( TQPoint gpos )
const;
243 void startSelectAction(
const TQPoint &viewportPos );
246 void performSelectAction(
const TQPoint &viewportPos );
249 void endSelectAction(
const TQPoint &viewportPos );
252 void startItemAction(
const TQPoint& viewportPos);
255 void performItemAction(
const TQPoint& viewportPos);
258 void endItemAction();
261 void setNoActionCursor( KOAgendaItem *moveItem,
const TQPoint &viewportPos );
266 void setActionCursor(
int actionType,
bool acting=
false );
269 double calcSubCellWidth( KOAgendaItem *item );
271 void placeAgendaItem( KOAgendaItem *item,
double subCellWidth );
273 void placeSubCells( KOAgendaItem *placeItem );
275 void adjustItemPosition( KOAgendaItem *item );
280 void keyPressEvent( TQKeyEvent * );
282 void calculateWorkingHours();
284 virtual void contentsMousePressEvent ( TQMouseEvent * );
286 void emitNewEventForSelection();
290 void deleteItemsToDelete();
295 void resizeAllContents();
308 double mGridSpacingX;
309 double mGridSpacingY;
310 double mDesiredGridSpacingY;
313 int mResizeBorderWidth;
316 int mScrollBorderWidth;
320 TQTimer mScrollUpTimer;
321 TQTimer mScrollDownTimer;
332 bool mWorkingHoursEnable;
333 TQMemArray<bool> *mHolidayMask;
334 int mWorkingHoursYTop;
335 int mWorkingHoursYBottom;
339 TQPoint mSelectionStartPoint;
340 TQPoint mSelectionStartCell;
341 TQPoint mSelectionEndCell;
344 DateList mSelectedDates;
347 TQGuardedPtr<KOAgendaItem> mClickedItem;
350 TQGuardedPtr<KOAgendaItem> mActionItem;
351 TQPair<ResourceCalendar *, TQString> mResPair;
354 TQGuardedPtr<KOAgendaItem> mSelectedItem;
358 TQString mSelectedUid;
361 MarcusBains *mMarcusBains;
363 MouseActionType mActionType;
368 TQPtrList<KOAgendaItem> mItems;
369 TQPtrList<KOAgendaItem> mItemsToDelete;
371 TQPopupMenu *mItemPopup;
373 int mOldLowerScrollValue;
374 int mOldUpperScrollValue;
377 TQObject *mTypeAheadReceiver;
378 TQPtrList<TQEvent> mTypeAheadEvents;
381 KOrg::IncidenceChangerBase *mChanger;
This is the main calendar widget.