00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "actionmanager.h"
00027
00028 #include <qapplication.h>
00029 #include <qtimer.h>
00030
00031 #include <dcopclient.h>
00032 #include <kaction.h>
00033 #include <kfiledialog.h>
00034 #include <kio/netaccess.h>
00035 #include <kkeydialog.h>
00036 #include <kpopupmenu.h>
00037 #include <kstandarddirs.h>
00038 #include <ktip.h>
00039 #include <ktempfile.h>
00040 #include <kxmlguiclient.h>
00041 #include <kwin.h>
00042 #include <knotifyclient.h>
00043
00044 #include <libkcal/htmlexport.h>
00045 #include <libkcal/calendarlocal.h>
00046 #include <libkcal/calendarresources.h>
00047 #include <libkcal/resourcelocal.h>
00048
00049 #include "alarmclient.h"
00050 #include "calendarview.h"
00051 #include "kocore.h"
00052 #include "kodialogmanager.h"
00053 #include "koglobals.h"
00054 #include "koprefs.h"
00055 #include "koviewmanager.h"
00056 #include "kowindowlist.h"
00057 #include "korganizer.h"
00058 #include "kprocess.h"
00059 #include "konewstuff.h"
00060 #include "history.h"
00061 #include "kogroupware.h"
00062 #include "resourceview.h"
00063 #include "resourceimportdialog.h"
00064
00065 KOWindowList *ActionManager::mWindowList = 0;
00066
00067 ActionManager::ActionManager( KXMLGUIClient *client, CalendarView *widget,
00068 QObject *parent, KOrg::MainWindow *mainWindow,
00069 bool isPart )
00070 : QObject( parent ), KCalendarIface(), mRecent( 0 ), mCalendar( 0 ),
00071 mCalendarResources( 0 ), mIsClosing( false )
00072 {
00073 mGUIClient = client;
00074 mACollection = mGUIClient->actionCollection();
00075 mCalendarView = widget;
00076 mIsPart = isPart;
00077 mTempFile = 0;
00078 mNewStuff = 0;
00079 mHtmlExportSync = false;
00080 mMainWindow = mainWindow;
00081 }
00082
00083 ActionManager::~ActionManager()
00084 {
00085 delete mNewStuff;
00086
00087
00088 KOCore::self()->unloadParts( mMainWindow, mParts );
00089
00090 delete mTempFile;
00091
00092
00093 mWindowList->removeWindow( mMainWindow );
00094
00095 delete mCalendarView;
00096
00097 delete mCalendar;
00098 delete mCalendarResources;
00099
00100 kdDebug(5850) << "~ActionManager() done" << endl;
00101 }
00102
00103
00104 void ActionManager::ActionManager::init()
00105 {
00106
00107 if ( !mWindowList ) {
00108 mWindowList = new KOWindowList;
00109
00110 if ( !mIsPart )
00111 QTimer::singleShot( 0, this, SLOT( showTipOnStart() ) );
00112 }
00113
00114
00115
00116 mWindowList->addWindow( mMainWindow );
00117
00118 initActions();
00119
00120
00121 mAutoSaveTimer = new QTimer( this );
00122 connect( mAutoSaveTimer,SIGNAL( timeout() ), SLOT( checkAutoSave() ) );
00123 if ( KOPrefs::instance()->mAutoSave &&
00124 KOPrefs::instance()->mAutoSaveInterval > 0 ) {
00125 mAutoSaveTimer->start( 1000 * 60 * KOPrefs::instance()->mAutoSaveInterval );
00126 }
00127
00128 setTitle();
00129
00130 connect( mCalendarView, SIGNAL( modifiedChanged( bool ) ), SLOT( setTitle() ) );
00131 connect( mCalendarView, SIGNAL( configChanged() ), SLOT( updateConfig() ) );
00132
00133 connect( mCalendarView, SIGNAL( incidenceSelected( Incidence * ) ),
00134 this, SLOT( processIncidenceSelection( Incidence * ) ) );
00135
00136 processIncidenceSelection( 0 );
00137
00138
00139 mCalendarView->checkClipboard();
00140
00141 mCalendarView->lookForOutgoingMessages();
00142 mCalendarView->lookForIncomingMessages();
00143 }
00144
00145 void ActionManager::createCalendarLocal()
00146 {
00147 mCalendar = new CalendarLocal( KOPrefs::instance()->mTimeZoneId );
00148 mCalendarView->setCalendar( mCalendar );
00149 mCalendarView->readSettings();
00150
00151 initCalendar( mCalendar );
00152 }
00153
00154 void ActionManager::createCalendarResources()
00155 {
00156 mCalendarResources = KOCore::self()->calendarResources();
00157
00158 CalendarResourceManager *manager = mCalendarResources->resourceManager();
00159
00160 kdDebug(5850) << "CalendarResources used by KOrganizer:" << endl;
00161 CalendarResourceManager::Iterator it;
00162 for( it = manager->begin(); it != manager->end(); ++it ) {
00163 (*it)->dump();
00164 }
00165
00166 setDestinationPolicy();
00167
00168 mCalendarView->setCalendar( mCalendarResources );
00169 mCalendarView->readSettings();
00170
00171
00172 KOGroupware::create( mCalendarView, mCalendarResources );
00173
00174 ResourceViewFactory factory( mCalendarResources, mCalendarView );
00175 mCalendarView->addExtension( &factory );
00176
00177 connect( mCalendarResources, SIGNAL( calendarChanged() ),
00178 mCalendarView, SLOT( slotCalendarChanged() ) );
00179
00180 connect( mCalendarView, SIGNAL( configChanged() ),
00181 SLOT( updateConfig() ) );
00182
00183 initCalendar( mCalendarResources );
00184 }
00185
00186 void ActionManager::initCalendar( Calendar *cal )
00187 {
00188 cal->setOwner( KOPrefs::instance()->fullName() );
00189 cal->setEmail( KOPrefs::instance()->email() );
00190
00191 mCalendarView->setModified( false );
00192 }
00193
00194 void ActionManager::initActions()
00195 {
00196 KAction *action;
00197
00198
00199 if ( mIsPart ) {
00200 if ( mMainWindow->hasDocument() ) {
00201 new KAction( i18n("&New"), "filenew", CTRL+Key_N, this,
00202 SLOT( file_new() ), mACollection, "korganizer_openNew" );
00203 new KAction( i18n("&Open"), "fileopen", CTRL+Key_O, this,
00204 SLOT( file_open() ), mACollection, "korganizer_open" );
00205 mRecent = new KRecentFilesAction( i18n("Open &Recent"), 0, 0, this,
00206 SLOT( file_openRecent( const KURL & ) ),
00207 mACollection, "korganizer_openRecent" );
00208 new KAction( i18n("Re&vert"), "revert", 0, this,
00209 SLOT( file_revert() ), mACollection, "korganizer_revert" );
00210 new KAction( i18n("Save &As..."), "filesaveas", 0, this,
00211 SLOT( file_saveas() ), mACollection, "korganizer_saveAs" );
00212 new KAction( i18n("&Close"), "fileclose", CTRL+Key_W, this,
00213 SLOT( file_close() ), mACollection, "korganizer_close" );
00214 }
00215 new KAction( i18n("&Save"), "filesave", CTRL+Key_S, this,
00216 SLOT( file_save() ), mACollection, "korganizer_save" );
00217 } else {
00218 KStdAction::openNew(this, SLOT(file_new()), mACollection);
00219 KStdAction::open(this, SLOT(file_open()), mACollection);
00220 mRecent = KStdAction::openRecent(this, SLOT(file_openRecent(const KURL&)),
00221 mACollection);
00222 KStdAction::revert(this,SLOT(file_revert()),mACollection);
00223 KStdAction::save(this, SLOT(file_save()), mACollection);
00224 KStdAction::saveAs(this, SLOT(file_saveas()), mACollection);
00225 KStdAction::close(this, SLOT(file_close()), mACollection);
00226 }
00227
00228 (void)new KAction(i18n("&Import From Ical"), 0, this, SLOT(file_import()),
00229 mACollection, "import_ical");
00230 (void)new KAction(i18n("&Merge Calendar..."), 0, this, SLOT(file_merge()),
00231 mACollection, "merge_calendar");
00232 (void)new KAction(i18n("Archive Old Entries..."), 0, this, SLOT(file_archive()),
00233 mACollection, "file_archive");
00234
00235
00236
00237 (void)new KAction(i18n("Configure &Date && Time..."), 0,
00238 this,SLOT(configureDateTime()),
00239 mACollection, "conf_datetime");
00240
00241 mFilterViewAction = new KToggleAction(i18n("Show Filter"),0,this,
00242 SLOT(toggleFilterView()),
00243 mACollection,
00244 "show_filter");
00245
00246 KStdAction::tipOfDay( this, SLOT( showTip() ), mACollection,
00247 "help_tipofday" );
00248
00249 new KAction( i18n("Get Hot New Stuff..."), 0, this,
00250 SLOT( downloadNewStuff() ), mACollection,
00251 "downloadnewstuff" );
00252
00253 new KAction( i18n("Upload Hot New Stuff..."), 0, this,
00254 SLOT( uploadNewStuff() ), mACollection,
00255 "uploadnewstuff" );
00256
00257 (void)new KAction(i18n("iCalendar..."), 0,
00258 mCalendarView, SLOT(exportICalendar()),
00259 mACollection, "export_icalendar");
00260 (void)new KAction(i18n("vCalendar..."), 0,
00261 mCalendarView, SLOT(exportVCalendar()),
00262 mACollection, "export_vcalendar");
00263
00264
00265 #if 0
00266 (void)new KAction(i18n("Print Setup..."), 0,
00267 mCalendarView, SLOT(printSetup()),
00268 mACollection, "print_setup");
00269 #endif
00270
00271 if (mIsPart) {
00272 new KAction(i18n("&Print..."), "fileprint", CTRL+Key_P, mCalendarView,
00273 SLOT(print()), mACollection, "korganizer_print" );
00274 } else {
00275 KStdAction::print(mCalendarView, SLOT(print()), mACollection);
00276 }
00277
00278 #if 1
00279 if (mIsPart) {
00280 new KAction(i18n("Print Previe&w..."), "filequickprint", 0, mCalendarView,
00281 SLOT(printPreview()), mACollection, "korganizer_quickprint" );
00282 } else {
00283 KStdAction::printPreview(mCalendarView, SLOT(printPreview()),
00284 mACollection);
00285 }
00286 #endif
00287
00288 new KAction( i18n("delete completed To-Dos","Purge Completed"), 0,
00289 mCalendarView, SLOT( purgeCompleted() ), mACollection,
00290 "purge_completed" );
00291
00292 KOrg::History *h = mCalendarView->history();
00293
00294 KAction *pasteAction;
00295
00296 if ( mIsPart ) {
00297
00298 mCutAction = new KAction(i18n("Cu&t"), "editcut", CTRL+Key_X, mCalendarView,
00299 SLOT(edit_cut()), mACollection, "korganizer_cut");
00300 mCopyAction = new KAction(i18n("&Copy"), "editcopy", CTRL+Key_C, mCalendarView,
00301 SLOT(edit_copy()), mACollection, "korganizer_copy");
00302 pasteAction = new KAction(i18n("&Paste"), "editpaste", CTRL+Key_V, mCalendarView,
00303 SLOT(edit_paste()), mACollection, "korganizer_paste");
00304 mUndoAction = new KAction( i18n("&Undo"), "undo", CTRL+Key_Z, h,
00305 SLOT( undo() ), mACollection, "korganizer_undo" );
00306 mRedoAction = new KAction( i18n("Re&do"), "redo", CTRL+SHIFT+Key_Z, h,
00307 SLOT( redo() ), mACollection, "korganizer_redo" );
00308 } else {
00309 mCutAction = KStdAction::cut(mCalendarView,SLOT(edit_cut()),
00310 mACollection);
00311
00312 mCopyAction = KStdAction::copy(mCalendarView,SLOT(edit_copy()),
00313 mACollection);
00314
00315 pasteAction = KStdAction::paste(mCalendarView,SLOT(edit_paste()),
00316 mACollection);
00317
00318 mUndoAction = KStdAction::undo( h, SLOT( undo() ), mACollection );
00319 mRedoAction = KStdAction::redo( h, SLOT( redo() ), mACollection );
00320 }
00321
00322 pasteAction->setEnabled( false );
00323 connect( mCalendarView, SIGNAL( pasteEnabled( bool ) ),
00324 pasteAction, SLOT( setEnabled( bool ) ) );
00325
00326 connect( h, SIGNAL( undoAvailable( const QString & ) ),
00327 SLOT( updateUndoAction( const QString & ) ) );
00328 connect( h, SIGNAL( redoAvailable( const QString & ) ),
00329 SLOT( updateRedoAction( const QString & ) ) );
00330 mUndoAction->setEnabled( false );
00331 mRedoAction->setEnabled( false );
00332
00333 mDeleteAction = new KAction(i18n("&Delete"),"editdelete",0,
00334 mCalendarView,SLOT(appointment_delete()),
00335 mACollection, "edit_delete");
00336
00337 if ( mIsPart ) {
00338 new KAction(i18n("&Find..."),"find",CTRL+Key_F,
00339 mCalendarView->dialogManager(), SLOT(showSearchDialog()),
00340 mACollection, "korganizer_find");
00341 } else {
00342 KStdAction::find(mCalendarView->dialogManager(), SLOT(showSearchDialog()),
00343 mACollection);
00344 }
00345
00346
00347
00348 (void)new KAction(i18n("What's &Next"), "whatsnext", 0,
00349 mCalendarView->viewManager(), SLOT(showWhatsNextView()),
00350 mACollection, "view_whatsnext");
00351 (void)new KAction(i18n("&List"), "list", 0,
00352 mCalendarView->viewManager(), SLOT(showListView()),
00353 mACollection, "view_list");
00354 (void)new KAction(i18n("&Day"), "1day", 0,
00355 mCalendarView->viewManager(), SLOT(showDayView()),
00356 mACollection, "view_day");
00357 (void)new KAction(i18n("W&ork Week"), "5days", 0,
00358 mCalendarView->viewManager(), SLOT(showWorkWeekView()),
00359 mACollection, "view_workweek");
00360 (void)new KAction(i18n("&Week"), "7days", 0,
00361 mCalendarView->viewManager(), SLOT(showWeekView()),
00362 mACollection, "view_week");
00363 mNextXDays = new KAction("", "xdays", 0,mCalendarView->viewManager(),
00364 SLOT(showNextXView()),mACollection, "view_nextx");
00365 mNextXDays->setText(i18n("&Next Day", "Ne&xt %n Days", KOPrefs::instance()->mNextXDays));
00366 (void)new KAction(i18n("&Month"), "month", 0,
00367 mCalendarView->viewManager(), SLOT(showMonthView()),
00368 mACollection, "view_month");
00369 (void)new KAction(i18n("&To-Do List"), "todo", 0,
00370 mCalendarView->viewManager(), SLOT(showTodoView()),
00371 mACollection, "view_todo");
00372 (void)new KAction(i18n("&Journal"), "journal", 0,
00373 mCalendarView->viewManager(), SLOT(showJournalView()),
00374 mACollection, "view_journal");
00375 (void)new KAction(i18n("&Time Span"), "timespan", 0,
00376 mCalendarView->viewManager(), SLOT(showTimeSpanView()),
00377 mACollection, "view_timespan");
00378 (void)new KAction(i18n("&Update"), 0,
00379 mCalendarView, SLOT( updateView() ),
00380 mACollection, "update");
00381
00382
00383
00384 (void)new KAction(i18n("New E&vent..."), "appointment", 0,
00385 mCalendarView,SLOT( newEvent() ),
00386 mACollection, "new_event");
00387 (void)new KAction(i18n("New &To-Do..."), "newtodo", 0,
00388 mCalendarView,SLOT(newTodo()),
00389 mACollection, "new_todo");
00390 action = new KAction(i18n("New Su&b-To-Do..."), 0,
00391 mCalendarView,SLOT(newSubTodo()),
00392 mACollection, "new_subtodo");
00393 action->setEnabled(false);
00394 connect(mCalendarView,SIGNAL(todoSelected(bool)),
00395 action,SLOT(setEnabled(bool)));
00396
00397 mShowIncidenceAction = new KAction(i18n("&Show"), 0,
00398 mCalendarView,SLOT(showIncidence()),
00399 mACollection, "show_incidence");
00400 mEditIncidenceAction = new KAction(i18n("&Edit..."), 0,
00401 mCalendarView,SLOT(editIncidence()),
00402 mACollection, "edit_incidence");
00403 mDeleteIncidenceAction = new KAction(i18n("&Delete"), Key_Delete,
00404 mCalendarView,SLOT(deleteIncidence()),
00405 mACollection, "delete_incidence");
00406
00407 #if 0
00408 action = new KAction(i18n("T&ake over Event"), 0,
00409 mCalendarView,SLOT(takeOverEvent()),
00410 mACollection, "takeover_event");
00411 connect(mCalendarView,SIGNAL(eventsSelected(bool)),
00412 action,SLOT(setEnabled(bool)));
00413 (void)new KAction(i18n("T&ake over Calendar"), 0,
00414 mCalendarView,SLOT(takeOverCalendar()),
00415 mACollection, "takeover_calendar");
00416
00417 action = new KAction(i18n("&Mail Appointment"), "mail_generic", 0,
00418 mCalendarView,SLOT(action_mail()),
00419 mACollection, "mail_appointment");
00420 connect(mCalendarView,SIGNAL(eventsSelected(bool)),
00421 action,SLOT(setEnabled(bool)));
00422 #endif
00423
00424 action = new KAction(i18n("&Make Sub-To-Do Independent"), 0,
00425 mCalendarView,SLOT(todo_unsub()),
00426 mACollection, "unsub_todo");
00427 action->setEnabled(false);
00428 connect(mCalendarView,SIGNAL(todoSelected(bool)),
00429 action,SLOT(setEnabled(bool)));
00430
00431
00432
00433 (void)new KAction(i18n("Outgoing Messages"),0,
00434 mCalendarView->dialogManager(),SLOT(showOutgoingDialog()),
00435 mACollection,"outgoing");
00436 (void)new KAction(i18n("Incoming Messages"),0,
00437 mCalendarView->dialogManager(),SLOT(showIncomingDialog()),
00438 mACollection,"incoming");
00439 mPublishEvent = new KAction(i18n("Publish..."),"mail_send",0,
00440 mCalendarView,SLOT(schedule_publish()),
00441 mACollection,"publish");
00442 mPublishEvent->setEnabled(false);
00443 action = new KAction(i18n("Request"),"mail_generic",0,
00444 mCalendarView,SLOT(schedule_request()),
00445 mACollection,"request");
00446 action->setEnabled(false);
00447 connect(mCalendarView,SIGNAL(organizerEventsSelected(bool)),
00448 action,SLOT(setEnabled(bool)));
00449 action = new KAction(i18n("Refresh"),0,
00450 mCalendarView,SLOT(schedule_refresh()),
00451 mACollection,"refresh");
00452 action->setEnabled(false);
00453 connect(mCalendarView,SIGNAL(groupEventsSelected(bool)),
00454 action,SLOT(setEnabled(bool)));
00455 action = new KAction(i18n("Cancel"),0,
00456 mCalendarView,SLOT(schedule_cancel()),
00457 mACollection,"cancel");
00458 action->setEnabled(false);
00459 connect(mCalendarView,SIGNAL(organizerEventsSelected(bool)),
00460 action,SLOT(setEnabled(bool)));
00461
00462
00463
00464
00465
00466 action = new KAction(i18n("Reply"),"mail_reply",0,
00467 mCalendarView,SLOT(schedule_reply()),
00468 mACollection,"reply");
00469 action->setEnabled(false);
00470 connect(mCalendarView,SIGNAL(groupEventsSelected(bool)),
00471 action,SLOT(setEnabled(bool)));
00472 action = new KAction(i18n("counter proposal","Counter"),0,
00473 mCalendarView,SLOT(schedule_counter()),
00474 mACollection,"counter");
00475 action->setEnabled(false);
00476 connect(mCalendarView,SIGNAL(groupEventsSelected(bool)),
00477 action,SLOT(setEnabled(bool)));
00478 action = new KAction(i18n("Publish Free Busy Information"),0,
00479 mCalendarView,SLOT(schedule_publish_freebusy()),
00480 mACollection,"publish_freebusy");
00481 action->setEnabled(true);
00482
00483
00484
00485
00486
00487
00488 if ( !mIsPart ) {
00489 action = new KAction(i18n("Addressbook"),"contents",0,
00490 mCalendarView,SLOT(openAddressbook()),
00491 mACollection,"addressbook");
00492 }
00493
00494
00495 bool isRTL = QApplication::reverseLayout();
00496
00497 (void)new KAction(i18n("Go to &Today"), "today", 0,
00498 mCalendarView,SLOT(goToday()),
00499 mACollection, "go_today");
00500
00501 action = new KAction(i18n("Go &Backward"), isRTL ? "1rightarrow" : "1leftarrow", 0,
00502 mCalendarView,SLOT(goPrevious()),
00503 mACollection, "go_previous");
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514 action = new KAction(i18n("Go &Forward"), isRTL ? "1leftarrow" : "1rightarrow", 0,
00515 mCalendarView,SLOT(goNext()),
00516 mACollection, "go_next");
00517
00518
00519
00520
00521
00522
00523
00524 if ( mIsPart ) {
00525 new KAction( i18n("&Configure KOrganizer..."),
00526 "configure", 0, mCalendarView,
00527 SLOT(edit_options()), mACollection,
00528 "korganizer_configure" );
00529 new KAction( i18n("Configure S&hortcuts..."),
00530 "configure_shortcuts", 0, this,
00531 SLOT(keyBindings()), mACollection,
00532 "korganizer_configure_shortcuts" );
00533 } else {
00534 KStdAction::preferences(mCalendarView, SLOT(edit_options()),
00535 mACollection);
00536 KStdAction::keyBindings(this, SLOT(keyBindings()), mACollection);
00537 }
00538
00539 (void)new KAction(i18n("Edit C&ategories..."), 0,
00540 mCalendarView->dialogManager(),
00541 SLOT(showCategoryEditDialog()),
00542 mACollection,"edit_categories");
00543 (void)new KAction(i18n("Edit &Filters..."), 0,
00544 mCalendarView,SLOT(editFilters()),
00545 mACollection,"edit_filters");
00546 (void)new KAction(i18n("Configure &Plugins..."), 0,
00547 mCalendarView->dialogManager(),SLOT(showPluginDialog()),
00548 mACollection,"configure_plugins");
00549
00550 #if 0
00551 (void)new KAction(i18n("Show Intro Page"), 0,
00552 mCalendarView,SLOT(showIntro()),
00553 mACollection,"show_intro");
00554 #endif
00555
00556 KConfig *config = KOGlobals::self()->config();
00557 config->setGroup("Settings");
00558 mFilterViewAction->setChecked(config->readBoolEntry("Filter Visible",false));
00559 toggleFilterView();
00560 }
00561
00562 void ActionManager::readSettings()
00563 {
00564
00565
00566
00567 KConfig *config = KOGlobals::self()->config();
00568 if ( mRecent ) mRecent->loadEntries( config );
00569 mCalendarView->readSettings();
00570 }
00571
00572 void ActionManager::writeSettings()
00573 {
00574 kdDebug(5850) << "ActionManager::writeSettings" << endl;
00575 KConfig *config = KOGlobals::self()->config();
00576 mCalendarView->writeSettings();
00577
00578 config->setGroup( "Settings" );
00579 config->writeEntry( "Filter Visible", mFilterViewAction->isChecked() );
00580 if ( mRecent ) mRecent->saveEntries( config );
00581 }
00582
00583 void ActionManager::file_new()
00584 {
00585 emit actionNew();
00586 }
00587
00588 void ActionManager::file_open()
00589 {
00590 KURL url;
00591 QString defaultPath = locateLocal("data","korganizer/");
00592 url = KFileDialog::getOpenURL(defaultPath,i18n("*.vcs *.ics|Calendar Files"),
00593 mCalendarView->topLevelWidget());
00594
00595 if (url.isEmpty()) return;
00596
00597 KOrg::MainWindow *korg=ActionManager::findInstance(url);
00598 if ((0 != korg)&&(korg != mMainWindow)) {
00599 KWin::setActiveWindow(korg->topLevelWidget()->winId());
00600 return;
00601 }
00602
00603 kdDebug(5850) << "ActionManager::file_open(): " << url.prettyURL() << endl;
00604
00605 if (!mCalendarView->isModified() && mFile.isEmpty()) {
00606 openURL(url);
00607 } else {
00608 emit actionNew( url );
00609 }
00610 }
00611
00612 void ActionManager::file_openRecent(const KURL& url)
00613 {
00614 if (!url.isEmpty()) {
00615 KOrg::MainWindow *korg=ActionManager::findInstance(url);
00616 if ((0 != korg)&&(korg != mMainWindow)) {
00617 KWin::setActiveWindow(korg->topLevelWidget()->winId());
00618 return;
00619 }
00620 openURL(url);
00621 }
00622 }
00623
00624 void ActionManager::file_import()
00625 {
00626
00627
00628 int retVal = -1;
00629 QString progPath;
00630 KTempFile tmpfn;
00631
00632 QString homeDir = QDir::homeDirPath() + QString::fromLatin1("/.calendar");
00633
00634 if (!QFile::exists(homeDir)) {
00635 KMessageBox::error(mCalendarView->topLevelWidget(),
00636 i18n("You have no ical file in your home directory.\n"
00637 "Import cannot proceed.\n"));
00638 return;
00639 }
00640
00641 KProcess proc;
00642 proc << "ical2vcal" << tmpfn.name();
00643 bool success = proc.start( KProcess::Block );
00644
00645 if ( !success ) {
00646 kdDebug(5850) << "Error starting ical2vcal." << endl;
00647 return;
00648 } else {
00649 retVal = proc.exitStatus();
00650 }
00651
00652 kdDebug(5850) << "ical2vcal return value: " << retVal << endl;
00653
00654 if (retVal >= 0 && retVal <= 2) {
00655
00656 mCalendarView->openCalendar(tmpfn.name(),1);
00657 if (!retVal)
00658 KMessageBox::information(mCalendarView->topLevelWidget(),
00659 i18n("KOrganizer successfully imported and "
00660 "merged your .calendar file from ical "
00661 "into the currently opened calendar."));
00662 else
00663 KMessageBox::information(mCalendarView->topLevelWidget(),
00664 i18n("KOrganizer encountered some unknown fields while "
00665 "parsing your .calendar ical file, and had to "
00666 "discard them. Please check to see that all "
00667 "your relevant data was correctly imported."),
00668 i18n("ICal Import Successful With Warning"));
00669 } else if (retVal == -1) {
00670 KMessageBox::error(mCalendarView->topLevelWidget(),
00671 i18n("KOrganizer encountered an error parsing your "
00672 ".calendar file from ical. Import has failed."));
00673 } else if (retVal == -2) {
00674 KMessageBox::error(mCalendarView->topLevelWidget(),
00675 i18n("KOrganizer doesn't think that your .calendar "
00676 "file is a valid ical calendar. Import has failed."));
00677 }
00678 tmpfn.unlink();
00679 }
00680
00681 void ActionManager::file_merge()
00682 {
00683 KURL url = KFileDialog::getOpenURL(locateLocal("data","korganizer/"),
00684 i18n("*.vcs *.ics|Calendar Files"),
00685 mCalendarView->topLevelWidget());
00686 openURL(url,true);
00687 }
00688
00689 void ActionManager::file_archive()
00690 {
00691 mCalendarView->archiveCalendar();
00692 }
00693
00694 void ActionManager::file_revert()
00695 {
00696 openURL(mURL);
00697 }
00698
00699 void ActionManager::file_saveas()
00700 {
00701 KURL url = getSaveURL();
00702
00703 if (url.isEmpty()) return;
00704
00705 saveAsURL(url);
00706 }
00707
00708 void ActionManager::file_save()
00709 {
00710 if ( mMainWindow->hasDocument() ) {
00711 if (mURL.isEmpty()) {
00712 file_saveas();
00713 } else {
00714 saveURL();
00715 }
00716 } else {
00717 mCalendarView->calendar()->save();
00718 }
00719 }
00720
00721 void ActionManager::file_close()
00722 {
00723 if (!saveModifiedURL()) return;
00724
00725 mCalendarView->closeCalendar();
00726 KIO::NetAccess::removeTempFile(mFile);
00727 mURL="";
00728 mFile="";
00729
00730 setTitle();
00731 }
00732
00733 bool ActionManager::openURL(const KURL &url,bool merge)
00734 {
00735 kdDebug(5850) << "ActionManager::openURL()" << endl;
00736
00737 if (url.isEmpty()) {
00738 kdDebug(5850) << "ActionManager::openURL(): Error! Empty URL." << endl;
00739 return false;
00740 }
00741 if ( !url.isValid() ) {
00742 kdDebug(5850) << "ActionManager::openURL(): Error! URL is malformed." << endl;
00743 return false;
00744 }
00745
00746 QString tmpFile;
00747 if( KIO::NetAccess::download( url, tmpFile, view() ) ) {
00748 kdDebug(5850) << "--- Downloaded to " << tmpFile << endl;
00749 bool success = mCalendarView->openCalendar(tmpFile,merge);
00750 if (merge) {
00751 KIO::NetAccess::removeTempFile(tmpFile);
00752 if (success)
00753 mMainWindow->showStatusMessage(i18n("Merged calendar '%1'.").arg(url.prettyURL()));
00754 } else {
00755 if (success) {
00756 KIO::NetAccess::removeTempFile(mFile);
00757 mURL = url;
00758 mFile = tmpFile;
00759 KConfig *config = KOGlobals::self()->config();
00760 config->setGroup("General");
00761 setTitle();
00762 kdDebug(5850) << "-- Add recent URL: " << url.prettyURL() << endl;
00763 if ( mRecent ) mRecent->addURL(url);
00764 mMainWindow->showStatusMessage(i18n("Opened calendar '%1'.").arg(mURL.prettyURL()));
00765 }
00766 }
00767 return success;
00768 } else {
00769 QString msg;
00770 msg = i18n("Cannot download calendar from '%1'.").arg(url.prettyURL());
00771 KMessageBox::error(mCalendarView->topLevelWidget(),msg);
00772 return false;
00773 }
00774 }
00775
00776 void ActionManager::closeURL()
00777 {
00778 kdDebug(5850) << "ActionManager::closeURL()" << endl;
00779
00780 file_close();
00781 }
00782
00783 bool ActionManager::saveURL()
00784 {
00785 QString ext;
00786
00787 if ( mURL.isLocalFile() ) {
00788 ext = mFile.right( 4 );
00789 } else {
00790 ext = mURL.filename().right( 4 );
00791 }
00792
00793 if ( ext == ".vcs" ) {
00794 int result = KMessageBox::warningContinueCancel(
00795 mCalendarView->topLevelWidget(),
00796 i18n("Your calendar will be saved in iCalendar format. Use "
00797 "'Export vCalendar' to save in vCalendar format."),
00798 i18n("Format Conversion"), i18n("Proceed"), "dontaskFormatConversion",
00799 true );
00800 if ( result != KMessageBox::Continue ) return false;
00801
00802 QString filename = mURL.fileName();
00803 filename.replace( filename.length() - 4, 4, ".ics" );
00804 mURL.setFileName( filename );
00805 if ( mURL.isLocalFile() ) {
00806 mFile = mURL.path();
00807 }
00808 setTitle();
00809 if ( mRecent ) mRecent->addURL( mURL );
00810 }
00811
00812 if ( !mCalendarView->saveCalendar( mFile ) ) {
00813 kdDebug(5850) << "ActionManager::saveURL(): calendar view save failed."
00814 << endl;
00815 return false;
00816 } else {
00817 mCalendarView->setModified( false );
00818 }
00819
00820 if ( !mURL.isLocalFile() ) {
00821 if ( !KIO::NetAccess::upload( mFile, mURL, view() ) ) {
00822 QString msg = i18n("Cannot upload calendar to '%1'")
00823 .arg( mURL.prettyURL() );
00824 KMessageBox::error( mCalendarView->topLevelWidget() ,msg );
00825 return false;
00826 }
00827 }
00828
00829
00830 if (KOPrefs::instance()->mAutoSave) {
00831 mAutoSaveTimer->stop();
00832 mAutoSaveTimer->start(1000*60*KOPrefs::instance()->mAutoSaveInterval);
00833 }
00834
00835 mMainWindow->showStatusMessage(i18n("Saved calendar '%1'.").arg(mURL.prettyURL()));
00836
00837
00838 if ( KOPrefs::instance()->mHtmlWithSave==true &&
00839 !KOPrefs::instance()->mHtmlExportFile.isNull() ) {
00840 KURL dest( KOPrefs::instance()->mHtmlExportFile );
00841 KCal::HtmlExport mExport( mCalendarView->calendar() );
00842 mExport.setEmail( KOPrefs::instance()->email() );
00843 mExport.setFullName( KOPrefs::instance()->fullName() );
00844
00845 KConfig *cfg = KOGlobals::self()->config();
00846 cfg->setGroup( "HtmlExport" );
00847
00848 mExport.setMonthViewEnabled( cfg->readBoolEntry( "Month", false ) );
00849 mExport.setEventsEnabled( cfg->readBoolEntry( "Event", true ) );
00850 mExport.setTodosEnabled( cfg->readBoolEntry( "Todo", true ) );
00851 mExport.setCategoriesEventEnabled( cfg->readBoolEntry( "CategoriesEvent", false ) );
00852 mExport.setAttendeesEventEnabled( cfg->readBoolEntry( "AttendeesEvent", false ) );
00853 mExport.setExcludePrivateEventEnabled( cfg->readBoolEntry( "ExcludePrivateEvent", true ) );
00854 mExport.setExcludeConfidentialEventEnabled( cfg->readBoolEntry( "ExcludeConfidentialEvent", true ) );
00855 mExport.setCategoriesTodoEnabled( cfg->readBoolEntry( "CategoriesTodo", false ) );
00856 mExport.setAttendeesTodoEnabled( cfg->readBoolEntry( "AttendeesTodo", false ) );
00857 mExport.setExcludePrivateTodoEnabled( cfg->readBoolEntry( "ExcludePrivateTodo", true ) );
00858 mExport.setExcludeConfidentialTodoEnabled( cfg->readBoolEntry( "ExcludeConfidentialTodo", true ) );
00859 mExport.setDueDateEnabled( cfg->readBoolEntry( "DueDates", true ) );
00860 QDate qd1;
00861 qd1 = QDate::currentDate();
00862 QDate qd2;
00863 qd2 = QDate::currentDate();
00864 if ( mExport.monthViewEnabled() )
00865 qd2.addMonths( 1 );
00866 else
00867 qd2.addDays( 7 );
00868
00869 mExport.setDateRange( qd1, qd2 );
00870 QDate cdate=qd1;
00871 while (cdate<=qd2)
00872 {
00873 if ( !KOCore::self()->holiday(cdate).isEmpty() )
00874 mExport.addHoliday( cdate, KOCore::self()->holiday(cdate) );
00875 cdate = cdate.addDays(1);
00876 }
00877
00878 if ( dest.isLocalFile() ) {
00879 mExport.save( dest.path() );
00880 } else {
00881 KTempFile tf;
00882 QString tfile = tf.name();
00883 tf.close();
00884 mExport.save( tfile );
00885 if (!KIO::NetAccess::upload( tfile, dest, view() ) ) {
00886 KNotifyClient::event ( view()->winId(),
00887 i18n("Could not upload file.") );
00888 }
00889 tf.unlink();
00890 }
00891 }
00892
00893 return true;
00894 }
00895
00896 bool ActionManager::saveAsURL(const KURL &url)
00897 {
00898 kdDebug(5850) << "ActionManager::saveAsURL() " << url.prettyURL() << endl;
00899
00900 if ( url.isEmpty() ) {
00901 kdDebug(5850) << "ActionManager::saveAsURL(): Empty URL." << endl;
00902 return false;
00903 }
00904 if ( !url.isValid() ) {
00905 kdDebug(5850) << "ActionManager::saveAsURL(): Malformed URL." << endl;
00906 return false;
00907 }
00908
00909 QString fileOrig = mFile;
00910 KURL URLOrig = mURL;
00911
00912 KTempFile *tempFile = 0;
00913 if (url.isLocalFile()) {
00914 mFile = url.path();
00915 } else {
00916 tempFile = new KTempFile;
00917 mFile = tempFile->name();
00918 }
00919 mURL = url;
00920
00921 bool success = saveURL();
00922 if (success) {
00923 delete mTempFile;
00924 mTempFile = tempFile;
00925 KIO::NetAccess::removeTempFile(fileOrig);
00926 KConfig *config = KOGlobals::self()->config();
00927 config->setGroup("General");
00928 setTitle();
00929 if ( mRecent ) mRecent->addURL(mURL);
00930 } else {
00931 kdDebug(5850) << "ActionManager::saveAsURL() failed" << endl;
00932 mURL = URLOrig;
00933 mFile = fileOrig;
00934 delete tempFile;
00935 }
00936
00937 return success;
00938 }
00939
00940
00941 bool ActionManager::saveModifiedURL()
00942 {
00943 kdDebug(5850) << "ActionManager::saveModifiedURL()" << endl;
00944
00945
00946 if (!mCalendarView->isModified()) return true;
00947
00948 mHtmlExportSync = true;
00949 if (KOPrefs::instance()->mAutoSave && !mURL.isEmpty()) {
00950
00951 return saveURL();
00952 } else {
00953 int result = KMessageBox::warningYesNoCancel(
00954 mCalendarView->topLevelWidget(),
00955 i18n("The calendar has been modified.\nDo you want to save it?"),
00956 QString::null,
00957 KStdGuiItem::save(), KStdGuiItem::discard());
00958 switch(result) {
00959 case KMessageBox::Yes:
00960 if (mURL.isEmpty()) {
00961 KURL url = getSaveURL();
00962 return saveAsURL(url);
00963 } else {
00964 return saveURL();
00965 }
00966 case KMessageBox::No:
00967 return true;
00968 case KMessageBox::Cancel:
00969 default:
00970 {
00971 mHtmlExportSync = false;
00972 return false;
00973 }
00974 }
00975 }
00976 }
00977
00978
00979 KURL ActionManager::getSaveURL()
00980 {
00981 KURL url = KFileDialog::getSaveURL(locateLocal("data","korganizer/"),
00982 i18n("*.vcs *.ics|Calendar Files"),
00983 mCalendarView->topLevelWidget());
00984
00985 if (url.isEmpty()) return url;
00986
00987 QString filename = url.fileName(false);
00988
00989 QString e = filename.right(4);
00990 if (e != ".vcs" && e != ".ics") {
00991
00992 filename += ".ics";
00993 }
00994
00995 url.setFileName(filename);
00996
00997 kdDebug(5850) << "ActionManager::getSaveURL(): url: " << url.url() << endl;
00998
00999 return url;
01000 }
01001
01002 void ActionManager::saveProperties(KConfig *config)
01003 {
01004 kdDebug() << "ActionManager::saveProperties" << endl;
01005
01006 config->writeEntry( "UseResourceCalendar", !mMainWindow->hasDocument() );
01007 if ( mMainWindow->hasDocument() ) {
01008 config->writePathEntry("Calendar",mURL.url());
01009 }
01010 }
01011
01012 void ActionManager::readProperties(KConfig *config)
01013 {
01014 kdDebug() << "ActionManager::readProperties" << endl;
01015
01016 bool isResourceCalendar(
01017 config->readBoolEntry( "UseResourceCalendar", true ) );
01018 QString calendarUrl = config->readPathEntry("Calendar");
01019
01020 if (!isResourceCalendar && !calendarUrl.isEmpty()) {
01021 mMainWindow->init( true );
01022 KURL u(calendarUrl);
01023 openURL(u);
01024 } else {
01025 mMainWindow->init( false );
01026 }
01027 }
01028
01029 void ActionManager::checkAutoSave()
01030 {
01031 kdDebug(5850) << "ActionManager::checkAutoSave()" << endl;
01032
01033
01034 if (KOPrefs::instance()->mAutoSaveInterval == 0) return;
01035
01036
01037 if ( KOPrefs::instance()->mAutoSave ) {
01038 if ( mCalendarResources || ( mCalendar && !url().isEmpty() ) ) {
01039 saveCalendar();
01040 }
01041 }
01042 }
01043
01044
01045
01046 void ActionManager::updateConfig()
01047 {
01048 kdDebug(5850) << "ActionManager::updateConfig()" << endl;
01049
01050 if ( KOPrefs::instance()->mAutoSave && !mAutoSaveTimer->isActive() ) {
01051 checkAutoSave();
01052 if ( KOPrefs::instance()->mAutoSaveInterval > 0) {
01053 mAutoSaveTimer->start( 1000 * 60 *
01054 KOPrefs::instance()->mAutoSaveInterval );
01055 }
01056 }
01057 if ( !KOPrefs::instance()->mAutoSave ) mAutoSaveTimer->stop();
01058 mNextXDays->setText( i18n( "&Next Day", "&Next %n Days",
01059 KOPrefs::instance()->mNextXDays ) );
01060
01061 KOCore::self()->reloadPlugins();
01062 mParts = KOCore::self()->reloadParts( mMainWindow, mParts );
01063
01064 setDestinationPolicy();
01065 }
01066
01067 void ActionManager::setDestinationPolicy()
01068 {
01069 if ( mCalendarResources ) {
01070 if ( KOPrefs::instance()->mDestination == KOPrefs::askDestination )
01071 mCalendarResources->setAskDestinationPolicy();
01072 else
01073 mCalendarResources->setStandardDestinationPolicy();
01074 }
01075 }
01076
01077 void ActionManager::configureDateTime()
01078 {
01079 KProcess *proc = new KProcess;
01080 *proc << "kcmshell" << "language";
01081
01082 connect(proc,SIGNAL(processExited(KProcess *)),
01083 SLOT(configureDateTimeFinished(KProcess *)));
01084
01085 if (!proc->start()) {
01086 KMessageBox::sorry(mCalendarView->topLevelWidget(),
01087 i18n("Couldn't start control module for date and time format."));
01088 }
01089 }
01090
01091 void ActionManager::showTip()
01092 {
01093 KTipDialog::showTip(mCalendarView->topLevelWidget(),QString::null,true);
01094 }
01095
01096 void ActionManager::showTipOnStart()
01097 {
01098 KTipDialog::showTip(mCalendarView->topLevelWidget());
01099 }
01100
01101 KOrg::MainWindow *ActionManager::findInstance( const KURL &url )
01102 {
01103 if ( mWindowList ) {
01104 if ( url.isEmpty() ) return mWindowList->defaultInstance();
01105 else return mWindowList->findInstance( url );
01106 } else {
01107 return 0;
01108 }
01109 }
01110
01111 void ActionManager::dumpText(const QString &str)
01112 {
01113 kdDebug(5850) << "ActionManager::dumpText(): " << str << endl;
01114 }
01115
01116 void ActionManager::toggleFilterView()
01117 {
01118 bool visible = mFilterViewAction->isChecked();
01119 mCalendarView->showFilter(visible);
01120 }
01121
01122 bool ActionManager::openURL(QString url)
01123 {
01124 return openURL(KURL(url));
01125 }
01126
01127 bool ActionManager::mergeURL(QString url)
01128 {
01129 return openURL(KURL(url),true);
01130 }
01131
01132 bool ActionManager::saveAsURL(QString url)
01133 {
01134 return saveAsURL(KURL(url));
01135 }
01136
01137 QString ActionManager::getCurrentURLasString() const
01138 {
01139 return mURL.url();
01140 }
01141
01142 bool ActionManager::deleteEvent(QString uid)
01143 {
01144 return mCalendarView->deleteEvent(uid);
01145 }
01146
01147 bool ActionManager::eventRequest(QString request, QCString receiver,
01148 QString ical)
01149 {
01150 if( !KOGroupware::instance() ) return false;
01151 return KOGroupware::instance()->incomingEventRequest(request, receiver,
01152 ical);
01153 }
01154
01155 bool ActionManager::eventReply( QString ical )
01156 {
01157 if( !KOGroupware::instance() ) return false;
01158 return KOGroupware::instance()->incidenceAnswer( ical );
01159 }
01160
01161 void ActionManager::configureDateTimeFinished(KProcess *proc)
01162 {
01163 delete proc;
01164 }
01165
01166 void ActionManager::downloadNewStuff()
01167 {
01168 kdDebug(5850) << "ActionManager::downloadNewStuff()" << endl;
01169
01170 if ( !mNewStuff ) mNewStuff = new KONewStuff( mCalendarView );
01171 mNewStuff->download();
01172 }
01173
01174 void ActionManager::uploadNewStuff()
01175 {
01176 if ( !mNewStuff ) mNewStuff = new KONewStuff( mCalendarView );
01177 mNewStuff->upload();
01178 }
01179
01180 QString ActionManager::localFileName()
01181 {
01182 return mFile;
01183 }
01184
01185 void ActionManager::processIncidenceSelection( Incidence *incidence )
01186 {
01187
01188
01189 if ( !incidence ) {
01190 enableIncidenceActions( false );
01191 return;
01192 }
01193
01194 enableIncidenceActions( true );
01195
01196 if ( incidence->type() == "Event" ) {
01197 mShowIncidenceAction->setText( i18n("&Show Event") );
01198 mEditIncidenceAction->setText( i18n("&Edit Event...") );
01199 mDeleteIncidenceAction->setText( i18n("&Delete Event") );
01200 } else if ( incidence->type() == "Todo" ) {
01201 mShowIncidenceAction->setText( i18n("&Show To-Do") );
01202 mEditIncidenceAction->setText( i18n("&Edit To-Do...") );
01203 mDeleteIncidenceAction->setText( i18n("&Delete To-Do") );
01204 } else {
01205 mShowIncidenceAction->setText( i18n("&Show") );
01206 mEditIncidenceAction->setText( i18n("&Edit...") );
01207 mDeleteIncidenceAction->setText( i18n("&Delete") );
01208 }
01209 }
01210
01211 void ActionManager::enableIncidenceActions( bool enabled )
01212 {
01213 mShowIncidenceAction->setEnabled( enabled );
01214 mEditIncidenceAction->setEnabled( enabled );
01215 mDeleteIncidenceAction->setEnabled( enabled );
01216
01217 mCutAction->setEnabled( enabled );
01218 mCopyAction->setEnabled( enabled );
01219 mDeleteAction->setEnabled( enabled );
01220 mPublishEvent->setEnabled( enabled );
01221 }
01222
01223 void ActionManager::keyBindings()
01224 {
01225 emit actionKeyBindings();
01226 }
01227
01228
01229 void ActionManager::loadParts()
01230 {
01231 mParts = KOCore::self()->loadParts( mMainWindow );
01232 }
01233
01234 void ActionManager::setTitle()
01235 {
01236 mMainWindow->setTitle();
01237 }
01238
01239 KCalendarIface::ResourceRequestReply ActionManager::resourceRequest( const QValueList<QPair<QDateTime, QDateTime> >&,
01240 const QCString& resource,
01241 const QString& vCalIn )
01242 {
01243 kdDebug(5850) << k_funcinfo << "resource=" << resource << " vCalIn=" << vCalIn << endl;
01244 KCalendarIface::ResourceRequestReply reply;
01245 reply.vCalOut = "VCalOut";
01246 return reply;
01247 }
01248
01249 void ActionManager::openEventEditor( QString text )
01250 {
01251 mCalendarView->newEvent( text );
01252 }
01253
01254 void ActionManager::openEventEditor( QString summary, QString description,
01255 QString attachment )
01256 {
01257 mCalendarView->newEvent( summary, description, attachment );
01258 }
01259
01260 void ActionManager::openTodoEditor( QString text )
01261 {
01262 mCalendarView->newTodo( text );
01263 }
01264
01265 void ActionManager::openTodoEditor( QString summary, QString description,
01266 QString attachment )
01267 {
01268 mCalendarView->newTodo( summary, description, attachment );
01269 }
01270
01271 void ActionManager::showTodoView()
01272 {
01273 mCalendarView->viewManager()->showTodoView();
01274 }
01275
01276 void ActionManager::showEventView()
01277 {
01278 mCalendarView->viewManager()->showEventView();
01279 }
01280
01281 void ActionManager::updateUndoAction( const QString &text )
01282 {
01283 if ( text.isNull() ) {
01284 mUndoAction->setEnabled( false );
01285 mUndoAction->setText( i18n("Undo") );
01286 } else {
01287 mUndoAction->setEnabled( true );
01288 if ( text.isEmpty() ) mUndoAction->setText( i18n("Undo") );
01289 else mUndoAction->setText( i18n("Undo (%1)").arg( text ) );
01290 }
01291 }
01292
01293 void ActionManager::updateRedoAction( const QString &text )
01294 {
01295 if ( text.isNull() ) {
01296 mRedoAction->setEnabled( false );
01297 mRedoAction->setText( i18n("Redo") );
01298 } else {
01299 mRedoAction->setEnabled( true );
01300 if ( text.isEmpty() ) mRedoAction->setText( i18n("Redo") );
01301 else mRedoAction->setText( i18n("Redo (%1)").arg( text ) );
01302 }
01303 }
01304
01305 bool ActionManager::queryClose()
01306 {
01307 kdDebug() << "ActionManager::queryClose()" << endl;
01308
01309 bool close = true;
01310
01311 if ( mCalendar ) {
01312 close = saveModifiedURL();
01313 } else if ( mCalendarResources ) {
01314 mCalendarResources->resourceManager()->writeConfig();
01315 if ( !mIsClosing ) {
01316 kdDebug(5850) << "!mIsClosing" << endl;
01317 if ( !saveResourceCalendar() ) return false;
01318
01319
01320 mIsClosing = true;
01321
01322
01323
01324 }
01325 if ( mCalendarResources->isSaving() ) {
01326 kdDebug(5850) << "KOrganizer::queryClose(): isSaving" << endl;
01327 close = false;
01328 } else {
01329 kdDebug(5850) << "KOrganizer::queryClose(): close = true" << endl;
01330 close = true;
01331 }
01332 } else {
01333 close = true;
01334 }
01335
01336 return close;
01337 }
01338
01339 void ActionManager::saveCalendar()
01340 {
01341 if ( mCalendar ) {
01342 if ( view()->isModified() ) {
01343 if ( !url().isEmpty() ) {
01344 saveURL();
01345 } else {
01346 QString location = locateLocal( "data", "korganizer/kontact.ics" );
01347 saveAsURL( location );
01348 }
01349 }
01350 } else if ( mCalendarResources ) {
01351 mCalendarResources->save();
01352
01353 }
01354 }
01355
01356 bool ActionManager::saveResourceCalendar()
01357 {
01358 if ( !mCalendarResources ) return false;
01359 CalendarResourceManager *m = mCalendarResources->resourceManager();
01360
01361 CalendarResourceManager::ActiveIterator it;
01362 for ( it = m->activeBegin(); it != m->activeEnd(); ++it ) {
01363 if ( (*it)->readOnly() ) continue;
01364 if ( !(*it)->save() ) {
01365 int result = KMessageBox::warningContinueCancel( view(),
01366 i18n("Saving '%1' failed. Please check, if the resource is "
01367 "properly configured.\nIgnore problem and continue without "
01368 "saving or cancel save?").arg( (*it)->resourceName() ),
01369 i18n("Save Error"), i18n("Don't save") );
01370 if ( result == KMessageBox::Cancel ) return false;
01371 }
01372 }
01373 return true;
01374 }
01375
01376 void ActionManager::importResource( const QString &url )
01377 {
01378 ResourceImportDialog *dialog;
01379 dialog = new ResourceImportDialog( url, mMainWindow->topLevelWidget() );
01380 dialog->show();
01381 }
01382
01383 #include "actionmanager.moc"