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