summaryrefslogtreecommitdiffabout
path: root/korganizer/calendarview.h
Unidiff
Diffstat (limited to 'korganizer/calendarview.h') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.h586
1 files changed, 586 insertions, 0 deletions
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
new file mode 100644
index 0000000..e7aa351
--- a/dev/null
+++ b/korganizer/calendarview.h
@@ -0,0 +1,586 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2000, 2001
4 Cornelius Schumacher <schumacher@kde.org>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution.
23*/
24#ifndef CALENDARVIEW_H
25#define CALENDARVIEW_H
26
27#include <qframe.h>
28#include <qlayout.h>
29#include <qwidget.h>
30#include <qptrlist.h>
31#include <qvbox.h>
32#include <qmap.h>
33#ifndef DESKTOP_VERSION
34#include <qtopia/ir.h>
35#else
36#define Ir char
37#endif
38#include <libkcal/calendar.h>
39#include <libkcal/scheduler.h>
40#include <libkcal/calendarresources.h>
41#include <libkcal/resourcecalendar.h>
42
43#include <korganizer/calendarviewbase.h>
44
45class QWidgetStack;
46class QSplitter;
47
48class CalPrinter;
49class KOFilterView;
50class KOViewManager;
51class KODialogManager;
52class KOTodoView;
53class KDateNavigator;
54class DateNavigator;
55class KOIncidenceEditor;
56class KDatePicker;
57class ResourceView;
58class NavigatorBar;
59class KOEventEditor;
60class KOTodoEditor ;
61class KOEventViewerDialog;
62class KOBeamPrefs;
63class KSyncProfile;
64class AlarmDialog;
65class KCal::Attendee;
66
67namespace KCal { class FileStorage; }
68
69using namespace KCal;
70
71/**
72 This is the main calendar widget. It provides the different vies on t he
73 calendar data as well as the date navigator. It also handles synchronisation
74 of the different views and controls the different dialogs like preferences,
75 event editor, search dialog etc.
76
77 @short main calendar view widget
78 @author Cornelius Schumacher
79*/
80class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer
81{
82 Q_OBJECT
83 public:
84 /**
85 Constructs a new calendar view widget.
86
87 @param calendar calendar document
88 @param parent parent window
89 @param name Qt internal widget object name
90 */
91 CalendarView( CalendarResources *calendar, QWidget *parent = 0,
92 const char *name = 0 );
93 CalendarView( Calendar *calendar, QWidget *parent = 0,
94 const char *name = 0 );
95 virtual ~CalendarView();
96
97 Calendar *calendar() { return mCalendar; }
98
99 KOViewManager *viewManager();
100 KODialogManager *dialogManager();
101
102 QDate startDate();
103 QDate endDate();
104
105 QWidgetStack *viewStack();
106 QWidget *leftFrame();
107 NavigatorBar *navigatorBar();
108
109 DateNavigator *dateNavigator();
110 KDateNavigator *dateNavigatorWidget();
111
112 void addView(KOrg::BaseView *);
113 void showView(KOrg::BaseView *);
114 KOEventViewerDialog* getEventViewerDialog();
115 Incidence *currentSelection();
116
117 signals:
118 /** This todo has been modified */
119 void todoModified(Todo *, int);
120
121 /** when change is made to options dialog, the topwidget will catch this
122 * and emit this signal which notifies all widgets which have registered
123 * for notification to update their settings. */
124 void configChanged();
125 /** emitted when the topwidget is closing down, so that any attached
126 child windows can also close. */
127 void closingDown();
128 /** emitted right before we die */
129 void closed(QWidget *);
130
131 /** Emitted when state of modified flag changes */
132 void modifiedChanged(bool);
133 void signalmodified();
134
135 /** Emitted when state of read-only flag changes */
136 void readOnlyChanged(bool);
137
138 /** Emitted when the unit of navigation changes */
139 void changeNavStringPrev(const QString &);
140 void changeNavStringNext(const QString &);
141
142 /** Emitted when state of events selection has changed and user is organizer*/
143 void organizerEventsSelected(bool);
144 /** Emitted when state of events selection has changed and user is attendee*/
145 void groupEventsSelected(bool);
146 /**
147 Emitted when an incidence gets selected. If the selection is cleared the
148 signal is emitted with 0 as argument.
149 */
150 void incidenceSelected( Incidence * );
151 /** Emitted, when a todoitem is selected or deselected. */
152 void todoSelected( bool );
153
154 /**
155 Emitted, when clipboard content changes. Parameter indicates if paste
156 is possible or not.
157 */
158 void pasteEnabled(bool);
159
160 /** Emitted, when the number of incoming messages has changed. */
161 void numIncomingChanged(int);
162
163 /** Emitted, when the number of outgoing messages has changed. */
164 void numOutgoingChanged(int);
165
166 /** Send status message, which can e.g. be displayed in the status bar. */
167 void statusMessage(const QString &);
168
169 void calendarViewExpanded( bool );
170 void updateSearchDialog();
171
172
173 public slots:
174
175 void addAlarm(const QDateTime &qdt, const QString &noti );
176 void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
177 void removeAlarm(const QDateTime &qdt, const QString &noti );
178
179 /** options dialog made a changed to the configuration. we catch this
180 * and notify all widgets which need to update their configuration. */
181 void updateConfig();
182
183 /**
184 Load calendar from file \a filename. If \a merge is true, load
185 calendar into existing one, if it is false, clear calendar, before
186 loading. Return true, if calendar could be successfully loaded.
187 */
188 bool openCalendar(QString filename, bool merge=false);
189 bool syncCalendar(QString filename,int mode = 0 );
190
191 /**
192 Save calendar data to file. Return true if calendar could be
193 successfully saved.
194 */
195 bool saveCalendar(QString filename);
196
197 /**
198 Close calendar. Clear calendar data and reset views to display an empty
199 calendar.
200 */
201 void closeCalendar();
202
203 /** Archive old events of calendar */
204 void archiveCalendar();
205
206 void showIncidence();
207 void editIncidence();
208 void editIncidenceDescription();
209 void deleteIncidence();
210
211 /** create an editeventwin with supplied date/time, and if bool is true,
212 * make the event take all day. */
213 void newEvent(QDateTime, QDateTime, bool allDay = false);
214 void newEvent(QDateTime fh);
215 void newEvent(QDate dt);
216 /** create new event without having a date hint. Takes current date as
217 default hint. */
218 void newEvent();
219 void newFloatingEvent();
220
221 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
222 void showIncidence(Incidence *);
223 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/
224 void editIncidence(Incidence *);
225 /** Delete the supplied incidence. It calls the correct deleteXXX method*/
226 void deleteIncidence(Incidence *);
227 void cloneIncidence(Incidence *);
228 void cancelIncidence(Incidence *);
229 /** Create an editor for the supplied event. */
230 void editEvent(Event *);
231 /** Delete the supplied event. */
232 void deleteEvent(Event *);
233 /** Delete the event with the given unique ID. Returns false, if event wasn't
234 found. */
235 bool deleteEvent(const QString &uid);
236 /** Create a read-only viewer dialog for the supplied event. */
237 void showEvent(Event *);
238
239 void editJournal(Journal *);
240 void showJournal(Journal *);
241 void deleteJournal(Journal *);
242 /** Create an editor dialog for a todo */
243 void editTodo(Todo *);
244 /** Create a read-only viewer dialog for the supplied todo */
245 void showTodo(Todo *);
246 /** create new todo */
247 void newTodo();
248 /** create new todo with a parent todo */
249 void newSubTodo();
250 /** create new todo with a parent todo */
251 void newSubTodo(Todo *);
252 /** Delete todo */
253 void deleteTodo(Todo *);
254
255
256 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is
257 * emitted as result. */
258 void checkClipboard();
259
260 /** using the KConfig associated with the kapp variable, read in the
261 * settings from the config file.
262 */
263 void readSettings();
264
265 /** write current state to config file. */
266 void writeSettings();
267
268 /** read settings for calendar filters */
269 void readFilterSettings(KConfig *config);
270
271 /** write settings for calendar filters */
272 void writeFilterSettings(KConfig *config);
273
274 /** passes on the message that an event has changed to the currently
275 * activated view so that it can make appropriate display changes. */
276 void changeEventDisplay(Event *, int);
277 void changeIncidenceDisplay(Incidence *, int);
278 void changeTodoDisplay(Todo *, int);
279
280 void eventAdded(Event *);
281 void eventChanged(Event *);
282 void eventToBeDeleted(Event *);
283 void eventDeleted();
284
285 void todoAdded(Todo *);
286 void todoChanged(Todo *);
287 void todoToBeDeleted(Todo *);
288 void todoDeleted();
289
290 void updateView(const QDate &start, const QDate &end);
291 void updateView();
292
293 /** Full update of visible todo views */
294 void updateTodoViews();
295
296 void updateUnmanagedViews();
297
298 /** cut the current appointment to the clipboard */
299 void edit_cut();
300
301 /** copy the current appointment(s) to the clipboard */
302 void edit_copy();
303
304 /** paste the current vobject(s) in the clipboard buffer into calendar */
305 void edit_paste();
306
307 /** edit viewing and configuration options. */
308 void edit_options();
309 void edit_sync_options();
310 /**
311 Functions for printing, previewing a print, and setting up printing
312 parameters.
313 */
314 void print();
315 void printSetup();
316 void printPreview();
317
318 /** Export as iCalendar file */
319 void exportICalendar();
320
321 /** Export as vCalendar file */
322 bool exportVCalendar( QString fn);
323
324 /** pop up a dialog to show an existing appointment. */
325 void appointment_show();
326 /**
327 * pop up an Appointment Dialog to edit an existing appointment.Get
328 * information on the appointment from the list of unique IDs that is
329 * currently in the View, called currIds.
330 */
331 void appointment_edit();
332 /**
333 * pop up dialog confirming deletion of currently selected event in the
334 * View.
335 */
336 void appointment_delete();
337
338 /** mails the currently selected event to a particular user as a vCalendar
339 attachment. */
340 void action_mail();
341
342 /* frees a subtodo from it's relation */
343 void todo_unsub( Todo * );
344
345 /** Take ownership of selected event. */
346 void takeOverEvent();
347
348 /** Take ownership of all events in calendar. */
349 void takeOverCalendar();
350
351 /** query whether or not the calendar is "dirty". */
352 bool isModified();
353 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */
354 void setModified(bool modified=true);
355
356 /** query if the calendar is read-only. */
357 bool isReadOnly();
358 /** set state of calendar to read-only */
359 void setReadOnly(bool readOnly=true);
360
361 void eventUpdated(Incidence *);
362
363 /* iTIP scheduling actions */
364 void schedule_publish(Incidence *incidence = 0);
365 void schedule_request(Incidence *incidence = 0);
366 void schedule_refresh(Incidence *incidence = 0);
367 void schedule_cancel(Incidence *incidence = 0);
368 void schedule_add(Incidence *incidence = 0);
369 void schedule_reply(Incidence *incidence = 0);
370 void schedule_counter(Incidence *incidence = 0);
371 void schedule_declinecounter(Incidence *incidence = 0);
372 void schedule_publish_freebusy(int daysToPublish = 30);
373
374 void openAddressbook();
375
376 void editFilters();
377 void toggleFilerEnabled();
378
379 void toggleFilter();
380 void showFilter(bool visible);
381 void updateFilter();
382 void filterEdited();
383 void selectFilter( int );
384
385 void showIntro();
386
387 /** Move the curdatepient view date to today */
388 void goToday();
389
390 /** Move to the next date(s) in the current view */
391 void goNext();
392
393 /** Move to the previous date(s) in the current view */
394 void goPrevious();
395 /** Move to the next date(s) in the current view */
396 void goNextMonth();
397
398 /** Move to the previous date(s) in the current view */
399 void goPreviousMonth();
400
401 void toggleExpand();
402 void toggleDateNavigatorWidget();
403 void toggleAllDaySize();
404 void dialogClosing(Incidence *);
405
406 /** Look for new messages in the inbox */
407 void lookForIncomingMessages();
408 /** Look for new messages in the outbox */
409 void lookForOutgoingMessages();
410
411 void processMainViewSelection( Incidence * );
412 void processTodoListSelection( Incidence * );
413
414 void processIncidenceSelection( Incidence * );
415
416 void purgeCompleted();
417 bool removeCompletedSubTodos( Todo* );
418 void slotCalendarChanged();
419 bool importBday();
420 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday );
421 bool importQtopia( const QString &categoriesFile,
422 const QString &datebookFile,
423 const QString &tasklistFile );
424 void syncSharp( );
425 void slotSelectPickerDate( QDate ) ;
426 void showDatePicker( ) ;
427 void moveIncidence(Incidence *) ;
428 void beamIncidence(Incidence *) ;
429 void beamCalendar() ;
430 void beamFilteredCalendar() ;
431 void beamIncidenceList(QPtrList<Incidence>) ;
432 void manageCategories();
433 int addCategories();
434 void removeCategories();
435 void setSyncDevice( QString );
436 void setSyncName( QString );
437 protected slots:
438 void timerAlarm();
439 void suspendAlarm();
440 void beamDone( Ir *ir );
441 /** Select a view or adapt the current view to display the specified dates. */
442 void showDates( const KCal::DateList & );
443 void selectWeekNum ( int );
444
445 public:
446 // show a standard warning
447 // returns KMsgBox::yesNoCancel()
448 int msgCalModified();
449 void confSync();
450 void setLoadedFileVersion(QDateTime);
451 bool checkFileVersion(QString fn);
452 bool checkFileChanged(QString fn);
453 Event* getLastSyncEvent();
454 /** Adapt navigation units correpsonding to step size of navigation of the
455 * current view.
456 */
457 void adaptNavigationUnits();
458 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
459 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
460 //Attendee* getYourAttendee(Event *event);
461 protected:
462 void schedule(Scheduler::Method, Incidence *incidence = 0);
463
464 // returns KMsgBox::OKCandel()
465 int msgItemDelete();
466 void showEventEditor();
467 void showTodoEditor();
468 void writeLocale();
469 Todo *selectedTodo();
470
471 private:
472 AlarmDialog * mAlarmDialog;
473 QString mAlarmNotification;
474 QString mSuspendAlarmNotification;
475 QTimer* mSuspendTimer;
476 QTimer* mAlarmTimer;
477 void computeAlarm( QString );
478 void startAlarm( QString, QString );
479 void setSyncEventsReadOnly();
480
481 QDateTime loadedFileVersion;
482 void checkSharpEvent( Event* lastSync, Incidence* toDelete );
483 QPtrList<KSyncProfile> mSyncProfiles;
484 QStringList mSyncProfileNames;
485 void checkZaurusId( int id, bool todo = false );
486 int mGlobalSyncMode;
487 QString mCurrentSyncDevice;
488 QString mCurrentSyncName;
489 KOBeamPrefs* beamDialog;
490 void init();
491 int mDatePickerMode;
492 bool mFlagEditDescription;
493 QDateTime mLastCalendarSync;
494 void createPrinter();
495
496 void calendarModified( bool, Calendar * );
497
498 CalPrinter *mCalPrinter;
499
500 QSplitter *mPanner;
501 QSplitter *mLeftSplitter;
502 QWidget *mLeftFrame;
503 QWidgetStack *mRightFrame;
504
505 KDatePicker* mDatePicker;
506 QVBox* mDateFrame;
507 NavigatorBar *mNavigatorBar;
508
509 KDateNavigator *mDateNavigator; // widget showing small month view.
510
511 KOFilterView *mFilterView;
512
513 ResourceView *mResourceView;
514
515 // calendar object for this viewing instance
516 Calendar *mCalendar;
517
518 CalendarResourceManager *mResourceManager;
519
520 FileStorage *mStorage;
521
522 DateNavigator *mNavigator;
523
524 KOViewManager *mViewManager;
525 KODialogManager *mDialogManager;
526
527 // Calendar filters
528 QPtrList<CalFilter> mFilters;
529
530 // various housekeeping variables.
531 bool mModified; // flag indicating if calendar is modified
532 bool mReadOnly; // flag indicating if calendar is read-only
533 QDate mSaveSingleDate;
534
535 Incidence *mSelectedIncidence;
536 Incidence *mMoveIncidence;
537
538 KOTodoView *mTodoList;
539 KOEventEditor * mEventEditor;
540 KOTodoEditor * mTodoEditor;
541 KOEventViewerDialog * mEventViewerDialog;
542 void keyPressEvent ( QKeyEvent *e) ;
543 //QMap<Incidence*,KOIncidenceEditor*> mDialogList;
544};
545
546
547class CalendarViewVisitor : public Incidence::Visitor
548{
549 public:
550 CalendarViewVisitor() : mView( 0 ) {}
551
552 bool act( Incidence *incidence, CalendarView *view )
553 {
554 mView = view;
555 return incidence->accept( *this );
556 }
557
558 protected:
559 CalendarView *mView;
560};
561
562class ShowIncidenceVisitor : public CalendarViewVisitor
563{
564 protected:
565 bool visit( Event *event ) { mView->showEvent( event ); return true; }
566 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; }
567 bool visit( Journal * j ) { mView->showJournal( j );return true; }
568};
569
570class EditIncidenceVisitor : public CalendarViewVisitor
571{
572 protected:
573 bool visit( Event *event ) { mView->editEvent( event ); return true; }
574 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; }
575 bool visit( Journal *j ) { mView->editJournal( j); return true; }
576};
577
578class DeleteIncidenceVisitor : public CalendarViewVisitor
579{
580 protected:
581 bool visit( Event *event ) { mView->deleteEvent( event ); return true; }
582 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; }
583 bool visit( Journal * j) {mView->deleteJournal( j ); return true; }
584};
585
586#endif