summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp73
-rw-r--r--korganizer/calendarview.h4
-rw-r--r--korganizer/mainwindow.cpp14
-rw-r--r--korganizer/mainwindow.h4
4 files changed, 78 insertions, 17 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 8965d3b..307027a 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -177,384 +177,385 @@ MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Inciden
177 } else if ( inc->typeID() == todoID ) { 177 } else if ( inc->typeID() == todoID ) {
178 tempText += "href=\"todo:"; 178 tempText += "href=\"todo:";
179 } 179 }
180 tempText += inc->uid() + "\">"; 180 tempText += inc->uid() + "\">";
181 if ( inc->typeID() == todoID ) 181 if ( inc->typeID() == todoID )
182 tempText += i18n("Todo: "); 182 tempText += i18n("Todo: ");
183 if ( inc->summary().length() > 0 ) 183 if ( inc->summary().length() > 0 )
184 tempText += inc->summary(); 184 tempText += inc->summary();
185 else 185 else
186 tempText += i18n("-no summary-"); 186 tempText += i18n("-no summary-");
187 QString timestr; 187 QString timestr;
188 if (!inc->doesFloat()) 188 if (!inc->doesFloat())
189 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; 189 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": ";
190 else 190 else
191 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; 191 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
192 if ( dt.date() < QDate::currentDate() && time == 0 ) { 192 if ( dt.date() < QDate::currentDate() && time == 0 ) {
193 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; 193 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
194 mText += "<table>"; 194 mText += "<table>";
195 time = 1; 195 time = 1;
196 } 196 }
197 if ( dt.date() == QDate::currentDate() && time <= 1 ) { 197 if ( dt.date() == QDate::currentDate() && time <= 1 ) {
198 if ( time > 0 ) 198 if ( time > 0 )
199 mText +="</table>"; 199 mText +="</table>";
200 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; 200 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>";
201 mText += "<table>"; 201 mText += "<table>";
202 time = 2; 202 time = 2;
203 203
204 } 204 }
205 if ( dt.date() > QDate::currentDate() && time <= 2 ) { 205 if ( dt.date() > QDate::currentDate() && time <= 2 ) {
206 if ( time > 0 ) 206 if ( time > 0 )
207 mText +="</table>"; 207 mText +="</table>";
208 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; 208 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>";
209 mText += "<table>"; 209 mText += "<table>";
210 time = 3; 210 time = 3;
211 } 211 }
212 mText +="<tr><td><b>"; 212 mText +="<tr><td><b>";
213 mText += timestr; 213 mText += timestr;
214 mText += "</b></td><td>"; 214 mText += "</b></td><td>";
215 mText += tempText; 215 mText += tempText;
216 mText += "</td></tr>\n"; 216 mText += "</td></tr>\n";
217 inc = getNextInc( start ); 217 inc = getNextInc( start );
218 } 218 }
219 mText +="</table>"; 219 mText +="</table>";
220 setText( mText ); 220 setText( mText );
221} 221}
222 222
223MissedAlarmTextBrowser::~MissedAlarmTextBrowser() 223MissedAlarmTextBrowser::~MissedAlarmTextBrowser()
224{ 224{
225 //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); 225 //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() ");
226} 226}
227Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) 227Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start )
228{ 228{
229 QDateTime dt ; 229 QDateTime dt ;
230 Incidence * retInc; 230 Incidence * retInc;
231 Incidence * inc = mAlarms.first(); 231 Incidence * inc = mAlarms.first();
232 if ( inc == 0 ) 232 if ( inc == 0 )
233 return 0; 233 return 0;
234 bool ok; 234 bool ok;
235 dt = inc->getNextOccurence( start, &ok ); 235 dt = inc->getNextOccurence( start, &ok );
236 if ( ! ok ) return 0; 236 if ( ! ok ) return 0;
237 QDateTime dtn ; 237 QDateTime dtn ;
238 retInc = inc; 238 retInc = inc;
239 inc = mAlarms.next(); 239 inc = mAlarms.next();
240 while ( inc ) { 240 while ( inc ) {
241 dtn = inc->getNextOccurence( start, &ok ); 241 dtn = inc->getNextOccurence( start, &ok );
242 if ( ! ok ) return 0; 242 if ( ! ok ) return 0;
243 if ( dtn < dt ) { 243 if ( dtn < dt ) {
244 dt = dtn; 244 dt = dtn;
245 retInc = inc; 245 retInc = inc;
246 } 246 }
247 inc = mAlarms.next(); 247 inc = mAlarms.next();
248 } 248 }
249 mAlarms.remove( retInc ); 249 mAlarms.remove( retInc );
250 return retInc; 250 return retInc;
251 251
252} 252}
253void MissedAlarmTextBrowser::setSource(const QString & n) 253void MissedAlarmTextBrowser::setSource(const QString & n)
254{ 254{
255 if (n.startsWith("event:")) { 255 if (n.startsWith("event:")) {
256#ifdef DESKTOP_VERSION 256#ifdef DESKTOP_VERSION
257 emit showIncidence(n.mid(8)); 257 emit showIncidence(n.mid(8));
258#else 258#else
259 emit showIncidence(n.mid(6)); 259 emit showIncidence(n.mid(6));
260#endif 260#endif
261 return; 261 return;
262 } else if (n.startsWith("todo:")) { 262 } else if (n.startsWith("todo:")) {
263#ifdef DESKTOP_VERSION 263#ifdef DESKTOP_VERSION
264 emit showIncidence(n.mid(7)); 264 emit showIncidence(n.mid(7));
265#else 265#else
266 emit showIncidence(n.mid(5)); 266 emit showIncidence(n.mid(5));
267#endif 267#endif
268 return; 268 return;
269 } 269 }
270} 270}
271 271
272 272
273class KOBeamPrefs : public QDialog 273class KOBeamPrefs : public QDialog
274{ 274{
275 public: 275 public:
276 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 276 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
277 QDialog( parent, name, true ) 277 QDialog( parent, name, true )
278 { 278 {
279 setCaption( i18n("Beam Options") ); 279 setCaption( i18n("Beam Options") );
280 QVBoxLayout* lay = new QVBoxLayout( this ); 280 QVBoxLayout* lay = new QVBoxLayout( this );
281 lay->setSpacing( 3 ); 281 lay->setSpacing( 3 );
282 lay->setMargin( 3 ); 282 lay->setMargin( 3 );
283 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 283 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
284 lay->addWidget( format ); 284 lay->addWidget( format );
285 format->setExclusive ( true ) ; 285 format->setExclusive ( true ) ;
286 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 286 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
287 lay->addWidget( time ); time->setExclusive ( true ) ; 287 lay->addWidget( time ); time->setExclusive ( true ) ;
288 vcal = new QRadioButton(" vCalendar ", format ); 288 vcal = new QRadioButton(" vCalendar ", format );
289 ical = new QRadioButton(" iCalendar ", format ); 289 ical = new QRadioButton(" iCalendar ", format );
290 vcal->setChecked( true ); 290 vcal->setChecked( true );
291 tz = new QRadioButton(i18n(" With timezone "), time ); 291 tz = new QRadioButton(i18n(" With timezone "), time );
292 local = new QRadioButton(i18n(" Local time "), time ); 292 local = new QRadioButton(i18n(" Local time "), time );
293 tz->setChecked( true ); 293 tz->setChecked( true );
294 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 294 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
295 lay->addWidget( ok ); 295 lay->addWidget( ok );
296 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 296 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
297 lay->addWidget( cancel ); 297 lay->addWidget( cancel );
298 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 298 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
299 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 299 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
300 resize( 200, 200 ); 300 resize( 200, 200 );
301 } 301 }
302 302
303 bool beamVcal() { return vcal->isChecked(); } 303 bool beamVcal() { return vcal->isChecked(); }
304 bool beamLocal() { return local->isChecked(); } 304 bool beamLocal() { return local->isChecked(); }
305private: 305private:
306 QRadioButton* vcal, *ical, *local, *tz; 306 QRadioButton* vcal, *ical, *local, *tz;
307}; 307};
308class KOCatPrefs : public QDialog 308class KOCatPrefs : public QDialog
309{ 309{
310 public: 310 public:
311 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 311 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
312 QDialog( parent, name, true ) 312 QDialog( parent, name, true )
313 { 313 {
314 setCaption( i18n("Manage new Categories") ); 314 setCaption( i18n("Manage new Categories") );
315 QVBoxLayout* lay = new QVBoxLayout( this ); 315 QVBoxLayout* lay = new QVBoxLayout( this );
316 lay->setSpacing( 3 ); 316 lay->setSpacing( 3 );
317 lay->setMargin( 3 ); 317 lay->setMargin( 3 );
318 QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this ); 318 QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this );
319 lay->addWidget( lab ); 319 lay->addWidget( lab );
320 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 320 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
321 lay->addWidget( format ); 321 lay->addWidget( format );
322 format->setExclusive ( true ) ; 322 format->setExclusive ( true ) ;
323 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 323 addCatBut = new QRadioButton(i18n("Add to category list"), format );
324 new QRadioButton(i18n("Remove from Events/Todos"), format ); 324 new QRadioButton(i18n("Remove from Events/Todos"), format );
325 addCatBut->setChecked( true ); 325 addCatBut->setChecked( true );
326 QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); 326 QPushButton * ok = new QPushButton( i18n("Change category list now!"), this );
327 lay->addWidget( ok ); 327 lay->addWidget( ok );
328 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 328 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
329 lay->addWidget( cancel ); 329 lay->addWidget( cancel );
330 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 330 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
331 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 331 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
332 resize( 200, 200 ); 332 resize( 200, 200 );
333 } 333 }
334 334
335 bool addCat() { return addCatBut->isChecked(); } 335 bool addCat() { return addCatBut->isChecked(); }
336private: 336private:
337 QRadioButton* addCatBut; 337 QRadioButton* addCatBut;
338}; 338};
339 339
340 340
341 341
342CalendarView::CalendarView( CalendarResources *calendar, 342CalendarView::CalendarView( CalendarResources *calendar,
343 QWidget *parent, const char *name ) 343 QWidget *parent, const char *name )
344 : CalendarViewBase( parent, name ), 344 : CalendarViewBase( parent, name ),
345 mCalendar( calendar ), 345 mCalendar( calendar ),
346 mResourceManager( calendar->resourceManager() ) 346 mResourceManager( calendar->resourceManager() )
347{ 347{
348 348
349 mEventEditor = 0; 349 mEventEditor = 0;
350 mTodoEditor = 0; 350 mTodoEditor = 0;
351 351
352 init(); 352 init();
353} 353}
354 354
355CalendarView::CalendarView( Calendar *calendar, 355CalendarView::CalendarView( Calendar *calendar,
356 QWidget *parent, const char *name ) 356 QWidget *parent, const char *name )
357 : CalendarViewBase( parent, name ), 357 : CalendarViewBase( parent, name ),
358 mCalendar( calendar ), 358 mCalendar( calendar ),
359 mResourceManager( 0 ) 359 mResourceManager( 0 )
360{ 360{
361 361
362 mEventEditor = 0; 362 mEventEditor = 0;
363 mTodoEditor = 0; 363 mTodoEditor = 0;
364 init(); 364 init();
365} 365}
366 366
367void CalendarView::init() 367void CalendarView::init()
368{ 368{
369 mMultiResourceSync = false;
369 flag_blockConflict = false; 370 flag_blockConflict = false;
370 flag_blockScrollBar = false; 371 flag_blockScrollBar = false;
371 flag_checkFileFirsttime = true; 372 flag_checkFileFirsttime = true;
372 flag_clearallviewsEventDisplay = false; 373 flag_clearallviewsEventDisplay = false;
373 flag_clearallviewsupdateView = false; 374 flag_clearallviewsupdateView = false;
374 mNextAlarmDateTime = QDateTime::currentDateTime(); 375 mNextAlarmDateTime = QDateTime::currentDateTime();
375 setFocusPolicy (NoFocus ); 376 setFocusPolicy (NoFocus );
376 mViewerCallerIsSearchDialog = false; 377 mViewerCallerIsSearchDialog = false;
377 mBlockShowDates = false; 378 mBlockShowDates = false;
378 mConflictingEvent = 0; 379 mConflictingEvent = 0;
379 mDatePickerMode = 0; 380 mDatePickerMode = 0;
380 mCurrentSyncDevice = ""; 381 mCurrentSyncDevice = "";
381 mViewManager = new KOViewManager( this ); 382 mViewManager = new KOViewManager( this );
382 mDialogManager = new KODialogManager( this ); 383 mDialogManager = new KODialogManager( this );
383 mEventViewerDialog = 0; 384 mEventViewerDialog = 0;
384 mModified = false; 385 mModified = false;
385 mReadOnly = false; 386 mReadOnly = false;
386 mSelectedIncidence = 0; 387 mSelectedIncidence = 0;
387 mCalPrinter = 0; 388 mCalPrinter = 0;
388 mFilters.setAutoDelete(true); 389 mFilters.setAutoDelete(true);
389 390
390 mCalendar->registerObserver( this ); 391 mCalendar->registerObserver( this );
391 // TODO: Make sure that view is updated, when calendar is changed. 392 // TODO: Make sure that view is updated, when calendar is changed.
392 393
393 mStorage = new FileStorage( mCalendar ); 394 mStorage = new FileStorage( mCalendar );
394 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 395 mNavigator = new DateNavigator( this, "datevav", mViewManager );
395 396
396 QBoxLayout *topLayout = (QBoxLayout*)layout(); 397 QBoxLayout *topLayout = (QBoxLayout*)layout();
397#ifndef KORG_NOSPLITTER 398#ifndef KORG_NOSPLITTER
398 // create the main layout frames. 399 // create the main layout frames.
399 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 400 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
400 topLayout->addWidget(mPanner); 401 topLayout->addWidget(mPanner);
401 402
402 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 403 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
403 "CalendarView::LeftFrame"); 404 "CalendarView::LeftFrame");
404 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 405 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
405 406
406 mDateNavigator = new DateNavigatorContainer( mLeftSplitter, 407 mDateNavigator = new DateNavigatorContainer( mLeftSplitter,
407 "CalendarView::DateNavigator" ); 408 "CalendarView::DateNavigator" );
408 409
409 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 410 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
410 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 411 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
411 mTodoList->setNavigator( mNavigator ); 412 mTodoList->setNavigator( mNavigator );
412 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 413 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
413 414
414#ifdef KORG_NORESOURCEVIEW 415#ifdef KORG_NORESOURCEVIEW
415 mResourceView = 0; 416 mResourceView = 0;
416#else 417#else
417 if ( mResourceManager ) { 418 if ( mResourceManager ) {
418 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 419 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
419 mResourceView->updateView(); 420 mResourceView->updateView();
420 connect( mResourceView, SIGNAL( resourcesChanged() ), 421 connect( mResourceView, SIGNAL( resourcesChanged() ),
421 SLOT( updateView() ) ); 422 SLOT( updateView() ) );
422 } else { 423 } else {
423 mResourceView = 0; 424 mResourceView = 0;
424 } 425 }
425#endif 426#endif
426 QWidget *rightBox = new QWidget( mPanner ); 427 QWidget *rightBox = new QWidget( mPanner );
427 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 428 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
428 429
429 mRightFrame = new QWidgetStack( rightBox ); 430 mRightFrame = new QWidgetStack( rightBox );
430 rightLayout->addWidget( mRightFrame, 1 ); 431 rightLayout->addWidget( mRightFrame, 1 );
431 432
432 mLeftFrame = mLeftSplitter; 433 mLeftFrame = mLeftSplitter;
433#else 434#else
434 //QWidget *mainBox = new QWidget( this ); 435 //QWidget *mainBox = new QWidget( this );
435 //QWidget *leftFrame = new QWidget( mainBox ); 436 //QWidget *leftFrame = new QWidget( mainBox );
436 //QBoxLayout * mainBoxLayout; 437 //QBoxLayout * mainBoxLayout;
437 if ( KOPrefs::instance()->mVerticalScreen ) { 438 if ( KOPrefs::instance()->mVerticalScreen ) {
438 //mainBoxLayout = new QVBoxLayout(mainBox); 439 //mainBoxLayout = new QVBoxLayout(mainBox);
439 //leftFrameLayout = new QHBoxLayout(leftFrame ); 440 //leftFrameLayout = new QHBoxLayout(leftFrame );
440 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); 441 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this );
441 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 442 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
442 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; 443 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);;
443 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 444 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
444 } else { 445 } else {
445 //mainBoxLayout = new QHBoxLayout(mainBox); 446 //mainBoxLayout = new QHBoxLayout(mainBox);
446 //leftFrameLayout = new QVBoxLayout(leftFrame ); 447 //leftFrameLayout = new QVBoxLayout(leftFrame );
447 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 448 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
448 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); 449 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left);
449 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); 450 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame);
450 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 451 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
451 } 452 }
452 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 453 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
453 //QBoxLayout * leftFrameLayout; 454 //QBoxLayout * leftFrameLayout;
454 topLayout->addWidget( mMainFrame ); 455 topLayout->addWidget( mMainFrame );
455#ifdef DESKTOP_VERSION 456#ifdef DESKTOP_VERSION
456 mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); 457 mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this );
457 topLayout->addWidget( mDateScrollBar ); 458 topLayout->addWidget( mDateScrollBar );
458 connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); 459 connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) );
459 if ( QApplication::desktop()->width() < 800 ) 460 if ( QApplication::desktop()->width() < 800 )
460 mDateScrollBar->hide(); 461 mDateScrollBar->hide();
461#endif 462#endif
462 //mainBoxLayout->addWidget (mLeftFrame); 463 //mainBoxLayout->addWidget (mLeftFrame);
463 mDateNavigator = new DateNavigatorContainer( mLeftFrame, 464 mDateNavigator = new DateNavigatorContainer( mLeftFrame,
464 "CalendarView::DateNavigator" ); 465 "CalendarView::DateNavigator" );
465#if 0 466#if 0
466 // FIXME 467 // FIXME
467 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, 468 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE,
468 "CalendarView::DateNavigator", QDate::currentDate()); 469 "CalendarView::DateNavigator", QDate::currentDate());
469#endif 470#endif
470 // mDateNavigator->blockSignals( true ); 471 // mDateNavigator->blockSignals( true );
471 //leftFrameLayout->addWidget( mDateNavigator ); 472 //leftFrameLayout->addWidget( mDateNavigator );
472 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); 473 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall");
473 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); 474 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView");
474 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); 475 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView");
475 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); 476 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) );
476 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); 477 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) );
477 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); 478 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) );
478 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); 479 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) );
479 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); 480 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) );
480 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); 481 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) );
481 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); 482 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) );
482 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); 483 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) );
483 connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); 484 connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() ));
484 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); 485 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) );
485 connect( mCalEditView, SIGNAL( requestCalendarInfo( int ) ),this, SLOT( displayCalendarInfo( int ) ) ); 486 connect( mCalEditView, SIGNAL( requestCalendarInfo( int ) ),this, SLOT( displayCalendarInfo( int ) ) );
486 487
487 488
488 mTodoList->setNavigator( mNavigator ); 489 mTodoList->setNavigator( mNavigator );
489#if 0 490#if 0
490 if ( QApplication::desktop()->width() < 480 ) { 491 if ( QApplication::desktop()->width() < 480 ) {
491 leftFrameLayout->addWidget(mFilterView); 492 leftFrameLayout->addWidget(mFilterView);
492 leftFrameLayout->addWidget(mTodoList, 2 ); 493 leftFrameLayout->addWidget(mTodoList, 2 );
493 494
494 } else { 495 } else {
495 leftFrameLayout->addWidget(mTodoList,2 ); 496 leftFrameLayout->addWidget(mTodoList,2 );
496 leftFrameLayout->addWidget(mFilterView ); 497 leftFrameLayout->addWidget(mFilterView );
497 } 498 }
498#endif 499#endif
499 mFilterView->hide(); 500 mFilterView->hide();
500 mCalEditView->hide(); 501 mCalEditView->hide();
501 QWidget *rightBox = new QWidget( mMainFrame ); 502 QWidget *rightBox = new QWidget( mMainFrame );
502 //mainBoxLayout->addWidget ( rightBox, 10 ); 503 //mainBoxLayout->addWidget ( rightBox, 10 );
503 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 504 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
504 mRightFrame = new QWidgetStack( rightBox ); 505 mRightFrame = new QWidgetStack( rightBox );
505 rightLayout->addWidget( mRightFrame, 10 ); 506 rightLayout->addWidget( mRightFrame, 10 );
506 507
507 //mLeftFrame = (QWidget *)leftFrame; 508 //mLeftFrame = (QWidget *)leftFrame;
508 if ( KOPrefs::instance()->mVerticalScreen ) { 509 if ( KOPrefs::instance()->mVerticalScreen ) {
509 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); 510 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() );
510 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); 511 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() );
511 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 512 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
512 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 513 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
513 } else { 514 } else {
514 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); 515 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() );
515 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 516 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
516 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 517 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
517 } 518 }
518 if ( !KOPrefs::instance()->mShowDateNavigator) 519 if ( !KOPrefs::instance()->mShowDateNavigator)
519 mDateNavigator->hide(); 520 mDateNavigator->hide();
520 //qDebug("Calendarview Size %d %d ", width(), height()); 521 //qDebug("Calendarview Size %d %d ", width(), height());
521#endif 522#endif
522 523
523 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 524 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
524 SLOT( showDates( const KCal::DateList & ) ) ); 525 SLOT( showDates( const KCal::DateList & ) ) );
525 526
526 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 527 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
527 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 528 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
528 529
529 530
530 531
531 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), 532 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ),
532 mViewManager, SLOT( showMonth( const QDate & ) ) ); 533 mViewManager, SLOT( showMonth( const QDate & ) ) );
533 534
534 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 535 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
535 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 536 mNavigator, SLOT( selectWeek( const QDate & ) ) );
536 537
537 connect( mDateNavigator, SIGNAL( goPrevYear() ), 538 connect( mDateNavigator, SIGNAL( goPrevYear() ),
538 mNavigator, SLOT( selectPreviousYear() ) ); 539 mNavigator, SLOT( selectPreviousYear() ) );
539 connect( mDateNavigator, SIGNAL( goNextYear() ), 540 connect( mDateNavigator, SIGNAL( goNextYear() ),
540 mNavigator, SLOT( selectNextYear() ) ); 541 mNavigator, SLOT( selectNextYear() ) );
541 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 542 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
542 mNavigator, SLOT( selectPreviousMonth() ) ); 543 mNavigator, SLOT( selectPreviousMonth() ) );
543 connect( mDateNavigator, SIGNAL( goNextMonth() ), 544 connect( mDateNavigator, SIGNAL( goNextMonth() ),
544 mNavigator, SLOT( selectNextMonth() ) ); 545 mNavigator, SLOT( selectNextMonth() ) );
545 546
546 connect( mDateNavigator, SIGNAL( goPrevious() ), 547 connect( mDateNavigator, SIGNAL( goPrevious() ),
547 mNavigator, SLOT( selectPrevious() ) ); 548 mNavigator, SLOT( selectPrevious() ) );
548 connect( mDateNavigator, SIGNAL( goNext() ), 549 connect( mDateNavigator, SIGNAL( goNext() ),
549 mNavigator, SLOT( selectNext() ) ); 550 mNavigator, SLOT( selectNext() ) );
550 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 551 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
551 mNavigator, SLOT( slotMonthSelect( int ) ) ); 552 mNavigator, SLOT( slotMonthSelect( int ) ) );
552 553
553 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 554 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
554 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 555 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
555#if 0 556#if 0
556 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), 557 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ),
557 SLOT( incidenceAdded( Incidence *) ) ); 558 SLOT( incidenceAdded( Incidence *) ) );
558#endif 559#endif
559 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 560 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
560 561
@@ -1363,744 +1364,750 @@ QDate CalendarView::startDate()
1363 1364
1364QDate CalendarView::endDate() 1365QDate CalendarView::endDate()
1365{ 1366{
1366 DateList dates = mNavigator->selectedDates(); 1367 DateList dates = mNavigator->selectedDates();
1367 1368
1368 return dates.last(); 1369 return dates.last();
1369} 1370}
1370 1371
1371 1372
1372void CalendarView::createPrinter() 1373void CalendarView::createPrinter()
1373{ 1374{
1374#ifndef KORG_NOPRINTER 1375#ifndef KORG_NOPRINTER
1375 if (!mCalPrinter) { 1376 if (!mCalPrinter) {
1376 mCalPrinter = new CalPrinter(this, mCalendar); 1377 mCalPrinter = new CalPrinter(this, mCalendar);
1377 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 1378 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
1378 } 1379 }
1379#endif 1380#endif
1380} 1381}
1381 1382
1382 1383
1383//KOPrefs::instance()->mWriteBackFile 1384//KOPrefs::instance()->mWriteBackFile
1384//KOPrefs::instance()->mWriteBackExistingOnly 1385//KOPrefs::instance()->mWriteBackExistingOnly
1385 1386
1386// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 1387// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
1387// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 1388// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
1388// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 1389// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
1389// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 1390// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
1390// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 1391// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
1391// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 1392// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
1392 1393
1393int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 1394int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
1394{ 1395{
1395 1396
1396 // 0 equal 1397 // 0 equal
1397 // 1 take local 1398 // 1 take local
1398 // 2 take remote 1399 // 2 take remote
1399 // 3 cancel 1400 // 3 cancel
1400 QDateTime lastSync = mLastCalendarSync; 1401 QDateTime lastSync = mLastCalendarSync;
1401 QDateTime localMod = local->lastModified(); 1402 QDateTime localMod = local->lastModified();
1402 QDateTime remoteMod = remote->lastModified(); 1403 QDateTime remoteMod = remote->lastModified();
1403 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1404 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1404 bool remCh, locCh; 1405 bool remCh, locCh;
1405 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 1406 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
1406 //if ( remCh ) 1407 //if ( remCh )
1407 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 1408 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
1408 locCh = ( localMod > mLastCalendarSync ); 1409 locCh = ( localMod > mLastCalendarSync );
1409 if ( !remCh && ! locCh ) { 1410 if ( !remCh && ! locCh ) {
1410 //qDebug("both not changed "); 1411 //qDebug("both not changed ");
1411 lastSync = localMod.addDays(1); 1412 lastSync = localMod.addDays(1);
1412 if ( mode <= SYNC_PREF_ASK ) 1413 if ( mode <= SYNC_PREF_ASK )
1413 return 0; 1414 return 0;
1414 } else { 1415 } else {
1415 if ( locCh ) { 1416 if ( locCh ) {
1416 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 1417 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
1417 lastSync = localMod.addDays( -1 ); 1418 lastSync = localMod.addDays( -1 );
1418 if ( !remCh ) 1419 if ( !remCh )
1419 remoteMod = ( lastSync.addDays( -1 ) ); 1420 remoteMod = ( lastSync.addDays( -1 ) );
1420 } else { 1421 } else {
1421 //qDebug(" not loc changed "); 1422 //qDebug(" not loc changed ");
1422 lastSync = localMod.addDays( 1 ); 1423 lastSync = localMod.addDays( 1 );
1423 if ( remCh ) 1424 if ( remCh )
1424 remoteMod =( lastSync.addDays( 1 ) ); 1425 remoteMod =( lastSync.addDays( 1 ) );
1425 1426
1426 } 1427 }
1427 } 1428 }
1428 full = true; 1429 full = true;
1429 if ( mode < SYNC_PREF_ASK ) 1430 if ( mode < SYNC_PREF_ASK )
1430 mode = SYNC_PREF_ASK; 1431 mode = SYNC_PREF_ASK;
1431 } else { 1432 } else {
1432 if ( localMod == remoteMod ) 1433 if ( localMod == remoteMod )
1433 // if ( local->revision() == remote->revision() ) 1434 // if ( local->revision() == remote->revision() )
1434 return 0; 1435 return 0;
1435 1436
1436 } 1437 }
1437 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 1438 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
1438 1439
1439 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 1440 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
1440 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 1441 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
1441 //full = true; //debug only 1442 //full = true; //debug only
1442 if ( full ) { 1443 if ( full ) {
1443 bool equ = false; 1444 bool equ = false;
1444 if ( local->typeID() == eventID ) { 1445 if ( local->typeID() == eventID ) {
1445 equ = (*((Event*) local) == *((Event*) remote)); 1446 equ = (*((Event*) local) == *((Event*) remote));
1446 } 1447 }
1447 else if ( local->typeID() == todoID ) 1448 else if ( local->typeID() == todoID )
1448 equ = (*((Todo*) local) == (*(Todo*) remote)); 1449 equ = (*((Todo*) local) == (*(Todo*) remote));
1449 else if ( local->typeID() == journalID ) 1450 else if ( local->typeID() == journalID )
1450 equ = (*((Journal*) local) == *((Journal*) remote)); 1451 equ = (*((Journal*) local) == *((Journal*) remote));
1451 if ( equ ) { 1452 if ( equ ) {
1452 //qDebug("equal "); 1453 //qDebug("equal ");
1453 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1454 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1454 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 1455 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
1455 } 1456 }
1456 if ( mode < SYNC_PREF_FORCE_LOCAL ) 1457 if ( mode < SYNC_PREF_FORCE_LOCAL )
1457 return 0; 1458 return 0;
1458 1459
1459 }//else //debug only 1460 }//else //debug only
1460 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 1461 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
1461 } 1462 }
1462 int result; 1463 int result;
1463 bool localIsNew; 1464 bool localIsNew;
1464 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); 1465 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() );
1465 1466
1466 1467
1467 // ************************************************ 1468 // ************************************************
1468 // ************************************************ 1469 // ************************************************
1469 // ************************************************ 1470 // ************************************************
1470 // We may have that lastSync > remoteMod AND lastSync > localMod 1471 // We may have that lastSync > remoteMod AND lastSync > localMod
1471 // BUT remoteMod != localMod 1472 // BUT remoteMod != localMod
1472 1473
1473 1474
1474 if ( full && mode < SYNC_PREF_NEWEST ) 1475 if ( full && mode < SYNC_PREF_NEWEST )
1475 mode = SYNC_PREF_ASK; 1476 mode = SYNC_PREF_ASK;
1476 1477
1477 switch( mode ) { 1478 switch( mode ) {
1478 case SYNC_PREF_LOCAL: 1479 case SYNC_PREF_LOCAL:
1479 if ( lastSync > remoteMod ) 1480 if ( lastSync > remoteMod )
1480 return 1; 1481 return 1;
1481 if ( lastSync > localMod ) 1482 if ( lastSync > localMod )
1482 return 2; 1483 return 2;
1483 return 1; 1484 return 1;
1484 break; 1485 break;
1485 case SYNC_PREF_REMOTE: 1486 case SYNC_PREF_REMOTE:
1486 if ( lastSync > localMod ) 1487 if ( lastSync > localMod )
1487 return 2; 1488 return 2;
1488 if ( lastSync > remoteMod ) 1489 if ( lastSync > remoteMod )
1489 return 1; 1490 return 1;
1490 return 2; 1491 return 2;
1491 break; 1492 break;
1492 case SYNC_PREF_NEWEST: 1493 case SYNC_PREF_NEWEST:
1493 if ( localMod >= remoteMod ) 1494 if ( localMod >= remoteMod )
1494 return 1; 1495 return 1;
1495 else 1496 else
1496 return 2; 1497 return 2;
1497 break; 1498 break;
1498 case SYNC_PREF_ASK: 1499 case SYNC_PREF_ASK:
1499 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1500 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1500 if ( lastSync > remoteMod && lastSync > localMod) 1501 if ( lastSync > remoteMod && lastSync > localMod)
1501 return 0; 1502 return 0;
1502 if ( lastSync > remoteMod ) 1503 if ( lastSync > remoteMod )
1503 return 1; 1504 return 1;
1504 if ( lastSync > localMod ) 1505 if ( lastSync > localMod )
1505 return 2; 1506 return 2;
1506 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1507 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1507 localIsNew = localMod >= remoteMod; 1508 localIsNew = localMod >= remoteMod;
1508 if ( localIsNew ) 1509 if ( localIsNew )
1509 getEventViewerDialog()->setColorMode( 1 ); 1510 getEventViewerDialog()->setColorMode( 1 );
1510 else 1511 else
1511 getEventViewerDialog()->setColorMode( 2 ); 1512 getEventViewerDialog()->setColorMode( 2 );
1512 getEventViewerDialog()->setIncidence(local); 1513 getEventViewerDialog()->setIncidence(local);
1513 if ( localIsNew ) 1514 if ( localIsNew )
1514 getEventViewerDialog()->setColorMode( 2 ); 1515 getEventViewerDialog()->setColorMode( 2 );
1515 else 1516 else
1516 getEventViewerDialog()->setColorMode( 1 ); 1517 getEventViewerDialog()->setColorMode( 1 );
1517 getEventViewerDialog()->addIncidence(remote); 1518 getEventViewerDialog()->addIncidence(remote);
1518 getEventViewerDialog()->setColorMode( 0 ); 1519 getEventViewerDialog()->setColorMode( 0 );
1519 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 1520 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
1520 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 1521 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
1521 getEventViewerDialog()->showMe(); 1522 getEventViewerDialog()->showMe();
1522 result = getEventViewerDialog()->executeS( localIsNew ); 1523 result = getEventViewerDialog()->executeS( localIsNew );
1523 return result; 1524 return result;
1524 1525
1525 break; 1526 break;
1526 case SYNC_PREF_FORCE_LOCAL: 1527 case SYNC_PREF_FORCE_LOCAL:
1527 return 1; 1528 return 1;
1528 break; 1529 break;
1529 case SYNC_PREF_FORCE_REMOTE: 1530 case SYNC_PREF_FORCE_REMOTE:
1530 return 2; 1531 return 2;
1531 break; 1532 break;
1532 1533
1533 default: 1534 default:
1534 // SYNC_PREF_TAKE_BOTH not implemented 1535 // SYNC_PREF_TAKE_BOTH not implemented
1535 break; 1536 break;
1536 } 1537 }
1537 return 0; 1538 return 0;
1538} 1539}
1539Event* CalendarView::getLastSyncEvent() 1540Event* CalendarView::getLastSyncEvent()
1540{ 1541{
1541 Event* lse; 1542 Event* lse;
1542 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 1543 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
1543 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 1544 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
1544 if (!lse) { 1545 if (!lse) {
1545 lse = new Event(); 1546 lse = new Event();
1546 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 1547 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
1547 QString sum = ""; 1548 QString sum = "";
1548 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 1549 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
1549 sum = "E: "; 1550 sum = "E: ";
1550 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 1551 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
1551 lse->setDtStart( mLastCalendarSync ); 1552 lse->setDtStart( mLastCalendarSync );
1552 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1553 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1553 lse->setCategories( i18n("SyncEvent") ); 1554 lse->setCategories( i18n("SyncEvent") );
1554 lse->setReadOnly( true ); 1555 lse->setReadOnly( true );
1556 lse->setCalID( 1 );
1555 mCalendar->addEvent( lse ); 1557 mCalendar->addEvent( lse );
1556 } 1558 }
1557 1559
1558 return lse; 1560 return lse;
1559 1561
1560} 1562}
1561 1563
1562// we check, if the to delete event has a id for a profile 1564// we check, if the to delete event has a id for a profile
1563// if yes, we set this id in the profile to delete 1565// if yes, we set this id in the profile to delete
1564void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 1566void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
1565{ 1567{
1566 if ( lastSync.count() == 0 ) { 1568 if ( lastSync.count() == 0 ) {
1567 //qDebug(" lastSync.count() == 0"); 1569 //qDebug(" lastSync.count() == 0");
1568 return; 1570 return;
1569 } 1571 }
1570 if ( toDelete->typeID() == journalID ) 1572 if ( toDelete->typeID() == journalID )
1571 return; 1573 return;
1572 1574
1573 Event* eve = lastSync.first(); 1575 Event* eve = lastSync.first();
1574 1576
1575 while ( eve ) { 1577 while ( eve ) {
1576 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 1578 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
1577 if ( !id.isEmpty() ) { 1579 if ( !id.isEmpty() ) {
1578 QString des = eve->description(); 1580 QString des = eve->description();
1579 QString pref = "e"; 1581 QString pref = "e";
1580 if ( toDelete->typeID() == todoID ) 1582 if ( toDelete->typeID() == todoID )
1581 pref = "t"; 1583 pref = "t";
1582 des += pref+ id + ","; 1584 des += pref+ id + ",";
1583 eve->setReadOnly( false ); 1585 eve->setReadOnly( false );
1584 eve->setDescription( des ); 1586 eve->setDescription( des );
1585 //qDebug("setdes %s ", des.latin1()); 1587 //qDebug("setdes %s ", des.latin1());
1586 eve->setReadOnly( true ); 1588 eve->setReadOnly( true );
1587 } 1589 }
1588 eve = lastSync.next(); 1590 eve = lastSync.next();
1589 } 1591 }
1590 1592
1591} 1593}
1592void CalendarView::checkExternalId( Incidence * inc ) 1594void CalendarView::checkExternalId( Incidence * inc )
1593{ 1595{
1594 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 1596 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
1595 checkExternSyncEvent( lastSync, inc ); 1597 checkExternSyncEvent( lastSync, inc );
1596 1598
1597} 1599}
1598bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 1600bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
1599{ 1601{
1600 bool syncOK = true; 1602 bool syncOK = true;
1601 int addedEvent = 0; 1603 int addedEvent = 0;
1602 int addedEventR = 0; 1604 int addedEventR = 0;
1603 int deletedEventR = 0; 1605 int deletedEventR = 0;
1604 int deletedEventL = 0; 1606 int deletedEventL = 0;
1605 int changedLocal = 0; 1607 int changedLocal = 0;
1606 int changedRemote = 0; 1608 int changedRemote = 0;
1607 int filteredIN = 0; 1609 int filteredIN = 0;
1608 int filteredOUT = 0; 1610 int filteredOUT = 0;
1609 //QPtrList<Event> el = local->rawEvents(); 1611 //QPtrList<Event> el = local->rawEvents();
1610 Event* eventR; 1612 Event* eventR;
1611 QString uid; 1613 QString uid;
1612 int take; 1614 int take;
1613 Event* eventRSync; 1615 Event* eventRSync;
1614 Event* eventLSync; 1616 Event* eventLSync;
1615 clearAllViews(); 1617 clearAllViews();
1616 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 1618 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
1617 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 1619 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
1618 bool fullDateRange = false; 1620 bool fullDateRange = false;
1619 local->resetTempSyncStat(); 1621 local->resetTempSyncStat();
1620 mLastCalendarSync = QDateTime::currentDateTime(); 1622 mLastCalendarSync = QDateTime::currentDateTime();
1621 if ( mSyncManager->syncWithDesktop() ) { 1623 if ( mSyncManager->syncWithDesktop() ) {
1622 remote->resetPilotStat(1); 1624 remote->resetPilotStat(1);
1623 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1625 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1624 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 1626 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
1625 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 1627 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
1626 } else { 1628 } else {
1627 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 1629 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
1628 } 1630 }
1629 } 1631 }
1630 QDateTime modifiedCalendar = mLastCalendarSync; 1632 QDateTime modifiedCalendar = mLastCalendarSync;
1631 eventLSync = getLastSyncEvent(); 1633 eventLSync = getLastSyncEvent();
1632 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 1634 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
1633 if ( eventR ) { 1635 if ( eventR ) {
1634 qDebug("last-syncEvent on remote found "); 1636 qDebug("last-syncEvent on remote found ");
1635 eventRSync = (Event*) eventR->clone(); 1637 eventRSync = (Event*) eventR->clone();
1636 remote->deleteEvent(eventR ); 1638 remote->deleteEvent(eventR );
1637 1639
1638 } else { 1640 } else {
1639 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 1641 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
1640 eventRSync = (Event*)eventLSync->clone(); 1642 eventRSync = (Event*)eventLSync->clone();
1641 } else { 1643 } else {
1642 fullDateRange = true; 1644 fullDateRange = true;
1643 eventRSync = new Event(); 1645 eventRSync = new Event();
1644 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 1646 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
1645 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 1647 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
1646 eventRSync->setDtStart( mLastCalendarSync ); 1648 eventRSync->setDtStart( mLastCalendarSync );
1647 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1649 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1648 eventRSync->setCategories( i18n("SyncEvent") ); 1650 eventRSync->setCategories( i18n("SyncEvent") );
1649 } 1651 }
1650 } 1652 }
1651 if ( eventLSync->dtStart() == mLastCalendarSync ) 1653 if ( eventLSync->dtStart() == mLastCalendarSync )
1652 fullDateRange = true; 1654 fullDateRange = true;
1653 1655
1654 if ( ! fullDateRange ) { 1656 if ( ! fullDateRange ) {
1655 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 1657 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
1656 1658
1657 qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 1659 qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
1658 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 1660 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
1659 fullDateRange = true; 1661 fullDateRange = true;
1660 } 1662 }
1661 } 1663 }
1662 if ( mSyncManager->syncWithDesktop() ) { 1664 if ( mSyncManager->syncWithDesktop() ) {
1663 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 1665 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
1664 } 1666 }
1665 if ( fullDateRange ) 1667 if ( fullDateRange )
1666 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 1668 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
1667 else 1669 else
1668 mLastCalendarSync = eventLSync->dtStart(); 1670 mLastCalendarSync = eventLSync->dtStart();
1669 // for resyncing if own file has changed 1671 // for resyncing if own file has changed
1670 if ( mCurrentSyncDevice == "deleteaftersync" ) { 1672 if ( mCurrentSyncDevice == "deleteaftersync" ) {
1671 mLastCalendarSync = loadedFileVersion; 1673 mLastCalendarSync = loadedFileVersion;
1672 //qDebug("setting mLastCalendarSync "); 1674 //qDebug("setting mLastCalendarSync ");
1673 } 1675 }
1674 //qDebug("*************************** "); 1676 //qDebug("*************************** ");
1675 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1677 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1676 QPtrList<Incidence> er = remote->rawIncidences(); 1678 QPtrList<Incidence> er = remote->rawIncidences();
1677 Incidence* inR = er.first(); 1679 Incidence* inR = er.first();
1678 Incidence* inL; 1680 Incidence* inL;
1679 QProgressBar bar( er.count(),0 ); 1681 QProgressBar bar( er.count(),0 );
1680 bar.setCaption (i18n("Syncing - close to abort!") ); 1682 bar.setCaption (i18n("Syncing - close to abort!") );
1681 1683
1682 // ************** setting up filter ************* 1684 // ************** setting up filter *************
1683 CalFilter *filterIN = 0; 1685 CalFilter *filterIN = 0;
1684 CalFilter *filterOUT = 0; 1686 CalFilter *filterOUT = 0;
1685 CalFilter *filter = mFilters.first(); 1687 CalFilter *filter = mFilters.first();
1686 while(filter) { 1688 while(filter) {
1687 if ( filter->name() == mSyncManager->mFilterInCal ) 1689 if ( filter->name() == mSyncManager->mFilterInCal )
1688 filterIN = filter; 1690 filterIN = filter;
1689 if ( filter->name() == mSyncManager->mFilterOutCal ) 1691 if ( filter->name() == mSyncManager->mFilterOutCal )
1690 filterOUT = filter; 1692 filterOUT = filter;
1691 filter = mFilters.next(); 1693 filter = mFilters.next();
1692 } 1694 }
1693 int w = 300; 1695 int w = 300;
1694 if ( QApplication::desktop()->width() < 320 ) 1696 if ( QApplication::desktop()->width() < 320 )
1695 w = 220; 1697 w = 220;
1696 int h = bar.sizeHint().height() ; 1698 int h = bar.sizeHint().height() ;
1697 int dw = QApplication::desktop()->width(); 1699 int dw = QApplication::desktop()->width();
1698 int dh = QApplication::desktop()->height(); 1700 int dh = QApplication::desktop()->height();
1699 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1701 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1700 bar.show(); 1702 bar.show();
1701 int modulo = (er.count()/10)+1; 1703 int modulo = (er.count()/10)+1;
1702 int incCounter = 0; 1704 int incCounter = 0;
1703 while ( inR ) { 1705 while ( inR ) {
1704 if ( ! bar.isVisible() ) 1706 if ( ! bar.isVisible() )
1705 return false; 1707 return false;
1706 if ( incCounter % modulo == 0 ) 1708 if ( incCounter % modulo == 0 )
1707 bar.setProgress( incCounter ); 1709 bar.setProgress( incCounter );
1708 ++incCounter; 1710 ++incCounter;
1709 uid = inR->uid(); 1711 uid = inR->uid();
1710 bool skipIncidence = false; 1712 bool skipIncidence = false;
1711 if ( uid.left(15) == QString("last-syncEvent-") ) 1713 if ( uid.left(15) == QString("last-syncEvent-") )
1712 skipIncidence = true; 1714 skipIncidence = true;
1713 QString idS; 1715 QString idS;
1714 qApp->processEvents(); 1716 qApp->processEvents();
1715 if ( !skipIncidence ) { 1717 if ( !skipIncidence ) {
1716 inL = local->incidenceForUid( uid , false ); 1718 inL = local->incidenceForUid( uid , false );
1717 if ( inL ) { // maybe conflict - same uid in both calendars 1719 if ( inL ) { // maybe conflict - same uid in both calendars
1718 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1720 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1719 //qDebug("take %d %s ", take, inL->summary().latin1()); 1721 //qDebug("take %d %s ", take, inL->summary().latin1());
1720 if ( take == 3 ) 1722 if ( take == 3 )
1721 return false; 1723 return false;
1722 if ( take == 1 ) {// take local ********************** 1724 if ( take == 1 ) {// take local **********************
1723 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1725 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1724 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1726 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1725 else 1727 else
1726 idS = inR->IDStr(); 1728 idS = inR->IDStr();
1727 int calID = inR->calID(); 1729 int calID = inR->calID();
1728 remote->deleteIncidence( inR ); 1730 remote->deleteIncidence( inR );
1729 inR = inL->clone(); 1731 inR = inL->clone();
1730 inR->setCalID( calID ); 1732 inR->setCalID( calID );
1731 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1733 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1732 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1734 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1733 inR->setIDStr( idS ); 1735 inR->setIDStr( idS );
1734 remote->addIncidence( inR ); 1736 remote->addIncidence( inR );
1735 if ( mSyncManager->syncWithDesktop() ) 1737 if ( mSyncManager->syncWithDesktop() )
1736 inR->setPilotId( 2 ); 1738 inR->setPilotId( 2 );
1737 ++changedRemote; 1739 ++changedRemote;
1738 } else {// take remote ********************** 1740 } else {// take remote **********************
1739 if ( !inL->isReadOnly() ) { 1741 if ( !inL->isReadOnly() ) {
1740 idS = inL->IDStr(); 1742 idS = inL->IDStr();
1741 int pid = inL->pilotId(); 1743 int pid = inL->pilotId();
1742 int calID = inL->calID(); 1744 int calID = inL->calID();
1743 local->deleteIncidence( inL ); 1745 local->deleteIncidence( inL );
1744 inL = inR->clone(); 1746 inL = inR->clone();
1745 inL->setCalID( calID ); 1747 inL->setCalID( calID );
1746 if ( mSyncManager->syncWithDesktop() ) 1748 if ( mSyncManager->syncWithDesktop() )
1747 inL->setPilotId( pid ); 1749 inL->setPilotId( pid );
1748 inL->setIDStr( idS ); 1750 inL->setIDStr( idS );
1749 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1751 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1750 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1752 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1751 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1753 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1752 } 1754 }
1753 local->addIncidence( inL ); 1755 local->addIncidence( inL );
1754 ++changedLocal; 1756 ++changedLocal;
1755 } 1757 }
1756 } 1758 }
1757 } 1759 }
1758 } else { // no conflict ********** add or delete remote 1760 } else { // no conflict ********** add or delete remote
1759 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1761 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1760 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1762 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1761 QString des = eventLSync->description(); 1763 QString des = eventLSync->description();
1762 QString pref = "e"; 1764 QString pref = "e";
1763 if ( inR->typeID() == todoID ) 1765 if ( inR->typeID() == todoID )
1764 pref = "t"; 1766 pref = "t";
1765 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1767 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1766 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1768 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1767 //remote->deleteIncidence( inR ); 1769 //remote->deleteIncidence( inR );
1768 ++deletedEventR; 1770 ++deletedEventR;
1769 } else { 1771 } else {
1770 inR->setLastModified( modifiedCalendar ); 1772 inR->setLastModified( modifiedCalendar );
1771 inL = inR->clone(); 1773 inL = inR->clone();
1772 inL->setIDStr( ":" ); 1774 inL->setIDStr( ":" );
1773 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1775 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1774 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1776 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1775 1777
1776 inL->setCalID( 0 );// add to default cal 1778 inL->setCalID( 0 );// add to default cal
1777 local->addIncidence( inL ); 1779 local->addIncidence( inL );
1778 ++addedEvent; 1780 ++addedEvent;
1779 1781
1780 } 1782 }
1781 } else { 1783 } else {
1782 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1784 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1783 inR->setLastModified( modifiedCalendar ); 1785 inR->setLastModified( modifiedCalendar );
1784 inL = inR->clone(); 1786 inL = inR->clone();
1785 inL->setIDStr( ":" ); 1787 inL->setIDStr( ":" );
1786 inL->setCalID( 0 );// add to default cal 1788 inL->setCalID( 0 );// add to default cal
1787 local->addIncidence( inL ); 1789 local->addIncidence( inL );
1788 ++addedEvent; 1790 ++addedEvent;
1789 1791
1790 } else { 1792 } else {
1791 checkExternSyncEvent(eventRSyncSharp, inR); 1793 checkExternSyncEvent(eventRSyncSharp, inR);
1792 remote->deleteIncidence( inR ); 1794 remote->deleteIncidence( inR );
1793 ++deletedEventR; 1795 ++deletedEventR;
1794 } 1796 }
1795 } 1797 }
1796 } else { 1798 } else {
1797 ++filteredIN; 1799 ++filteredIN;
1798 } 1800 }
1799 } 1801 }
1800 } 1802 }
1801 inR = er.next(); 1803 inR = er.next();
1802 } 1804 }
1803 QPtrList<Incidence> el = local->rawIncidences(); 1805 QPtrList<Incidence> el = local->rawIncidences();
1804 inL = el.first(); 1806 inL = el.first();
1805 modulo = (el.count()/10)+1; 1807 modulo = (el.count()/10)+1;
1806 bar.setCaption (i18n("Add / remove events") ); 1808 bar.setCaption (i18n("Add / remove events") );
1807 bar.setTotalSteps ( el.count() ) ; 1809 bar.setTotalSteps ( el.count() ) ;
1808 bar.show(); 1810 bar.show();
1809 incCounter = 0; 1811 incCounter = 0;
1810 1812
1811 while ( inL ) { 1813 while ( inL ) {
1812 1814
1813 qApp->processEvents(); 1815 qApp->processEvents();
1814 if ( ! bar.isVisible() ) 1816 if ( ! bar.isVisible() )
1815 return false; 1817 return false;
1816 if ( incCounter % modulo == 0 ) 1818 if ( incCounter % modulo == 0 )
1817 bar.setProgress( incCounter ); 1819 bar.setProgress( incCounter );
1818 ++incCounter; 1820 ++incCounter;
1819 uid = inL->uid(); 1821 uid = inL->uid();
1820 bool skipIncidence = false; 1822 bool skipIncidence = false;
1821 if ( uid.left(15) == QString("last-syncEvent-") ) 1823 if ( uid.left(15) == QString("last-syncEvent-") )
1822 skipIncidence = true; 1824 skipIncidence = true;
1823 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) 1825 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID )
1824 skipIncidence = true; 1826 skipIncidence = true;
1825 if ( !skipIncidence ) { 1827 if ( !skipIncidence ) {
1826 inR = remote->incidenceForUid( uid , true ); 1828 inR = remote->incidenceForUid( uid , true );
1827 if ( ! inR ) { 1829 if ( ! inR ) {
1828 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1830 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1829 // no conflict ********** add or delete local 1831 // no conflict ********** add or delete local
1830 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1832 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1831 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1833 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1832 checkExternSyncEvent(eventLSyncSharp, inL); 1834 checkExternSyncEvent(eventLSyncSharp, inL);
1833 local->deleteIncidence( inL ); 1835 local->deleteIncidence( inL );
1834 ++deletedEventL; 1836 ++deletedEventL;
1835 } else { 1837 } else {
1836 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1838 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1837 inL->removeID(mCurrentSyncDevice ); 1839 inL->removeID(mCurrentSyncDevice );
1838 ++addedEventR; 1840 ++addedEventR;
1839 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1841 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1840 inL->setLastModified( modifiedCalendar ); 1842 inL->setLastModified( modifiedCalendar );
1841 inR = inL->clone(); 1843 inR = inL->clone();
1842 inR->setIDStr( ":" ); 1844 inR->setIDStr( ":" );
1843 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1845 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1844 inR->setCalID( 0 );// add to default cal 1846 inR->setCalID( 0 );// add to default cal
1845 remote->addIncidence( inR ); 1847 remote->addIncidence( inR );
1846 } 1848 }
1847 } 1849 }
1848 } else { 1850 } else {
1849 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1851 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1850 checkExternSyncEvent(eventLSyncSharp, inL); 1852 checkExternSyncEvent(eventLSyncSharp, inL);
1851 local->deleteIncidence( inL ); 1853 local->deleteIncidence( inL );
1852 ++deletedEventL; 1854 ++deletedEventL;
1853 } else { 1855 } else {
1854 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1856 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1855 ++addedEventR; 1857 ++addedEventR;
1856 inL->setLastModified( modifiedCalendar ); 1858 inL->setLastModified( modifiedCalendar );
1857 inR = inL->clone(); 1859 inR = inL->clone();
1858 inR->setIDStr( ":" ); 1860 inR->setIDStr( ":" );
1859 inR->setCalID( 0 );// add to default cal 1861 inR->setCalID( 0 );// add to default cal
1860 remote->addIncidence( inR ); 1862 remote->addIncidence( inR );
1861 } 1863 }
1862 } 1864 }
1863 } 1865 }
1864 } else { 1866 } else {
1865 ++filteredOUT; 1867 ++filteredOUT;
1866 } 1868 }
1867 } 1869 }
1868 } 1870 }
1869 inL = el.next(); 1871 inL = el.next();
1870 } 1872 }
1871 int delFut = 0; 1873 int delFut = 0;
1872 int remRem = 0; 1874 int remRem = 0;
1873 if ( mSyncManager->mWriteBackInFuture ) { 1875 if ( mSyncManager->mWriteBackInFuture ) {
1874 er = remote->rawIncidences(); 1876 er = remote->rawIncidences();
1875 remRem = er.count(); 1877 remRem = er.count();
1876 inR = er.first(); 1878 inR = er.first();
1877 QDateTime dt; 1879 QDateTime dt;
1878 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1880 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1879 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1881 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1880 while ( inR ) { 1882 while ( inR ) {
1881 if ( inR->typeID() == todoID ) { 1883 if ( inR->typeID() == todoID ) {
1882 Todo * t = (Todo*)inR; 1884 Todo * t = (Todo*)inR;
1883 if ( t->hasDueDate() ) 1885 if ( t->hasDueDate() )
1884 dt = t->dtDue(); 1886 dt = t->dtDue();
1885 else 1887 else
1886 dt = cur.addSecs( 62 ); 1888 dt = cur.addSecs( 62 );
1887 } 1889 }
1888 else if (inR->typeID() == eventID ) { 1890 else if (inR->typeID() == eventID ) {
1889 bool ok; 1891 bool ok;
1890 dt = inR->getNextOccurence( cur, &ok ); 1892 dt = inR->getNextOccurence( cur, &ok );
1891 if ( !ok ) 1893 if ( !ok )
1892 dt = cur.addSecs( -62 ); 1894 dt = cur.addSecs( -62 );
1893 } 1895 }
1894 else 1896 else
1895 dt = inR->dtStart(); 1897 dt = inR->dtStart();
1896 if ( dt < cur || dt > end ) { 1898 if ( dt < cur || dt > end ) {
1897 remote->deleteIncidence( inR ); 1899 remote->deleteIncidence( inR );
1898 ++delFut; 1900 ++delFut;
1899 } 1901 }
1900 inR = er.next(); 1902 inR = er.next();
1901 } 1903 }
1902 } 1904 }
1903 bar.hide(); 1905 bar.hide();
1904 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1906 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1905 eventLSync->setReadOnly( false ); 1907 if ( mMultiResourceSync ) {
1906 eventLSync->setDtStart( mLastCalendarSync ); 1908 remote->removeSyncInfo( "" ); //all
1907 eventRSync->setDtStart( mLastCalendarSync ); 1909
1908 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1910 } else {
1909 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1911 eventLSync->setReadOnly( false );
1910 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1912 eventLSync->setDtStart( mLastCalendarSync );
1911 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1913 eventRSync->setDtStart( mLastCalendarSync );
1912 eventLSync->setReadOnly( true ); 1914 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1915 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1916 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1917 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1918 eventLSync->setReadOnly( true );
1919 }
1913 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); 1920 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1914 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1921 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop() && !mMultiResourceSync ) // kde is abnormal...
1915 remote->addEvent( eventRSync ); 1922 remote->addEvent( eventRSync );
1916 else 1923 else
1917 delete eventRSync; 1924 delete eventRSync;
1918 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 1925 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1919 QString mes; 1926 QString mes;
1920 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); 1927 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT );
1921 QString delmess; 1928 QString delmess;
1922 if ( delFut ) { 1929 if ( delFut ) {
1923 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); 1930 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut);
1924 mes += delmess; 1931 mes += delmess;
1925 } 1932 }
1926 mes = i18n("Local calendar changed!\n") +mes; 1933 mes = i18n("Local calendar changed!\n") +mes;
1927 mCalendar->checkAlarmForIncidence( 0, true ); 1934 mCalendar->checkAlarmForIncidence( 0, true );
1928 qDebug( mes ); 1935 qDebug( mes );
1929 if ( mSyncManager->mShowSyncSummary ) { 1936 if ( mSyncManager->mShowSyncSummary ) {
1930 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1937 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1931 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1938 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1932 qDebug("KO: WB cancelled "); 1939 qDebug("KO: WB cancelled ");
1933 mSyncManager->mWriteBackFile = false; 1940 mSyncManager->mWriteBackFile = false;
1934 return syncOK; 1941 return syncOK;
1935 } 1942 }
1936 } 1943 }
1937 return syncOK; 1944 return syncOK;
1938} 1945}
1939 1946
1940void CalendarView::setSyncDevice( QString s ) 1947void CalendarView::setSyncDevice( QString s )
1941{ 1948{
1942 mCurrentSyncDevice= s; 1949 mCurrentSyncDevice= s;
1943} 1950}
1944void CalendarView::setSyncName( QString s ) 1951void CalendarView::setSyncName( QString s )
1945{ 1952{
1946 mCurrentSyncName= s; 1953 mCurrentSyncName= s;
1947} 1954}
1948bool CalendarView::syncCalendar(QString filename, int mode) 1955bool CalendarView::syncCalendar(QString filename, int mode)
1949{ 1956{
1950 //qDebug("syncCalendar %s ", filename.latin1()); 1957 //qDebug("syncCalendar %s ", filename.latin1());
1951 mGlobalSyncMode = SYNC_MODE_NORMAL; 1958 mGlobalSyncMode = SYNC_MODE_NORMAL;
1952 CalendarLocal* calendar = new CalendarLocal(); 1959 CalendarLocal* calendar = new CalendarLocal();
1953 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1960 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1954 FileStorage* storage = new FileStorage( calendar ); 1961 FileStorage* storage = new FileStorage( calendar );
1955 bool syncOK = false; 1962 bool syncOK = false;
1956 storage->setFileName( filename ); 1963 storage->setFileName( filename );
1957 // qDebug("loading ... "); 1964 // qDebug("loading ... ");
1958 if ( storage->load() ) { 1965 if ( storage->load() ) {
1959 getEventViewerDialog()->setSyncMode( true ); 1966 getEventViewerDialog()->setSyncMode( true );
1960 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1967 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1961 getEventViewerDialog()->setSyncMode( false ); 1968 getEventViewerDialog()->setSyncMode( false );
1962 if ( syncOK ) { 1969 if ( syncOK ) {
1963 if ( mSyncManager->mWriteBackFile ) 1970 if ( mSyncManager->mWriteBackFile )
1964 { 1971 {
1965 storage->setSaveFormat( new ICalFormat() ); 1972 storage->setSaveFormat( new ICalFormat() );
1966 storage->save(); 1973 storage->save();
1967 } 1974 }
1968 } 1975 }
1969 setModified( true ); 1976 setModified( true );
1970 } 1977 }
1971 delete storage; 1978 delete storage;
1972 delete calendar; 1979 delete calendar;
1973 if ( syncOK ) 1980 if ( syncOK )
1974 updateView(); 1981 updateView();
1975 return syncOK; 1982 return syncOK;
1976} 1983}
1977 1984
1978void CalendarView::syncExternal( int mode ) 1985void CalendarView::syncExternal( int mode )
1979{ 1986{
1980 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1987 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1981 qApp->processEvents(); 1988 qApp->processEvents();
1982 CalendarLocal* calendar = new CalendarLocal(); 1989 CalendarLocal* calendar = new CalendarLocal();
1983 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1990 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1984 bool syncOK = false; 1991 bool syncOK = false;
1985 bool loadSuccess = false; 1992 bool loadSuccess = false;
1986 PhoneFormat* phoneFormat = 0; 1993 PhoneFormat* phoneFormat = 0;
1987 emit tempDisableBR(true); 1994 emit tempDisableBR(true);
1988#ifndef DESKTOP_VERSION 1995#ifndef DESKTOP_VERSION
1989 SharpFormat* sharpFormat = 0; 1996 SharpFormat* sharpFormat = 0;
1990 if ( mode == 0 ) { // sharp 1997 if ( mode == 0 ) { // sharp
1991 sharpFormat = new SharpFormat () ; 1998 sharpFormat = new SharpFormat () ;
1992 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1999 loadSuccess = sharpFormat->load( calendar, mCalendar );
1993 2000
1994 } else 2001 } else
1995#endif 2002#endif
1996 if ( mode == 1 ) { // phone 2003 if ( mode == 1 ) { // phone
1997 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 2004 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1998 mSyncManager->mPhoneDevice, 2005 mSyncManager->mPhoneDevice,
1999 mSyncManager->mPhoneConnection, 2006 mSyncManager->mPhoneConnection,
2000 mSyncManager->mPhoneModel); 2007 mSyncManager->mPhoneModel);
2001 loadSuccess = phoneFormat->load( calendar,mCalendar); 2008 loadSuccess = phoneFormat->load( calendar,mCalendar);
2002 2009
2003 } else { 2010 } else {
2004 emit tempDisableBR(false); 2011 emit tempDisableBR(false);
2005 return; 2012 return;
2006 } 2013 }
2007 if ( loadSuccess ) { 2014 if ( loadSuccess ) {
2008 getEventViewerDialog()->setSyncMode( true ); 2015 getEventViewerDialog()->setSyncMode( true );
2009 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 2016 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
2010 getEventViewerDialog()->setSyncMode( false ); 2017 getEventViewerDialog()->setSyncMode( false );
2011 qApp->processEvents(); 2018 qApp->processEvents();
2012 if ( syncOK ) { 2019 if ( syncOK ) {
2013 if ( mSyncManager->mWriteBackFile ) 2020 if ( mSyncManager->mWriteBackFile )
2014 { 2021 {
2015 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 2022 QPtrList<Incidence> iL = mCalendar->rawIncidences();
2016 Incidence* inc = iL.first(); 2023 Incidence* inc = iL.first();
2017 if ( phoneFormat ) { 2024 if ( phoneFormat ) {
2018 while ( inc ) { 2025 while ( inc ) {
2019 inc->removeID(mCurrentSyncDevice); 2026 inc->removeID(mCurrentSyncDevice);
2020 inc = iL.next(); 2027 inc = iL.next();
2021 } 2028 }
2022 } 2029 }
2023#ifndef DESKTOP_VERSION 2030#ifndef DESKTOP_VERSION
2024 if ( sharpFormat ) 2031 if ( sharpFormat )
2025 sharpFormat->save(calendar); 2032 sharpFormat->save(calendar);
2026#endif 2033#endif
2027 if ( phoneFormat ) 2034 if ( phoneFormat )
2028 phoneFormat->save(calendar); 2035 phoneFormat->save(calendar);
2029 iL = calendar->rawIncidences(); 2036 iL = calendar->rawIncidences();
2030 inc = iL.first(); 2037 inc = iL.first();
2031 Incidence* loc; 2038 Incidence* loc;
2032 while ( inc ) { 2039 while ( inc ) {
2033 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 2040 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
2034 loc = mCalendar->incidence(inc->uid() ); 2041 loc = mCalendar->incidence(inc->uid() );
2035 if ( loc ) { 2042 if ( loc ) {
2036 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 2043 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
2037 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 2044 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
2038 } 2045 }
2039 } 2046 }
2040 inc = iL.next(); 2047 inc = iL.next();
2041 } 2048 }
2042 Incidence* lse = getLastSyncEvent(); 2049 Incidence* lse = getLastSyncEvent();
2043 if ( lse ) { 2050 if ( lse ) {
2044 lse->setReadOnly( false ); 2051 lse->setReadOnly( false );
2045 lse->setDescription( "" ); 2052 lse->setDescription( "" );
2046 lse->setReadOnly( true ); 2053 lse->setReadOnly( true );
2047 } 2054 }
2048 } 2055 }
2049 } else { 2056 } else {
2050 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 2057 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
2051 } 2058 }
2052 setModified( true ); 2059 setModified( true );
2053 } else { 2060 } else {
2054 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 2061 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
2055 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 2062 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
2056 question, i18n("Ok")) ; 2063 question, i18n("Ok")) ;
2057 2064
2058 } 2065 }
2059 delete calendar; 2066 delete calendar;
2060 updateView(); 2067 updateView();
2061 emit tempDisableBR(false); 2068 emit tempDisableBR(false);
2062 return ;//syncOK; 2069 return ;//syncOK;
2063 2070
2064} 2071}
2065 2072
2066bool CalendarView::importBday() 2073bool CalendarView::importBday()
2067{ 2074{
2068#ifndef KORG_NOKABC 2075#ifndef KORG_NOKABC
2069 2076
2070#ifdef DESKTOP_VERSION 2077#ifdef DESKTOP_VERSION
2071 int curCal = mCalendar->defaultCalendar(); 2078 int curCal = mCalendar->defaultCalendar();
2072 int bd = mCalEditView->getBirtdayID(); 2079 int bd = mCalEditView->getBirtdayID();
2073 if ( bd == 0 ) 2080 if ( bd == 0 )
2074 return false; 2081 return false;
2075 mCalendar->setDefaultCalendar( bd ); 2082 mCalendar->setDefaultCalendar( bd );
2076 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 2083 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
2077 KABC::AddressBook::Iterator it; 2084 KABC::AddressBook::Iterator it;
2078 int count = 0; 2085 int count = 0;
2079 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 2086 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
2080 ++count; 2087 ++count;
2081 } 2088 }
2082 QProgressBar bar(count,0 ); 2089 QProgressBar bar(count,0 );
2083 int w = 300; 2090 int w = 300;
2084 if ( QApplication::desktop()->width() < 320 ) 2091 if ( QApplication::desktop()->width() < 320 )
2085 w = 220; 2092 w = 220;
2086 int h = bar.sizeHint().height() ; 2093 int h = bar.sizeHint().height() ;
2087 int dw = QApplication::desktop()->width(); 2094 int dw = QApplication::desktop()->width();
2088 int dh = QApplication::desktop()->height(); 2095 int dh = QApplication::desktop()->height();
2089 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2096 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2090 bar.show(); 2097 bar.show();
2091 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 2098 bar.setCaption (i18n("Reading addressbook - close to abort!") );
2092 qApp->processEvents(); 2099 qApp->processEvents();
2093 count = 0; 2100 count = 0;
2094 int addCount = 0; 2101 int addCount = 0;
2095 KCal::Attendee* a = 0; 2102 KCal::Attendee* a = 0;
2096 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 2103 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
2097 if ( ! bar.isVisible() ) 2104 if ( ! bar.isVisible() )
2098 return false; 2105 return false;
2099 bar.setProgress( count++ ); 2106 bar.setProgress( count++ );
2100 qApp->processEvents(); 2107 qApp->processEvents();
2101 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 2108 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
2102 if ( (*it).birthday().date().isValid() ){ 2109 if ( (*it).birthday().date().isValid() ){
2103 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 2110 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
2104 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 2111 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
2105 ++addCount; 2112 ++addCount;
2106 } 2113 }
@@ -2246,507 +2253,551 @@ bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a
2246 } 2253 }
2247 return true; 2254 return true;
2248 2255
2249} 2256}
2250bool CalendarView::importQtopia( const QString &categories, 2257bool CalendarView::importQtopia( const QString &categories,
2251 const QString &datebook, 2258 const QString &datebook,
2252 const QString &todolist ) 2259 const QString &todolist )
2253{ 2260{
2254 2261
2255 QtopiaFormat qtopiaFormat; 2262 QtopiaFormat qtopiaFormat;
2256 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 2263 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
2257 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 2264 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
2258 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 2265 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
2259 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 2266 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
2260 2267
2261 updateView(); 2268 updateView();
2262 return true; 2269 return true;
2263 2270
2264#if 0 2271#if 0
2265 mGlobalSyncMode = SYNC_MODE_QTOPIA; 2272 mGlobalSyncMode = SYNC_MODE_QTOPIA;
2266 mCurrentSyncDevice = "qtopia-XML"; 2273 mCurrentSyncDevice = "qtopia-XML";
2267 if ( mSyncManager->mAskForPreferences ) 2274 if ( mSyncManager->mAskForPreferences )
2268 edit_sync_options(); 2275 edit_sync_options();
2269 qApp->processEvents(); 2276 qApp->processEvents();
2270 CalendarLocal* calendar = new CalendarLocal(); 2277 CalendarLocal* calendar = new CalendarLocal();
2271 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2278 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2272 bool syncOK = false; 2279 bool syncOK = false;
2273 QtopiaFormat qtopiaFormat; 2280 QtopiaFormat qtopiaFormat;
2274 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 2281 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
2275 bool loadOk = true; 2282 bool loadOk = true;
2276 if ( !categories.isEmpty() ) 2283 if ( !categories.isEmpty() )
2277 loadOk = qtopiaFormat.load( calendar, categories ); 2284 loadOk = qtopiaFormat.load( calendar, categories );
2278 if ( loadOk && !datebook.isEmpty() ) 2285 if ( loadOk && !datebook.isEmpty() )
2279 loadOk = qtopiaFormat.load( calendar, datebook ); 2286 loadOk = qtopiaFormat.load( calendar, datebook );
2280 if ( loadOk && !todolist.isEmpty() ) 2287 if ( loadOk && !todolist.isEmpty() )
2281 loadOk = qtopiaFormat.load( calendar, todolist ); 2288 loadOk = qtopiaFormat.load( calendar, todolist );
2282 2289
2283 if ( loadOk ) { 2290 if ( loadOk ) {
2284 getEventViewerDialog()->setSyncMode( true ); 2291 getEventViewerDialog()->setSyncMode( true );
2285 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 2292 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
2286 getEventViewerDialog()->setSyncMode( false ); 2293 getEventViewerDialog()->setSyncMode( false );
2287 qApp->processEvents(); 2294 qApp->processEvents();
2288 if ( syncOK ) { 2295 if ( syncOK ) {
2289 if ( mSyncManager->mWriteBackFile ) 2296 if ( mSyncManager->mWriteBackFile )
2290 { 2297 {
2291 // write back XML file 2298 // write back XML file
2292 2299
2293 } 2300 }
2294 setModified( true ); 2301 setModified( true );
2295 } 2302 }
2296 } else { 2303 } else {
2297 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 2304 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
2298 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 2305 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
2299 question, i18n("Ok")) ; 2306 question, i18n("Ok")) ;
2300 } 2307 }
2301 delete calendar; 2308 delete calendar;
2302 updateView(); 2309 updateView();
2303 return syncOK; 2310 return syncOK;
2304 2311
2305 2312
2306#endif 2313#endif
2307 2314
2308} 2315}
2309 2316
2310void CalendarView::setSyncEventsReadOnly() 2317void CalendarView::setSyncEventsReadOnly()
2311{ 2318{
2312 mCalendar->setSyncEventsReadOnly(); 2319 mCalendar->setSyncEventsReadOnly();
2313} 2320}
2314 2321
2315bool CalendarView::loadCalendars() 2322bool CalendarView::loadCalendars()
2316{ 2323{
2317 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2324 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2318 KopiCalendarFile * cal = calendars.first(); 2325 KopiCalendarFile * cal = calendars.first();
2319 mCalendar->setDefaultCalendar( 1 ); 2326 mCalendar->setDefaultCalendar( 1 );
2320 openCalendar( MainWindow::defaultFileName(), false ); 2327 openCalendar( MainWindow::defaultFileName(), false );
2321 cal = calendars.next(); 2328 cal = calendars.next();
2322 while ( cal ) { 2329 while ( cal ) {
2323 addCalendar( cal ); 2330 addCalendar( cal );
2324 cal = calendars.next(); 2331 cal = calendars.next();
2325 } 2332 }
2326 restoreCalendarSettings(); 2333 restoreCalendarSettings();
2327 return true; 2334 return true;
2328} 2335}
2329bool CalendarView::restoreCalendarSettings() 2336bool CalendarView::restoreCalendarSettings()
2330{ 2337{
2331 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2338 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2332 KopiCalendarFile * cal = calendars.first(); 2339 KopiCalendarFile * cal = calendars.first();
2333 while ( cal ) { 2340 while ( cal ) {
2334 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); 2341 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
2335 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); 2342 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
2336 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); 2343 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
2337 if ( cal->isStandard ) 2344 if ( cal->isStandard )
2338 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2345 mCalendar->setDefaultCalendar( cal->mCalNumber );
2339 cal = calendars.next(); 2346 cal = calendars.next();
2340 } 2347 }
2341 setSyncEventsReadOnly(); 2348 setSyncEventsReadOnly();
2342 mCalendar->reInitAlarmSettings(); 2349 mCalendar->reInitAlarmSettings();
2343 updateUnmanagedViews(); 2350 updateUnmanagedViews();
2344 updateView(); 2351 updateView();
2345 return true; 2352 return true;
2346} 2353}
2347void CalendarView::addCalendarId( int id ) 2354void CalendarView::addCalendarId( int id )
2348{ 2355{
2349 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); 2356 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id );
2350 if ( cal ) 2357 if ( cal )
2351 addCalendar( cal ); 2358 addCalendar( cal );
2352} 2359}
2353bool CalendarView::addCalendar( KopiCalendarFile * cal ) 2360bool CalendarView::addCalendar( KopiCalendarFile * cal )
2354{ 2361{
2355 cal->mErrorOnLoad = false; 2362 cal->mErrorOnLoad = false;
2356 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { 2363 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) {
2357 cal->mLoadDt = QDateTime::currentDateTime(); 2364 cal->mLoadDt = QDateTime::currentDateTime();
2358 return true; 2365 return true;
2359 } 2366 }
2360 qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); 2367 qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() );
2361 cal->mErrorOnLoad = true; 2368 cal->mErrorOnLoad = true;
2362 return false; 2369 return false;
2363} 2370}
2364bool CalendarView::openCalendar(QString filename, bool merge) 2371bool CalendarView::openCalendar(QString filename, bool merge)
2365{ 2372{
2366 2373
2367 if (filename.isEmpty()) { 2374 if (filename.isEmpty()) {
2368 return false; 2375 return false;
2369 } 2376 }
2370 2377
2371 if (!QFile::exists(filename)) { 2378 if (!QFile::exists(filename)) {
2372 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 2379 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
2373 return false; 2380 return false;
2374 } 2381 }
2375 2382
2376 globalFlagBlockAgenda = 1; 2383 globalFlagBlockAgenda = 1;
2377 clearAllViews(); 2384 clearAllViews();
2378 if (!merge) { 2385 if (!merge) {
2379 mViewManager->setDocumentId( filename ); 2386 mViewManager->setDocumentId( filename );
2380 mCalendar->close(); 2387 mCalendar->close();
2381 } 2388 }
2382 mStorage->setFileName( filename ); 2389 mStorage->setFileName( filename );
2383 2390
2384 if ( mStorage->load() ) { 2391 if ( mStorage->load() ) {
2385 if ( merge ) ;//setModified( true ); 2392 if ( merge ) ;//setModified( true );
2386 else { 2393 else {
2387 //setModified( true ); 2394 //setModified( true );
2388 mViewManager->setDocumentId( filename ); 2395 mViewManager->setDocumentId( filename );
2389 mDialogManager->setDocumentId( filename ); 2396 mDialogManager->setDocumentId( filename );
2390 mTodoList->setDocumentId( filename ); 2397 mTodoList->setDocumentId( filename );
2391 } 2398 }
2392 globalFlagBlockAgenda = 2; 2399 globalFlagBlockAgenda = 2;
2393 // if ( getLastSyncEvent() ) 2400 // if ( getLastSyncEvent() )
2394 // getLastSyncEvent()->setReadOnly( true ); 2401 // getLastSyncEvent()->setReadOnly( true );
2395 mCalendar->reInitAlarmSettings(); 2402 mCalendar->reInitAlarmSettings();
2396 setSyncEventsReadOnly(); 2403 setSyncEventsReadOnly();
2397 //updateUnmanagedViews(); 2404 //updateUnmanagedViews();
2398 //updateView(); 2405 //updateView();
2399 if ( filename != MainWindow::defaultFileName() ) { 2406 if ( filename != MainWindow::defaultFileName() ) {
2400 saveCalendar( MainWindow::defaultFileName() ); 2407 saveCalendar( MainWindow::defaultFileName() );
2401 } else { 2408 } else {
2402 QFileInfo finf ( MainWindow::defaultFileName()); 2409 QFileInfo finf ( MainWindow::defaultFileName());
2403 if ( finf.exists() ) { 2410 if ( finf.exists() ) {
2404 setLoadedFileVersion( finf.lastModified () ); 2411 setLoadedFileVersion( finf.lastModified () );
2405 } 2412 }
2406 } 2413 }
2407 return true; 2414 return true;
2408 } else { 2415 } else {
2409 // while failing to load, the calendar object could 2416 // while failing to load, the calendar object could
2410 // have become partially populated. Clear it out. 2417 // have become partially populated. Clear it out.
2411 if ( !merge ) { 2418 if ( !merge ) {
2412 mCalendar->close(); 2419 mCalendar->close();
2413 mViewManager->setDocumentId( filename ); 2420 mViewManager->setDocumentId( filename );
2414 mDialogManager->setDocumentId( filename ); 2421 mDialogManager->setDocumentId( filename );
2415 mTodoList->setDocumentId( filename ); 2422 mTodoList->setDocumentId( filename );
2416 } 2423 }
2417 2424
2418 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 2425 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
2419 2426
2420 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 2427 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
2421 globalFlagBlockAgenda = 2; 2428 globalFlagBlockAgenda = 2;
2422 mCalendar->reInitAlarmSettings(); 2429 mCalendar->reInitAlarmSettings();
2423 setSyncEventsReadOnly(); 2430 setSyncEventsReadOnly();
2424 updateUnmanagedViews(); 2431 updateUnmanagedViews();
2425 updateView(); 2432 updateView();
2426 } 2433 }
2427 return false; 2434 return false;
2428} 2435}
2429void CalendarView::mergeFile( QString fn ) 2436void CalendarView::mergeFile( QString fn )
2430{ 2437{
2431 clearAllViews(); 2438 clearAllViews();
2432 mCalendar->mergeCalendarFile( fn ); 2439 mCalendar->mergeCalendarFile( fn );
2433 mCalendar->reInitAlarmSettings(); 2440 mCalendar->reInitAlarmSettings();
2434 setSyncEventsReadOnly(); 2441 setSyncEventsReadOnly();
2435 updateUnmanagedViews(); 2442 updateUnmanagedViews();
2436 updateView(); 2443 updateView();
2437} 2444}
2445void CalendarView::mergeFileResource( QString fn ,QString resource )
2446{
2447
2448 if ( resource == "ALL" ) {
2449 mergeFile( fn );
2450 return;
2451 }
2452
2453 int exclusiveResource = KOPrefs::instance()->getFuzzyCalendarID( resource );
2454 if ( !exclusiveResource ) {
2455 qDebug("KO: CalendarView::mergeFileResource: resource not found %s", resource.latin1() );
2456 return;
2457 }
2458 clearAllViews();
2459 mCalendar->setCalendarRemove( exclusiveResource );
2460 int def = mCalendar->defaultCalendar();
2461 mCalendar->setDefaultCalendar(exclusiveResource);
2462 if ( !mCalendar->addCalendarFile( fn, exclusiveResource )) {
2463 qDebug("KO: CalendarView::mergeFileResource: error adding file %s", fn.latin1() );
2464 }
2465 mCalendar->setDefaultCalendar( def );
2466 mCalendar->reInitAlarmSettings();
2467 setSyncEventsReadOnly();
2468 updateUnmanagedViews();
2469 updateView();
2470}
2438void CalendarView::showOpenError() 2471void CalendarView::showOpenError()
2439{ 2472{
2440 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 2473 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
2441} 2474}
2442void CalendarView::setLoadedFileVersion(QDateTime dt) 2475void CalendarView::setLoadedFileVersion(QDateTime dt)
2443{ 2476{
2444 loadedFileVersion = dt; 2477 loadedFileVersion = dt;
2445} 2478}
2446bool CalendarView::checkFileChanged(QString fn) 2479bool CalendarView::checkFileChanged(QString fn)
2447{ 2480{
2448 QFileInfo finf ( fn ); 2481 QFileInfo finf ( fn );
2449 if ( !finf.exists() ) 2482 if ( !finf.exists() )
2450 return true; 2483 return true;
2451 QDateTime dt = finf.lastModified (); 2484 QDateTime dt = finf.lastModified ();
2452 if ( dt <= loadedFileVersion ) 2485 if ( dt <= loadedFileVersion )
2453 return false; 2486 return false;
2454 return true; 2487 return true;
2455 2488
2456} 2489}
2457void CalendarView::watchSavedFile() 2490void CalendarView::watchSavedFile()
2458{ 2491{
2459 QFileInfo finf ( MainWindow::defaultFileName()); 2492 QFileInfo finf ( MainWindow::defaultFileName());
2460 if ( !finf.exists() ) 2493 if ( !finf.exists() )
2461 return; 2494 return;
2462 QDateTime dt = finf.lastModified (); 2495 QDateTime dt = finf.lastModified ();
2463 if ( dt < loadedFileVersion ) { 2496 if ( dt < loadedFileVersion ) {
2464 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 2497 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
2465 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 2498 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
2466 return; 2499 return;
2467 } 2500 }
2468 loadedFileVersion = dt; 2501 loadedFileVersion = dt;
2469} 2502}
2470bool CalendarView::checkAllFileVersions() 2503bool CalendarView::checkAllFileVersions()
2471{ 2504{
2472 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2505 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2473 KopiCalendarFile * cal = calendars.first(); 2506 KopiCalendarFile * cal = calendars.first();
2474 mCalendar->setDefaultCalendar( 1 ); 2507 mCalendar->setDefaultCalendar( 1 );
2475 mCalendar->setDefaultCalendarEnabledOnly(); 2508 mCalendar->setDefaultCalendarEnabledOnly();
2476 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2509 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2477 if ( !checkFileVersion(MainWindow::defaultFileName())) { 2510 if ( !checkFileVersion(MainWindow::defaultFileName())) {
2478 restoreCalendarSettings(); 2511 restoreCalendarSettings();
2479 return false; 2512 return false;
2480 } 2513 }
2481 } 2514 }
2482 cal = calendars.next(); 2515 cal = calendars.next();
2483 QDateTime storeTemp = loadedFileVersion; 2516 QDateTime storeTemp = loadedFileVersion;
2484 while ( cal ) { 2517 while ( cal ) {
2485 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2518 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2486 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2519 mCalendar->setDefaultCalendar( cal->mCalNumber );
2487 mCalendar->setDefaultCalendarEnabledOnly(); 2520 mCalendar->setDefaultCalendarEnabledOnly();
2488 loadedFileVersion = cal->mLoadDt.addSecs( 15 ); 2521 loadedFileVersion = cal->mLoadDt.addSecs( 15 );
2489 if ( !checkFileVersion(cal->mFileName )) { 2522 if ( !checkFileVersion(cal->mFileName )) {
2490 loadedFileVersion = storeTemp; 2523 loadedFileVersion = storeTemp;
2491 restoreCalendarSettings(); 2524 restoreCalendarSettings();
2492 return false; 2525 return false;
2493 } 2526 }
2494 } 2527 }
2495 cal = calendars.next(); 2528 cal = calendars.next();
2496 } 2529 }
2497 loadedFileVersion = storeTemp; 2530 loadedFileVersion = storeTemp;
2498 return true; 2531 return true;
2499} 2532}
2500bool CalendarView::checkFileVersion(QString fn) 2533bool CalendarView::checkFileVersion(QString fn)
2501{ 2534{
2502 QFileInfo finf ( fn ); 2535 QFileInfo finf ( fn );
2503 if ( !finf.exists() ) 2536 if ( !finf.exists() )
2504 return true; 2537 return true;
2505 QDateTime dt = finf.lastModified (); 2538 QDateTime dt = finf.lastModified ();
2506 //qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); 2539 //qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1());
2507 //qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); 2540 //qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1());
2508 if ( dt <= loadedFileVersion ) 2541 if ( dt <= loadedFileVersion )
2509 return true; 2542 return true;
2510 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 2543 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
2511 i18n("KO/Pi Warning"),i18n("Overwrite"), 2544 i18n("KO/Pi Warning"),i18n("Overwrite"),
2512 i18n("Sync+save")); 2545 i18n("Sync+save"));
2513 2546
2514 if ( km == KMessageBox::Cancel ) 2547 if ( km == KMessageBox::Cancel )
2515 return false; 2548 return false;
2516 if ( km == KMessageBox::Yes ) 2549 if ( km == KMessageBox::Yes )
2517 return true; 2550 return true;
2518 2551
2519 setSyncDevice("deleteaftersync" ); 2552 setSyncDevice("deleteaftersync" );
2520 mSyncManager->mAskForPreferences = true; 2553 mSyncManager->mAskForPreferences = true;
2521 mSyncManager->mSyncAlgoPrefs = 3; 2554 mSyncManager->mSyncAlgoPrefs = 3;
2522 mSyncManager->mWriteBackFile = false; 2555 mSyncManager->mWriteBackFile = false;
2523 mSyncManager->mWriteBackExistingOnly = false; 2556 mSyncManager->mWriteBackExistingOnly = false;
2524 mSyncManager->mShowSyncSummary = false; 2557 mSyncManager->mShowSyncSummary = false;
2558 mMultiResourceSync = false;
2525 syncCalendar( fn, 3 ); 2559 syncCalendar( fn, 3 );
2526 Event * e = getLastSyncEvent(); 2560 Event * e = getLastSyncEvent();
2527 if ( e ) 2561 if ( e )
2528 mCalendar->deleteEvent( e ); 2562 mCalendar->deleteEvent( e );
2529 return true; 2563 return true;
2530} 2564}
2531bool CalendarView::saveCalendars() 2565bool CalendarView::saveCalendars()
2532{ 2566{
2533 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2567 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2534 KopiCalendarFile * cal = calendars.first(); 2568 KopiCalendarFile * cal = calendars.first();
2535 mCalendar->setDefaultCalendar( 1 ); 2569 mCalendar->setDefaultCalendar( 1 );
2536 mCalendar->setDefaultCalendarEnabledOnly(); 2570 mCalendar->setDefaultCalendarEnabledOnly();
2537 QString saveError; 2571 QString saveError;
2538 if ( !saveCalendar( MainWindow::defaultFileName() ) ) 2572 if ( !saveCalendar( MainWindow::defaultFileName() ) )
2539 saveError = cal->mName +"\n"; 2573 saveError = cal->mName +"\n";
2540 cal = calendars.next(); 2574 cal = calendars.next();
2541 while ( cal ) { 2575 while ( cal ) {
2542 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2576 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2543 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2577 mCalendar->setDefaultCalendar( cal->mCalNumber );
2544 mCalendar->setDefaultCalendarEnabledOnly(); 2578 mCalendar->setDefaultCalendarEnabledOnly();
2545 if ( saveCalendar( cal->mFileName ) ) 2579 if ( saveCalendar( cal->mFileName ) )
2546 cal->mLoadDt = QDateTime::currentDateTime(); 2580 cal->mLoadDt = QDateTime::currentDateTime();
2547 else 2581 else
2548 saveError += cal->mName + "\n"; 2582 saveError += cal->mName + "\n";
2549 } 2583 }
2550 cal = calendars.next(); 2584 cal = calendars.next();
2551 } 2585 }
2552 restoreCalendarSettings(); 2586 restoreCalendarSettings();
2553 //saveError = "test error"; 2587 //saveError = "test error";
2554 if ( !saveError.isEmpty() ) { 2588 if ( !saveError.isEmpty() ) {
2555 saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError; 2589 saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError;
2556 KMessageBox::error(this, saveError, i18n("Error saving data")); 2590 KMessageBox::error(this, saveError, i18n("Error saving data"));
2557 return false; 2591 return false;
2558 } 2592 }
2559 return true; 2593 return true;
2560} 2594}
2595bool CalendarView::saveCalendarResource(QString filename, QString resource)
2596{
2597 if ( resource == "ALL" )
2598 return saveCalendar( filename );
2599 int exclusiveResource = KOPrefs::instance()->getFuzzyCalendarID( resource );
2600 if ( !exclusiveResource ) {
2601 qDebug("KO: CalendarView::saveCalendarResource: resource not found %s", resource.latin1() );
2602 return false;
2603 }
2604 mCalendar->setDefaultCalendar( exclusiveResource );
2605 mCalendar->setDefaultCalendarEnabledOnly();
2606 mCalendar->setSyncEventsEnabled();
2607 bool res = saveCalendar( filename );
2608 restoreCalendarSettings();
2609 return res;
2610
2611}
2561bool CalendarView::saveCalendar( QString filename ) 2612bool CalendarView::saveCalendar( QString filename )
2562{ 2613{
2563 2614
2564 // Store back all unsaved data into calendar object 2615 // Store back all unsaved data into calendar object
2565 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 2616 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
2566 if ( mViewManager->currentView() ) 2617 if ( mViewManager->currentView() )
2567 mViewManager->currentView()->flushView(); 2618 mViewManager->currentView()->flushView();
2568 2619
2569 2620
2570 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 2621 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
2571 mStorage->setSaveFormat( new ICalFormat() ); 2622 mStorage->setSaveFormat( new ICalFormat() );
2572 mStorage->setFileName( filename ); 2623 mStorage->setFileName( filename );
2573 bool success; 2624 bool success;
2574 success = mStorage->save(); 2625 success = mStorage->save();
2575 if ( !success ) { 2626 if ( !success ) {
2576 return false; 2627 return false;
2577 } 2628 }
2578 if ( filename == MainWindow::defaultFileName() ) { 2629 if ( filename == MainWindow::defaultFileName() ) {
2579 setLoadedFileVersion( lfv ); 2630 setLoadedFileVersion( lfv );
2580 watchSavedFile(); 2631 watchSavedFile();
2581 } 2632 }
2582 return true; 2633 return true;
2583} 2634}
2584 2635
2585void CalendarView::closeCalendar() 2636void CalendarView::closeCalendar()
2586{ 2637{
2587 2638
2588 // child windows no longer valid 2639 // child windows no longer valid
2589 clearAllViews(); 2640 clearAllViews();
2590 emit closingDown(); 2641 emit closingDown();
2591 2642
2592 mCalendar->close(); 2643 mCalendar->close();
2593 setModified(false); 2644 setModified(false);
2594 updateView(); 2645 updateView();
2595} 2646}
2596 2647
2597void CalendarView::archiveCalendar() 2648void CalendarView::archiveCalendar()
2598{ 2649{
2599 mDialogManager->showArchiveDialog(); 2650 mDialogManager->showArchiveDialog();
2600} 2651}
2601 2652
2602 2653
2603void CalendarView::readSettings() 2654void CalendarView::readSettings()
2604{ 2655{
2605 2656
2606 2657
2607 // mViewManager->showAgendaView(); 2658 // mViewManager->showAgendaView();
2608 QString str; 2659 QString str;
2609 //qDebug("CalendarView::readSettings() "); 2660 //qDebug("CalendarView::readSettings() ");
2610 // read settings from the KConfig, supplying reasonable 2661 // read settings from the KConfig, supplying reasonable
2611 // defaults where none are to be found 2662 // defaults where none are to be found
2612 KConfig *config = KOGlobals::config(); 2663 KConfig *config = KOGlobals::config();
2613#ifndef KORG_NOSPLITTER 2664#ifndef KORG_NOSPLITTER
2614 config->setGroup("KOrganizer Geometry"); 2665 config->setGroup("KOrganizer Geometry");
2615 2666
2616 QValueList<int> sizes = config->readIntListEntry("Separator1"); 2667 QValueList<int> sizes = config->readIntListEntry("Separator1");
2617 if (sizes.count() != 2) { 2668 if (sizes.count() != 2) {
2618 sizes << mDateNavigator->minimumSizeHint().width(); 2669 sizes << mDateNavigator->minimumSizeHint().width();
2619 sizes << 300; 2670 sizes << 300;
2620 } 2671 }
2621 mPanner->setSizes(sizes); 2672 mPanner->setSizes(sizes);
2622 2673
2623 sizes = config->readIntListEntry("Separator2"); 2674 sizes = config->readIntListEntry("Separator2");
2624 if ( ( mResourceView && sizes.count() == 4 ) || 2675 if ( ( mResourceView && sizes.count() == 4 ) ||
2625 ( !mResourceView && sizes.count() == 3 ) ) { 2676 ( !mResourceView && sizes.count() == 3 ) ) {
2626 mLeftSplitter->setSizes(sizes); 2677 mLeftSplitter->setSizes(sizes);
2627 } 2678 }
2628#endif 2679#endif
2629 globalFlagBlockAgenda = 1; 2680 globalFlagBlockAgenda = 1;
2630 mViewManager->showAgendaView(); 2681 mViewManager->showAgendaView();
2631 //mViewManager->readSettings( config ); 2682 //mViewManager->readSettings( config );
2632 mTodoList->restoreLayout(config,QString("Todo Layout")); 2683 mTodoList->restoreLayout(config,QString("Todo Layout"));
2633 readFilterSettings(config); 2684 readFilterSettings(config);
2634 2685
2635#ifdef DESKTOP_VERSION 2686#ifdef DESKTOP_VERSION
2636 config->setGroup("WidgetLayout"); 2687 config->setGroup("WidgetLayout");
2637 QStringList list; 2688 QStringList list;
2638 list = config->readListEntry("MainLayout"); 2689 list = config->readListEntry("MainLayout");
2639 int x,y,w,h; 2690 int x,y,w,h;
2640 if ( ! list.isEmpty() ) { 2691 if ( ! list.isEmpty() ) {
2641 x = list[0].toInt(); 2692 x = list[0].toInt();
2642 y = list[1].toInt(); 2693 y = list[1].toInt();
2643 w = list[2].toInt(); 2694 w = list[2].toInt();
2644 h = list[3].toInt(); 2695 h = list[3].toInt();
2645 KApplication::testCoords( &x,&y,&w,&h ); 2696 KApplication::testCoords( &x,&y,&w,&h );
2646 topLevelWidget()->setGeometry(x,y,w,h); 2697 topLevelWidget()->setGeometry(x,y,w,h);
2647 2698
2648 } else { 2699 } else {
2649 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 2700 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
2650 } 2701 }
2651 list = config->readListEntry("EditEventLayout"); 2702 list = config->readListEntry("EditEventLayout");
2652 if ( ! list.isEmpty() ) { 2703 if ( ! list.isEmpty() ) {
2653 x = list[0].toInt(); 2704 x = list[0].toInt();
2654 y = list[1].toInt(); 2705 y = list[1].toInt();
2655 w = list[2].toInt(); 2706 w = list[2].toInt();
2656 h = list[3].toInt(); 2707 h = list[3].toInt();
2657 KApplication::testCoords( &x,&y,&w,&h ); 2708 KApplication::testCoords( &x,&y,&w,&h );
2658 mEventEditor->setGeometry(x,y,w,h); 2709 mEventEditor->setGeometry(x,y,w,h);
2659 2710
2660 } 2711 }
2661 list = config->readListEntry("EditTodoLayout"); 2712 list = config->readListEntry("EditTodoLayout");
2662 if ( ! list.isEmpty() ) { 2713 if ( ! list.isEmpty() ) {
2663 x = list[0].toInt(); 2714 x = list[0].toInt();
2664 y = list[1].toInt(); 2715 y = list[1].toInt();
2665 w = list[2].toInt(); 2716 w = list[2].toInt();
2666 h = list[3].toInt(); 2717 h = list[3].toInt();
2667 KApplication::testCoords( &x,&y,&w,&h ); 2718 KApplication::testCoords( &x,&y,&w,&h );
2668 mTodoEditor->setGeometry(x,y,w,h); 2719 mTodoEditor->setGeometry(x,y,w,h);
2669 2720
2670 } 2721 }
2671 list = config->readListEntry("ViewerLayout"); 2722 list = config->readListEntry("ViewerLayout");
2672 if ( ! list.isEmpty() ) { 2723 if ( ! list.isEmpty() ) {
2673 x = list[0].toInt(); 2724 x = list[0].toInt();
2674 y = list[1].toInt(); 2725 y = list[1].toInt();
2675 w = list[2].toInt(); 2726 w = list[2].toInt();
2676 h = list[3].toInt(); 2727 h = list[3].toInt();
2677 KApplication::testCoords( &x,&y,&w,&h ); 2728 KApplication::testCoords( &x,&y,&w,&h );
2678 getEventViewerDialog()->setGeometry(x,y,w,h); 2729 getEventViewerDialog()->setGeometry(x,y,w,h);
2679 } 2730 }
2680#endif 2731#endif
2681 config->setGroup( "Views" ); 2732 config->setGroup( "Views" );
2682 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 2733 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
2683 2734
2684 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 2735 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
2685 2736
2686 int resetval = 0; 2737 int resetval = 0;
2687 int maxVal = 0; 2738 int maxVal = 0;
2688 if (sizes.count() != 3) { 2739 if (sizes.count() != 3) {
2689 if ( KOPrefs::instance()->mVerticalScreen ) { 2740 if ( KOPrefs::instance()->mVerticalScreen ) {
2690 resetval = mDateNavigator->sizeHint().width()+2; 2741 resetval = mDateNavigator->sizeHint().width()+2;
2691 } else { 2742 } else {
2692 resetval = mDateNavigator->sizeHint().height()+2; 2743 resetval = mDateNavigator->sizeHint().height()+2;
2693 } 2744 }
2694 } 2745 }
2695 if ( resetval ) { 2746 if ( resetval ) {
2696 sizes.clear(); 2747 sizes.clear();
2697 if ( KOPrefs::instance()->mVerticalScreen ) { 2748 if ( KOPrefs::instance()->mVerticalScreen ) {
2698 maxVal = QApplication::desktop()->width() -10; 2749 maxVal = QApplication::desktop()->width() -10;
2699 } else { 2750 } else {
2700 maxVal = QApplication::desktop()->height()-10; 2751 maxVal = QApplication::desktop()->height()-10;
2701 } 2752 }
2702 sizes << resetval; 2753 sizes << resetval;
2703 if ( maxVal < resetval + resetval) 2754 if ( maxVal < resetval + resetval)
2704 resetval = maxVal - resetval; 2755 resetval = maxVal - resetval;
2705 sizes << resetval; 2756 sizes << resetval;
2706 sizes << 100; 2757 sizes << 100;
2707 } 2758 }
2708 mLeftFrame->setSizes(sizes); 2759 mLeftFrame->setSizes(sizes);
2709 sizes = config->readIntListEntry("Main Splitter Frame"); 2760 sizes = config->readIntListEntry("Main Splitter Frame");
2710 resetval = 0; 2761 resetval = 0;
2711 maxVal = 0; 2762 maxVal = 0;
2712 if (sizes.count() != 2) { 2763 if (sizes.count() != 2) {
2713 if ( !KOPrefs::instance()->mVerticalScreen ) { 2764 if ( !KOPrefs::instance()->mVerticalScreen ) {
2714 resetval = mDateNavigator->sizeHint().width()+2; 2765 resetval = mDateNavigator->sizeHint().width()+2;
2715 } else { 2766 } else {
2716 resetval = mDateNavigator->sizeHint().height()+2; 2767 resetval = mDateNavigator->sizeHint().height()+2;
2717 } 2768 }
2718 } 2769 }
2719 if ( resetval ) { 2770 if ( resetval ) {
2720 sizes.clear(); 2771 sizes.clear();
2721 if ( !KOPrefs::instance()->mVerticalScreen ) { 2772 if ( !KOPrefs::instance()->mVerticalScreen ) {
2722 maxVal = QApplication::desktop()->width() -10; 2773 maxVal = QApplication::desktop()->width() -10;
2723 } else { 2774 } else {
2724 maxVal = QApplication::desktop()->height()-10; 2775 maxVal = QApplication::desktop()->height()-10;
2725 } 2776 }
2726 sizes << resetval; 2777 sizes << resetval;
2727 if ( maxVal < resetval + resetval) 2778 if ( maxVal < resetval + resetval)
2728 resetval = maxVal - resetval; 2779 resetval = maxVal - resetval;
2729 sizes << resetval; 2780 sizes << resetval;
2730 } 2781 }
2731 mMainFrame->setSizes(sizes); 2782 mMainFrame->setSizes(sizes);
2732 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 2783 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
2733 else if ( dateCount == 7 ) mNavigator->selectWeek(); 2784 else if ( dateCount == 7 ) mNavigator->selectWeek();
2734 else mNavigator->selectDates( dateCount ); 2785 else mNavigator->selectDates( dateCount );
2735 // mViewManager->readSettings( config ); 2786 // mViewManager->readSettings( config );
2736 updateConfig(); 2787 updateConfig();
2737 globalFlagBlockAgenda = 2; 2788 globalFlagBlockAgenda = 2;
2738 mViewManager->readSettings( config ); 2789 mViewManager->readSettings( config );
2739 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); 2790 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) );
2740} 2791}
2741 2792
2742void CalendarView::checkSuspendAlarm() 2793void CalendarView::checkSuspendAlarm()
2743{ 2794{
2744 if ( mSuspendTimer->isActive() ) { 2795 if ( mSuspendTimer->isActive() ) {
2745 KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); 2796 KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm"));
2746 } 2797 }
2747} 2798}
2748void CalendarView::writeSettings() 2799void CalendarView::writeSettings()
2749{ 2800{
2750 // kdDebug() << "CalendarView::writeSettings" << endl; 2801 // kdDebug() << "CalendarView::writeSettings" << endl;
2751 2802
2752 KConfig *config = KOGlobals::config(); 2803 KConfig *config = KOGlobals::config();
@@ -4843,347 +4894,351 @@ void CalendarView::toggleAllDaySize()
4843 else 4894 else
4844 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 4895 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
4845 */ 4896 */
4846 viewManager()->agendaView()->toggleAllDay(); 4897 viewManager()->agendaView()->toggleAllDay();
4847} 4898}
4848void CalendarView::toggleExpand() 4899void CalendarView::toggleExpand()
4849{ 4900{
4850 // if ( mLeftFrame->isHidden() ) { 4901 // if ( mLeftFrame->isHidden() ) {
4851 // mLeftFrame->show(); 4902 // mLeftFrame->show();
4852 // emit calendarViewExpanded( false ); 4903 // emit calendarViewExpanded( false );
4853 // } else { 4904 // } else {
4854 // mLeftFrame->hide(); 4905 // mLeftFrame->hide();
4855 // emit calendarViewExpanded( true ); 4906 // emit calendarViewExpanded( true );
4856 // } 4907 // }
4857 //qDebug(" CalendarView::toggleExpand()"); 4908 //qDebug(" CalendarView::toggleExpand()");
4858 globalFlagBlockAgenda = 1; 4909 globalFlagBlockAgenda = 1;
4859 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 4910 emit calendarViewExpanded( !mLeftFrame->isHidden() );
4860 globalFlagBlockAgenda = 5; 4911 globalFlagBlockAgenda = 5;
4861 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 4912 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
4862 //mViewManager->showView( 0, true ); 4913 //mViewManager->showView( 0, true );
4863} 4914}
4864 4915
4865void CalendarView::calendarModified( bool modified, Calendar * ) 4916void CalendarView::calendarModified( bool modified, Calendar * )
4866{ 4917{
4867 setModified( modified ); 4918 setModified( modified );
4868} 4919}
4869 4920
4870Todo *CalendarView::selectedTodo() 4921Todo *CalendarView::selectedTodo()
4871{ 4922{
4872 Incidence *incidence = currentSelection(); 4923 Incidence *incidence = currentSelection();
4873 if ( incidence && incidence->typeID() == todoID ) { 4924 if ( incidence && incidence->typeID() == todoID ) {
4874 return static_cast<Todo *>( incidence ); 4925 return static_cast<Todo *>( incidence );
4875 } 4926 }
4876 4927
4877 incidence = mTodoList->selectedIncidences().first(); 4928 incidence = mTodoList->selectedIncidences().first();
4878 if ( incidence && incidence->typeID() == todoID ) { 4929 if ( incidence && incidence->typeID() == todoID ) {
4879 return static_cast<Todo *>( incidence ); 4930 return static_cast<Todo *>( incidence );
4880 } 4931 }
4881 4932
4882 return 0; 4933 return 0;
4883} 4934}
4884 4935
4885void CalendarView::showIncidence() 4936void CalendarView::showIncidence()
4886{ 4937{
4887 mViewerCallerIsSearchDialog = false; 4938 mViewerCallerIsSearchDialog = false;
4888 Incidence *incidence = currentSelection(); 4939 Incidence *incidence = currentSelection();
4889 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4940 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4890 if ( incidence ) { 4941 if ( incidence ) {
4891 ShowIncidenceVisitor v; 4942 ShowIncidenceVisitor v;
4892 v.act( incidence, this ); 4943 v.act( incidence, this );
4893 } 4944 }
4894} 4945}
4895void CalendarView::editIncidenceDescription() 4946void CalendarView::editIncidenceDescription()
4896{ 4947{
4897 mFlagEditDescription = true; 4948 mFlagEditDescription = true;
4898 editIncidence(); 4949 editIncidence();
4899 mFlagEditDescription = false; 4950 mFlagEditDescription = false;
4900} 4951}
4901void CalendarView::editIncidence() 4952void CalendarView::editIncidence()
4902{ 4953{
4903 // qDebug("editIncidence() "); 4954 // qDebug("editIncidence() ");
4904 Incidence *incidence = currentSelection(); 4955 Incidence *incidence = currentSelection();
4905 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4956 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4906 if ( incidence ) { 4957 if ( incidence ) {
4907 EditIncidenceVisitor v; 4958 EditIncidenceVisitor v;
4908 v.act( incidence, this ); 4959 v.act( incidence, this );
4909 } 4960 }
4910} 4961}
4911 4962
4912void CalendarView::deleteIncidence() 4963void CalendarView::deleteIncidence()
4913{ 4964{
4914 Incidence *incidence = currentSelection(); 4965 Incidence *incidence = currentSelection();
4915 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4966 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4916 if ( incidence ) { 4967 if ( incidence ) {
4917 deleteIncidence(incidence); 4968 deleteIncidence(incidence);
4918 } 4969 }
4919} 4970}
4920void CalendarView::showIncidence(QString uid) 4971void CalendarView::showIncidence(QString uid)
4921{ 4972{
4922 Incidence *inc = mCalendar->incidence( uid ); 4973 Incidence *inc = mCalendar->incidence( uid );
4923 if ( inc ) 4974 if ( inc )
4924 showIncidence( inc ); 4975 showIncidence( inc );
4925} 4976}
4926void CalendarView::showIncidence(Incidence *incidence) 4977void CalendarView::showIncidence(Incidence *incidence)
4927{ 4978{
4928 mViewerCallerIsSearchDialog = false; 4979 mViewerCallerIsSearchDialog = false;
4929 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); 4980 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() );
4930 if ( sender() && mDialogManager->getSearchDialog() ) { 4981 if ( sender() && mDialogManager->getSearchDialog() ) {
4931 if ( sender () == mDialogManager->getSearchDialog()->listview() ) { 4982 if ( sender () == mDialogManager->getSearchDialog()->listview() ) {
4932 mViewerCallerIsSearchDialog = true; 4983 mViewerCallerIsSearchDialog = true;
4933 } 4984 }
4934 } 4985 }
4935 if ( incidence ) { 4986 if ( incidence ) {
4936 ShowIncidenceVisitor v; 4987 ShowIncidenceVisitor v;
4937 v.act( incidence, this ); 4988 v.act( incidence, this );
4938 } 4989 }
4939} 4990}
4940 4991
4941void CalendarView::editIncidence(Incidence *incidence) 4992void CalendarView::editIncidence(Incidence *incidence)
4942{ 4993{
4943 if ( incidence ) { 4994 if ( incidence ) {
4944 4995
4945 EditIncidenceVisitor v; 4996 EditIncidenceVisitor v;
4946 v.act( incidence, this ); 4997 v.act( incidence, this );
4947 4998
4948 } 4999 }
4949} 5000}
4950 5001
4951void CalendarView::deleteIncidence(Incidence *incidence) 5002void CalendarView::deleteIncidence(Incidence *incidence)
4952{ 5003{
4953 //qDebug(" CalendarView::deleteIncidence "); 5004 //qDebug(" CalendarView::deleteIncidence ");
4954 if ( incidence == 0 ) { 5005 if ( incidence == 0 ) {
4955 updateView(); 5006 updateView();
4956 emit updateSearchDialog(); 5007 emit updateSearchDialog();
4957 return; 5008 return;
4958 } 5009 }
4959 if ( incidence ) { 5010 if ( incidence ) {
4960 DeleteIncidenceVisitor v; 5011 DeleteIncidenceVisitor v;
4961 v.act( incidence, this ); 5012 v.act( incidence, this );
4962 } 5013 }
4963} 5014}
4964 5015
4965 5016
4966void CalendarView::lookForOutgoingMessages() 5017void CalendarView::lookForOutgoingMessages()
4967{ 5018{
4968 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 5019 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
4969 ogd->loadMessages(); 5020 ogd->loadMessages();
4970} 5021}
4971 5022
4972void CalendarView::lookForIncomingMessages() 5023void CalendarView::lookForIncomingMessages()
4973{ 5024{
4974 IncomingDialog *icd = mDialogManager->incomingDialog(); 5025 IncomingDialog *icd = mDialogManager->incomingDialog();
4975 icd->retrieve(); 5026 icd->retrieve();
4976} 5027}
4977 5028
4978bool CalendarView::removeCompletedSubTodos( Todo* t ) 5029bool CalendarView::removeCompletedSubTodos( Todo* t )
4979{ 5030{
4980 bool deleteTodo = true; 5031 bool deleteTodo = true;
4981 QPtrList<Incidence> subTodos; 5032 QPtrList<Incidence> subTodos;
4982 Incidence *aTodo; 5033 Incidence *aTodo;
4983 subTodos = t->relations(); 5034 subTodos = t->relations();
4984 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 5035 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
4985 if (! removeCompletedSubTodos( (Todo*) aTodo )) 5036 if (! removeCompletedSubTodos( (Todo*) aTodo ))
4986 deleteTodo = false; 5037 deleteTodo = false;
4987 } 5038 }
4988 if ( deleteTodo ) { 5039 if ( deleteTodo ) {
4989 if ( t->isCompleted() && !t->doesRecur()) { 5040 if ( t->isCompleted() && !t->doesRecur()) {
4990 checkExternalId( t ); 5041 checkExternalId( t );
4991 mCalendar->deleteTodo( t ); 5042 mCalendar->deleteTodo( t );
4992 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 5043 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
4993 } 5044 }
4994 else 5045 else
4995 deleteTodo = false; 5046 deleteTodo = false;
4996 } 5047 }
4997 return deleteTodo; 5048 return deleteTodo;
4998 5049
4999} 5050}
5000void CalendarView::purgeCompleted() 5051void CalendarView::purgeCompleted()
5001{ 5052{
5002 int result = KMessageBox::warningContinueCancel(this, 5053 int result = KMessageBox::warningContinueCancel(this,
5003 i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); 5054 i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge"));
5004 5055
5005 if (result == KMessageBox::Continue) { 5056 if (result == KMessageBox::Continue) {
5006 5057
5007 QPtrList<Todo> todoCal; 5058 QPtrList<Todo> todoCal;
5008 QPtrList<Todo> rootTodos; 5059 QPtrList<Todo> rootTodos;
5009 //QPtrList<Incidence> rel; 5060 //QPtrList<Incidence> rel;
5010 Todo *aTodo; 5061 Todo *aTodo;
5011 todoCal = calendar()->todos(); 5062 todoCal = calendar()->todos();
5012 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 5063 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
5013 if ( !aTodo->relatedTo() ) 5064 if ( !aTodo->relatedTo() )
5014 rootTodos.append( aTodo ); 5065 rootTodos.append( aTodo );
5015 } 5066 }
5016 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 5067 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
5017 removeCompletedSubTodos( aTodo ); 5068 removeCompletedSubTodos( aTodo );
5018 } 5069 }
5019 5070
5020 updateView(); 5071 updateView();
5021 } 5072 }
5022} 5073}
5023 5074
5024void CalendarView::slotCalendarChanged() 5075void CalendarView::slotCalendarChanged()
5025{ 5076{
5026 ; 5077 ;
5027} 5078}
5028 5079
5029void CalendarView::keyPressEvent ( QKeyEvent *e) 5080void CalendarView::keyPressEvent ( QKeyEvent *e)
5030{ 5081{
5031 //qDebug("CalendarView::keyPressEvent "); 5082 //qDebug("CalendarView::keyPressEvent ");
5032 e->ignore(); 5083 e->ignore();
5033} 5084}
5034 5085
5086void CalendarView::multiResourceSyncStart( bool start )
5087{
5088 mMultiResourceSync = start;
5035 5089
5090}
5036bool CalendarView::sync(KSyncManager* manager, QString filename, int mode,QString resource) 5091bool CalendarView::sync(KSyncManager* manager, QString filename, int mode,QString resource)
5037{ 5092{
5038 5093
5039 if ( manager != mSyncManager) 5094 if ( manager != mSyncManager)
5040 qDebug("KO: Internal error-1. SyncManager mismatch "); 5095 qDebug("KO: Internal error-1. SyncManager mismatch ");
5041 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 5096 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
5042 qDebug("KO: SyncKDE request detected!"); 5097 qDebug("KO: SyncKDE request detected!");
5043 } 5098 }
5044 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 5099 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
5045 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 5100 mCurrentSyncName = mSyncManager->getCurrentSyncName();
5046 if ( !resource.isEmpty() ) { 5101 if ( !resource.isEmpty() ) {
5047 int exclusiveSyncResource = KOPrefs::instance()->getFuzzyCalendarID( resource ); 5102 int exclusiveSyncResource = KOPrefs::instance()->getFuzzyCalendarID( resource );
5048 qDebug( "KO: Sync request for resource: %s", resource.latin1() ); 5103 qDebug( "KO: Sync request for resource: %s", resource.latin1() );
5049 5104
5050 if ( !exclusiveSyncResource ) { 5105 if ( !exclusiveSyncResource ) {
5051 qDebug( "KO: Requested sync resource not found: %s", resource.latin1() ); 5106 qDebug( "KO: Requested sync resource not found: %s", resource.latin1() );
5052 return false; 5107 return false;
5053 } 5108 }
5054 mCalendar->setDefaultCalendar( exclusiveSyncResource ); 5109 mCalendar->setDefaultCalendar( exclusiveSyncResource );
5055 mCalendar->setDefaultCalendarEnabledOnly(); 5110 mCalendar->setDefaultCalendarEnabledOnly();
5056 } 5111 }
5057 bool result = syncCalendar( filename, mode ); 5112 bool result = syncCalendar( filename, mode );
5058 if ( !resource.isEmpty() ) 5113 if ( !resource.isEmpty() )
5059 restoreCalendarSettings(); 5114 restoreCalendarSettings();
5060 return result; 5115 return result;
5061} 5116}
5062bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 5117bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
5063{ 5118{
5064 //mSyncManager = manager; 5119 //mSyncManager = manager;
5065 if ( manager != mSyncManager) 5120 if ( manager != mSyncManager)
5066 qDebug("KO: Internal error-2. SyncManager mismatch "); 5121 qDebug("KO: Internal error-2. SyncManager mismatch ");
5067 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 5122 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
5068 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 5123 mCurrentSyncName = mSyncManager->getCurrentSyncName();
5069 if ( resource == "sharp" ) 5124 if ( resource == "sharp" )
5070 syncExternal( 0 ); 5125 syncExternal( 0 );
5071 if ( resource == "phone" ) 5126 if ( resource == "phone" )
5072 syncExternal( 1 ); 5127 syncExternal( 1 );
5073 // pending setmodified 5128 // pending setmodified
5074 return true; 5129 return true;
5075} 5130}
5076void CalendarView::setSyncManager(KSyncManager* manager) 5131void CalendarView::setSyncManager(KSyncManager* manager)
5077{ 5132{
5078 mSyncManager = manager; 5133 mSyncManager = manager;
5079} 5134}
5080 5135
5081void CalendarView::removeSyncInfo( QString syncProfile) 5136void CalendarView::removeSyncInfo( QString syncProfile)
5082{ 5137{
5083 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); 5138 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1());
5084 mCalendar->removeSyncInfo( syncProfile ); 5139 mCalendar->removeSyncInfo( syncProfile );
5085 5140
5086} 5141}
5087 5142
5088void CalendarView::undo_delete() 5143void CalendarView::undo_delete()
5089{ 5144{
5090 //qDebug("undo_delete() "); 5145 //qDebug("undo_delete() ");
5091 Incidence* undo = mCalendar->undoIncidence(); 5146 Incidence* undo = mCalendar->undoIncidence();
5092 if ( !undo ) { 5147 if ( !undo ) {
5093 KMessageBox::sorry(this,i18n("There is nothing to undo!"), 5148 KMessageBox::sorry(this,i18n("There is nothing to undo!"),
5094 i18n("KO/Pi")); 5149 i18n("KO/Pi"));
5095 return; 5150 return;
5096 } 5151 }
5097 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + 5152 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) +
5098 i18n("\nAre you sure you want\nto restore this?"), 5153 i18n("\nAre you sure you want\nto restore this?"),
5099 i18n("KO/Pi Confirmation"),i18n("Restore"))) { 5154 i18n("KO/Pi Confirmation"),i18n("Restore"))) {
5100 mCalendar->undoDeleteIncidence(); 5155 mCalendar->undoDeleteIncidence();
5101 updateView(); 5156 updateView();
5102 } 5157 }
5103} 5158}
5104 5159
5105void CalendarView::slotViewerClosed() 5160void CalendarView::slotViewerClosed()
5106{ 5161{
5107 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); 5162 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) );
5108} 5163}
5109 5164
5110void CalendarView::resetFocus() 5165void CalendarView::resetFocus()
5111{ 5166{
5112 if ( mViewerCallerIsSearchDialog ) { 5167 if ( mViewerCallerIsSearchDialog ) {
5113 if ( mDialogManager->getSearchDialog()->isVisible() ){ 5168 if ( mDialogManager->getSearchDialog()->isVisible() ){
5114 mDialogManager->getSearchDialog()->raise(); 5169 mDialogManager->getSearchDialog()->raise();
5115 mDialogManager->getSearchDialog()->setActiveWindow(); 5170 mDialogManager->getSearchDialog()->setActiveWindow();
5116 mDialogManager->getSearchDialog()->listview()->resetFocus(); 5171 mDialogManager->getSearchDialog()->listview()->resetFocus();
5117 } else 5172 } else
5118 mViewerCallerIsSearchDialog = false; 5173 mViewerCallerIsSearchDialog = false;
5119 } 5174 }
5120 if ( !mViewerCallerIsSearchDialog ) { 5175 if ( !mViewerCallerIsSearchDialog ) {
5121 //mViewManager->currentView()->setFocus(); 5176 //mViewManager->currentView()->setFocus();
5122 //qDebug("sssssssssssssssset focus "); 5177 //qDebug("sssssssssssssssset focus ");
5123 topLevelWidget()->raise(); 5178 topLevelWidget()->raise();
5124 setActiveWindow(); 5179 setActiveWindow();
5125 //setFocus(); 5180 //setFocus();
5126 } 5181 }
5127 mViewerCallerIsSearchDialog = false; 5182 mViewerCallerIsSearchDialog = false;
5128} 5183}
5129 5184
5130void CalendarView::showNextAlarms() 5185void CalendarView::showNextAlarms()
5131{ 5186{
5132 QString message; 5187 QString message;
5133 QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); 5188 QDateTime nextAl = mCalendar->nextAlarmEventDateTime();
5134 if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { 5189 if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) {
5135 QString sum = mCalendar->nextSummary(); 5190 QString sum = mCalendar->nextSummary();
5136 QDateTime nextA = mNextAlarmDateTime; 5191 QDateTime nextA = mNextAlarmDateTime;
5137 QDateTime cur = QDateTime::currentDateTime(); 5192 QDateTime cur = QDateTime::currentDateTime();
5138 int secs = cur.secsTo( nextA ); 5193 int secs = cur.secsTo( nextA );
5139 int min = secs /60; 5194 int min = secs /60;
5140 int hours = min /60; 5195 int hours = min /60;
5141 min = min % 60; 5196 min = min % 60;
5142 int days = hours /24; 5197 int days = hours /24;
5143 hours = hours % 24; 5198 hours = hours % 24;
5144 5199
5145 //message = i18n("The next alarm is in:\n"); 5200 //message = i18n("The next alarm is in:\n");
5146 if ( days > 1 ) 5201 if ( days > 1 )
5147 message += i18n("%1 days\n").arg( days ); 5202 message += i18n("%1 days\n").arg( days );
5148 else if ( days == 1 ) 5203 else if ( days == 1 )
5149 message += i18n("1 day\n"); 5204 message += i18n("1 day\n");
5150 if ( hours > 1 ) 5205 if ( hours > 1 )
5151 message += i18n("%1 hours\n").arg( hours ); 5206 message += i18n("%1 hours\n").arg( hours );
5152 else if ( hours == 1 ) 5207 else if ( hours == 1 )
5153 message += i18n("1 hour\n"); 5208 message += i18n("1 hour\n");
5154 if ( min > 1 ) 5209 if ( min > 1 )
5155 message += i18n("%1 minutes\n").arg( min ); 5210 message += i18n("%1 minutes\n").arg( min );
5156 else if ( min == 1 ) 5211 else if ( min == 1 )
5157 message += i18n("1 minute\n"); 5212 message += i18n("1 minute\n");
5158 if ( message.isEmpty() ) 5213 if ( message.isEmpty() )
5159 message = i18n("The next alarm is in\nless than one minute!"); 5214 message = i18n("The next alarm is in\nless than one minute!");
5160 else 5215 else
5161 message = i18n("The next alarm is in:\n") + message; 5216 message = i18n("The next alarm is in:\n") + message;
5162 message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; 5217 message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ;
5163 } else { 5218 } else {
5164 message = i18n("There is no next alarm."); 5219 message = i18n("There is no next alarm.");
5165 5220
5166 } 5221 }
5167#ifdef DESKTOP_VERSION 5222#ifdef DESKTOP_VERSION
5168 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 5223 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
5169 message += i18n("\nThe internal alarm notification is disabled!\n"); 5224 message += i18n("\nThe internal alarm notification is disabled!\n");
5170 message += i18n("Enable it in the settings menu, TAB alarm."); 5225 message += i18n("Enable it in the settings menu, TAB alarm.");
5171 } 5226 }
5172 5227
5173#endif 5228#endif
5174 KMessageBox::information( this, message); 5229 KMessageBox::information( this, message);
5175} 5230}
5176 5231
5177void CalendarView::displayCalendarInfo( int id ) 5232void CalendarView::displayCalendarInfo( int id )
5178{ 5233{
5179 int e, t,j; 5234 int e, t,j;
5180 KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); 5235 KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id );
5181 QString name = kkf->mName; 5236 QString name = kkf->mName;
5182 mCalendar->getIncidenceCount( id, e, t, j ); 5237 mCalendar->getIncidenceCount( id, e, t, j );
5183 QString file = KGlobal::formatMessage ( kkf->mFileName ,0 ); 5238 QString file = KGlobal::formatMessage ( kkf->mFileName ,0 );
5184 QString mess = i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file); 5239 QString mess = i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file);
5185 mess += i18n("<br>The calendar contains<br><b>%1 events<br>%2 todos<br>%3 journals</b>").arg( e ).arg( t ).arg( j ); 5240 mess += i18n("<br>The calendar contains<br><b>%1 events<br>%2 todos<br>%3 journals</b>").arg( e ).arg( t ).arg( j );
5186 KMessageBox::information( this, mess ); 5241 KMessageBox::information( this, mess );
5187 5242
5188 5243
5189} 5244}
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index f85b6a3..60b1276 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -1,675 +1,679 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000, 2001 3 Copyright (c) 2000, 2001
4 Cornelius Schumacher <schumacher@kde.org> 4 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24#ifndef CALENDARVIEW_H 24#ifndef CALENDARVIEW_H
25#define CALENDARVIEW_H 25#define CALENDARVIEW_H
26 26
27#include <qframe.h> 27#include <qframe.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qwidget.h> 29#include <qwidget.h>
30#include <qptrlist.h> 30#include <qptrlist.h>
31#include <qvbox.h> 31#include <qvbox.h>
32#include <qmap.h> 32#include <qmap.h>
33#include <qscrollbar.h> 33#include <qscrollbar.h>
34#ifndef DESKTOP_VERSION 34#ifndef DESKTOP_VERSION
35#include <qtopia/ir.h> 35#include <qtopia/ir.h>
36#else 36#else
37#define Ir char 37#define Ir char
38#endif 38#endif
39#include <libkcal/calendar.h> 39#include <libkcal/calendar.h>
40#include <libkcal/scheduler.h> 40#include <libkcal/scheduler.h>
41#include <libkcal/calendarresources.h> 41#include <libkcal/calendarresources.h>
42#include <libkcal/resourcecalendar.h> 42#include <libkcal/resourcecalendar.h>
43#include <KDGanttMinimizeSplitter.h> 43#include <KDGanttMinimizeSplitter.h>
44 44
45#include <korganizer/calendarviewbase.h> 45#include <korganizer/calendarviewbase.h>
46 46
47#include <ksyncmanager.h> 47#include <ksyncmanager.h>
48//#include <koprefs.h> 48//#include <koprefs.h>
49 49
50class QWidgetStack; 50class QWidgetStack;
51class QSplitter; 51class QSplitter;
52class KopiCalendarFile; 52class KopiCalendarFile;
53class CalPrinter; 53class CalPrinter;
54class KOFilterView; 54class KOFilterView;
55class KOCalEditView; 55class KOCalEditView;
56class KOViewManager; 56class KOViewManager;
57class KODialogManager; 57class KODialogManager;
58class KOTodoView; 58class KOTodoView;
59class KDateNavigator; 59class KDateNavigator;
60class DateNavigatorContainer; 60class DateNavigatorContainer;
61class DateNavigator; 61class DateNavigator;
62class KOIncidenceEditor; 62class KOIncidenceEditor;
63class KDatePicker; 63class KDatePicker;
64class ResourceView; 64class ResourceView;
65class KOEventEditor; 65class KOEventEditor;
66class KOTodoEditor ; 66class KOTodoEditor ;
67class KOEventViewerDialog; 67class KOEventViewerDialog;
68class KOBeamPrefs; 68class KOBeamPrefs;
69class KSyncProfile; 69class KSyncProfile;
70class AlarmDialog; 70class AlarmDialog;
71class KCal::Attendee; 71class KCal::Attendee;
72 72
73namespace KCal { class FileStorage; } 73namespace KCal { class FileStorage; }
74 74
75using namespace KCal; 75using namespace KCal;
76 76
77/** 77/**
78 This is the main calendar widget. It provides the different vies on t he 78 This is the main calendar widget. It provides the different vies on t he
79 calendar data as well as the date navigator. It also handles synchronisation 79 calendar data as well as the date navigator. It also handles synchronisation
80 of the different views and controls the different dialogs like preferences, 80 of the different views and controls the different dialogs like preferences,
81 event editor, search dialog etc. 81 event editor, search dialog etc.
82 82
83 @short main calendar view widget 83 @short main calendar view widget
84 @author Cornelius Schumacher 84 @author Cornelius Schumacher
85*/ 85*/
86 86
87#include <qtextbrowser.h> 87#include <qtextbrowser.h>
88#include <qtextcodec.h> 88#include <qtextcodec.h>
89 89
90class MissedAlarmTextBrowser : public QTextBrowser { 90class MissedAlarmTextBrowser : public QTextBrowser {
91 Q_OBJECT 91 Q_OBJECT
92 public: 92 public:
93 MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start); 93 MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start);
94 ~MissedAlarmTextBrowser(); 94 ~MissedAlarmTextBrowser();
95 void setSource(const QString & n); 95 void setSource(const QString & n);
96 96
97 private: 97 private:
98 Incidence * getNextInc(QDateTime start ); 98 Incidence * getNextInc(QDateTime start );
99 QPtrList<Incidence> mAlarms; 99 QPtrList<Incidence> mAlarms;
100 signals: 100 signals:
101 void showIncidence( QString uid); 101 void showIncidence( QString uid);
102}; 102};
103 103
104 104
105class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface 105class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface
106{ 106{
107 Q_OBJECT 107 Q_OBJECT
108 public: 108 public:
109 /** 109 /**
110 Constructs a new calendar view widget. 110 Constructs a new calendar view widget.
111 111
112 @param calendar calendar document 112 @param calendar calendar document
113 @param parent parent window 113 @param parent parent window
114 @param name Qt internal widget object name 114 @param name Qt internal widget object name
115 */ 115 */
116 CalendarView( CalendarResources *calendar, QWidget *parent = 0, 116 CalendarView( CalendarResources *calendar, QWidget *parent = 0,
117 const char *name = 0 ); 117 const char *name = 0 );
118 CalendarView( Calendar *calendar, QWidget *parent = 0, 118 CalendarView( Calendar *calendar, QWidget *parent = 0,
119 const char *name = 0 ); 119 const char *name = 0 );
120 virtual ~CalendarView(); 120 virtual ~CalendarView();
121 121
122 Calendar *calendar() { return mCalendar; } 122 Calendar *calendar() { return mCalendar; }
123 123
124 KOViewManager *viewManager(); 124 KOViewManager *viewManager();
125 KODialogManager *dialogManager(); 125 KODialogManager *dialogManager();
126 126
127 QDate startDate(); 127 QDate startDate();
128 QDate endDate(); 128 QDate endDate();
129 129
130 QWidgetStack *viewStack(); 130 QWidgetStack *viewStack();
131 QWidget *leftFrame(); 131 QWidget *leftFrame();
132 132
133 DateNavigator *dateNavigator(); 133 DateNavigator *dateNavigator();
134 KDateNavigator *dateNavigatorWidget(); 134 KDateNavigator *dateNavigatorWidget();
135 135
136 void addView(KOrg::BaseView *); 136 void addView(KOrg::BaseView *);
137 void showView(KOrg::BaseView *); 137 void showView(KOrg::BaseView *);
138 KOEventViewerDialog* getEventViewerDialog(); 138 KOEventViewerDialog* getEventViewerDialog();
139 Incidence *currentSelection(); 139 Incidence *currentSelection();
140 void checkSuspendAlarm(); 140 void checkSuspendAlarm();
141 void mergeFile( QString fn ); 141 void mergeFile( QString fn );
142 void mergeFileResource( QString fn ,QString res);
142 143
143 signals: 144 signals:
144 void save (); 145 void save ();
145 void saveStopTimer (); 146 void saveStopTimer ();
146 void tempDisableBR(bool); 147 void tempDisableBR(bool);
147 /** This todo has been modified */ 148 /** This todo has been modified */
148 void todoModified(Todo *, int); 149 void todoModified(Todo *, int);
149 150
150 /** when change is made to options dialog, the topwidget will catch this 151 /** when change is made to options dialog, the topwidget will catch this
151 * and emit this signal which notifies all widgets which have registered 152 * and emit this signal which notifies all widgets which have registered
152 * for notification to update their settings. */ 153 * for notification to update their settings. */
153 void configChanged(); 154 void configChanged();
154 /** emitted when the topwidget is closing down, so that any attached 155 /** emitted when the topwidget is closing down, so that any attached
155 child windows can also close. */ 156 child windows can also close. */
156 void closingDown(); 157 void closingDown();
157 /** emitted right before we die */ 158 /** emitted right before we die */
158 void closed(QWidget *); 159 void closed(QWidget *);
159 160
160 /** Emitted when state of modified flag changes */ 161 /** Emitted when state of modified flag changes */
161 void modifiedChanged(bool); 162 void modifiedChanged(bool);
162 void signalmodified(); 163 void signalmodified();
163 164
164 /** Emitted when state of read-only flag changes */ 165 /** Emitted when state of read-only flag changes */
165 void readOnlyChanged(bool); 166 void readOnlyChanged(bool);
166 167
167 /** Emitted when the unit of navigation changes */ 168 /** Emitted when the unit of navigation changes */
168 void changeNavStringPrev(const QString &); 169 void changeNavStringPrev(const QString &);
169 void changeNavStringNext(const QString &); 170 void changeNavStringNext(const QString &);
170 171
171 /** Emitted when state of events selection has changed and user is organizer*/ 172 /** Emitted when state of events selection has changed and user is organizer*/
172 void organizerEventsSelected(bool); 173 void organizerEventsSelected(bool);
173 /** Emitted when state of events selection has changed and user is attendee*/ 174 /** Emitted when state of events selection has changed and user is attendee*/
174 void groupEventsSelected(bool); 175 void groupEventsSelected(bool);
175 /** 176 /**
176 Emitted when an incidence gets selected. If the selection is cleared the 177 Emitted when an incidence gets selected. If the selection is cleared the
177 signal is emitted with 0 as argument. 178 signal is emitted with 0 as argument.
178 */ 179 */
179 void incidenceSelected( Incidence * ); 180 void incidenceSelected( Incidence * );
180 /** Emitted, when a todoitem is selected or deselected. */ 181 /** Emitted, when a todoitem is selected or deselected. */
181 void todoSelected( bool ); 182 void todoSelected( bool );
182 183
183 /** 184 /**
184 Emitted, when clipboard content changes. Parameter indicates if paste 185 Emitted, when clipboard content changes. Parameter indicates if paste
185 is possible or not. 186 is possible or not.
186 */ 187 */
187 void pasteEnabled(bool); 188 void pasteEnabled(bool);
188 189
189 /** Emitted, when the number of incoming messages has changed. */ 190 /** Emitted, when the number of incoming messages has changed. */
190 void numIncomingChanged(int); 191 void numIncomingChanged(int);
191 192
192 /** Emitted, when the number of outgoing messages has changed. */ 193 /** Emitted, when the number of outgoing messages has changed. */
193 void numOutgoingChanged(int); 194 void numOutgoingChanged(int);
194 195
195 /** Send status message, which can e.g. be displayed in the status bar. */ 196 /** Send status message, which can e.g. be displayed in the status bar. */
196 void statusMessage(const QString &); 197 void statusMessage(const QString &);
197 198
198 void calendarViewExpanded( bool ); 199 void calendarViewExpanded( bool );
199 void updateSearchDialog(); 200 void updateSearchDialog();
200 void filtersUpdated(); 201 void filtersUpdated();
201 202
202 203
203 public slots: 204 public slots:
205 void multiResourceSyncStart( bool );
204 void displayCalendarInfo( int id ); 206 void displayCalendarInfo( int id );
205 void nextConflict( bool all, bool allday ); 207 void nextConflict( bool all, bool allday );
206 void conflictAll(); 208 void conflictAll();
207 void conflictAllday(); 209 void conflictAllday();
208 void conflictNotAll(); 210 void conflictNotAll();
209 void setCalReadOnly( int id, bool readO ); 211 void setCalReadOnly( int id, bool readO );
210 void checkAlarms(); 212 void checkAlarms();
211 void checkFiles(); 213 void checkFiles();
212 void slotprintSelInc(); 214 void slotprintSelInc();
213 void showNextAlarms(); 215 void showNextAlarms();
214 void showOpenError(); 216 void showOpenError();
215 void watchSavedFile(); 217 void watchSavedFile();
216 void recheckTimerAlarm(); 218 void recheckTimerAlarm();
217 void checkNextTimerAlarm(); 219 void checkNextTimerAlarm();
218 void addAlarm(const QDateTime &qdt, const QString &noti ); 220 void addAlarm(const QDateTime &qdt, const QString &noti );
219 void addSuspendAlarm(const QDateTime &qdt, const QString &noti ); 221 void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
220 void removeAlarm(const QDateTime &qdt, const QString &noti ); 222 void removeAlarm(const QDateTime &qdt, const QString &noti );
221 223
222 /** options dialog made a changed to the configuration. we catch this 224 /** options dialog made a changed to the configuration. we catch this
223 * and notify all widgets which need to update their configuration. */ 225 * and notify all widgets which need to update their configuration. */
224 void updateConfig(); 226 void updateConfig();
225 227
226 void insertBirthdays(const QString& uid, const QStringList& birthdayList, 228 void insertBirthdays(const QString& uid, const QStringList& birthdayList,
227 const QStringList& anniversaryList, const QStringList& realNameList, 229 const QStringList& anniversaryList, const QStringList& realNameList,
228 const QStringList& emailList, const QStringList& assembledNameList, 230 const QStringList& emailList, const QStringList& assembledNameList,
229 const QStringList& uidList); 231 const QStringList& uidList);
230 232
231 /** 233 /**
232 Load calendar from file \a filename. If \a merge is true, load 234 Load calendar from file \a filename. If \a merge is true, load
233 calendar into existing one, if it is false, clear calendar, before 235 calendar into existing one, if it is false, clear calendar, before
234 loading. Return true, if calendar could be successfully loaded. 236 loading. Return true, if calendar could be successfully loaded.
235 */ 237 */
236 bool openCalendar(QString filename, bool merge=false); 238 bool openCalendar(QString filename, bool merge=false);
237 bool loadCalendars(); 239 bool loadCalendars();
238 bool saveCalendars(); 240 bool saveCalendars();
239 bool restoreCalendarSettings(); 241 bool restoreCalendarSettings();
240 bool addCalendar( KopiCalendarFile * ); 242 bool addCalendar( KopiCalendarFile * );
241 void addCalendarId( int id ); 243 void addCalendarId( int id );
242 bool syncCalendar(QString filename,int mode = 0 ); 244 bool syncCalendar(QString filename,int mode = 0 );
243 245
244 /** 246 /**
245 Save calendar data to file. Return true if calendar could be 247 Save calendar data to file. Return true if calendar could be
246 successfully saved. 248 successfully saved.
247 */ 249 */
248 bool saveCalendar(QString filename); 250 bool saveCalendar(QString filename);
251 bool saveCalendarResource(QString filename, QString resource);
249 252
250 /** 253 /**
251 Close calendar. Clear calendar data and reset views to display an empty 254 Close calendar. Clear calendar data and reset views to display an empty
252 calendar. 255 calendar.
253 */ 256 */
254 void closeCalendar(); 257 void closeCalendar();
255 258
256 /** Archive old events of calendar */ 259 /** Archive old events of calendar */
257 void archiveCalendar(); 260 void archiveCalendar();
258 261
259 void showIncidence(); 262 void showIncidence();
260 void editIncidence(); 263 void editIncidence();
261 void editIncidenceDescription(); 264 void editIncidenceDescription();
262 void deleteIncidence(); 265 void deleteIncidence();
263 void cloneIncidence(); 266 void cloneIncidence();
264 void moveIncidence(); 267 void moveIncidence();
265 void beamIncidence(); 268 void beamIncidence();
266 void toggleCancelIncidence(); 269 void toggleCancelIncidence();
267 270
268 /** create an editeventwin with supplied date/time, and if bool is true, 271 /** create an editeventwin with supplied date/time, and if bool is true,
269 * make the event take all day. */ 272 * make the event take all day. */
270 void newEvent(QDateTime, QDateTime, bool allDay ); 273 void newEvent(QDateTime, QDateTime, bool allDay );
271 void newEvent(QDateTime, QDateTime); 274 void newEvent(QDateTime, QDateTime);
272 void newEvent(QDateTime fh); 275 void newEvent(QDateTime fh);
273 void newEvent(QDate dt); 276 void newEvent(QDate dt);
274 /** create new event without having a date hint. Takes current date as 277 /** create new event without having a date hint. Takes current date as
275 default hint. */ 278 default hint. */
276 void newEvent(); 279 void newEvent();
277 void newFloatingEvent(); 280 void newFloatingEvent();
278 281
279 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ 282 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
280 void showIncidence(Incidence *); 283 void showIncidence(Incidence *);
281 void showIncidence(QString uid); 284 void showIncidence(QString uid);
282 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ 285 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/
283 void editIncidence(Incidence *); 286 void editIncidence(Incidence *);
284 /** Delete the supplied incidence. It calls the correct deleteXXX method*/ 287 /** Delete the supplied incidence. It calls the correct deleteXXX method*/
285 void deleteIncidence(Incidence *); 288 void deleteIncidence(Incidence *);
286 void cloneIncidence(Incidence *); 289 void cloneIncidence(Incidence *);
287 void cancelIncidence(Incidence *); 290 void cancelIncidence(Incidence *);
288 /** Create an editor for the supplied event. */ 291 /** Create an editor for the supplied event. */
289 void editEvent(Event *); 292 void editEvent(Event *);
290 /** Delete the supplied event. */ 293 /** Delete the supplied event. */
291 void deleteEvent(Event *); 294 void deleteEvent(Event *);
292 /** Delete the event with the given unique ID. Returns false, if event wasn't 295 /** Delete the event with the given unique ID. Returns false, if event wasn't
293 found. */ 296 found. */
294 bool deleteEvent(const QString &uid); 297 bool deleteEvent(const QString &uid);
295 /** Create a read-only viewer dialog for the supplied event. */ 298 /** Create a read-only viewer dialog for the supplied event. */
296 void showEvent(Event *); 299 void showEvent(Event *);
297 300
298 void editJournal(Journal *); 301 void editJournal(Journal *);
299 void showJournal(Journal *); 302 void showJournal(Journal *);
300 void deleteJournal(Journal *); 303 void deleteJournal(Journal *);
301 /** Create an editor dialog for a todo */ 304 /** Create an editor dialog for a todo */
302 void editTodo(Todo *); 305 void editTodo(Todo *);
303 /** Create a read-only viewer dialog for the supplied todo */ 306 /** Create a read-only viewer dialog for the supplied todo */
304 void showTodo(Todo *); 307 void showTodo(Todo *);
305 /** create new todo */ 308 /** create new todo */
306 void newTodo(); 309 void newTodo();
307 void newTodoDateTime(QDateTime, bool allday); 310 void newTodoDateTime(QDateTime, bool allday);
308 /** create new todo with a parent todo */ 311 /** create new todo with a parent todo */
309 void newSubTodo(); 312 void newSubTodo();
310 /** create new todo with a parent todo */ 313 /** create new todo with a parent todo */
311 void newSubTodo(Todo *); 314 void newSubTodo(Todo *);
312 /** Delete todo */ 315 /** Delete todo */
313 void deleteTodo(Todo *); 316 void deleteTodo(Todo *);
314 317
315 318
316 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is 319 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is
317 * emitted as result. */ 320 * emitted as result. */
318 void checkClipboard(); 321 void checkClipboard();
319 322
320 /** using the KConfig associated with the kapp variable, read in the 323 /** using the KConfig associated with the kapp variable, read in the
321 * settings from the config file. 324 * settings from the config file.
322 */ 325 */
323 void readSettings(); 326 void readSettings();
324 327
325 /** write current state to config file. */ 328 /** write current state to config file. */
326 void writeSettings(); 329 void writeSettings();
327 330
328 /** read settings for calendar filters */ 331 /** read settings for calendar filters */
329 void readFilterSettings(KConfig *config); 332 void readFilterSettings(KConfig *config);
330 333
331 /** write settings for calendar filters */ 334 /** write settings for calendar filters */
332 void writeFilterSettings(KConfig *config); 335 void writeFilterSettings(KConfig *config);
333 336
334 /** passes on the message that an event has changed to the currently 337 /** passes on the message that an event has changed to the currently
335 * activated view so that it can make appropriate display changes. */ 338 * activated view so that it can make appropriate display changes. */
336 void changeEventDisplay(Event *, int); 339 void changeEventDisplay(Event *, int);
337 void changeIncidenceDisplay(Incidence *, int); 340 void changeIncidenceDisplay(Incidence *, int);
338 void changeTodoDisplay(Todo *, int); 341 void changeTodoDisplay(Todo *, int);
339 342
340 void eventAdded(Event *); 343 void eventAdded(Event *);
341 void eventChanged(Event *); 344 void eventChanged(Event *);
342 void eventToBeDeleted(Event *); 345 void eventToBeDeleted(Event *);
343 void eventDeleted(); 346 void eventDeleted();
344 347
345 void todoAdded(Todo *); 348 void todoAdded(Todo *);
346 void todoChanged(Todo *); 349 void todoChanged(Todo *);
347 void todoToBeDeleted(Todo *); 350 void todoToBeDeleted(Todo *);
348 void todoDeleted(); 351 void todoDeleted();
349 352
350 void updateView(const QDate &start, const QDate &end); 353 void updateView(const QDate &start, const QDate &end);
351 void updateView(); 354 void updateView();
352 void clearAllViews(); 355 void clearAllViews();
353 356
354 /** Full update of visible todo views */ 357 /** Full update of visible todo views */
355 void updateTodoViews(); 358 void updateTodoViews();
356 359
357 void updateUnmanagedViews(); 360 void updateUnmanagedViews();
358 361
359 /** cut the current appointment to the clipboard */ 362 /** cut the current appointment to the clipboard */
360 void edit_cut(); 363 void edit_cut();
361 364
362 /** copy the current appointment(s) to the clipboard */ 365 /** copy the current appointment(s) to the clipboard */
363 void edit_copy(); 366 void edit_copy();
364 367
365 /** paste the current vobject(s) in the clipboard buffer into calendar */ 368 /** paste the current vobject(s) in the clipboard buffer into calendar */
366 void edit_paste(); 369 void edit_paste();
367 370
368 /** edit viewing and configuration options. */ 371 /** edit viewing and configuration options. */
369 void edit_options(); 372 void edit_options();
370 void edit_global_options(); 373 void edit_global_options();
371 /** 374 /**
372 Functions for printing, previewing a print, and setting up printing 375 Functions for printing, previewing a print, and setting up printing
373 parameters. 376 parameters.
374 */ 377 */
375 void print(); 378 void print();
376 void printSetup(); 379 void printSetup();
377 void printPreview(); 380 void printPreview();
378 381
379 /** Export as iCalendar file */ 382 /** Export as iCalendar file */
380 bool exportICalendar(); 383 bool exportICalendar();
381 bool exportICalendar( QString fn ); 384 bool exportICalendar( QString fn );
382 385
383 /** Export as vCalendar file */ 386 /** Export as vCalendar file */
384 bool exportVCalendar( QString fn); 387 bool exportVCalendar( QString fn);
385 388
386 /** pop up a dialog to show an existing appointment. */ 389 /** pop up a dialog to show an existing appointment. */
387 void appointment_show(); 390 void appointment_show();
388 /** 391 /**
389 * pop up an Appointment Dialog to edit an existing appointment.Get 392 * pop up an Appointment Dialog to edit an existing appointment.Get
390 * information on the appointment from the list of unique IDs that is 393 * information on the appointment from the list of unique IDs that is
391 * currently in the View, called currIds. 394 * currently in the View, called currIds.
392 */ 395 */
393 void appointment_edit(); 396 void appointment_edit();
394 /** 397 /**
395 * pop up dialog confirming deletion of currently selected event in the 398 * pop up dialog confirming deletion of currently selected event in the
396 * View. 399 * View.
397 */ 400 */
398 void appointment_delete(); 401 void appointment_delete();
399 402
400 /** mails the currently selected event to a particular user as a vCalendar 403 /** mails the currently selected event to a particular user as a vCalendar
401 attachment. */ 404 attachment. */
402 void action_mail(); 405 void action_mail();
403 406
404 /* frees a subtodo from it's relation */ 407 /* frees a subtodo from it's relation */
405 void todo_unsub( Todo * ); 408 void todo_unsub( Todo * );
406 void todo_resub( Todo * parent, Todo * sub ); 409 void todo_resub( Todo * parent, Todo * sub );
407 410
408 /** Take ownership of selected event. */ 411 /** Take ownership of selected event. */
409 void takeOverEvent(); 412 void takeOverEvent();
410 413
411 /** Take ownership of all events in calendar. */ 414 /** Take ownership of all events in calendar. */
412 void takeOverCalendar(); 415 void takeOverCalendar();
413 416
414 /** query whether or not the calendar is "dirty". */ 417 /** query whether or not the calendar is "dirty". */
415 bool isModified(); 418 bool isModified();
416 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ 419 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */
417 void setModified(bool modified=true); 420 void setModified(bool modified=true);
418 421
419 /** query if the calendar is read-only. */ 422 /** query if the calendar is read-only. */
420 bool isReadOnly(); 423 bool isReadOnly();
421 /** set state of calendar to read-only */ 424 /** set state of calendar to read-only */
422 void setReadOnly(bool readOnly=true); 425 void setReadOnly(bool readOnly=true);
423 426
424 void eventUpdated(Incidence *); 427 void eventUpdated(Incidence *);
425 428
426 /* iTIP scheduling actions */ 429 /* iTIP scheduling actions */
427 void schedule_publish(Incidence *incidence = 0); 430 void schedule_publish(Incidence *incidence = 0);
428 void schedule_request(Incidence *incidence = 0); 431 void schedule_request(Incidence *incidence = 0);
429 void schedule_refresh(Incidence *incidence = 0); 432 void schedule_refresh(Incidence *incidence = 0);
430 void schedule_cancel(Incidence *incidence = 0); 433 void schedule_cancel(Incidence *incidence = 0);
431 void schedule_add(Incidence *incidence = 0); 434 void schedule_add(Incidence *incidence = 0);
432 void schedule_reply(Incidence *incidence = 0); 435 void schedule_reply(Incidence *incidence = 0);
433 void schedule_counter(Incidence *incidence = 0); 436 void schedule_counter(Incidence *incidence = 0);
434 void schedule_declinecounter(Incidence *incidence = 0); 437 void schedule_declinecounter(Incidence *incidence = 0);
435 void schedule_publish_freebusy(int daysToPublish = 30); 438 void schedule_publish_freebusy(int daysToPublish = 30);
436 439
437 void openAddressbook(); 440 void openAddressbook();
438 441
439 void editFilters(); 442 void editFilters();
440 void toggleFilerEnabled(); 443 void toggleFilerEnabled();
441 QPtrList<CalFilter> filters(); 444 QPtrList<CalFilter> filters();
442 void toggleFilter(); 445 void toggleFilter();
443 void showFilter(bool visible); 446 void showFilter(bool visible);
444 void updateFilter(); 447 void updateFilter();
445 void filterEdited(); 448 void filterEdited();
446 void selectFilter( int ); 449 void selectFilter( int );
447 KOFilterView *filterView(); 450 KOFilterView *filterView();
448 451
449 void showIntro(); 452 void showIntro();
450 453
451 /** Move the curdatepient view date to today */ 454 /** Move the curdatepient view date to today */
452 void goToday(); 455 void goToday();
453 456
454 /** Move to the next date(s) in the current view */ 457 /** Move to the next date(s) in the current view */
455 void goNext(); 458 void goNext();
456 459
457 /** Move to the previous date(s) in the current view */ 460 /** Move to the previous date(s) in the current view */
458 void goPrevious(); 461 void goPrevious();
459 /** Move to the next date(s) in the current view */ 462 /** Move to the next date(s) in the current view */
460 void goNextMonth(); 463 void goNextMonth();
461 464
462 /** Move to the previous date(s) in the current view */ 465 /** Move to the previous date(s) in the current view */
463 void goPreviousMonth(); 466 void goPreviousMonth();
464 467
465 void toggleExpand(); 468 void toggleExpand();
466 void toggleDateNavigatorWidget(); 469 void toggleDateNavigatorWidget();
467 void toggleAllDaySize(); 470 void toggleAllDaySize();
468 471
469 /** Look for new messages in the inbox */ 472 /** Look for new messages in the inbox */
470 void lookForIncomingMessages(); 473 void lookForIncomingMessages();
471 /** Look for new messages in the outbox */ 474 /** Look for new messages in the outbox */
472 void lookForOutgoingMessages(); 475 void lookForOutgoingMessages();
473 476
474 void processMainViewSelection( Incidence * ); 477 void processMainViewSelection( Incidence * );
475 void processTodoListSelection( Incidence * ); 478 void processTodoListSelection( Incidence * );
476 479
477 void processIncidenceSelection( Incidence * ); 480 void processIncidenceSelection( Incidence * );
478 481
479 void purgeCompleted(); 482 void purgeCompleted();
480 bool removeCompletedSubTodos( Todo* ); 483 bool removeCompletedSubTodos( Todo* );
481 void slotCalendarChanged(); 484 void slotCalendarChanged();
482 bool importBday(); 485 bool importBday();
483 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); 486 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday );
484 bool importQtopia( const QString &categoriesFile, 487 bool importQtopia( const QString &categoriesFile,
485 const QString &datebookFile, 488 const QString &datebookFile,
486 const QString &tasklistFile ); 489 const QString &tasklistFile );
487 void syncExternal( int mode ); 490 void syncExternal( int mode );
488 void slotSelectPickerDate( QDate ) ; 491 void slotSelectPickerDate( QDate ) ;
489 void showDatePicker() ; 492 void showDatePicker() ;
490 void showDatePickerPopup() ; 493 void showDatePickerPopup() ;
491 void moveIncidence(Incidence *) ; 494 void moveIncidence(Incidence *) ;
492 void beamIncidence(Incidence *) ; 495 void beamIncidence(Incidence *) ;
493 void beamCalendar() ; 496 void beamCalendar() ;
494 void beamFilteredCalendar() ; 497 void beamFilteredCalendar() ;
495 void beamIncidenceList(QPtrList<Incidence>) ; 498 void beamIncidenceList(QPtrList<Incidence>) ;
496 void manageCategories(); 499 void manageCategories();
497 void editCategories(); 500 void editCategories();
498 int addCategories(); 501 int addCategories();
499 void removeCategories(); 502 void removeCategories();
500 void setSyncDevice( QString ); 503 void setSyncDevice( QString );
501 void setSyncName( QString ); 504 void setSyncName( QString );
502 void showDay( QDate ); 505 void showDay( QDate );
503 void undo_delete(); 506 void undo_delete();
504 protected slots: 507 protected slots:
505 void resetFocus(); 508 void resetFocus();
506 void scrollBarValue(int); 509 void scrollBarValue(int);
507 void slotViewerClosed(); 510 void slotViewerClosed();
508 void timerAlarm(); 511 void timerAlarm();
509 void suspendAlarm(); 512 void suspendAlarm();
510 void beamDone( Ir *ir ); 513 void beamDone( Ir *ir );
511 /** Select a view or adapt the current view to display the specified dates. */ 514 /** Select a view or adapt the current view to display the specified dates. */
512 void showDates( const KCal::DateList & ); 515 void showDates( const KCal::DateList & );
513 void selectWeekNum ( int ); 516 void selectWeekNum ( int );
514 void checkConflictForEvent(); 517 void checkConflictForEvent();
515 518
516 public: 519 public:
517 void createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ); 520 void createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval );
518 // show a standard warning 521 // show a standard warning
519 // returns KMsgBox::yesNoCancel() 522 // returns KMsgBox::yesNoCancel()
520 int msgCalModified(); 523 int msgCalModified();
521 virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource); 524 virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource);
522 525
523 virtual bool syncExternal(KSyncManager* manager, QString resource); 526 virtual bool syncExternal(KSyncManager* manager, QString resource);
524 virtual void removeSyncInfo( QString syncProfile); 527 virtual void removeSyncInfo( QString syncProfile);
525 void setSyncManager(KSyncManager* manager); 528 void setSyncManager(KSyncManager* manager);
526 void setLoadedFileVersion(QDateTime); 529 void setLoadedFileVersion(QDateTime);
527 bool checkFileVersion(QString fn); 530 bool checkFileVersion(QString fn);
528 bool checkAllFileVersions(); 531 bool checkAllFileVersions();
529 bool checkFileChanged(QString fn); 532 bool checkFileChanged(QString fn);
530 Event* getLastSyncEvent(); 533 Event* getLastSyncEvent();
531 /** Adapt navigation units correpsonding to step size of navigation of the 534 /** Adapt navigation units correpsonding to step size of navigation of the
532 * current view. 535 * current view.
533 */ 536 */
534 void adaptNavigationUnits(); 537 void adaptNavigationUnits();
535 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); 538 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
536 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 539 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
537 //Attendee* getYourAttendee(Event *event); 540 //Attendee* getYourAttendee(Event *event);
538 void setBlockShowDates( bool b ) { mBlockShowDates = b ;} 541 void setBlockShowDates( bool b ) { mBlockShowDates = b ;}
539 void setScrollBarStep(int val ); 542 void setScrollBarStep(int val );
540 543
541 protected: 544 protected:
545 bool mMultiResourceSync;
542 Event *mConflictingEvent; 546 Event *mConflictingEvent;
543 void schedule(Scheduler::Method, Incidence *incidence = 0); 547 void schedule(Scheduler::Method, Incidence *incidence = 0);
544 548
545 // returns KMsgBox::OKCandel() 549 // returns KMsgBox::OKCandel()
546 int msgItemDelete(const QString name); 550 int msgItemDelete(const QString name);
547 void showEventEditor(); 551 void showEventEditor();
548 void showTodoEditor(); 552 void showTodoEditor();
549 Todo *selectedTodo(); 553 Todo *selectedTodo();
550 private: 554 private:
551#ifdef DESKTOP_VERSION 555#ifdef DESKTOP_VERSION
552 QScrollBar * mDateScrollBar; 556 QScrollBar * mDateScrollBar;
553#endif 557#endif
554 bool flag_blockConflict; 558 bool flag_blockConflict;
555 bool flag_blockScrollBar; 559 bool flag_blockScrollBar;
556 bool flag_checkFileFirsttime; 560 bool flag_checkFileFirsttime;
557 bool flag_clearallviewsEventDisplay; 561 bool flag_clearallviewsEventDisplay;
558 bool flag_clearallviewsupdateView; 562 bool flag_clearallviewsupdateView;
559 QDateTime mNextAlarmDateTime; 563 QDateTime mNextAlarmDateTime;
560 bool mViewerCallerIsSearchDialog; 564 bool mViewerCallerIsSearchDialog;
561 bool mBlockShowDates; 565 bool mBlockShowDates;
562 KSyncManager* mSyncManager; 566 KSyncManager* mSyncManager;
563 AlarmDialog * mAlarmDialog; 567 AlarmDialog * mAlarmDialog;
564 QString mAlarmNotification; 568 QString mAlarmNotification;
565 QString mSuspendAlarmNotification; 569 QString mSuspendAlarmNotification;
566 QTimer* mSuspendTimer; 570 QTimer* mSuspendTimer;
567 QTimer* mAlarmTimer; 571 QTimer* mAlarmTimer;
568 QTimer* mRecheckAlarmTimer; 572 QTimer* mRecheckAlarmTimer;
569 void computeAlarm( QString ); 573 void computeAlarm( QString );
570 void startAlarm( QString, QString ); 574 void startAlarm( QString, QString );
571 void setSyncEventsReadOnly(); 575 void setSyncEventsReadOnly();
572 576
573 QDateTime loadedFileVersion; 577 QDateTime loadedFileVersion;
574 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); 578 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete );
575 void checkExternalId( Incidence * inc ); 579 void checkExternalId( Incidence * inc );
576 int mGlobalSyncMode; 580 int mGlobalSyncMode;
577 QString mCurrentSyncDevice; 581 QString mCurrentSyncDevice;
578 QString mCurrentSyncName; 582 QString mCurrentSyncName;
579 void init(); 583 void init();
580 int mDatePickerMode; 584 int mDatePickerMode;
581 bool mFlagEditDescription; 585 bool mFlagEditDescription;
582 QDateTime mLastCalendarSync; 586 QDateTime mLastCalendarSync;
583 void createPrinter(); 587 void createPrinter();
584 588
585 void calendarModified( bool, Calendar * ); 589 void calendarModified( bool, Calendar * );
586 590
587 CalPrinter *mCalPrinter; 591 CalPrinter *mCalPrinter;
588 592
589 QSplitter *mPanner; 593 QSplitter *mPanner;
590 QSplitter *mLeftSplitter; 594 QSplitter *mLeftSplitter;
591 KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame; 595 KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame;
592 QWidgetStack *mRightFrame; 596 QWidgetStack *mRightFrame;
593 597
594 KDatePicker* mDatePicker; 598 KDatePicker* mDatePicker;
595 QVBox* mDateFrame; 599 QVBox* mDateFrame;
596 600
597 DateNavigatorContainer *mDateNavigator; // widget showing small month view. 601 DateNavigatorContainer *mDateNavigator; // widget showing small month view.
598 602
599 KOFilterView *mFilterView; 603 KOFilterView *mFilterView;
600 KOCalEditView *mCalEditView; 604 KOCalEditView *mCalEditView;
601 605
602 ResourceView *mResourceView; 606 ResourceView *mResourceView;
603 607
604 // calendar object for this viewing instance 608 // calendar object for this viewing instance
605 Calendar *mCalendar; 609 Calendar *mCalendar;
606 610
607 CalendarResourceManager *mResourceManager; 611 CalendarResourceManager *mResourceManager;
608 612
609 FileStorage *mStorage; 613 FileStorage *mStorage;
610 614
611 DateNavigator *mNavigator; 615 DateNavigator *mNavigator;
612 616
613 KOViewManager *mViewManager; 617 KOViewManager *mViewManager;
614 KODialogManager *mDialogManager; 618 KODialogManager *mDialogManager;
615 619
616 // Calendar filters 620 // Calendar filters
617 QPtrList<CalFilter> mFilters; 621 QPtrList<CalFilter> mFilters;
618 622
619 // various housekeeping variables. 623 // various housekeeping variables.
620 bool mModified; // flag indicating if calendar is modified 624 bool mModified; // flag indicating if calendar is modified
621 bool mReadOnly; // flag indicating if calendar is read-only 625 bool mReadOnly; // flag indicating if calendar is read-only
622 QDate mSaveSingleDate; 626 QDate mSaveSingleDate;
623 627
624 Incidence *mSelectedIncidence; 628 Incidence *mSelectedIncidence;
625 Incidence *mMoveIncidence; 629 Incidence *mMoveIncidence;
626 QDate mMoveIncidenceOldDate; 630 QDate mMoveIncidenceOldDate;
627 KOTodoView *mTodoList; 631 KOTodoView *mTodoList;
628 KOEventEditor * mEventEditor; 632 KOEventEditor * mEventEditor;
629 KOTodoEditor * mTodoEditor; 633 KOTodoEditor * mTodoEditor;
630 KOEventViewerDialog * mEventViewerDialog; 634 KOEventViewerDialog * mEventViewerDialog;
631 void keyPressEvent ( QKeyEvent *e) ; 635 void keyPressEvent ( QKeyEvent *e) ;
632 //QMap<Incidence*,KOIncidenceEditor*> mDialogList; 636 //QMap<Incidence*,KOIncidenceEditor*> mDialogList;
633}; 637};
634 638
635 639
636class CalendarViewVisitor : public Incidence::Visitor 640class CalendarViewVisitor : public Incidence::Visitor
637{ 641{
638 public: 642 public:
639 CalendarViewVisitor() : mView( 0 ) {} 643 CalendarViewVisitor() : mView( 0 ) {}
640 644
641 bool act( Incidence *incidence, CalendarView *view ) 645 bool act( Incidence *incidence, CalendarView *view )
642 { 646 {
643 mView = view; 647 mView = view;
644 return incidence->accept( *this ); 648 return incidence->accept( *this );
645 } 649 }
646 650
647 protected: 651 protected:
648 CalendarView *mView; 652 CalendarView *mView;
649}; 653};
650 654
651class ShowIncidenceVisitor : public CalendarViewVisitor 655class ShowIncidenceVisitor : public CalendarViewVisitor
652{ 656{
653 protected: 657 protected:
654 bool visit( Event *event ) { mView->showEvent( event ); return true; } 658 bool visit( Event *event ) { mView->showEvent( event ); return true; }
655 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } 659 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; }
656 bool visit( Journal * j ) { mView->showJournal( j );return true; } 660 bool visit( Journal * j ) { mView->showJournal( j );return true; }
657}; 661};
658 662
659class EditIncidenceVisitor : public CalendarViewVisitor 663class EditIncidenceVisitor : public CalendarViewVisitor
660{ 664{
661 protected: 665 protected:
662 bool visit( Event *event ) { mView->editEvent( event ); return true; } 666 bool visit( Event *event ) { mView->editEvent( event ); return true; }
663 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } 667 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; }
664 bool visit( Journal *j ) { mView->editJournal( j); return true; } 668 bool visit( Journal *j ) { mView->editJournal( j); return true; }
665}; 669};
666 670
667class DeleteIncidenceVisitor : public CalendarViewVisitor 671class DeleteIncidenceVisitor : public CalendarViewVisitor
668{ 672{
669 protected: 673 protected:
670 bool visit( Event *event ) { mView->deleteEvent( event ); return true; } 674 bool visit( Event *event ) { mView->deleteEvent( event ); return true; }
671 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } 675 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; }
672 bool visit( Journal * j) {mView->deleteJournal( j ); return true; } 676 bool visit( Journal * j) {mView->deleteJournal( j ); return true; }
673}; 677};
674 678
675#endif 679#endif
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 66bb19b..69ccde1 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -185,386 +185,388 @@ MainWindow::MainWindow( QWidget *parent, const char *name ) :
185 p->mCurrentDisplayedView = 0; 185 p->mCurrentDisplayedView = 0;
186 if ( p->mHourSize > 22 ) 186 if ( p->mHourSize > 22 )
187 p->mHourSize = 22; 187 p->mHourSize = 22;
188 QMainWindow::ToolBarDock tbd; 188 QMainWindow::ToolBarDock tbd;
189 if ( p->mToolBarHor ) { 189 if ( p->mToolBarHor ) {
190 if ( p->mToolBarUp ) 190 if ( p->mToolBarUp )
191 tbd = Bottom; 191 tbd = Bottom;
192 else 192 else
193 tbd = Top; 193 tbd = Top;
194 } 194 }
195 else { 195 else {
196 if ( p->mToolBarUp ) 196 if ( p->mToolBarUp )
197 tbd = Right; 197 tbd = Right;
198 else 198 else
199 tbd = Left; 199 tbd = Left;
200 } 200 }
201 if ( KOPrefs::instance()->mUseAppColors ) 201 if ( KOPrefs::instance()->mUseAppColors )
202 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 202 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
203 globalFlagBlockStartup = 1; 203 globalFlagBlockStartup = 1;
204 iconToolBar = new QPEToolBar( this ); 204 iconToolBar = new QPEToolBar( this );
205 addToolBar (iconToolBar , tbd ); 205 addToolBar (iconToolBar , tbd );
206 206
207#ifdef DESKTOP_VERSION 207#ifdef DESKTOP_VERSION
208 if ( KOPrefs::instance()->mShowIconFilter ) 208 if ( KOPrefs::instance()->mShowIconFilter )
209#else 209#else
210 if ( KOPrefs::instance()->mShowIconFilter || ( !p->mShowIconOnetoolbar &&!p->mShowIconFilterview ) ) 210 if ( KOPrefs::instance()->mShowIconFilter || ( !p->mShowIconOnetoolbar &&!p->mShowIconFilterview ) )
211#endif 211#endif
212 212
213{ 213{
214 if ( p->mToolBarHorF ) { 214 if ( p->mToolBarHorF ) {
215 if ( p->mToolBarUpF ) 215 if ( p->mToolBarUpF )
216 tbd = Bottom; 216 tbd = Bottom;
217 else 217 else
218 tbd = Top; 218 tbd = Top;
219 } 219 }
220 else { 220 else {
221 if ( p->mToolBarUpF ) 221 if ( p->mToolBarUpF )
222 tbd = Right; 222 tbd = Right;
223 else 223 else
224 tbd = Left; 224 tbd = Left;
225 } 225 }
226 filterToolBar = new QPEToolBar ( this ); 226 filterToolBar = new QPEToolBar ( this );
227 filterMenubar = new KMenuBar( 0 ); 227 filterMenubar = new KMenuBar( 0 );
228 QFontMetrics fm ( filterMenubar->font() ); 228 QFontMetrics fm ( filterMenubar->font() );
229#ifndef DESKTOP_VERSION 229#ifndef DESKTOP_VERSION
230 filterToolBar->setFocusPolicy( NoFocus ); 230 filterToolBar->setFocusPolicy( NoFocus );
231 filterMenubar->setFocusPolicy( NoFocus ); 231 filterMenubar->setFocusPolicy( NoFocus );
232#endif 232#endif
233 filterPopupMenu = new QPopupMenu( this ); 233 filterPopupMenu = new QPopupMenu( this );
234 filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); 234 filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 );
235 QString addTest = "A"; 235 QString addTest = "A";
236 filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) ); 236 filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) );
237#ifdef DESKTOP_VERSION 237#ifdef DESKTOP_VERSION
238 addTest = "AAAAAABBBCCCx"; 238 addTest = "AAAAAABBBCCCx";
239#else 239#else
240 addTest = "AAAAAx"; 240 addTest = "AAAAAx";
241#endif 241#endif
242 filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) ); 242 filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) );
243 addToolBar (filterToolBar , tbd ); 243 addToolBar (filterToolBar , tbd );
244 connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); 244 connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) );
245 connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); 245 connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) );
246 if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar ) 246 if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar )
247 filterToolBar->hide(); 247 filterToolBar->hide();
248 } else { 248 } else {
249 filterToolBar = 0; 249 filterToolBar = 0;
250 filterMenubar = 0; 250 filterMenubar = 0;
251 filterPopupMenu = 0; 251 filterPopupMenu = 0;
252 } 252 }
253 if ( p->mShowIconOnetoolbar ) { 253 if ( p->mShowIconOnetoolbar ) {
254 viewToolBar = iconToolBar ; 254 viewToolBar = iconToolBar ;
255 navigatorToolBar = iconToolBar ; 255 navigatorToolBar = iconToolBar ;
256 } else { 256 } else {
257#ifndef DESKTOP_VERSION 257#ifndef DESKTOP_VERSION
258 setToolBarsMovable( false ); 258 setToolBarsMovable( false );
259#endif 259#endif
260 if ( p->mToolBarHorV ) { 260 if ( p->mToolBarHorV ) {
261 if ( p->mToolBarUpV ) 261 if ( p->mToolBarUpV )
262 tbd = Bottom; 262 tbd = Bottom;
263 else 263 else
264 tbd = Top; 264 tbd = Top;
265 } 265 }
266 else { 266 else {
267 if ( p->mToolBarUpV ) 267 if ( p->mToolBarUpV )
268 tbd = Right; 268 tbd = Right;
269 else 269 else
270 tbd = Left; 270 tbd = Left;
271 } 271 }
272 viewToolBar = new QPEToolBar( this ); 272 viewToolBar = new QPEToolBar( this );
273 addToolBar (viewToolBar , tbd ); 273 addToolBar (viewToolBar , tbd );
274 if ( p->mToolBarHorN ) { 274 if ( p->mToolBarHorN ) {
275 if ( p->mToolBarUpN ) 275 if ( p->mToolBarUpN )
276 tbd = Bottom; 276 tbd = Bottom;
277 else 277 else
278 tbd = Top; 278 tbd = Top;
279 } 279 }
280 else { 280 else {
281 if ( p->mToolBarUpN ) 281 if ( p->mToolBarUpN )
282 tbd = Right; 282 tbd = Right;
283 else 283 else
284 tbd = Left; 284 tbd = Left;
285 } 285 }
286 navigatorToolBar = new QPEToolBar( this ); 286 navigatorToolBar = new QPEToolBar( this );
287 addToolBar (navigatorToolBar , tbd ); 287 addToolBar (navigatorToolBar , tbd );
288 } 288 }
289 289
290 290
291 291
292 mCalendarModifiedFlag = false; 292 mCalendarModifiedFlag = false;
293 // QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 293 // QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
294 //splash->setAlignment ( AlignCenter ); 294 //splash->setAlignment ( AlignCenter );
295 //setCentralWidget( splash ); 295 //setCentralWidget( splash );
296#ifndef DESKTOP_VERSION 296#ifndef DESKTOP_VERSION
297 //showMaximized(); 297 //showMaximized();
298#endif 298#endif
299 299
300 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 300 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
301 setDefaultPreferences(); 301 setDefaultPreferences();
302 mCalendar = new CalendarLocal(); 302 mCalendar = new CalendarLocal();
303 mView = new CalendarView( mCalendar, this,"mCalendar " ); 303 mView = new CalendarView( mCalendar, this,"mCalendar " );
304 setCentralWidget( mView ); 304 setCentralWidget( mView );
305 //mView->hide(); 305 //mView->hide();
306 //mView->resize(splash->size() ); 306 //mView->resize(splash->size() );
307 initActions(); 307 initActions();
308 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); 308 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
309 mSyncManager->setBlockSave(false); 309 mSyncManager->setBlockSave(false);
310 mView->setSyncManager(mSyncManager); 310 mView->setSyncManager(mSyncManager);
311#ifndef DESKTOP_VERSION 311#ifndef DESKTOP_VERSION
312 iconToolBar->show(); 312 iconToolBar->show();
313 qApp->processEvents(); 313 qApp->processEvents();
314#endif 314#endif
315 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 315 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
316 int vh = height() ; 316 int vh = height() ;
317 int vw = width(); 317 int vw = width();
318 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 318 //qDebug("Toolbar hei %d ",iconToolBar->height() );
319 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 319 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
320 vh -= iconToolBar->height(); 320 vh -= iconToolBar->height();
321 } else { 321 } else {
322 vw -= iconToolBar->height(); 322 vw -= iconToolBar->height();
323 } 323 }
324 //mView->setMaximumSize( splash->size() ); 324 //mView->setMaximumSize( splash->size() );
325 //mView->resize( splash->size() ); 325 //mView->resize( splash->size() );
326 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 326 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
327 mView->readSettings(); 327 mView->readSettings();
328 bool newFile = false; 328 bool newFile = false;
329 if( !QFile::exists( defaultFileName() ) ) { 329 if( !QFile::exists( defaultFileName() ) ) {
330 QFileInfo finfo ( defaultFileName() ); 330 QFileInfo finfo ( defaultFileName() );
331 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 331 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
332 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; 332 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
333 finfo.setFile( oldFile ); 333 finfo.setFile( oldFile );
334 if (finfo.exists() ) { 334 if (finfo.exists() ) {
335 KMessageBox::information( this, message); 335 KMessageBox::information( this, message);
336 mView->openCalendar( oldFile ); 336 mView->openCalendar( oldFile );
337 qApp->processEvents(); 337 qApp->processEvents();
338 } else { 338 } else {
339 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 339 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
340 finfo.setFile( oldFile ); 340 finfo.setFile( oldFile );
341 if (finfo.exists() ) { 341 if (finfo.exists() ) {
342 KMessageBox::information( this, message); 342 KMessageBox::information( this, message);
343 mView->openCalendar( oldFile ); 343 mView->openCalendar( oldFile );
344 qApp->processEvents(); 344 qApp->processEvents();
345 } 345 }
346 } 346 }
347 mView->saveCalendar( defaultFileName() ); 347 mView->saveCalendar( defaultFileName() );
348 newFile = true; 348 newFile = true;
349 } 349 }
350 350
351 //QTime neededSaveTime = QDateTime::currentDateTime().time(); 351 //QTime neededSaveTime = QDateTime::currentDateTime().time();
352 //mView->loadCalendars(); 352 //mView->loadCalendars();
353 //int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 353 //int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
354 //qDebug("KO: Calendar loading time: %d ms",msNeeded ); 354 //qDebug("KO: Calendar loading time: %d ms",msNeeded );
355 355
356 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { 356 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) {
357 KOPrefs::instance()->setAllDefaults(); 357 KOPrefs::instance()->setAllDefaults();
358 } 358 }
359 359
360 360
361 connect( mView, SIGNAL( tempDisableBR(bool) ), 361 connect( mView, SIGNAL( tempDisableBR(bool) ),
362 SLOT( disableBR(bool) ) ); 362 SLOT( disableBR(bool) ) );
363 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 363 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
364 setCentralWidget( mView ); 364 setCentralWidget( mView );
365 globalFlagBlockStartup = 0; 365 globalFlagBlockStartup = 0;
366 //mView->show(); 366 //mView->show();
367 //delete splash; 367 //delete splash;
368 if ( newFile ) 368 if ( newFile )
369 mView->updateConfig(); 369 mView->updateConfig();
370 // qApp->processEvents(); 370 // qApp->processEvents();
371 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 371 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
372 //fillSyncMenu(); 372 //fillSyncMenu();
373 373
374 374
375 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 375 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
376 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); 376 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) );
377 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 377 connect(mSyncManager , SIGNAL( request_file(const QString &) ), this, SLOT( syncFileRequest(const QString &) ) );
378 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 378 connect(mSyncManager , SIGNAL( getFile( bool, const QString &)), this, SLOT(getFile( bool,const QString & ) ) );
379 connect(mSyncManager , SIGNAL( multiResourceSyncStart( bool )), mView, SLOT( multiResourceSyncStart( bool ) ) );
380
379 mSyncManager->setDefaultFileName( sentSyncFile()); 381 mSyncManager->setDefaultFileName( sentSyncFile());
380 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); 382 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
381 mSyncManager->fillSyncMenu(); 383 mSyncManager->fillSyncMenu();
382 384
383 385
384 386
385 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 387 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
386 if ( showWarning ) { 388 if ( showWarning ) {
387 KMessageBox::information( this, 389 KMessageBox::information( this,
388 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); 390 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
389 //qApp->processEvents(); 391 //qApp->processEvents();
390 mView->dialogManager()->showSyncOptions(); 392 mView->dialogManager()->showSyncOptions();
391 } 393 }
392 394
393 //US listen for result adressed from Ka/Pi 395 //US listen for result adressed from Ka/Pi
394 396
395#ifndef DESKTOP_VERSION 397#ifndef DESKTOP_VERSION
396 infrared = 0; 398 infrared = 0;
397#endif 399#endif
398 updateFilterToolbar(); 400 updateFilterToolbar();
399 updateWeek( mView->startDate() ); 401 updateWeek( mView->startDate() );
400 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), 402 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
401 SLOT( updateWeekNum( const KCal::DateList & ) ) ); 403 SLOT( updateWeekNum( const KCal::DateList & ) ) );
402 mBRdisabled = false; 404 mBRdisabled = false;
403 //toggleBeamReceive(); 405 //toggleBeamReceive();
404 406
405 setCaption(i18n("Loading calendar files ... please wait" )); 407 setCaption(i18n("Loading calendar files ... please wait" ));
406 mSaveDelay = 0; 408 mSaveDelay = 0;
407 QTimer::singleShot( 10, this, SLOT ( loadDataAfterStart() )); 409 QTimer::singleShot( 10, this, SLOT ( loadDataAfterStart() ));
408} 410}
409MainWindow::~MainWindow() 411MainWindow::~MainWindow()
410{ 412{
411 //qDebug("MainWindow::~MainWindow() "); 413 //qDebug("MainWindow::~MainWindow() ");
412 //save toolbar location 414 //save toolbar location
413 delete mCalendar; 415 delete mCalendar;
414 delete mSyncManager; 416 delete mSyncManager;
415#ifndef DESKTOP_VERSION 417#ifndef DESKTOP_VERSION
416 if ( infrared ) 418 if ( infrared )
417 delete infrared; 419 delete infrared;
418#endif 420#endif
419 421
420 422
421} 423}
422 424
423void MainWindow::loadDataAfterStart() 425void MainWindow::loadDataAfterStart()
424{ 426{
425 qDebug("KO: Start loading files..." ); 427 qDebug("KO: Start loading files..." );
426 QTime neededSaveTime = QDateTime::currentDateTime().time(); 428 QTime neededSaveTime = QDateTime::currentDateTime().time();
427 mView->loadCalendars(); 429 mView->loadCalendars();
428 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 430 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
429 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 431 qDebug("KO: Calendar loading time: %d ms",msNeeded );
430 //QTimer::singleShot( 1000, mView, SLOT ( checkFiles() )); 432 //QTimer::singleShot( 1000, mView, SLOT ( checkFiles() ));
431 mView->setModified( false ); 433 mView->setModified( false );
432 mBlockAtStartup = false; 434 mBlockAtStartup = false;
433 mView->setModified( false ); 435 mView->setModified( false );
434 connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); 436 connect(mView , SIGNAL( save() ), this, SLOT( save() ) );
435 processIncidenceSelection( 0 ); 437 processIncidenceSelection( 0 );
436 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 438 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
437 SLOT( processIncidenceSelection( Incidence * ) ) ); 439 SLOT( processIncidenceSelection( Incidence * ) ) );
438 connect( mView, SIGNAL( modifiedChanged( bool ) ), 440 connect( mView, SIGNAL( modifiedChanged( bool ) ),
439 SLOT( slotModifiedChanged( bool ) ) ); 441 SLOT( slotModifiedChanged( bool ) ) );
440#ifndef DESKTOP_VERSION 442#ifndef DESKTOP_VERSION
441 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 443 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
442 connect( qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT(recieve( const QCString&, const QByteArray& ))); 444 connect( qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT(recieve( const QCString&, const QByteArray& )));
443 disconnect( qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT(receiveStart( const QCString&, const QByteArray& ))); 445 disconnect( qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT(receiveStart( const QCString&, const QByteArray& )));
444 if ( !mCStringMess.isEmpty() ) 446 if ( !mCStringMess.isEmpty() )
445 recieve( mCStringMess, mByteData ); 447 recieve( mCStringMess, mByteData );
446#endif 448#endif
447 QTimer::singleShot( 1000, mView, SLOT ( checkFiles() )); 449 QTimer::singleShot( 1000, mView, SLOT ( checkFiles() ));
448} 450}
449 451
450void MainWindow::slotResetFocus() 452void MainWindow::slotResetFocus()
451{ 453{
452 //qDebug(" CalendarView::slotResetFocus() %x %x %x %x", qApp->focusWidget(), menuBar1, mView,iconToolBar); 454 //qDebug(" CalendarView::slotResetFocus() %x %x %x %x", qApp->focusWidget(), menuBar1, mView,iconToolBar);
453 mFocusLoop = 3; 455 mFocusLoop = 3;
454 QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() )); 456 QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() ));
455} 457}
456void MainWindow::slotResetFocusLoop() 458void MainWindow::slotResetFocusLoop()
457{ 459{
458 --mFocusLoop; 460 --mFocusLoop;
459 QWidget* fw = mView->viewManager()->currentView(); 461 QWidget* fw = mView->viewManager()->currentView();
460 if ( fw ) { 462 if ( fw ) {
461 //qDebug("loop "); 463 //qDebug("loop ");
462 fw->setFocus(); 464 fw->setFocus();
463 if ( qApp->focusWidget() != fw && mFocusLoop > 0 ) 465 if ( qApp->focusWidget() != fw && mFocusLoop > 0 )
464 QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() )); 466 QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() ));
465 } 467 }
466 468
467} 469}
468void MainWindow::disableBR(bool b) 470void MainWindow::disableBR(bool b)
469{ 471{
470#ifndef DESKTOP_VERSION 472#ifndef DESKTOP_VERSION
471 if ( b ) { 473 if ( b ) {
472 if ( infrared ) { 474 if ( infrared ) {
473 toggleBeamReceive(); 475 toggleBeamReceive();
474 mBRdisabled = true; 476 mBRdisabled = true;
475 } 477 }
476 mBRdisabled = true; 478 mBRdisabled = true;
477 } else { 479 } else {
478 if ( mBRdisabled ) { 480 if ( mBRdisabled ) {
479 mBRdisabled = false; 481 mBRdisabled = false;
480 //makes no sense,because other cal ap is probably running 482 //makes no sense,because other cal ap is probably running
481 // toggleBeamReceive(); 483 // toggleBeamReceive();
482 } 484 }
483 } 485 }
484#endif 486#endif
485 487
486} 488}
487bool MainWindow::beamReceiveEnabled() 489bool MainWindow::beamReceiveEnabled()
488{ 490{
489#ifndef DESKTOP_VERSION 491#ifndef DESKTOP_VERSION
490 return ( infrared != 0 ); 492 return ( infrared != 0 );
491#endif 493#endif
492 return false; 494 return false;
493} 495}
494 496
495void MainWindow::toggleBeamReceive() 497void MainWindow::toggleBeamReceive()
496{ 498{
497 if ( mBRdisabled ) 499 if ( mBRdisabled )
498 return; 500 return;
499#ifndef DESKTOP_VERSION 501#ifndef DESKTOP_VERSION
500 if ( infrared ) { 502 if ( infrared ) {
501 qDebug("KO: Disable BeamReceive "); 503 qDebug("KO: Disable BeamReceive ");
502 delete infrared; 504 delete infrared;
503 infrared = 0; 505 infrared = 0;
504 brAction->setOn(false); 506 brAction->setOn(false);
505 return; 507 return;
506 } 508 }
507 qDebug("KO: Enable BeamReceive "); 509 qDebug("KO: Enable BeamReceive ");
508 brAction->setOn(true); 510 brAction->setOn(true);
509 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; 511 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ;
510 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); 512 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& )));
511#endif 513#endif
512} 514}
513void MainWindow::showMaximized () 515void MainWindow::showMaximized ()
514{ 516{
515#ifndef DESKTOP_VERSION 517#ifndef DESKTOP_VERSION
516 if ( ! globalFlagBlockStartup ) 518 if ( ! globalFlagBlockStartup )
517 if ( mClosed ) 519 if ( mClosed )
518 mView->goToday(); 520 mView->goToday();
519#endif 521#endif
520 QWidget::showMaximized () ; 522 QWidget::showMaximized () ;
521 mClosed = false; 523 mClosed = false;
522} 524}
523 525
524bool MainWindow::askForQuitOnSaveError() 526bool MainWindow::askForQuitOnSaveError()
525{ 527{
526 bool retval = false; 528 bool retval = false;
527 switch( QMessageBox::information( this, "KO/Pi", 529 switch( QMessageBox::information( this, "KO/Pi",
528 i18n("Error saving data") + "!\n" + 530 i18n("Error saving data") + "!\n" +
529 i18n("You can save all data\nto another file via\nFile->Export->Export All Data") + "!\n" + 531 i18n("You can save all data\nto another file via\nFile->Export->Export All Data") + "!\n" +
530 i18n("Do you really want\nto close KO/Pi?"), 532 i18n("Do you really want\nto close KO/Pi?"),
531 i18n(" Yes, close "), i18n("No"), 533 i18n(" Yes, close "), i18n("No"),
532 0, 1 ) ) { 534 0, 1 ) ) {
533 case 0: 535 case 0:
534 retval = true; 536 retval = true;
535 break; 537 break;
536 default: 538 default:
537 break; 539 break;
538 } 540 }
539 return retval; 541 return retval;
540} 542}
541bool MainWindow::checkAutosave() 543bool MainWindow::checkAutosave()
542{ 544{
543 bool savedata = true; 545 bool savedata = true;
544 if ( mAutoSaveDisabled && mCalendarModifiedFlag ) { 546 if ( mAutoSaveDisabled && mCalendarModifiedFlag ) {
545 switch( QMessageBox::information( this, "KO/Pi", 547 switch( QMessageBox::information( this, "KO/Pi",
546 i18n("Calendar is modified\nbut Autosave is disabled!\nDo you want\nto save the data?"), 548 i18n("Calendar is modified\nbut Autosave is disabled!\nDo you want\nto save the data?"),
547 i18n("Yes, Save!"), i18n("No"), 549 i18n("Yes, Save!"), i18n("No"),
548 0, 0 ) ) { 550 0, 0 ) ) {
549 case 1: 551 case 1:
550 case 2: 552 case 2:
551 savedata = false; 553 savedata = false;
552 break; 554 break;
553 default: 555 default:
554 break; 556 break;
555 } 557 }
556 } 558 }
557 return savedata; 559 return savedata;
558} 560}
559void MainWindow::closeEvent( QCloseEvent* ce ) 561void MainWindow::closeEvent( QCloseEvent* ce )
560{ 562{
561 if ( ! KOPrefs::instance()->mAskForQuit ) { 563 if ( ! KOPrefs::instance()->mAskForQuit ) {
562 if ( checkAutosave() ) { 564 if ( checkAutosave() ) {
563 saveOnClose(); 565 saveOnClose();
564 if ( mCalendarModifiedFlag && !askForQuitOnSaveError() ) { 566 if ( mCalendarModifiedFlag && !askForQuitOnSaveError() ) {
565 ce->ignore(); 567 ce->ignore();
566 return; 568 return;
567 } 569 }
568 } 570 }
569 mClosed = true; 571 mClosed = true;
570 ce->accept(); 572 ce->accept();
@@ -2515,307 +2517,307 @@ void MainWindow::setCaptionToDates()
2515 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 2517 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
2516 else { 2518 else {
2517 QString addString; 2519 QString addString;
2518 if ( date == QDateTime::currentDateTime().date() ) 2520 if ( date == QDateTime::currentDateTime().date() )
2519 addString = i18n("Today"); 2521 addString = i18n("Today");
2520 else if ( date == QDateTime::currentDateTime().date().addDays(1) ) 2522 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
2521 addString = i18n("Tomorrow"); 2523 addString = i18n("Tomorrow");
2522 if ( !addString.isEmpty() ) 2524 if ( !addString.isEmpty() )
2523 selDates = addString+", "+selDates ; 2525 selDates = addString+", "+selDates ;
2524 } 2526 }
2525 setCaption( i18n("Dates: ") + selDates ); 2527 setCaption( i18n("Dates: ") + selDates );
2526 2528
2527} 2529}
2528void MainWindow::showConfigureAgenda( ) 2530void MainWindow::showConfigureAgenda( )
2529{ 2531{
2530 int iii; 2532 int iii;
2531 for ( iii = 1;iii<= 10 ;++iii ){ 2533 for ( iii = 1;iii<= 10 ;++iii ){
2532 configureAgendaMenu->setItemChecked( (iii+1)*2, false ); 2534 configureAgendaMenu->setItemChecked( (iii+1)*2, false );
2533 } 2535 }
2534 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); 2536 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true );
2535} 2537}
2536void MainWindow::configureAgenda( int item ) 2538void MainWindow::configureAgenda( int item )
2537{ 2539{
2538 if ( KOPrefs::instance()->mHourSize == item ) 2540 if ( KOPrefs::instance()->mHourSize == item )
2539 return; 2541 return;
2540 KOPrefs::instance()->mHourSize=item; 2542 KOPrefs::instance()->mHourSize=item;
2541 mView->viewManager()->agendaView()->updateConfig(); 2543 mView->viewManager()->agendaView()->updateConfig();
2542} 2544}
2543 2545
2544void MainWindow::saveCalendar() 2546void MainWindow::saveCalendar()
2545{ 2547{
2546 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; 2548 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir;
2547 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) 2549 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir)
2548 bupDir = KGlobalSettings::backupDataDir(); 2550 bupDir = KGlobalSettings::backupDataDir();
2549 bupDir = KGlobal::formatMessage ( bupDir, 0 ); 2551 bupDir = KGlobal::formatMessage ( bupDir, 0 );
2550 QString bupHint; 2552 QString bupHint;
2551 if ( !KPimGlobalPrefs::instance()->mBackupEnabled ) 2553 if ( !KPimGlobalPrefs::instance()->mBackupEnabled )
2552 bupHint = i18n("(Hint: You can enable automatic backup in the global settings!)"); 2554 bupHint = i18n("(Hint: You can enable automatic backup in the global settings!)");
2553 if ( KMessageBox::warningContinueCancel( this, i18n("This will <b>backup all calendar files</b> to the directory %1 %2").arg(bupDir).arg(bupHint),i18n("Information") ) != KMessageBox::Continue ) return; 2555 if ( KMessageBox::warningContinueCancel( this, i18n("This will <b>backup all calendar files</b> to the directory %1 %2").arg(bupDir).arg(bupHint),i18n("Information") ) != KMessageBox::Continue ) return;
2554 bool enabled = KPimGlobalPrefs::instance()->mBackupEnabled; 2556 bool enabled = KPimGlobalPrefs::instance()->mBackupEnabled;
2555 KPimGlobalPrefs::instance()->mBackupEnabled = false; 2557 KPimGlobalPrefs::instance()->mBackupEnabled = false;
2556 save(); 2558 save();
2557#ifndef DESKTOP_VERSION 2559#ifndef DESKTOP_VERSION
2558 //QPEApplication::setTempScreenSaverMode ( QPEApplication::Disable ); 2560 //QPEApplication::setTempScreenSaverMode ( QPEApplication::Disable );
2559#endif 2561#endif
2560 KPimGlobalPrefs::instance()->mBackupEnabled = enabled; 2562 KPimGlobalPrefs::instance()->mBackupEnabled = enabled;
2561 backupAllFiles(); 2563 backupAllFiles();
2562#ifndef DESKTOP_VERSION 2564#ifndef DESKTOP_VERSION
2563 //QPEApplication::setTempScreenSaverMode ( QPEApplication::Enable ); 2565 //QPEApplication::setTempScreenSaverMode ( QPEApplication::Enable );
2564#endif 2566#endif
2565} 2567}
2566void MainWindow::loadCalendar() 2568void MainWindow::loadCalendar()
2567{ 2569{
2568 2570
2569 2571
2570#if 0 2572#if 0
2571 QString fn = KOPrefs::instance()->mLastLoadFile; 2573 QString fn = KOPrefs::instance()->mLastLoadFile;
2572 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 2574 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
2573 2575
2574 if ( fn == "" ) 2576 if ( fn == "" )
2575 return; 2577 return;
2576 QFileInfo info; 2578 QFileInfo info;
2577 info.setFile( fn ); 2579 info.setFile( fn );
2578 QString mess; 2580 QString mess;
2579 bool loadbup = true; 2581 bool loadbup = true;
2580 if ( info. exists() ) { 2582 if ( info. exists() ) {
2581 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 2583 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2582 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 2584 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
2583 mess, 2585 mess,
2584 i18n("Load!"), i18n("Cancel"), 0, 2586 i18n("Load!"), i18n("Cancel"), 0,
2585 0, 1 ); 2587 0, 1 );
2586 if ( result != 0 ) { 2588 if ( result != 0 ) {
2587 loadbup = false; 2589 loadbup = false;
2588 } 2590 }
2589 } else { 2591 } else {
2590 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2592 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2591 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 2593 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
2592 0, 1 ); 2594 0, 1 );
2593 2595
2594 return; 2596 return;
2595 } 2597 }
2596 if ( loadbup ) { 2598 if ( loadbup ) {
2597 mView->openCalendar( fn ); 2599 mView->openCalendar( fn );
2598 KOPrefs::instance()->mLastLoadFile = fn; 2600 KOPrefs::instance()->mLastLoadFile = fn;
2599 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 2601 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
2600 setCaption(mess); 2602 setCaption(mess);
2601 } 2603 }
2602#endif 2604#endif
2603 2605
2604} 2606}
2605void MainWindow::quickImportIcal() 2607void MainWindow::quickImportIcal()
2606{ 2608{
2607 importFile( KOPrefs::instance()->mLastImportFile, false ); 2609 importFile( KOPrefs::instance()->mLastImportFile, false );
2608} 2610}
2609void MainWindow::importFile( QString fn, bool quick ) 2611void MainWindow::importFile( QString fn, bool quick )
2610{ 2612{
2611 QFileInfo info; 2613 QFileInfo info;
2612 info.setFile( fn ); 2614 info.setFile( fn );
2613 QString mess; 2615 QString mess;
2614 if ( !info. exists() ) { 2616 if ( !info. exists() ) {
2615 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 2617 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
2616 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2618 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2617 mess ); 2619 mess );
2618 return; 2620 return;
2619 } 2621 }
2620 int result = 0; 2622 int result = 0;
2621 if ( !quick ) { 2623 if ( !quick ) {
2622 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 2624 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2623 result = QMessageBox::warning( this, "KO/Pi: Warning!", 2625 result = QMessageBox::warning( this, "KO/Pi: Warning!",
2624 mess, 2626 mess,
2625 "Import", "Cancel", 0, 2627 "Import", "Cancel", 0,
2626 0, 1 ); 2628 0, 1 );
2627 } 2629 }
2628 if ( result == 0 ) { 2630 if ( result == 0 ) {
2629 if ( mView->openCalendar( fn, true )) { 2631 if ( mView->openCalendar( fn, true )) {
2630 KOPrefs::instance()->mLastImportFile = fn; 2632 KOPrefs::instance()->mLastImportFile = fn;
2631 setCaption(i18n("Imported file successfully")); 2633 setCaption(i18n("Imported file successfully"));
2632 } else { 2634 } else {
2633 setCaption(i18n("Error importing file")); 2635 setCaption(i18n("Error importing file"));
2634 } 2636 }
2635 mView->updateView(); 2637 mView->updateView();
2636 } 2638 }
2637} 2639}
2638 2640
2639void MainWindow::importIcal() 2641void MainWindow::importIcal()
2640{ 2642{
2641 2643
2642 QString fn =KOPrefs::instance()->mLastImportFile; 2644 QString fn =KOPrefs::instance()->mLastImportFile;
2643 2645
2644 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 2646 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
2645 if ( fn == "" ) 2647 if ( fn == "" )
2646 return; 2648 return;
2647 importFile( fn, true ); 2649 importFile( fn, true );
2648 2650
2649} 2651}
2650void MainWindow::exportCalendar( bool iCalFormat ) 2652void MainWindow::exportCalendar( bool iCalFormat )
2651{ 2653{
2652 QString fn = KOPrefs::instance()->mLastVcalFile; 2654 QString fn = KOPrefs::instance()->mLastVcalFile;
2653 if ( iCalFormat ) { 2655 if ( iCalFormat ) {
2654 fn = QDir::homeDirPath()+"/kopiexport.ics"; 2656 fn = QDir::homeDirPath()+"/kopiexport.ics";
2655 fn = KFileDialog::getSaveFileName( fn, i18n("Export iCal filename(*.ics)"), this ); 2657 fn = KFileDialog::getSaveFileName( fn, i18n("Export iCal filename(*.ics)"), this );
2656 } 2658 }
2657 else 2659 else
2658 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 2660 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
2659 if ( fn == "" ) 2661 if ( fn == "" )
2660 return; 2662 return;
2661 QFileInfo info; 2663 QFileInfo info;
2662 info.setFile( fn ); 2664 info.setFile( fn );
2663 QString mes; 2665 QString mes;
2664 bool createbup = true; 2666 bool createbup = true;
2665 if ( info. exists() ) { 2667 if ( info. exists() ) {
2666 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 2668 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
2667 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 2669 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
2668 i18n("Overwrite!"), i18n("Cancel"), 0, 2670 i18n("Overwrite!"), i18n("Cancel"), 0,
2669 0, 1 ); 2671 0, 1 );
2670 if ( result != 0 ) { 2672 if ( result != 0 ) {
2671 createbup = false; 2673 createbup = false;
2672 } 2674 }
2673 } 2675 }
2674 if ( createbup ) { 2676 if ( createbup ) {
2675 bool success = false; 2677 bool success = false;
2676 if ( iCalFormat ) 2678 if ( iCalFormat )
2677 success = mView->exportICalendar( fn ); 2679 success = mView->exportICalendar( fn );
2678 else 2680 else
2679 success = mView->exportVCalendar( fn ); 2681 success = mView->exportVCalendar( fn );
2680 if ( success ) { 2682 if ( success ) {
2681 if ( fn.length() > 20 ) 2683 if ( fn.length() > 20 )
2682 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 2684 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
2683 else 2685 else
2684 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 2686 mes = i18n("KO/Pi:Exported to %1").arg(fn );
2685 setCaption(mes); 2687 setCaption(mes);
2686 } 2688 }
2687 } 2689 }
2688 2690
2689} 2691}
2690void MainWindow::exportICalendar() 2692void MainWindow::exportICalendar()
2691{ 2693{
2692 exportCalendar( true ); 2694 exportCalendar( true );
2693} 2695}
2694void MainWindow::exportVCalendar() 2696void MainWindow::exportVCalendar()
2695{ 2697{
2696 exportCalendar( false ); 2698 exportCalendar( false );
2697} 2699}
2698QString MainWindow::sentSyncFile() 2700QString MainWindow::sentSyncFile()
2699{ 2701{
2700#ifdef DESKTOP_VERSION 2702#ifdef DESKTOP_VERSION
2701 return QDir::convertSeparators( locateLocal( "tmp", "copysynccal.ics" ) ); 2703 return QDir::convertSeparators( locateLocal( "tmp", "copysynccal.ics" ) );
2702#else 2704#else
2703 return QString( "/tmp/copysynccal.ics" ); 2705 return QString( "/tmp/copysynccal.ics" );
2704#endif 2706#endif
2705} 2707}
2706 2708
2707void MainWindow::syncFileRequest() 2709void MainWindow::syncFileRequest(const QString& resource)
2708{ 2710{
2709 while ( mSyncManager->blockSave() ) { 2711 while ( mSyncManager->blockSave() ) {
2710 qApp->processEvents(); 2712 qApp->processEvents();
2711 } 2713 }
2712 mSyncManager->setBlockSave(true); 2714 mSyncManager->setBlockSave(true);
2713 2715
2714 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2716 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2715 mSyncManager->slotSyncMenu( 999 ); 2717 mSyncManager->slotSyncMenu( 999 );
2716 } 2718 }
2717 2719
2718 setCaption(i18n("Saving Data to temp file ..." )); 2720 setCaption(i18n("Saving Data to temp file ..." ));
2719 mView->saveCalendar( sentSyncFile() ); 2721 mView->saveCalendarResource( sentSyncFile(), resource );
2720 setCaption(i18n("Data saved to temp file!" )); 2722 setCaption(i18n("Data saved to temp file!" ));
2721 mSyncManager->setBlockSave( false ); 2723 mSyncManager->setBlockSave( false );
2722 2724
2723} 2725}
2724void MainWindow::getFile( bool success ) 2726void MainWindow::getFile( bool success ,const QString& resource)
2725{ 2727{
2726 if ( ! success ) { 2728 if ( ! success ) {
2727 setCaption( i18n("Error receiving file. Nothing changed!") ); 2729 setCaption( i18n("Error receiving file. Nothing changed!") );
2728 return; 2730 return;
2729 } 2731 }
2730 mView->mergeFile( sentSyncFile() ); 2732 mView->mergeFileResource( sentSyncFile(), resource);
2731 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2733 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2732 mSyncManager->slotSyncMenu( 999 ); 2734 mSyncManager->slotSyncMenu( 999 );
2733 } 2735 }
2734 setCaption( i18n("Pi-Sync successful!") ); 2736 setCaption( i18n("Pi-Sync successful!") );
2735} 2737}
2736void MainWindow::printListView() 2738void MainWindow::printListView()
2737{ 2739{
2738 2740
2739 QString message = i18n("You can make a printout of the <b>List View</b> and the list view in the <b>Search Dialog</b>! To do this, please go to the <b>List View/Search Dialog</b>. Right click on the list. Select in the popup menu the entry <b>Print complete list</b>. That prints the list as you see it. You can remove items from the list before printing without deleting the corresponding event/todo! Simply select all items you do not want to print out. Then right click on one of the items and choose <b>Hide selected items</b>. After that you can print the list without these items."); 2741 QString message = i18n("You can make a printout of the <b>List View</b> and the list view in the <b>Search Dialog</b>! To do this, please go to the <b>List View/Search Dialog</b>. Right click on the list. Select in the popup menu the entry <b>Print complete list</b>. That prints the list as you see it. You can remove items from the list before printing without deleting the corresponding event/todo! Simply select all items you do not want to print out. Then right click on one of the items and choose <b>Hide selected items</b>. After that you can print the list without these items.");
2740 2742
2741 KMessageBox::information( this, message); 2743 KMessageBox::information( this, message);
2742} 2744}
2743void MainWindow::printSel( ) 2745void MainWindow::printSel( )
2744{ 2746{
2745 mView->viewManager()->agendaView()->agenda()->printSelection(); 2747 mView->viewManager()->agendaView()->agenda()->printSelection();
2746} 2748}
2747 2749
2748void MainWindow::printCal() 2750void MainWindow::printCal()
2749{ 2751{
2750 mView->print();//mCp->showDialog(); 2752 mView->print();//mCp->showDialog();
2751} 2753}
2752 2754
2753 2755
2754#include "libkdepim/kdatepicker.h" 2756#include "libkdepim/kdatepicker.h"
2755#include <kdatetbl.h> 2757#include <kdatetbl.h>
2756 2758
2757void MainWindow::weekAction() 2759void MainWindow::weekAction()
2758{ 2760{
2759 int month; 2761 int month;
2760 KPopupFrame* popup = new KPopupFrame(this); 2762 KPopupFrame* popup = new KPopupFrame(this);
2761 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); 2763 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup);
2762 // ----- 2764 // -----
2763 picker->resize(picker->sizeHint()); 2765 picker->resize(picker->sizeHint());
2764 popup->setMainWidget(picker); 2766 popup->setMainWidget(picker);
2765 picker->setFocus(); 2767 picker->setFocus();
2766 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); 2768 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
2767 int x = 0; 2769 int x = 0;
2768 int y = iconToolBar->height(); 2770 int y = iconToolBar->height();
2769 int dX = 0; 2771 int dX = 0;
2770 int dY = 0; 2772 int dY = 0;
2771 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 2773 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
2772 if ( iconToolBar->y() > height()/2 ) { 2774 if ( iconToolBar->y() > height()/2 ) {
2773 dY = picker->sizeHint().height()+8; 2775 dY = picker->sizeHint().height()+8;
2774 y = 0; 2776 y = 0;
2775 } 2777 }
2776 } else { 2778 } else {
2777 if ( iconToolBar->x() > width()/2 ) { // right side 2779 if ( iconToolBar->x() > width()/2 ) { // right side
2778 x=0; 2780 x=0;
2779 dX= picker->sizeHint().width()+8; 2781 dX= picker->sizeHint().width()+8;
2780 y = 0; 2782 y = 0;
2781 } else { 2783 } else {
2782 x= iconToolBar->width(); 2784 x= iconToolBar->width();
2783 y = 0; 2785 y = 0;
2784 } 2786 }
2785 } 2787 }
2786 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); 2788 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() );
2787 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) 2789 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))))
2788 { 2790 {
2789 month = picker->getResult(); 2791 month = picker->getResult();
2790 emit selectWeek ( month ); 2792 emit selectWeek ( month );
2791 //qDebug("weekSelected %d ", month); 2793 //qDebug("weekSelected %d ", month);
2792 } 2794 }
2793 delete popup; 2795 delete popup;
2794} 2796}
2795 2797
2796void MainWindow::hideEvent ( QHideEvent * ) 2798void MainWindow::hideEvent ( QHideEvent * )
2797{ 2799{
2798 QString message; 2800 QString message;
2799 QDateTime nextA = mCalendar->nextAlarmEventDateTime(); 2801 QDateTime nextA = mCalendar->nextAlarmEventDateTime();
2800 if ( nextA.isValid() ) { 2802 if ( nextA.isValid() ) {
2801 QString sum = mCalendar->nextSummary(); 2803 QString sum = mCalendar->nextSummary();
2802 2804
2803 message = i18n("%1 %2 - %3 (next event/todo with alarm)").arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDate(nextA.date() , false)); 2805 message = i18n("%1 %2 - %3 (next event/todo with alarm)").arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDate(nextA.date() , false));
2804 setCaption( message ); 2806 setCaption( message );
2805 } 2807 }
2806} 2808}
2807 2809
2808void MainWindow::resizeEvent( QResizeEvent* e) 2810void MainWindow::resizeEvent( QResizeEvent* e)
2809{ 2811{
2810#ifndef DESKTOP_VERSION 2812#ifndef DESKTOP_VERSION
2811 if ( filterToolBar ) { 2813 if ( filterToolBar ) {
2812 if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) { 2814 if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) {
2813 if (QApplication::desktop()->width() > QApplication::desktop()->height() ) 2815 if (QApplication::desktop()->width() > QApplication::desktop()->height() )
2814 filterToolBar->hide(); 2816 filterToolBar->hide();
2815 else 2817 else
2816 filterToolBar->show(); 2818 filterToolBar->show();
2817 } 2819 }
2818 } 2820 }
2819#endif 2821#endif
2820 QMainWindow::resizeEvent( e); 2822 QMainWindow::resizeEvent( e);
2821} 2823}
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index d8018b6..a533d8b 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -1,191 +1,191 @@
1#ifndef KORGE_MAINWINDOW_H 1#ifndef KORGE_MAINWINDOW_H
2#define KORGE_MAINWINDOW_H 2#define KORGE_MAINWINDOW_H
3 3
4#include <qmainwindow.h> 4#include <qmainwindow.h>
5#include <qtimer.h> 5#include <qtimer.h>
6#include <qdict.h> 6#include <qdict.h>
7#include <qfile.h> 7#include <qfile.h>
8#include <qmenubar.h> 8#include <qmenubar.h>
9#include <qtextstream.h> 9#include <qtextstream.h>
10#include <qregexp.h> 10#include <qregexp.h>
11 11
12#include <libkcal/incidence.h> 12#include <libkcal/incidence.h>
13#include <ksyncmanager.h> 13#include <ksyncmanager.h>
14#include <kpopupmenu.h> 14#include <kpopupmenu.h>
15#ifndef DESKTOP_VERSION 15#ifndef DESKTOP_VERSION
16#include <qcopchannel_qws.h> 16#include <qcopchannel_qws.h>
17#endif 17#endif
18class QAction; 18class QAction;
19class CalendarView; 19class CalendarView;
20class KSyncProfile; 20class KSyncProfile;
21#ifdef DESKTOP_VERSION 21#ifdef DESKTOP_VERSION
22 22
23#define QPEToolBar QToolBar 23#define QPEToolBar QToolBar
24#endif 24#endif
25class QPEToolBar; 25class QPEToolBar;
26 26
27 27
28namespace KCal { 28namespace KCal {
29class CalendarLocal; 29class CalendarLocal;
30} 30}
31 31
32using namespace KCal; 32using namespace KCal;
33 33
34class MainWindow : public QMainWindow 34class MainWindow : public QMainWindow
35{ 35{
36 Q_OBJECT 36 Q_OBJECT
37 public: 37 public:
38 MainWindow( QWidget *parent = 0, const char *name = 0 ); 38 MainWindow( QWidget *parent = 0, const char *name = 0 );
39 ~MainWindow(); 39 ~MainWindow();
40 bool beamReceiveEnabled(); 40 bool beamReceiveEnabled();
41 static QString defaultFileName(); 41 static QString defaultFileName();
42 static QString syncFileName(); 42 static QString syncFileName();
43 static QString resourcePath(); 43 static QString resourcePath();
44 public slots: 44 public slots:
45 void setUsesBigPixmaps ( bool ); 45 void setUsesBigPixmaps ( bool );
46 void setCaption ( const QString & ); 46 void setCaption ( const QString & );
47 void updateWeekNum(const KCal::DateList &); 47 void updateWeekNum(const KCal::DateList &);
48 void updateWeek(QDate); 48 void updateWeek(QDate);
49 void updateFilterToolbar(); 49 void updateFilterToolbar();
50 virtual void showMaximized (); 50 virtual void showMaximized ();
51 void configureAgenda( int ); 51 void configureAgenda( int );
52 void recieve( const QCString& msg, const QByteArray& data ); 52 void recieve( const QCString& msg, const QByteArray& data );
53 void receiveStart( const QCString& msg, const QByteArray& data ); 53 void receiveStart( const QCString& msg, const QByteArray& data );
54 protected slots: 54 protected slots:
55 void autoSaveWarning(); 55 void autoSaveWarning();
56 void loadDataAfterStart(); 56 void loadDataAfterStart();
57 void calHint(); 57 void calHint();
58 void startMultiSync(); 58 void startMultiSync();
59 void setCaptionToDates(); 59 void setCaptionToDates();
60 void weekAction(); 60 void weekAction();
61 void about(); 61 void about();
62 void licence(); 62 void licence();
63 void faq(); 63 void faq();
64 void usertrans(); 64 void usertrans();
65 void features(); 65 void features();
66 void synchowto(); 66 void synchowto();
67 void storagehowto(); 67 void storagehowto();
68 void timetrackinghowto(); 68 void timetrackinghowto();
69 void kdesynchowto(); 69 void kdesynchowto();
70 void multisynchowto(); 70 void multisynchowto();
71 void whatsNew(); 71 void whatsNew();
72 void keyBindings(); 72 void keyBindings();
73 void aboutAutoSaving();; 73 void aboutAutoSaving();;
74 void aboutKnownBugs(); 74 void aboutKnownBugs();
75 75
76 void processIncidenceSelection( Incidence * ); 76 void processIncidenceSelection( Incidence * );
77 77
78 void importQtopia(); 78 void importQtopia();
79 void importBday(); 79 void importBday();
80 void importOL(); 80 void importOL();
81 void importIcal(); 81 void importIcal();
82 void importFile( QString, bool ); 82 void importFile( QString, bool );
83 void quickImportIcal(); 83 void quickImportIcal();
84 84
85 void slotModifiedChanged( bool ); 85 void slotModifiedChanged( bool );
86 86
87 void save(); 87 void save();
88 void backupAllFiles(); 88 void backupAllFiles();
89 void saveStopTimer(); 89 void saveStopTimer();
90 void configureToolBar( int ); 90 void configureToolBar( int );
91 void printSel(); 91 void printSel();
92 void printCal(); 92 void printCal();
93 void printListView(); 93 void printListView();
94 void saveCalendar(); 94 void saveCalendar();
95 void loadCalendar(); 95 void loadCalendar();
96 void exportVCalendar(); 96 void exportVCalendar();
97 void exportICalendar(); 97 void exportICalendar();
98 void exportCalendar( bool ); 98 void exportCalendar( bool );
99 void fillFilterMenu(); 99 void fillFilterMenu();
100 void fillFilterMenuTB(); 100 void fillFilterMenuTB();
101 void selectFilter( int ); 101 void selectFilter( int );
102 void fillFilterMenuPopup(); 102 void fillFilterMenuPopup();
103 void selectFilterPopup( int ); 103 void selectFilterPopup( int );
104 void exportToPhone( int ); 104 void exportToPhone( int );
105 void toggleBeamReceive(); 105 void toggleBeamReceive();
106 void disableBR(bool); 106 void disableBR(bool);
107 signals: 107 signals:
108 void selectWeek ( int ); 108 void selectWeek ( int );
109 private slots: 109 private slots:
110 void slotResetFocus(); 110 void slotResetFocus();
111 void slotResetFocusLoop(); 111 void slotResetFocusLoop();
112 void showConfigureAgenda(); 112 void showConfigureAgenda();
113 void getFile( bool ); 113 void getFile( bool ,const QString &);
114 void syncFileRequest(); 114 void syncFileRequest(const QString &);
115 115
116 protected: 116 protected:
117 int mFocusLoop; 117 int mFocusLoop;
118 void hideEvent ( QHideEvent * ); 118 void hideEvent ( QHideEvent * );
119 QString sentSyncFile(); 119 QString sentSyncFile();
120 void displayText( QString, QString); 120 void displayText( QString, QString);
121 void enableIncidenceActions( bool ); 121 void enableIncidenceActions( bool );
122 bool askForQuitOnSaveError(); 122 bool askForQuitOnSaveError();
123 123
124 private: 124 private:
125 bool mAutoSaveDisabled; 125 bool mAutoSaveDisabled;
126 bool checkAutosave(); 126 bool checkAutosave();
127 QCString mCStringMess; 127 QCString mCStringMess;
128 QByteArray mByteData; 128 QByteArray mByteData;
129 129
130 //void setMenuBar( QMenuBar * ); 130 //void setMenuBar( QMenuBar * );
131 bool mBRdisabled; 131 bool mBRdisabled;
132#ifndef DESKTOP_VERSION 132#ifndef DESKTOP_VERSION
133 QCopChannel* infrared; 133 QCopChannel* infrared;
134#endif 134#endif
135 QAction* brAction; 135 QAction* brAction;
136 KSyncManager* mSyncManager; 136 KSyncManager* mSyncManager;
137 bool mClosed; 137 bool mClosed;
138 void saveOnClose(); 138 void saveOnClose();
139 bool mFlagKeyPressed; 139 bool mFlagKeyPressed;
140 bool mBlockAtStartup; 140 bool mBlockAtStartup;
141 KMenuBar *menuBar1; 141 KMenuBar *menuBar1;
142 QPEToolBar *iconToolBar; 142 QPEToolBar *iconToolBar;
143 QPEToolBar *viewToolBar; 143 QPEToolBar *viewToolBar;
144 QPEToolBar *navigatorToolBar; 144 QPEToolBar *navigatorToolBar;
145 QPEToolBar *filterToolBar; 145 QPEToolBar *filterToolBar;
146 KMenuBar *filterMenubar; 146 KMenuBar *filterMenubar;
147 QPopupMenu * filterPopupMenu; 147 QPopupMenu * filterPopupMenu;
148 QPopupMenu * mCurrentItemMenu; 148 QPopupMenu * mCurrentItemMenu;
149 void initActions(); 149 void initActions();
150 void setDefaultPreferences(); 150 void setDefaultPreferences();
151 void resizeEvent( QResizeEvent* e); 151 void resizeEvent( QResizeEvent* e);
152 void keyPressEvent ( QKeyEvent * ) ; 152 void keyPressEvent ( QKeyEvent * ) ;
153 void keyReleaseEvent ( QKeyEvent * ) ; 153 void keyReleaseEvent ( QKeyEvent * ) ;
154 QPopupMenu *configureToolBarMenu; 154 QPopupMenu *configureToolBarMenu;
155 QPopupMenu *selectFilterMenu; 155 QPopupMenu *selectFilterMenu;
156 QPopupMenu *selectFilterMenuTB; 156 QPopupMenu *selectFilterMenuTB;
157 QPopupMenu *configureAgendaMenu, *syncMenu; 157 QPopupMenu *configureAgendaMenu, *syncMenu;
158 CalendarLocal *mCalendar; 158 CalendarLocal *mCalendar;
159 CalendarView *mView; 159 CalendarView *mView;
160 QAction *mNewSubTodoAction; 160 QAction *mNewSubTodoAction;
161 QAction *mWeekAction; 161 QAction *mWeekAction;
162 QFont mWeekFont; 162 QFont mWeekFont;
163 QPixmap mWeekPixmap; 163 QPixmap mWeekPixmap;
164 QColor mWeekBgColor; 164 QColor mWeekBgColor;
165 165
166 QAction *mShowAction; 166 QAction *mShowAction;
167 QAction *mEditAction; 167 QAction *mEditAction;
168 QAction *mDeleteAction; 168 QAction *mDeleteAction;
169 QAction *mCloneAction; 169 QAction *mCloneAction;
170 QAction *mMoveAction; 170 QAction *mMoveAction;
171 QAction *mBeamAction; 171 QAction *mBeamAction;
172 QAction *mCancelAction; 172 QAction *mCancelAction;
173 QAction *mPrintSelAction; 173 QAction *mPrintSelAction;
174 174
175 QAction *mToggleNav; 175 QAction *mToggleNav;
176 QAction *mToggleFilter; 176 QAction *mToggleFilter;
177 QAction *mToggleAllday; 177 QAction *mToggleAllday;
178 QAction *actionFilterMenuTB; 178 QAction *actionFilterMenuTB;
179 179
180 void closeEvent( QCloseEvent* ce ); 180 void closeEvent( QCloseEvent* ce );
181 QTimer mSaveTimer; 181 QTimer mSaveTimer;
182 QDateTime mSaveTimerStart; 182 QDateTime mSaveTimerStart;
183 int mSaveDelay; 183 int mSaveDelay;
184 //bool mBlockSaveFlag; 184 //bool mBlockSaveFlag;
185 bool mCalendarModifiedFlag; 185 bool mCalendarModifiedFlag;
186 QPixmap loadPixmap( QString ); 186 QPixmap loadPixmap( QString );
187 QPixmap listviewPix, listviewPix0, listviewPix20, listviewPix40, listviewPix60, listviewPix80, journalPix; 187 QPixmap listviewPix, listviewPix0, listviewPix20, listviewPix40, listviewPix60, listviewPix80, journalPix;
188}; 188};
189 189
190 190
191#endif 191#endif