calendarview.h
00001 /* 00002 This file is part of KOrganizer. 00003 00004 Copyright (c) 2000,2001,2003,2004 Cornelius Schumacher <schumacher@kde.org> 00005 Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> 00006 00007 This program is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 2 of the License, or 00010 (at your option) any later version. 00011 00012 This program is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program; if not, write to the Free Software 00019 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00020 00021 As a special exception, permission is given to link this program 00022 with any edition of TQt, and distribute the resulting executable, 00023 without including the source code for TQt in the source distribution. 00024 */ 00025 #ifndef CALENDARVIEW_H 00026 #define CALENDARVIEW_H 00027 00028 #include <tqwidget.h> 00029 #include <tqptrlist.h> 00030 #include <tqmap.h> 00031 #include <kfile.h> 00032 #include <korganizer/koeventviewer.h> 00033 #include <libkcal/scheduler.h> 00034 #include <kdepimmacros.h> 00035 00036 #include "koglobals.h" 00037 #include "interfaces/korganizer/calendarviewbase.h" 00038 00039 class TQWidgetStack; 00040 class TQSplitter; 00041 00042 class KOViewManager; 00043 class KODialogManager; 00044 class KOTodoView; 00045 class KOEventEditor; 00046 class DateNavigatorContainer; 00047 class DateNavigator; 00048 class KOIncidenceEditor; 00049 class ResourceView; 00050 class NavigatorBar; 00051 class DateChecker; 00052 00053 namespace KOrg { class History; class IncidenceChangerBase; } 00054 class HTMLExportSettings; 00055 00056 using namespace KOrg; 00057 using namespace KCal; 00058 00059 class CalendarViewExtension : public TQWidget 00060 { 00061 public: 00062 CalendarViewExtension( TQWidget *parent, const char *name = 0 ) 00063 : TQWidget( parent, name ) {} 00064 00065 class Factory 00066 { 00067 public: 00068 virtual CalendarViewExtension *create( TQWidget *parent ) = 0; 00069 }; 00070 }; 00071 00081 class KDE_EXPORT CalendarView : public KOrg::CalendarViewBase, public Calendar::Observer 00082 { 00083 Q_OBJECT 00084 TQ_OBJECT 00085 public: 00092 CalendarView( TQWidget *parent = 0, const char *name = 0 ); 00093 virtual ~CalendarView(); 00094 00095 class CalendarViewVisitor : public IncidenceBase::Visitor 00096 { 00097 public: 00098 CalendarViewVisitor() : mView( 0 ) {} 00099 bool act( IncidenceBase *incidence, CalendarView *view ) 00100 { 00101 mView = view; 00102 return incidence->accept( *this ); 00103 } 00104 protected: 00105 CalendarView *mView; 00106 }; 00107 00108 class CanDeleteIncidenceVisitor : public CalendarViewVisitor 00109 { 00110 protected: 00111 bool visit( Event *event ) { return mView->deleteEvent( event ); } 00112 bool visit( Todo *todo ) { return mView->deleteTodo( todo ); } 00113 bool visit( Journal *journal ) { return mView->deleteJournal( journal ); } 00114 }; 00115 00116 void setCalendar( Calendar * ); 00117 Calendar *calendar(); 00118 00119 TQPair<ResourceCalendar *, TQString> viewSubResourceCalendar(); 00120 00121 KOrg::History *history() const { return mHistory; } 00122 00123 KOViewManager *viewManager() const { return mViewManager; } 00124 KODialogManager *dialogManager() const { return mDialogManager; } 00125 00126 TQWidgetStack *viewStack() const { return mRightFrame; } 00127 TQWidget *leftFrame() const { return mLeftFrame; } 00128 NavigatorBar *navigatorBar() const { return mNavigatorBar; } 00129 DateNavigator *dateNavigator() const { return mDateNavigator; } 00130 00131 KOIncidenceEditor *editorDialog( Incidence* ) const; 00132 IncidenceChangerBase *incidenceChanger() const { return mChanger; } 00133 00134 TQDate startDate(); 00135 TQDate endDate(); 00136 00137 00138 void addView( KOrg::BaseView * ); 00139 void showView( KOrg::BaseView * ); 00140 00145 void addExtension( CalendarViewExtension::Factory * ); 00146 00148 Incidence *currentSelection(); 00151 Incidence *selectedIncidence(); 00153 TQString currentFilterName() const; 00154 00155 signals: 00159 void configChanged(); 00162 void categoriesChanged(); 00165 void closingDown(); 00167 void closed( TQWidget * ); 00168 00170 void modifiedChanged( bool ); 00171 00173 void readOnlyChanged( bool ); 00174 00176 void changeNavStringPrev( const TQString & ); 00177 void changeNavStringNext( const TQString & ); 00178 00180 void organizerEventsSelected( bool ); 00182 void groupEventsSelected( bool ); 00187 void incidenceSelected( Incidence *incidence, const TQDate &date ); 00190 void todoSelected( bool ); 00191 void subtodoSelected( bool ); 00192 00195 void dayPassed( const TQDate & ); 00201 void cancelAttendees( Incidence * ); 00202 00203 00208 void pasteEnabled( bool ); 00210 void statusMessage( const TQString & ); 00211 00212 void calendarViewExpanded( bool ); 00213 00215 void autoArchivingSettingsModified(); 00216 00217 void newIncidenceChanger( IncidenceChangerBase* ); 00218 void exportHTML( HTMLExportSettings* ); 00219 00220 void newFilterListSignal( const TQStringList & ); 00221 void selectFilterSignal( int ); 00222 void filterChanged(); 00223 00224 public slots: 00227 void updateConfig( const TQCString& ); 00230 void updateCategories(); 00231 00232 00238 bool openCalendar( const TQString &filename, bool merge = false ); 00239 00244 bool saveCalendar( const TQString &filename ); 00245 00250 void closeCalendar(); 00251 00253 void archiveCalendar(); 00254 00255 void showIncidence(); 00256 void editIncidence(); 00257 bool editIncidence( const TQString &uid ); 00258 bool editIncidence( const TQString &uid, const TQDate &date ); 00259 void deleteIncidence(); 00260 00269 bool addIncidence( const TQString &ical ); 00270 00271 void connectIncidenceEditor( KOIncidenceEditor *editor ); 00272 00275 void newEvent(); 00276 void newEvent( ResourceCalendar *res, const TQString &subRes ); 00279 void newEvent( ResourceCalendar *res, const TQString &subRes, 00280 const TQDate &startDt ); 00281 void newEvent( ResourceCalendar *res, const TQString &subRes, 00282 const TQDateTime &startDt ); 00283 void newEvent( ResourceCalendar *res, const TQString &subRes, 00284 const TQDateTime &startDt, const TQDateTime &EndDt, 00285 bool allDay = false ); 00290 void newEvent( ResourceCalendar *res, const TQString &subRes, 00291 const TQString &summary, 00292 const TQString &description = TQString(), 00293 const TQStringList &attachment = TQStringList(), 00294 const TQStringList &attendees = TQStringList(), 00295 const TQStringList &attachmentMimetypes = TQStringList(), 00296 bool inlineAttachment = false ); 00297 00299 void showIncidence( Incidence *, const TQDate & ); 00301 bool editIncidence( Incidence *incidence, const TQDate &date, bool isCounter = false ); 00307 void deleteIncidence( Incidence *, bool force = false ); 00311 void cutIncidence( Incidence * ); 00315 void copyIncidence( Incidence *); 00319 void pasteIncidence(); 00320 00322 void deleteSubTodosIncidence ( Todo *todo ); 00328 void deleteTodoIncidence ( Todo *todo, bool force = false ); 00330 bool deleteEvent( Event * ) { return true; } 00332 bool deleteTodo( Todo * ) {return true; } 00334 bool deleteJournal( Journal * ) { return true; } 00341 bool deleteIncidence( const TQString &uid, bool force = false ); 00342 00344 void newTodo(); 00345 void newTodo( ResourceCalendar *res, const TQString &subRes ); 00347 void newTodo( ResourceCalendar *res, const TQString &subRes, 00348 const TQDate &date ); 00350 void newSubTodo(); 00352 void newSubTodo( Todo * ); 00353 00354 void newTodo( ResourceCalendar *res, const TQString &subRes, 00355 const TQString &summary, 00356 const TQString &description = TQString(), 00357 const TQStringList &attachments = TQStringList(), 00358 const TQStringList &attendees = TQStringList(), 00359 const TQStringList &attachmentMimetypes = TQStringList(), 00360 bool inlineAttachment = false, bool createTask = false ); 00361 00362 void newJournal(); 00363 void newJournal( ResourceCalendar *res, const TQString &subRes ); 00364 void newJournal( ResourceCalendar *res, const TQString &subRes, 00365 const TQDate &date ); 00366 void newJournal( ResourceCalendar *res, const TQString &subRes, 00367 const TQString &text, const TQDate &date = TQDate() ); 00368 00369 void toggleAlarm( Incidence * ); 00370 void dissociateOccurrence( Incidence *, const TQDate & ); 00371 void dissociateFutureOccurrence( Incidence *, const TQDate & ); 00372 00373 00378 void checkClipboard(); 00379 00386 void readSettings(); 00387 00389 void writeSettings(); 00390 00392 void readFilterSettings( KConfig *config ); 00393 00395 void writeFilterSettings( KConfig *config ); 00396 00399 void changeIncidenceDisplay( Incidence *, int ); 00400 00401 void incidenceAdded( Incidence * ); 00402 void incidenceChanged( Incidence *oldEvent, Incidence *newEvent, 00403 KOGlobals::WhatChanged modification ); 00404 void incidenceToBeDeleted( Incidence *incidence ); 00405 void incidenceDeleted( Incidence * ); 00406 void startMultiModify( const TQString &text ); 00407 void endMultiModify(); 00408 00409 void editCanceled( Incidence * ); 00410 00411 void updateView( const TQDate &start, const TQDate &end ); 00412 void updateView(); 00413 00414 void updateUnmanagedViews(); 00415 00417 void edit_cut(); 00418 00420 void edit_copy(); 00421 00423 void edit_paste(); 00424 00426 void edit_options(); 00427 00432 void print(); 00433 00435 void exportWeb(); 00436 00438 void exportICalendar(); 00439 00441 void exportVCalendar(); 00442 00444 void appointment_show(); 00450 void appointment_edit(); 00455 void appointment_delete(); 00456 00457 /* frees the selected to-do's children from it's relation, update the view */ 00458 void todo_unsub(); 00459 00460 /* frees an incidence's children from it's relation, without update the view 00461 Works with any incidence type, although currently we only pass to-dos 00462 */ 00463 bool incidence_unsub( Incidence *inc ); 00464 00466 bool makeSubTodosIndependent ( ); 00467 00471 bool makeChildrenIndependent( Incidence *inc ); 00472 00474 void takeOverEvent(); 00475 00477 void takeOverCalendar(); 00478 00480 bool isModified(); 00482 void setModified( bool modified = true ); 00483 00485 bool isReadOnly(); 00487 void setReadOnly( bool readOnly = true ); 00488 00489 void eventUpdated( Incidence * ); 00490 00491 /* iTIP scheduling actions */ 00492 void schedule_publish( Incidence *incidence = 0 ); 00493 void schedule_request( Incidence *incidence = 0 ); 00494 void schedule_refresh( Incidence *incidence = 0 ); 00495 void schedule_cancel( Incidence *incidence = 0 ); 00496 void schedule_add( Incidence *incidence = 0 ); 00497 void schedule_reply( Incidence *incidence = 0 ); 00498 void schedule_counter( Incidence *incidence = 0 ); 00499 void schedule_declinecounter( Incidence *incidence = 0 ); 00500 void schedule_forward( Incidence *incidence = 0 ); 00501 void mailFreeBusy( int daysToPublish = 30 ); 00502 void uploadFreeBusy(); 00503 00504 void openAddressbook(); 00505 00506 void editFilters(); 00507 00508 void updateFilter(); 00509 00510 void showIntro(); 00511 00512 void showDateNavigator( bool ); 00513 void showTodoView( bool ); 00514 void showEventViewer( bool ); 00515 00517 void goDate( const TQDate& date ); 00518 00520 void showDate( const TQDate &date ); 00521 00523 void goToday(); 00524 00526 void goNext(); 00527 00529 void goPrevious(); 00530 00531 void toggleExpand(); 00532 void showLeftFrame( bool show = true ); 00533 00534 void dialogClosing( Incidence * ); 00535 00536 void processMainViewSelection( Incidence *incidence, const TQDate &date ); 00537 void processTodoListSelection( Incidence *incidence, const TQDate &date ); 00538 00539 void processIncidenceSelection( Incidence *incidence, const TQDate &date ); 00540 00541 void purgeCompleted(); 00542 00543 void slotAutoArchivingSettingsModified() { emit autoArchivingSettingsModified(); } 00544 00545 void showErrorMessage( const TQString & ); 00546 void schedule( Scheduler::Method, Incidence *incidence ); 00547 void addIncidenceOn( Incidence *, const TQDate & ); 00548 void moveIncidenceTo( Incidence *, const TQDate & ); 00549 void filterActivated( int filterNum ); 00550 00551 void resourcesChanged(); 00552 00559 void selectWeek( const TQDate & ); 00560 00561 protected slots: 00566 void showDates( const KCal::DateList &, const TQDate &preferredMonth = TQDate() ); 00567 00568 public: 00569 // show a standard warning 00570 // returns KMsgBox::yesNoCancel() 00571 int msgCalModified(); 00572 00576 void adaptNavigationUnits(); 00577 00584 TQDate activeIncidenceDate(); 00585 00596 TQDate activeDate( bool fallbackToToday = false ); 00597 00619 Incidence* singleOccurrenceOrAll( Incidence *inc, 00620 KOGlobals::OccurrenceAction userAction, 00621 KOGlobals::WhichOccurrences &chosenOption, 00622 const TQDate &itemDate = TQDate(), 00623 const bool commitToCalendar = false ); 00624 00625 protected: 00626 void setIncidenceChanger( IncidenceChangerBase *changer ); 00627 00628 // // returns KMsgBox::OKCancel() 00629 int msgItemDelete( Incidence *incidence ); 00630 00631 Todo *selectedTodo(); 00632 00633 void warningChangeFailed( Incidence * ); 00634 void checkForFilteredChange( Incidence *incidence ); 00638 void dateTimesForNewEvent( TQDateTime &startDt, TQDateTime &endDt, bool &allDay ); 00639 KOEventEditor *newEventEditor( ResourceCalendar *res, const TQString &subRes, 00640 const TQDateTime &startDtParam = TQDateTime(), 00641 const TQDateTime &endDtParam = TQDateTime() , 00642 bool allDayParam = false ); 00643 00644 private: 00645 void init(); 00646 00653 Incidence *incToSendToClipboard( bool cut ); 00654 00655 void calendarModified( bool, Calendar * ); 00656 // Helper function for purgeCompleted that recursively purges a todo and 00657 // its subitems. If it cannot delete a completed todo (because it has 00658 // uncompleted subitems), notAllPurged is set to true. 00659 bool purgeCompletedSubTodos( Todo* todo, bool ¬AllPurged ); 00660 00664 void getIncidenceHierarchy( Incidence *inc, Incidence::List &incidences ); 00665 00666 KOrg::History *mHistory; 00667 00668 TQSplitter *mPanner; 00669 TQSplitter *mLeftSplitter; 00670 TQWidget *mLeftFrame; 00671 TQWidgetStack *mRightFrame; 00672 00673 // This navigator bar is used when in full window month view 00674 // It has nothing to do with the date navigator 00675 NavigatorBar *mNavigatorBar; 00676 00677 DateNavigatorContainer *mDateNavigatorContainer; 00678 00679 00680 TQPtrList<CalendarViewExtension> mExtensions; 00681 00682 Calendar *mCalendar; 00683 00684 DateNavigator *mDateNavigator; 00685 DateChecker *mDateChecker; 00686 00687 KOEventViewer *mEventViewer; 00688 KOViewManager *mViewManager; 00689 KODialogManager *mDialogManager; 00690 00691 // Calendar filters 00692 TQPtrList<CalFilter> mFilters; 00693 CalFilter *mCurrentFilter; 00694 00695 // various housekeeping variables. 00696 bool mModified; // flag indicating if calendar is modified 00697 bool mReadOnly; // flag indicating if calendar is read-only 00698 00699 Incidence *mSelectedIncidence; 00700 TQDate mSaveDate; 00701 00702 KOTodoView *mTodoList; 00703 TQMap<Incidence*,KOIncidenceEditor*> mDialogList; 00704 00705 KOrg::IncidenceChangerBase *mChanger; 00706 }; 00707 00708 00709 00710 00711 #endif