-rw-r--r-- | korganizer/calendarview.cpp | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 00285a5..29c530b 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -157,393 +157,393 @@ class KOBeamPrefs : public QDialog | |||
157 | vcal = new QRadioButton(" vCalendar ", format ); | 157 | vcal = new QRadioButton(" vCalendar ", format ); |
158 | ical = new QRadioButton(" iCalendar ", format ); | 158 | ical = new QRadioButton(" iCalendar ", format ); |
159 | vcal->setChecked( true ); | 159 | vcal->setChecked( true ); |
160 | tz = new QRadioButton(i18n(" With timezone "), time ); | 160 | tz = new QRadioButton(i18n(" With timezone "), time ); |
161 | local = new QRadioButton(i18n(" Local time "), time ); | 161 | local = new QRadioButton(i18n(" Local time "), time ); |
162 | tz->setChecked( true ); | 162 | tz->setChecked( true ); |
163 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 163 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
164 | lay->addWidget( ok ); | 164 | lay->addWidget( ok ); |
165 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 165 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
166 | lay->addWidget( cancel ); | 166 | lay->addWidget( cancel ); |
167 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 167 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
168 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 168 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
169 | resize( 200, 200 ); | 169 | resize( 200, 200 ); |
170 | } | 170 | } |
171 | 171 | ||
172 | bool beamVcal() { return vcal->isChecked(); } | 172 | bool beamVcal() { return vcal->isChecked(); } |
173 | bool beamLocal() { return local->isChecked(); } | 173 | bool beamLocal() { return local->isChecked(); } |
174 | private: | 174 | private: |
175 | QRadioButton* vcal, *ical, *local, *tz; | 175 | QRadioButton* vcal, *ical, *local, *tz; |
176 | }; | 176 | }; |
177 | class KOCatPrefs : public QDialog | 177 | class KOCatPrefs : public QDialog |
178 | { | 178 | { |
179 | public: | 179 | public: |
180 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 180 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
181 | QDialog( parent, name, true ) | 181 | QDialog( parent, name, true ) |
182 | { | 182 | { |
183 | setCaption( i18n("Manage new Categories") ); | 183 | setCaption( i18n("Manage new Categories") ); |
184 | QVBoxLayout* lay = new QVBoxLayout( this ); | 184 | QVBoxLayout* lay = new QVBoxLayout( this ); |
185 | lay->setSpacing( 3 ); | 185 | lay->setSpacing( 3 ); |
186 | lay->setMargin( 3 ); | 186 | lay->setMargin( 3 ); |
187 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 187 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
188 | lay->addWidget( lab ); | 188 | lay->addWidget( lab ); |
189 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 189 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
190 | lay->addWidget( format ); | 190 | lay->addWidget( format ); |
191 | format->setExclusive ( true ) ; | 191 | format->setExclusive ( true ) ; |
192 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 192 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
193 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 193 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
194 | addCatBut->setChecked( true ); | 194 | addCatBut->setChecked( true ); |
195 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 195 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
196 | lay->addWidget( ok ); | 196 | lay->addWidget( ok ); |
197 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 197 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
198 | lay->addWidget( cancel ); | 198 | lay->addWidget( cancel ); |
199 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 199 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
200 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 200 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
201 | resize( 200, 200 ); | 201 | resize( 200, 200 ); |
202 | } | 202 | } |
203 | 203 | ||
204 | bool addCat() { return addCatBut->isChecked(); } | 204 | bool addCat() { return addCatBut->isChecked(); } |
205 | private: | 205 | private: |
206 | QRadioButton* addCatBut; | 206 | QRadioButton* addCatBut; |
207 | }; | 207 | }; |
208 | 208 | ||
209 | 209 | ||
210 | 210 | ||
211 | CalendarView::CalendarView( CalendarResources *calendar, | 211 | CalendarView::CalendarView( CalendarResources *calendar, |
212 | QWidget *parent, const char *name ) | 212 | QWidget *parent, const char *name ) |
213 | : CalendarViewBase( parent, name ), | 213 | : CalendarViewBase( parent, name ), |
214 | mCalendar( calendar ), | 214 | mCalendar( calendar ), |
215 | mResourceManager( calendar->resourceManager() ) | 215 | mResourceManager( calendar->resourceManager() ) |
216 | { | 216 | { |
217 | 217 | ||
218 | mEventEditor = 0; | 218 | mEventEditor = 0; |
219 | mTodoEditor = 0; | 219 | mTodoEditor = 0; |
220 | 220 | ||
221 | init(); | 221 | init(); |
222 | } | 222 | } |
223 | 223 | ||
224 | CalendarView::CalendarView( Calendar *calendar, | 224 | CalendarView::CalendarView( Calendar *calendar, |
225 | QWidget *parent, const char *name ) | 225 | QWidget *parent, const char *name ) |
226 | : CalendarViewBase( parent, name ), | 226 | : CalendarViewBase( parent, name ), |
227 | mCalendar( calendar ), | 227 | mCalendar( calendar ), |
228 | mResourceManager( 0 ) | 228 | mResourceManager( 0 ) |
229 | { | 229 | { |
230 | 230 | ||
231 | mEventEditor = 0; | 231 | mEventEditor = 0; |
232 | mTodoEditor = 0; | 232 | mTodoEditor = 0; |
233 | init(); | 233 | init(); |
234 | } | 234 | } |
235 | 235 | ||
236 | void CalendarView::init() | 236 | void CalendarView::init() |
237 | { | 237 | { |
238 | 238 | ||
239 | setFocusPolicy ( WheelFocus ); | 239 | setFocusPolicy ( WheelFocus ); |
240 | mViewerCallerIsSearchDialog = false; | 240 | mViewerCallerIsSearchDialog = false; |
241 | mBlockShowDates = false; | 241 | mBlockShowDates = false; |
242 | beamDialog = new KOBeamPrefs(); | 242 | beamDialog = new KOBeamPrefs(); |
243 | mDatePickerMode = 0; | 243 | mDatePickerMode = 0; |
244 | mCurrentSyncDevice = ""; | 244 | mCurrentSyncDevice = ""; |
245 | writeLocale(); | 245 | writeLocale(); |
246 | mViewManager = new KOViewManager( this ); | 246 | mViewManager = new KOViewManager( this ); |
247 | mDialogManager = new KODialogManager( this ); | 247 | mDialogManager = new KODialogManager( this ); |
248 | mEventViewerDialog = 0; | 248 | mEventViewerDialog = 0; |
249 | mModified = false; | 249 | mModified = false; |
250 | mReadOnly = false; | 250 | mReadOnly = false; |
251 | mSelectedIncidence = 0; | 251 | mSelectedIncidence = 0; |
252 | mCalPrinter = 0; | 252 | mCalPrinter = 0; |
253 | mFilters.setAutoDelete(true); | 253 | mFilters.setAutoDelete(true); |
254 | 254 | ||
255 | mCalendar->registerObserver( this ); | 255 | mCalendar->registerObserver( this ); |
256 | // TODO: Make sure that view is updated, when calendar is changed. | 256 | // TODO: Make sure that view is updated, when calendar is changed. |
257 | 257 | ||
258 | mStorage = new FileStorage( mCalendar ); | 258 | mStorage = new FileStorage( mCalendar ); |
259 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 259 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
260 | 260 | ||
261 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 261 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
262 | #ifndef KORG_NOSPLITTER | 262 | #ifndef KORG_NOSPLITTER |
263 | // create the main layout frames. | 263 | // create the main layout frames. |
264 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 264 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
265 | topLayout->addWidget(mPanner); | 265 | topLayout->addWidget(mPanner); |
266 | 266 | ||
267 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 267 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
268 | "CalendarView::LeftFrame"); | 268 | "CalendarView::LeftFrame"); |
269 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 269 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
270 | 270 | ||
271 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 271 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
272 | "CalendarView::DateNavigator" ); | 272 | "CalendarView::DateNavigator" ); |
273 | 273 | ||
274 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 274 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
275 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 275 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
276 | mTodoList->setNavigator( mNavigator ); | 276 | mTodoList->setNavigator( mNavigator ); |
277 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 277 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
278 | 278 | ||
279 | #ifdef KORG_NORESOURCEVIEW | 279 | #ifdef KORG_NORESOURCEVIEW |
280 | mResourceView = 0; | 280 | mResourceView = 0; |
281 | #else | 281 | #else |
282 | if ( mResourceManager ) { | 282 | if ( mResourceManager ) { |
283 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 283 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
284 | mResourceView->updateView(); | 284 | mResourceView->updateView(); |
285 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 285 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
286 | SLOT( updateView() ) ); | 286 | SLOT( updateView() ) ); |
287 | } else { | 287 | } else { |
288 | mResourceView = 0; | 288 | mResourceView = 0; |
289 | } | 289 | } |
290 | #endif | 290 | #endif |
291 | QWidget *rightBox = new QWidget( mPanner ); | 291 | QWidget *rightBox = new QWidget( mPanner ); |
292 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 292 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
293 | 293 | ||
294 | mRightFrame = new QWidgetStack( rightBox ); | 294 | mRightFrame = new QWidgetStack( rightBox ); |
295 | rightLayout->addWidget( mRightFrame, 1 ); | 295 | rightLayout->addWidget( mRightFrame, 1 ); |
296 | 296 | ||
297 | mLeftFrame = mLeftSplitter; | 297 | mLeftFrame = mLeftSplitter; |
298 | #else | 298 | #else |
299 | QWidget *mainBox = new QWidget( this ); | 299 | QWidget *mainBox = new QWidget( this ); |
300 | //QWidget *leftFrame = new QWidget( mainBox ); | 300 | //QWidget *leftFrame = new QWidget( mainBox ); |
301 | QBoxLayout * mainBoxLayout; | 301 | QBoxLayout * mainBoxLayout; |
302 | if ( KOPrefs::instance()->mVerticalScreen ) { | 302 | if ( KOPrefs::instance()->mVerticalScreen ) { |
303 | mainBoxLayout = new QVBoxLayout(mainBox); | 303 | mainBoxLayout = new QVBoxLayout(mainBox); |
304 | //leftFrameLayout = new QHBoxLayout(leftFrame ); | 304 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
305 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mainBox);; | 305 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mainBox);; |
306 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left ); | 306 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left ); |
307 | } else { | 307 | } else { |
308 | mainBoxLayout = new QHBoxLayout(mainBox); | 308 | mainBoxLayout = new QHBoxLayout(mainBox); |
309 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 309 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
310 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mainBox);; | 310 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mainBox);; |
311 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 311 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
312 | } | 312 | } |
313 | //QBoxLayout * leftFrameLayout; | 313 | //QBoxLayout * leftFrameLayout; |
314 | topLayout->addWidget( mainBox ); | 314 | topLayout->addWidget( mainBox ); |
315 | mainBoxLayout->addWidget (mLeftFrame); | 315 | mainBoxLayout->addWidget (mLeftFrame); |
316 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 316 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
317 | "CalendarView::DateNavigator" ); | 317 | "CalendarView::DateNavigator" ); |
318 | #if 0 | 318 | #if 0 |
319 | // FIXME | 319 | // FIXME |
320 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 320 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
321 | "CalendarView::DateNavigator", QDate::currentDate()); | 321 | "CalendarView::DateNavigator", QDate::currentDate()); |
322 | #endif | 322 | #endif |
323 | // mDateNavigator->blockSignals( true ); | 323 | // mDateNavigator->blockSignals( true ); |
324 | //leftFrameLayout->addWidget( mDateNavigator ); | 324 | //leftFrameLayout->addWidget( mDateNavigator ); |
325 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 325 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
326 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 326 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
327 | mTodoList->setNavigator( mNavigator ); | 327 | mTodoList->setNavigator( mNavigator ); |
328 | #if 0 | 328 | #if 0 |
329 | if ( QApplication::desktop()->width() < 480 ) { | 329 | if ( QApplication::desktop()->width() < 480 ) { |
330 | leftFrameLayout->addWidget(mFilterView); | 330 | leftFrameLayout->addWidget(mFilterView); |
331 | leftFrameLayout->addWidget(mTodoList, 2 ); | 331 | leftFrameLayout->addWidget(mTodoList, 2 ); |
332 | 332 | ||
333 | } else { | 333 | } else { |
334 | leftFrameLayout->addWidget(mTodoList,2 ); | 334 | leftFrameLayout->addWidget(mTodoList,2 ); |
335 | leftFrameLayout->addWidget(mFilterView ); | 335 | leftFrameLayout->addWidget(mFilterView ); |
336 | } | 336 | } |
337 | #endif | 337 | #endif |
338 | mFilterView->hide(); | 338 | mFilterView->hide(); |
339 | QWidget *rightBox = new QWidget( mainBox ); | 339 | QWidget *rightBox = new QWidget( mainBox ); |
340 | mainBoxLayout->addWidget ( rightBox, 10 ); | 340 | mainBoxLayout->addWidget ( rightBox, 10 ); |
341 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 341 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
342 | mRightFrame = new QWidgetStack( rightBox ); | 342 | mRightFrame = new QWidgetStack( rightBox ); |
343 | rightLayout->addWidget( mRightFrame, 10 ); | 343 | rightLayout->addWidget( mRightFrame, 10 ); |
344 | 344 | ||
345 | //mLeftFrame = (QWidget *)leftFrame; | 345 | //mLeftFrame = (QWidget *)leftFrame; |
346 | if ( KOPrefs::instance()->mVerticalScreen ) { | 346 | if ( KOPrefs::instance()->mVerticalScreen ) { |
347 | mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 347 | mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
348 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 348 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
349 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 349 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
350 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 350 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
351 | } else { | 351 | } else { |
352 | mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 352 | mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
353 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 353 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
354 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 354 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
355 | } | 355 | } |
356 | if ( !KOPrefs::instance()->mShowDateNavigator) | 356 | if ( !KOPrefs::instance()->mShowDateNavigator) |
357 | mLeftFrame->toggle(); | 357 | mDateNavigator->hide(); |
358 | //qDebug("Calendarview Size %d %d ", width(), height()); | 358 | //qDebug("Calendarview Size %d %d ", width(), height()); |
359 | #endif | 359 | #endif |
360 | 360 | ||
361 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 361 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
362 | SLOT( showDates( const KCal::DateList & ) ) ); | 362 | SLOT( showDates( const KCal::DateList & ) ) ); |
363 | 363 | ||
364 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 364 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
365 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 365 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
366 | 366 | ||
367 | 367 | ||
368 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 368 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
369 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 369 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
370 | 370 | ||
371 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 371 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
372 | mNavigator, SLOT( selectPreviousYear() ) ); | 372 | mNavigator, SLOT( selectPreviousYear() ) ); |
373 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 373 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
374 | mNavigator, SLOT( selectNextYear() ) ); | 374 | mNavigator, SLOT( selectNextYear() ) ); |
375 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 375 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
376 | mNavigator, SLOT( selectPreviousMonth() ) ); | 376 | mNavigator, SLOT( selectPreviousMonth() ) ); |
377 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 377 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
378 | mNavigator, SLOT( selectNextMonth() ) ); | 378 | mNavigator, SLOT( selectNextMonth() ) ); |
379 | 379 | ||
380 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 380 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
381 | mNavigator, SLOT( selectPrevious() ) ); | 381 | mNavigator, SLOT( selectPrevious() ) ); |
382 | connect( mDateNavigator, SIGNAL( goNext() ), | 382 | connect( mDateNavigator, SIGNAL( goNext() ), |
383 | mNavigator, SLOT( selectNext() ) ); | 383 | mNavigator, SLOT( selectNext() ) ); |
384 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 384 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
385 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 385 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
386 | 386 | ||
387 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 387 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
388 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 388 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
389 | #if 0 | 389 | #if 0 |
390 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 390 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
391 | SLOT( incidenceAdded( Incidence *) ) ); | 391 | SLOT( incidenceAdded( Incidence *) ) ); |
392 | #endif | 392 | #endif |
393 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 393 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
394 | 394 | ||
395 | connect( this, SIGNAL( configChanged() ), | 395 | connect( this, SIGNAL( configChanged() ), |
396 | mDateNavigator, SLOT( updateConfig() ) ); | 396 | mDateNavigator, SLOT( updateConfig() ) ); |
397 | 397 | ||
398 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 398 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
399 | SLOT( newTodo() ) ); | 399 | SLOT( newTodo() ) ); |
400 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 400 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
401 | SLOT( newSubTodo( Todo * ) ) ); | 401 | SLOT( newSubTodo( Todo * ) ) ); |
402 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 402 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
403 | SLOT( editTodo( Todo * ) ) ); | 403 | SLOT( editTodo( Todo * ) ) ); |
404 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 404 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
405 | SLOT( showTodo( Todo *) ) ); | 405 | SLOT( showTodo( Todo *) ) ); |
406 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 406 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
407 | SLOT( deleteTodo( Todo *) ) ); | 407 | SLOT( deleteTodo( Todo *) ) ); |
408 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 408 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
409 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 409 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
410 | SLOT( purgeCompleted() ) ); | 410 | SLOT( purgeCompleted() ) ); |
411 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 411 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
412 | SIGNAL( todoModified( Todo *, int ) ) ); | 412 | SIGNAL( todoModified( Todo *, int ) ) ); |
413 | 413 | ||
414 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 414 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
415 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 415 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
416 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 416 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
417 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 417 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
418 | 418 | ||
419 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 419 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
420 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 420 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
421 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 421 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
422 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 422 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
423 | 423 | ||
424 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 424 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
425 | this, SLOT ( todo_unsub( Todo * ) ) ); | 425 | this, SLOT ( todo_unsub( Todo * ) ) ); |
426 | 426 | ||
427 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 427 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
428 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 428 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
429 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 429 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
430 | SLOT( updateTodo( Todo *, int ) ) ); | 430 | SLOT( updateTodo( Todo *, int ) ) ); |
431 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 431 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
432 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 432 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
433 | 433 | ||
434 | 434 | ||
435 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 435 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
436 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 436 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
437 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 437 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
438 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 438 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
439 | 439 | ||
440 | 440 | ||
441 | 441 | ||
442 | 442 | ||
443 | 443 | ||
444 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 444 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
445 | SLOT(checkClipboard())); | 445 | SLOT(checkClipboard())); |
446 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 446 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
447 | SLOT( processTodoListSelection( Incidence * ) ) ); | 447 | SLOT( processTodoListSelection( Incidence * ) ) ); |
448 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 448 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
449 | 449 | ||
450 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 450 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
451 | 451 | ||
452 | mDateFrame = new QVBox(0,0,WType_Popup); | 452 | mDateFrame = new QVBox(0,0,WType_Popup); |
453 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 453 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
454 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 454 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
455 | mDateFrame->setLineWidth(3); | 455 | mDateFrame->setLineWidth(3); |
456 | mDateFrame->hide(); | 456 | mDateFrame->hide(); |
457 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 457 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
458 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 458 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
459 | 459 | ||
460 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 460 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
461 | 461 | ||
462 | mEventEditor = mDialogManager->getEventEditor(); | 462 | mEventEditor = mDialogManager->getEventEditor(); |
463 | mTodoEditor = mDialogManager->getTodoEditor(); | 463 | mTodoEditor = mDialogManager->getTodoEditor(); |
464 | 464 | ||
465 | mFlagEditDescription = false; | 465 | mFlagEditDescription = false; |
466 | 466 | ||
467 | mSuspendTimer = new QTimer( this ); | 467 | mSuspendTimer = new QTimer( this ); |
468 | mAlarmTimer = new QTimer( this ); | 468 | mAlarmTimer = new QTimer( this ); |
469 | mRecheckAlarmTimer = new QTimer( this ); | 469 | mRecheckAlarmTimer = new QTimer( this ); |
470 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 470 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
471 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 471 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
472 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 472 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
473 | mAlarmDialog = new AlarmDialog( this ); | 473 | mAlarmDialog = new AlarmDialog( this ); |
474 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 474 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
475 | mAlarmDialog->setServerNotification( false ); | 475 | mAlarmDialog->setServerNotification( false ); |
476 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 476 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
477 | 477 | ||
478 | 478 | ||
479 | #ifndef DESKTOP_VERSION | 479 | #ifndef DESKTOP_VERSION |
480 | //US listen for arriving address resultsets | 480 | //US listen for arriving address resultsets |
481 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 481 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
482 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 482 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
483 | #endif | 483 | #endif |
484 | mDateNavigator->setCalendar( mCalendar ); | 484 | mDateNavigator->setCalendar( mCalendar ); |
485 | } | 485 | } |
486 | 486 | ||
487 | 487 | ||
488 | CalendarView::~CalendarView() | 488 | CalendarView::~CalendarView() |
489 | { | 489 | { |
490 | // kdDebug() << "~CalendarView()" << endl; | 490 | // kdDebug() << "~CalendarView()" << endl; |
491 | //qDebug("CalendarView::~CalendarView() "); | 491 | //qDebug("CalendarView::~CalendarView() "); |
492 | delete mDialogManager; | 492 | delete mDialogManager; |
493 | delete mViewManager; | 493 | delete mViewManager; |
494 | delete mStorage; | 494 | delete mStorage; |
495 | delete mDateFrame ; | 495 | delete mDateFrame ; |
496 | delete beamDialog; | 496 | delete beamDialog; |
497 | delete mEventViewerDialog; | 497 | delete mEventViewerDialog; |
498 | //kdDebug() << "~CalendarView() done" << endl; | 498 | //kdDebug() << "~CalendarView() done" << endl; |
499 | } | 499 | } |
500 | 500 | ||
501 | void CalendarView::showDay( QDate d ) | 501 | void CalendarView::showDay( QDate d ) |
502 | { | 502 | { |
503 | dateNavigator()->blockSignals( true ); | 503 | dateNavigator()->blockSignals( true ); |
504 | dateNavigator()->selectDate( d ); | 504 | dateNavigator()->selectDate( d ); |
505 | dateNavigator()->blockSignals( false ); | 505 | dateNavigator()->blockSignals( false ); |
506 | mViewManager->showDayView(); | 506 | mViewManager->showDayView(); |
507 | //dateNavigator()->selectDate( d ); | 507 | //dateNavigator()->selectDate( d ); |
508 | } | 508 | } |
509 | void CalendarView::timerAlarm() | 509 | void CalendarView::timerAlarm() |
510 | { | 510 | { |
511 | //qDebug("CalendarView::timerAlarm() "); | 511 | //qDebug("CalendarView::timerAlarm() "); |
512 | computeAlarm(mAlarmNotification ); | 512 | computeAlarm(mAlarmNotification ); |
513 | } | 513 | } |
514 | 514 | ||
515 | void CalendarView::suspendAlarm() | 515 | void CalendarView::suspendAlarm() |
516 | { | 516 | { |
517 | //qDebug(" CalendarView::suspendAlarm() "); | 517 | //qDebug(" CalendarView::suspendAlarm() "); |
518 | computeAlarm(mSuspendAlarmNotification ); | 518 | computeAlarm(mSuspendAlarmNotification ); |
519 | 519 | ||
520 | } | 520 | } |
521 | 521 | ||
522 | void CalendarView::startAlarm( QString mess , QString filename) | 522 | void CalendarView::startAlarm( QString mess , QString filename) |
523 | { | 523 | { |
524 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 524 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
525 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 525 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
526 | 526 | ||
527 | } | 527 | } |
528 | 528 | ||
529 | void CalendarView::checkNextTimerAlarm() | 529 | void CalendarView::checkNextTimerAlarm() |
530 | { | 530 | { |
531 | mCalendar->checkAlarmForIncidence( 0, true ); | 531 | mCalendar->checkAlarmForIncidence( 0, true ); |
532 | } | 532 | } |
533 | 533 | ||
534 | void CalendarView::computeAlarm( QString msg ) | 534 | void CalendarView::computeAlarm( QString msg ) |
535 | { | 535 | { |
536 | 536 | ||
537 | QString mess = msg; | 537 | QString mess = msg; |
538 | QString mAlarmMessage = mess.mid( 9 ); | 538 | QString mAlarmMessage = mess.mid( 9 ); |
539 | QString filename = MainWindow::resourcePath(); | 539 | QString filename = MainWindow::resourcePath(); |
540 | filename += "koalarm.wav"; | 540 | filename += "koalarm.wav"; |
541 | QString tempfilename; | 541 | QString tempfilename; |
542 | if ( mess.left( 13 ) == "suspend_alarm") { | 542 | if ( mess.left( 13 ) == "suspend_alarm") { |
543 | bool error = false; | 543 | bool error = false; |
544 | int len = mess.mid( 13 ).find("+++"); | 544 | int len = mess.mid( 13 ).find("+++"); |
545 | if ( len < 2 ) | 545 | if ( len < 2 ) |
546 | error = true; | 546 | error = true; |
547 | else { | 547 | else { |
548 | tempfilename = mess.mid( 13, len ); | 548 | tempfilename = mess.mid( 13, len ); |
549 | if ( !QFile::exists( tempfilename ) ) | 549 | if ( !QFile::exists( tempfilename ) ) |
@@ -1632,464 +1632,503 @@ bool CalendarView::openCalendar(QString filename, bool merge) | |||
1632 | return false; | 1632 | return false; |
1633 | } | 1633 | } |
1634 | 1634 | ||
1635 | globalFlagBlockAgenda = 1; | 1635 | globalFlagBlockAgenda = 1; |
1636 | if (!merge) mCalendar->close(); | 1636 | if (!merge) mCalendar->close(); |
1637 | 1637 | ||
1638 | mStorage->setFileName( filename ); | 1638 | mStorage->setFileName( filename ); |
1639 | 1639 | ||
1640 | if ( mStorage->load() ) { | 1640 | if ( mStorage->load() ) { |
1641 | if ( merge ) ;//setModified( true ); | 1641 | if ( merge ) ;//setModified( true ); |
1642 | else { | 1642 | else { |
1643 | //setModified( true ); | 1643 | //setModified( true ); |
1644 | mViewManager->setDocumentId( filename ); | 1644 | mViewManager->setDocumentId( filename ); |
1645 | mDialogManager->setDocumentId( filename ); | 1645 | mDialogManager->setDocumentId( filename ); |
1646 | mTodoList->setDocumentId( filename ); | 1646 | mTodoList->setDocumentId( filename ); |
1647 | } | 1647 | } |
1648 | globalFlagBlockAgenda = 2; | 1648 | globalFlagBlockAgenda = 2; |
1649 | // if ( getLastSyncEvent() ) | 1649 | // if ( getLastSyncEvent() ) |
1650 | // getLastSyncEvent()->setReadOnly( true ); | 1650 | // getLastSyncEvent()->setReadOnly( true ); |
1651 | mCalendar->reInitAlarmSettings(); | 1651 | mCalendar->reInitAlarmSettings(); |
1652 | setSyncEventsReadOnly(); | 1652 | setSyncEventsReadOnly(); |
1653 | updateUnmanagedViews(); | 1653 | updateUnmanagedViews(); |
1654 | updateView(); | 1654 | updateView(); |
1655 | if ( filename != MainWindow::defaultFileName() ) { | 1655 | if ( filename != MainWindow::defaultFileName() ) { |
1656 | saveCalendar( MainWindow::defaultFileName() ); | 1656 | saveCalendar( MainWindow::defaultFileName() ); |
1657 | } else { | 1657 | } else { |
1658 | QFileInfo finf ( MainWindow::defaultFileName()); | 1658 | QFileInfo finf ( MainWindow::defaultFileName()); |
1659 | if ( finf.exists() ) { | 1659 | if ( finf.exists() ) { |
1660 | setLoadedFileVersion( finf.lastModified () ); | 1660 | setLoadedFileVersion( finf.lastModified () ); |
1661 | } | 1661 | } |
1662 | } | 1662 | } |
1663 | return true; | 1663 | return true; |
1664 | } else { | 1664 | } else { |
1665 | // while failing to load, the calendar object could | 1665 | // while failing to load, the calendar object could |
1666 | // have become partially populated. Clear it out. | 1666 | // have become partially populated. Clear it out. |
1667 | if ( !merge ) { | 1667 | if ( !merge ) { |
1668 | mCalendar->close(); | 1668 | mCalendar->close(); |
1669 | mViewManager->setDocumentId( filename ); | 1669 | mViewManager->setDocumentId( filename ); |
1670 | mDialogManager->setDocumentId( filename ); | 1670 | mDialogManager->setDocumentId( filename ); |
1671 | mTodoList->setDocumentId( filename ); | 1671 | mTodoList->setDocumentId( filename ); |
1672 | } | 1672 | } |
1673 | 1673 | ||
1674 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1674 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1675 | 1675 | ||
1676 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1676 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1677 | globalFlagBlockAgenda = 2; | 1677 | globalFlagBlockAgenda = 2; |
1678 | mCalendar->reInitAlarmSettings(); | 1678 | mCalendar->reInitAlarmSettings(); |
1679 | setSyncEventsReadOnly(); | 1679 | setSyncEventsReadOnly(); |
1680 | updateUnmanagedViews(); | 1680 | updateUnmanagedViews(); |
1681 | updateView(); | 1681 | updateView(); |
1682 | } | 1682 | } |
1683 | return false; | 1683 | return false; |
1684 | } | 1684 | } |
1685 | void CalendarView::showOpenError() | 1685 | void CalendarView::showOpenError() |
1686 | { | 1686 | { |
1687 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1687 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1688 | } | 1688 | } |
1689 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1689 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1690 | { | 1690 | { |
1691 | loadedFileVersion = dt; | 1691 | loadedFileVersion = dt; |
1692 | } | 1692 | } |
1693 | bool CalendarView::checkFileChanged(QString fn) | 1693 | bool CalendarView::checkFileChanged(QString fn) |
1694 | { | 1694 | { |
1695 | QFileInfo finf ( fn ); | 1695 | QFileInfo finf ( fn ); |
1696 | if ( !finf.exists() ) | 1696 | if ( !finf.exists() ) |
1697 | return true; | 1697 | return true; |
1698 | QDateTime dt = finf.lastModified (); | 1698 | QDateTime dt = finf.lastModified (); |
1699 | if ( dt <= loadedFileVersion ) | 1699 | if ( dt <= loadedFileVersion ) |
1700 | return false; | 1700 | return false; |
1701 | return true; | 1701 | return true; |
1702 | 1702 | ||
1703 | } | 1703 | } |
1704 | void CalendarView::watchSavedFile() | 1704 | void CalendarView::watchSavedFile() |
1705 | { | 1705 | { |
1706 | QFileInfo finf ( MainWindow::defaultFileName()); | 1706 | QFileInfo finf ( MainWindow::defaultFileName()); |
1707 | if ( !finf.exists() ) | 1707 | if ( !finf.exists() ) |
1708 | return; | 1708 | return; |
1709 | QDateTime dt = finf.lastModified (); | 1709 | QDateTime dt = finf.lastModified (); |
1710 | if ( dt < loadedFileVersion ) { | 1710 | if ( dt < loadedFileVersion ) { |
1711 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1711 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1712 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1712 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1713 | return; | 1713 | return; |
1714 | } | 1714 | } |
1715 | loadedFileVersion = dt; | 1715 | loadedFileVersion = dt; |
1716 | } | 1716 | } |
1717 | 1717 | ||
1718 | bool CalendarView::checkFileVersion(QString fn) | 1718 | bool CalendarView::checkFileVersion(QString fn) |
1719 | { | 1719 | { |
1720 | QFileInfo finf ( fn ); | 1720 | QFileInfo finf ( fn ); |
1721 | if ( !finf.exists() ) | 1721 | if ( !finf.exists() ) |
1722 | return true; | 1722 | return true; |
1723 | QDateTime dt = finf.lastModified (); | 1723 | QDateTime dt = finf.lastModified (); |
1724 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1724 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1725 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1725 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1726 | if ( dt <= loadedFileVersion ) | 1726 | if ( dt <= loadedFileVersion ) |
1727 | return true; | 1727 | return true; |
1728 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 1728 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
1729 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1729 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1730 | i18n("Sync+save")); | 1730 | i18n("Sync+save")); |
1731 | 1731 | ||
1732 | if ( km == KMessageBox::Cancel ) | 1732 | if ( km == KMessageBox::Cancel ) |
1733 | return false; | 1733 | return false; |
1734 | if ( km == KMessageBox::Yes ) | 1734 | if ( km == KMessageBox::Yes ) |
1735 | return true; | 1735 | return true; |
1736 | 1736 | ||
1737 | setSyncDevice("deleteaftersync" ); | 1737 | setSyncDevice("deleteaftersync" ); |
1738 | mSyncManager->mAskForPreferences = true; | 1738 | mSyncManager->mAskForPreferences = true; |
1739 | mSyncManager->mSyncAlgoPrefs = 3; | 1739 | mSyncManager->mSyncAlgoPrefs = 3; |
1740 | mSyncManager->mWriteBackFile = false; | 1740 | mSyncManager->mWriteBackFile = false; |
1741 | mSyncManager->mWriteBackExistingOnly = false; | 1741 | mSyncManager->mWriteBackExistingOnly = false; |
1742 | mSyncManager->mShowSyncSummary = false; | 1742 | mSyncManager->mShowSyncSummary = false; |
1743 | syncCalendar( fn, 3 ); | 1743 | syncCalendar( fn, 3 ); |
1744 | Event * e = getLastSyncEvent(); | 1744 | Event * e = getLastSyncEvent(); |
1745 | mCalendar->deleteEvent ( e ); | 1745 | mCalendar->deleteEvent ( e ); |
1746 | updateView(); | 1746 | updateView(); |
1747 | return true; | 1747 | return true; |
1748 | } | 1748 | } |
1749 | 1749 | ||
1750 | bool CalendarView::saveCalendar( QString filename ) | 1750 | bool CalendarView::saveCalendar( QString filename ) |
1751 | { | 1751 | { |
1752 | 1752 | ||
1753 | // Store back all unsaved data into calendar object | 1753 | // Store back all unsaved data into calendar object |
1754 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1754 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1755 | if ( mViewManager->currentView() ) | 1755 | if ( mViewManager->currentView() ) |
1756 | mViewManager->currentView()->flushView(); | 1756 | mViewManager->currentView()->flushView(); |
1757 | 1757 | ||
1758 | 1758 | ||
1759 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1759 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1760 | mStorage->setSaveFormat( new ICalFormat() ); | 1760 | mStorage->setSaveFormat( new ICalFormat() ); |
1761 | mStorage->setFileName( filename ); | 1761 | mStorage->setFileName( filename ); |
1762 | bool success; | 1762 | bool success; |
1763 | success = mStorage->save(); | 1763 | success = mStorage->save(); |
1764 | if ( !success ) { | 1764 | if ( !success ) { |
1765 | return false; | 1765 | return false; |
1766 | } | 1766 | } |
1767 | if ( filename == MainWindow::defaultFileName() ) { | 1767 | if ( filename == MainWindow::defaultFileName() ) { |
1768 | setLoadedFileVersion( lfv ); | 1768 | setLoadedFileVersion( lfv ); |
1769 | watchSavedFile(); | 1769 | watchSavedFile(); |
1770 | } | 1770 | } |
1771 | return true; | 1771 | return true; |
1772 | } | 1772 | } |
1773 | 1773 | ||
1774 | void CalendarView::closeCalendar() | 1774 | void CalendarView::closeCalendar() |
1775 | { | 1775 | { |
1776 | 1776 | ||
1777 | // child windows no longer valid | 1777 | // child windows no longer valid |
1778 | emit closingDown(); | 1778 | emit closingDown(); |
1779 | 1779 | ||
1780 | mCalendar->close(); | 1780 | mCalendar->close(); |
1781 | setModified(false); | 1781 | setModified(false); |
1782 | updateView(); | 1782 | updateView(); |
1783 | } | 1783 | } |
1784 | 1784 | ||
1785 | void CalendarView::archiveCalendar() | 1785 | void CalendarView::archiveCalendar() |
1786 | { | 1786 | { |
1787 | mDialogManager->showArchiveDialog(); | 1787 | mDialogManager->showArchiveDialog(); |
1788 | } | 1788 | } |
1789 | 1789 | ||
1790 | 1790 | ||
1791 | void CalendarView::readSettings() | 1791 | void CalendarView::readSettings() |
1792 | { | 1792 | { |
1793 | 1793 | ||
1794 | 1794 | ||
1795 | // mViewManager->showAgendaView(); | 1795 | // mViewManager->showAgendaView(); |
1796 | QString str; | 1796 | QString str; |
1797 | //qDebug("CalendarView::readSettings() "); | 1797 | //qDebug("CalendarView::readSettings() "); |
1798 | // read settings from the KConfig, supplying reasonable | 1798 | // read settings from the KConfig, supplying reasonable |
1799 | // defaults where none are to be found | 1799 | // defaults where none are to be found |
1800 | KConfig *config = KOGlobals::config(); | 1800 | KConfig *config = KOGlobals::config(); |
1801 | #ifndef KORG_NOSPLITTER | 1801 | #ifndef KORG_NOSPLITTER |
1802 | config->setGroup("KOrganizer Geometry"); | 1802 | config->setGroup("KOrganizer Geometry"); |
1803 | 1803 | ||
1804 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1804 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1805 | if (sizes.count() != 2) { | 1805 | if (sizes.count() != 2) { |
1806 | sizes << mDateNavigator->minimumSizeHint().width(); | 1806 | sizes << mDateNavigator->minimumSizeHint().width(); |
1807 | sizes << 300; | 1807 | sizes << 300; |
1808 | } | 1808 | } |
1809 | mPanner->setSizes(sizes); | 1809 | mPanner->setSizes(sizes); |
1810 | 1810 | ||
1811 | sizes = config->readIntListEntry("Separator2"); | 1811 | sizes = config->readIntListEntry("Separator2"); |
1812 | if ( ( mResourceView && sizes.count() == 4 ) || | 1812 | if ( ( mResourceView && sizes.count() == 4 ) || |
1813 | ( !mResourceView && sizes.count() == 3 ) ) { | 1813 | ( !mResourceView && sizes.count() == 3 ) ) { |
1814 | mLeftSplitter->setSizes(sizes); | 1814 | mLeftSplitter->setSizes(sizes); |
1815 | } | 1815 | } |
1816 | #endif | 1816 | #endif |
1817 | globalFlagBlockAgenda = 1; | 1817 | globalFlagBlockAgenda = 1; |
1818 | mViewManager->showAgendaView(); | 1818 | mViewManager->showAgendaView(); |
1819 | //mViewManager->readSettings( config ); | 1819 | //mViewManager->readSettings( config ); |
1820 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1820 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1821 | readFilterSettings(config); | 1821 | readFilterSettings(config); |
1822 | config->setGroup( "Views" ); | 1822 | config->setGroup( "Views" ); |
1823 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1823 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1824 | |||
1825 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | ||
1826 | |||
1827 | int resetval = 0; | ||
1828 | int maxVal = 0; | ||
1829 | if (sizes.count() != 3) { | ||
1830 | if ( KOPrefs::instance()->mVerticalScreen ) { | ||
1831 | resetval = mDateNavigator->sizeHint().width()+2; | ||
1832 | } else { | ||
1833 | resetval = mDateNavigator->sizeHint().height()+2; | ||
1834 | } | ||
1835 | } | ||
1836 | if ( !resetval ){// i.e. sizes.count() == 3 | ||
1837 | if ( KOPrefs::instance()->mVerticalScreen ) { | ||
1838 | if ( sizes[0] < mDateNavigator->sizeHint().width()+1 ) | ||
1839 | resetval = mDateNavigator->sizeHint().width()+2; | ||
1840 | } else { | ||
1841 | if ( sizes[0] < mDateNavigator->sizeHint().height()+1 ) | ||
1842 | resetval = mDateNavigator->sizeHint().height()+2; | ||
1843 | } | ||
1844 | } | ||
1845 | if ( resetval ) { | ||
1846 | sizes.clear(); | ||
1847 | if ( KOPrefs::instance()->mVerticalScreen ) { | ||
1848 | maxVal = QApplication::desktop()->width() -10; | ||
1849 | } else { | ||
1850 | maxVal = QApplication::desktop()->height()-10; | ||
1851 | } | ||
1852 | sizes << resetval; | ||
1853 | if ( maxVal < resetval + resetval) | ||
1854 | resetval = maxVal - resetval; | ||
1855 | sizes << resetval; | ||
1856 | sizes << 100; | ||
1857 | } | ||
1858 | mLeftFrame->setSizes(sizes); | ||
1859 | qDebug("sizes count %d ", sizes.count()); | ||
1824 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1860 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1825 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1861 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1826 | else mNavigator->selectDates( dateCount ); | 1862 | else mNavigator->selectDates( dateCount ); |
1827 | // mViewManager->readSettings( config ); | 1863 | // mViewManager->readSettings( config ); |
1828 | updateConfig(); | 1864 | updateConfig(); |
1829 | globalFlagBlockAgenda = 2; | 1865 | globalFlagBlockAgenda = 2; |
1830 | mViewManager->readSettings( config ); | 1866 | mViewManager->readSettings( config ); |
1831 | #ifdef DESKTOP_VERSION | 1867 | #ifdef DESKTOP_VERSION |
1832 | config->setGroup("WidgetLayout"); | 1868 | config->setGroup("WidgetLayout"); |
1833 | QStringList list; | 1869 | QStringList list; |
1834 | list = config->readListEntry("MainLayout"); | 1870 | list = config->readListEntry("MainLayout"); |
1835 | int x,y,w,h; | 1871 | int x,y,w,h; |
1836 | if ( ! list.isEmpty() ) { | 1872 | if ( ! list.isEmpty() ) { |
1837 | x = list[0].toInt(); | 1873 | x = list[0].toInt(); |
1838 | y = list[1].toInt(); | 1874 | y = list[1].toInt(); |
1839 | w = list[2].toInt(); | 1875 | w = list[2].toInt(); |
1840 | h = list[3].toInt(); | 1876 | h = list[3].toInt(); |
1841 | topLevelWidget()->setGeometry(x,y,w,h); | 1877 | topLevelWidget()->setGeometry(x,y,w,h); |
1842 | 1878 | ||
1843 | } else { | 1879 | } else { |
1844 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1880 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1845 | } | 1881 | } |
1846 | list = config->readListEntry("EditEventLayout"); | 1882 | list = config->readListEntry("EditEventLayout"); |
1847 | if ( ! list.isEmpty() ) { | 1883 | if ( ! list.isEmpty() ) { |
1848 | x = list[0].toInt(); | 1884 | x = list[0].toInt(); |
1849 | y = list[1].toInt(); | 1885 | y = list[1].toInt(); |
1850 | w = list[2].toInt(); | 1886 | w = list[2].toInt(); |
1851 | h = list[3].toInt(); | 1887 | h = list[3].toInt(); |
1852 | mEventEditor->setGeometry(x,y,w,h); | 1888 | mEventEditor->setGeometry(x,y,w,h); |
1853 | 1889 | ||
1854 | } | 1890 | } |
1855 | list = config->readListEntry("EditTodoLayout"); | 1891 | list = config->readListEntry("EditTodoLayout"); |
1856 | if ( ! list.isEmpty() ) { | 1892 | if ( ! list.isEmpty() ) { |
1857 | x = list[0].toInt(); | 1893 | x = list[0].toInt(); |
1858 | y = list[1].toInt(); | 1894 | y = list[1].toInt(); |
1859 | w = list[2].toInt(); | 1895 | w = list[2].toInt(); |
1860 | h = list[3].toInt(); | 1896 | h = list[3].toInt(); |
1861 | mTodoEditor->setGeometry(x,y,w,h); | 1897 | mTodoEditor->setGeometry(x,y,w,h); |
1862 | 1898 | ||
1863 | } | 1899 | } |
1864 | list = config->readListEntry("ViewerLayout"); | 1900 | list = config->readListEntry("ViewerLayout"); |
1865 | if ( ! list.isEmpty() ) { | 1901 | if ( ! list.isEmpty() ) { |
1866 | x = list[0].toInt(); | 1902 | x = list[0].toInt(); |
1867 | y = list[1].toInt(); | 1903 | y = list[1].toInt(); |
1868 | w = list[2].toInt(); | 1904 | w = list[2].toInt(); |
1869 | h = list[3].toInt(); | 1905 | h = list[3].toInt(); |
1870 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1906 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1871 | } | 1907 | } |
1872 | #endif | 1908 | #endif |
1873 | 1909 | ||
1874 | } | 1910 | } |
1875 | 1911 | ||
1876 | 1912 | ||
1877 | void CalendarView::writeSettings() | 1913 | void CalendarView::writeSettings() |
1878 | { | 1914 | { |
1879 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1915 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1880 | 1916 | ||
1881 | KConfig *config = KOGlobals::config(); | 1917 | KConfig *config = KOGlobals::config(); |
1882 | 1918 | ||
1883 | #ifndef KORG_NOSPLITTER | 1919 | #ifndef KORG_NOSPLITTER |
1884 | config->setGroup("KOrganizer Geometry"); | 1920 | config->setGroup("KOrganizer Geometry"); |
1885 | 1921 | ||
1886 | QValueList<int> list = mPanner->sizes(); | 1922 | QValueList<int> list = mPanner->sizes(); |
1887 | config->writeEntry("Separator1",list); | 1923 | config->writeEntry("Separator1",list); |
1888 | 1924 | ||
1889 | list = mLeftSplitter->sizes(); | 1925 | list = mLeftSplitter->sizes(); |
1890 | config->writeEntry("Separator2",list); | 1926 | config->writeEntry("Separator2",list); |
1891 | #endif | 1927 | #endif |
1892 | 1928 | ||
1893 | mViewManager->writeSettings( config ); | 1929 | mViewManager->writeSettings( config ); |
1894 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1930 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1895 | mDialogManager->writeSettings( config ); | 1931 | mDialogManager->writeSettings( config ); |
1896 | //KOPrefs::instance()->usrWriteConfig(); | 1932 | //KOPrefs::instance()->usrWriteConfig(); |
1897 | KOPrefs::instance()->writeConfig(); | 1933 | KOPrefs::instance()->writeConfig(); |
1898 | 1934 | ||
1899 | writeFilterSettings(config); | 1935 | writeFilterSettings(config); |
1900 | 1936 | ||
1901 | config->setGroup( "Views" ); | 1937 | config->setGroup( "Views" ); |
1902 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1938 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1903 | 1939 | ||
1940 | QValueList<int> list = mLeftFrame->sizes(); | ||
1941 | config->writeEntry("Left Splitter Frame",list); | ||
1942 | |||
1904 | #ifdef DESKTOP_VERSION | 1943 | #ifdef DESKTOP_VERSION |
1905 | config->setGroup("WidgetLayout"); | 1944 | config->setGroup("WidgetLayout"); |
1906 | QStringList list ;//= config->readListEntry("MainLayout"); | 1945 | QStringList list ;//= config->readListEntry("MainLayout"); |
1907 | int x,y,w,h; | 1946 | int x,y,w,h; |
1908 | QWidget* wid; | 1947 | QWidget* wid; |
1909 | wid = topLevelWidget(); | 1948 | wid = topLevelWidget(); |
1910 | x = wid->geometry().x(); | 1949 | x = wid->geometry().x(); |
1911 | y = wid->geometry().y(); | 1950 | y = wid->geometry().y(); |
1912 | w = wid->width(); | 1951 | w = wid->width(); |
1913 | h = wid->height(); | 1952 | h = wid->height(); |
1914 | list.clear(); | 1953 | list.clear(); |
1915 | list << QString::number( x ); | 1954 | list << QString::number( x ); |
1916 | list << QString::number( y ); | 1955 | list << QString::number( y ); |
1917 | list << QString::number( w ); | 1956 | list << QString::number( w ); |
1918 | list << QString::number( h ); | 1957 | list << QString::number( h ); |
1919 | config->writeEntry("MainLayout",list ); | 1958 | config->writeEntry("MainLayout",list ); |
1920 | 1959 | ||
1921 | wid = mEventEditor; | 1960 | wid = mEventEditor; |
1922 | x = wid->geometry().x(); | 1961 | x = wid->geometry().x(); |
1923 | y = wid->geometry().y(); | 1962 | y = wid->geometry().y(); |
1924 | w = wid->width(); | 1963 | w = wid->width(); |
1925 | h = wid->height(); | 1964 | h = wid->height(); |
1926 | list.clear(); | 1965 | list.clear(); |
1927 | list << QString::number( x ); | 1966 | list << QString::number( x ); |
1928 | list << QString::number( y ); | 1967 | list << QString::number( y ); |
1929 | list << QString::number( w ); | 1968 | list << QString::number( w ); |
1930 | list << QString::number( h ); | 1969 | list << QString::number( h ); |
1931 | config->writeEntry("EditEventLayout",list ); | 1970 | config->writeEntry("EditEventLayout",list ); |
1932 | 1971 | ||
1933 | wid = mTodoEditor; | 1972 | wid = mTodoEditor; |
1934 | x = wid->geometry().x(); | 1973 | x = wid->geometry().x(); |
1935 | y = wid->geometry().y(); | 1974 | y = wid->geometry().y(); |
1936 | w = wid->width(); | 1975 | w = wid->width(); |
1937 | h = wid->height(); | 1976 | h = wid->height(); |
1938 | list.clear(); | 1977 | list.clear(); |
1939 | list << QString::number( x ); | 1978 | list << QString::number( x ); |
1940 | list << QString::number( y ); | 1979 | list << QString::number( y ); |
1941 | list << QString::number( w ); | 1980 | list << QString::number( w ); |
1942 | list << QString::number( h ); | 1981 | list << QString::number( h ); |
1943 | config->writeEntry("EditTodoLayout",list ); | 1982 | config->writeEntry("EditTodoLayout",list ); |
1944 | wid = getEventViewerDialog(); | 1983 | wid = getEventViewerDialog(); |
1945 | x = wid->geometry().x(); | 1984 | x = wid->geometry().x(); |
1946 | y = wid->geometry().y(); | 1985 | y = wid->geometry().y(); |
1947 | w = wid->width(); | 1986 | w = wid->width(); |
1948 | h = wid->height(); | 1987 | h = wid->height(); |
1949 | list.clear(); | 1988 | list.clear(); |
1950 | list << QString::number( x ); | 1989 | list << QString::number( x ); |
1951 | list << QString::number( y ); | 1990 | list << QString::number( y ); |
1952 | list << QString::number( w ); | 1991 | list << QString::number( w ); |
1953 | list << QString::number( h ); | 1992 | list << QString::number( h ); |
1954 | config->writeEntry("ViewerLayout",list ); | 1993 | config->writeEntry("ViewerLayout",list ); |
1955 | wid = mDialogManager->getSearchDialog(); | 1994 | wid = mDialogManager->getSearchDialog(); |
1956 | if ( wid ) { | 1995 | if ( wid ) { |
1957 | x = wid->geometry().x(); | 1996 | x = wid->geometry().x(); |
1958 | y = wid->geometry().y(); | 1997 | y = wid->geometry().y(); |
1959 | w = wid->width(); | 1998 | w = wid->width(); |
1960 | h = wid->height(); | 1999 | h = wid->height(); |
1961 | list.clear(); | 2000 | list.clear(); |
1962 | list << QString::number( x ); | 2001 | list << QString::number( x ); |
1963 | list << QString::number( y ); | 2002 | list << QString::number( y ); |
1964 | list << QString::number( w ); | 2003 | list << QString::number( w ); |
1965 | list << QString::number( h ); | 2004 | list << QString::number( h ); |
1966 | config->writeEntry("SearchLayout",list ); | 2005 | config->writeEntry("SearchLayout",list ); |
1967 | } | 2006 | } |
1968 | #endif | 2007 | #endif |
1969 | 2008 | ||
1970 | 2009 | ||
1971 | config->sync(); | 2010 | config->sync(); |
1972 | } | 2011 | } |
1973 | 2012 | ||
1974 | void CalendarView::readFilterSettings(KConfig *config) | 2013 | void CalendarView::readFilterSettings(KConfig *config) |
1975 | { | 2014 | { |
1976 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2015 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1977 | 2016 | ||
1978 | mFilters.clear(); | 2017 | mFilters.clear(); |
1979 | 2018 | ||
1980 | config->setGroup("General"); | 2019 | config->setGroup("General"); |
1981 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2020 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1982 | 2021 | ||
1983 | QStringList::ConstIterator it = filterList.begin(); | 2022 | QStringList::ConstIterator it = filterList.begin(); |
1984 | QStringList::ConstIterator end = filterList.end(); | 2023 | QStringList::ConstIterator end = filterList.end(); |
1985 | while(it != end) { | 2024 | while(it != end) { |
1986 | // kdDebug() << " filter: " << (*it) << endl; | 2025 | // kdDebug() << " filter: " << (*it) << endl; |
1987 | 2026 | ||
1988 | CalFilter *filter; | 2027 | CalFilter *filter; |
1989 | filter = new CalFilter(*it); | 2028 | filter = new CalFilter(*it); |
1990 | config->setGroup("Filter_" + (*it)); | 2029 | config->setGroup("Filter_" + (*it)); |
1991 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2030 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1992 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2031 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1993 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2032 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1994 | mFilters.append(filter); | 2033 | mFilters.append(filter); |
1995 | 2034 | ||
1996 | ++it; | 2035 | ++it; |
1997 | } | 2036 | } |
1998 | 2037 | ||
1999 | if (mFilters.count() == 0) { | 2038 | if (mFilters.count() == 0) { |
2000 | CalFilter *filter = new CalFilter(i18n("Default")); | 2039 | CalFilter *filter = new CalFilter(i18n("Default")); |
2001 | mFilters.append(filter); | 2040 | mFilters.append(filter); |
2002 | } | 2041 | } |
2003 | mFilterView->updateFilters(); | 2042 | mFilterView->updateFilters(); |
2004 | config->setGroup("FilterView"); | 2043 | config->setGroup("FilterView"); |
2005 | 2044 | ||
2006 | mFilterView->blockSignals(true); | 2045 | mFilterView->blockSignals(true); |
2007 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2046 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2008 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2047 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2009 | mFilterView->blockSignals(false); | 2048 | mFilterView->blockSignals(false); |
2010 | // We do it manually to avoid it being done twice by the above calls | 2049 | // We do it manually to avoid it being done twice by the above calls |
2011 | updateFilter(); | 2050 | updateFilter(); |
2012 | } | 2051 | } |
2013 | 2052 | ||
2014 | void CalendarView::writeFilterSettings(KConfig *config) | 2053 | void CalendarView::writeFilterSettings(KConfig *config) |
2015 | { | 2054 | { |
2016 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2055 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2017 | 2056 | ||
2018 | QStringList filterList; | 2057 | QStringList filterList; |
2019 | 2058 | ||
2020 | CalFilter *filter = mFilters.first(); | 2059 | CalFilter *filter = mFilters.first(); |
2021 | while(filter) { | 2060 | while(filter) { |
2022 | // kdDebug() << " fn: " << filter->name() << endl; | 2061 | // kdDebug() << " fn: " << filter->name() << endl; |
2023 | filterList << filter->name(); | 2062 | filterList << filter->name(); |
2024 | config->setGroup("Filter_" + filter->name()); | 2063 | config->setGroup("Filter_" + filter->name()); |
2025 | config->writeEntry("Criteria",filter->criteria()); | 2064 | config->writeEntry("Criteria",filter->criteria()); |
2026 | config->writeEntry("CategoryList",filter->categoryList()); | 2065 | config->writeEntry("CategoryList",filter->categoryList()); |
2027 | filter = mFilters.next(); | 2066 | filter = mFilters.next(); |
2028 | } | 2067 | } |
2029 | config->setGroup("General"); | 2068 | config->setGroup("General"); |
2030 | config->writeEntry("CalendarFilters",filterList); | 2069 | config->writeEntry("CalendarFilters",filterList); |
2031 | 2070 | ||
2032 | config->setGroup("FilterView"); | 2071 | config->setGroup("FilterView"); |
2033 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2072 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2034 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2073 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2035 | } | 2074 | } |
2036 | 2075 | ||
2037 | 2076 | ||
2038 | void CalendarView::goToday() | 2077 | void CalendarView::goToday() |
2039 | { | 2078 | { |
2040 | if ( mViewManager->currentView()->isMonthView() ) | 2079 | if ( mViewManager->currentView()->isMonthView() ) |
2041 | mNavigator->selectTodayMonth(); | 2080 | mNavigator->selectTodayMonth(); |
2042 | else | 2081 | else |
2043 | mNavigator->selectToday(); | 2082 | mNavigator->selectToday(); |
2044 | } | 2083 | } |
2045 | 2084 | ||
2046 | void CalendarView::goNext() | 2085 | void CalendarView::goNext() |
2047 | { | 2086 | { |
2048 | mNavigator->selectNext(); | 2087 | mNavigator->selectNext(); |
2049 | } | 2088 | } |
2050 | 2089 | ||
2051 | void CalendarView::goPrevious() | 2090 | void CalendarView::goPrevious() |
2052 | { | 2091 | { |
2053 | mNavigator->selectPrevious(); | 2092 | mNavigator->selectPrevious(); |
2054 | } | 2093 | } |
2055 | void CalendarView::goNextMonth() | 2094 | void CalendarView::goNextMonth() |
2056 | { | 2095 | { |
2057 | mNavigator->selectNextMonth(); | 2096 | mNavigator->selectNextMonth(); |
2058 | } | 2097 | } |
2059 | 2098 | ||
2060 | void CalendarView::goPreviousMonth() | 2099 | void CalendarView::goPreviousMonth() |
2061 | { | 2100 | { |
2062 | mNavigator->selectPreviousMonth(); | 2101 | mNavigator->selectPreviousMonth(); |
2063 | } | 2102 | } |
2064 | void CalendarView::writeLocale() | 2103 | void CalendarView::writeLocale() |
2065 | { | 2104 | { |
2066 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 2105 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
2067 | #if 0 | 2106 | #if 0 |
2068 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 2107 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
2069 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 2108 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
2070 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 2109 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
2071 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 2110 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
2072 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 2111 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
2073 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 2112 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
2074 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 2113 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2075 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2114 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2076 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2115 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2077 | KOPrefs::instance()->mDaylightsavingStart, | 2116 | KOPrefs::instance()->mDaylightsavingStart, |
2078 | KOPrefs::instance()->mDaylightsavingEnd ); | 2117 | KOPrefs::instance()->mDaylightsavingEnd ); |
2079 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); | 2118 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); |
2080 | #endif | 2119 | #endif |
2081 | } | 2120 | } |
2082 | void CalendarView::updateConfig() | 2121 | void CalendarView::updateConfig() |
2083 | { | 2122 | { |
2084 | writeLocale(); | 2123 | writeLocale(); |
2085 | if ( KOPrefs::instance()->mUseAppColors ) | 2124 | if ( KOPrefs::instance()->mUseAppColors ) |
2086 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2125 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2087 | emit configChanged(); | 2126 | emit configChanged(); |
2088 | mTodoList->updateConfig(); | 2127 | mTodoList->updateConfig(); |
2089 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2128 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2090 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2129 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2091 | // To make the "fill window" configurations work | 2130 | // To make the "fill window" configurations work |
2092 | //mViewManager->raiseCurrentView(); | 2131 | //mViewManager->raiseCurrentView(); |
2093 | } | 2132 | } |
2094 | 2133 | ||
2095 | 2134 | ||
@@ -3525,392 +3564,389 @@ void CalendarView::processIncidenceSelection( Incidence *incidence ) | |||
3525 | emit todoSelected( true ); | 3564 | emit todoSelected( true ); |
3526 | } else { | 3565 | } else { |
3527 | emit todoSelected( false ); | 3566 | emit todoSelected( false ); |
3528 | }*/ | 3567 | }*/ |
3529 | } | 3568 | } |
3530 | 3569 | ||
3531 | 3570 | ||
3532 | void CalendarView::checkClipboard() | 3571 | void CalendarView::checkClipboard() |
3533 | { | 3572 | { |
3534 | #ifndef KORG_NODND | 3573 | #ifndef KORG_NODND |
3535 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 3574 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
3536 | emit pasteEnabled(true); | 3575 | emit pasteEnabled(true); |
3537 | } else { | 3576 | } else { |
3538 | emit pasteEnabled(false); | 3577 | emit pasteEnabled(false); |
3539 | } | 3578 | } |
3540 | #endif | 3579 | #endif |
3541 | } | 3580 | } |
3542 | 3581 | ||
3543 | void CalendarView::showDates(const DateList &selectedDates) | 3582 | void CalendarView::showDates(const DateList &selectedDates) |
3544 | { | 3583 | { |
3545 | // kdDebug() << "CalendarView::selectDates()" << endl; | 3584 | // kdDebug() << "CalendarView::selectDates()" << endl; |
3546 | 3585 | ||
3547 | 3586 | ||
3548 | if ( !mBlockShowDates ) { | 3587 | if ( !mBlockShowDates ) { |
3549 | if ( mViewManager->currentView() ) { | 3588 | if ( mViewManager->currentView() ) { |
3550 | updateView( selectedDates.first(), selectedDates.last() ); | 3589 | updateView( selectedDates.first(), selectedDates.last() ); |
3551 | } else { | 3590 | } else { |
3552 | mViewManager->showAgendaView(); | 3591 | mViewManager->showAgendaView(); |
3553 | } | 3592 | } |
3554 | } | 3593 | } |
3555 | 3594 | ||
3556 | QString selDates; | 3595 | QString selDates; |
3557 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); | 3596 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); |
3558 | if (selectedDates.first() < selectedDates.last() ) | 3597 | if (selectedDates.first() < selectedDates.last() ) |
3559 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 3598 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
3560 | else { | 3599 | else { |
3561 | QString addString; | 3600 | QString addString; |
3562 | if ( selectedDates.first() == QDateTime::currentDateTime().date() ) | 3601 | if ( selectedDates.first() == QDateTime::currentDateTime().date() ) |
3563 | addString = i18n("Today"); | 3602 | addString = i18n("Today"); |
3564 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 3603 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
3565 | addString = i18n("Tomorrow"); | 3604 | addString = i18n("Tomorrow"); |
3566 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 3605 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
3567 | addString = i18n("Yesterday"); | 3606 | addString = i18n("Yesterday"); |
3568 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 3607 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
3569 | addString = i18n("Day before yesterday"); | 3608 | addString = i18n("Day before yesterday"); |
3570 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 3609 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
3571 | addString = i18n("Day after tomorrow"); | 3610 | addString = i18n("Day after tomorrow"); |
3572 | if ( !addString.isEmpty() ) { | 3611 | if ( !addString.isEmpty() ) { |
3573 | topLevelWidget()->setCaption( addString+", " + selDates ); | 3612 | topLevelWidget()->setCaption( addString+", " + selDates ); |
3574 | return; | 3613 | return; |
3575 | } | 3614 | } |
3576 | } | 3615 | } |
3577 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 3616 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
3578 | 3617 | ||
3579 | } | 3618 | } |
3580 | 3619 | ||
3581 | QPtrList<CalFilter> CalendarView::filters() | 3620 | QPtrList<CalFilter> CalendarView::filters() |
3582 | { | 3621 | { |
3583 | return mFilters; | 3622 | return mFilters; |
3584 | 3623 | ||
3585 | } | 3624 | } |
3586 | void CalendarView::editFilters() | 3625 | void CalendarView::editFilters() |
3587 | { | 3626 | { |
3588 | // kdDebug() << "CalendarView::editFilters()" << endl; | 3627 | // kdDebug() << "CalendarView::editFilters()" << endl; |
3589 | 3628 | ||
3590 | CalFilter *filter = mFilters.first(); | 3629 | CalFilter *filter = mFilters.first(); |
3591 | while(filter) { | 3630 | while(filter) { |
3592 | kdDebug() << " Filter: " << filter->name() << endl; | 3631 | kdDebug() << " Filter: " << filter->name() << endl; |
3593 | filter = mFilters.next(); | 3632 | filter = mFilters.next(); |
3594 | } | 3633 | } |
3595 | 3634 | ||
3596 | mDialogManager->showFilterEditDialog(&mFilters); | 3635 | mDialogManager->showFilterEditDialog(&mFilters); |
3597 | } | 3636 | } |
3598 | void CalendarView::toggleFilter() | 3637 | void CalendarView::toggleFilter() |
3599 | { | 3638 | { |
3600 | showFilter(! mFilterView->isVisible()); | 3639 | showFilter(! mFilterView->isVisible()); |
3601 | } | 3640 | } |
3602 | 3641 | ||
3603 | KOFilterView *CalendarView::filterView() | 3642 | KOFilterView *CalendarView::filterView() |
3604 | { | 3643 | { |
3605 | return mFilterView; | 3644 | return mFilterView; |
3606 | } | 3645 | } |
3607 | void CalendarView::selectFilter( int fil ) | 3646 | void CalendarView::selectFilter( int fil ) |
3608 | { | 3647 | { |
3609 | mFilterView->setSelectedFilter( fil ); | 3648 | mFilterView->setSelectedFilter( fil ); |
3610 | } | 3649 | } |
3611 | void CalendarView::showFilter(bool visible) | 3650 | void CalendarView::showFilter(bool visible) |
3612 | { | 3651 | { |
3613 | if (visible) mFilterView->show(); | 3652 | if (visible) mFilterView->show(); |
3614 | else mFilterView->hide(); | 3653 | else mFilterView->hide(); |
3615 | } | 3654 | } |
3616 | void CalendarView::toggleFilerEnabled( ) | 3655 | void CalendarView::toggleFilerEnabled( ) |
3617 | { | 3656 | { |
3618 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 3657 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
3619 | if ( !mFilterView->filtersEnabled() ) | 3658 | if ( !mFilterView->filtersEnabled() ) |
3620 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 3659 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
3621 | 3660 | ||
3622 | } | 3661 | } |
3623 | void CalendarView::updateFilter() | 3662 | void CalendarView::updateFilter() |
3624 | { | 3663 | { |
3625 | CalFilter *filter = mFilterView->selectedFilter(); | 3664 | CalFilter *filter = mFilterView->selectedFilter(); |
3626 | if (filter) { | 3665 | if (filter) { |
3627 | QString mess; | 3666 | QString mess; |
3628 | if (mFilterView->filtersEnabled()) { | 3667 | if (mFilterView->filtersEnabled()) { |
3629 | mess = i18n("Filter selected: ")+filter->name(); | 3668 | mess = i18n("Filter selected: ")+filter->name(); |
3630 | filter->setEnabled(true); | 3669 | filter->setEnabled(true); |
3631 | } | 3670 | } |
3632 | else filter->setEnabled(false); | 3671 | else filter->setEnabled(false); |
3633 | mCalendar->setFilter(filter); | 3672 | mCalendar->setFilter(filter); |
3634 | updateView(); | 3673 | updateView(); |
3635 | if ( !mess.isEmpty() ) | 3674 | if ( !mess.isEmpty() ) |
3636 | topLevelWidget()->setCaption( mess ); | 3675 | topLevelWidget()->setCaption( mess ); |
3637 | 3676 | ||
3638 | } | 3677 | } |
3639 | } | 3678 | } |
3640 | 3679 | ||
3641 | void CalendarView::filterEdited() | 3680 | void CalendarView::filterEdited() |
3642 | { | 3681 | { |
3643 | mFilterView->updateFilters(); | 3682 | mFilterView->updateFilters(); |
3644 | updateFilter(); | 3683 | updateFilter(); |
3645 | writeSettings(); | 3684 | writeSettings(); |
3646 | } | 3685 | } |
3647 | 3686 | ||
3648 | 3687 | ||
3649 | void CalendarView::takeOverEvent() | 3688 | void CalendarView::takeOverEvent() |
3650 | { | 3689 | { |
3651 | Incidence *incidence = currentSelection(); | 3690 | Incidence *incidence = currentSelection(); |
3652 | 3691 | ||
3653 | if (!incidence) return; | 3692 | if (!incidence) return; |
3654 | 3693 | ||
3655 | incidence->setOrganizer(KOPrefs::instance()->email()); | 3694 | incidence->setOrganizer(KOPrefs::instance()->email()); |
3656 | incidence->recreate(); | 3695 | incidence->recreate(); |
3657 | incidence->setReadOnly(false); | 3696 | incidence->setReadOnly(false); |
3658 | 3697 | ||
3659 | updateView(); | 3698 | updateView(); |
3660 | } | 3699 | } |
3661 | 3700 | ||
3662 | void CalendarView::takeOverCalendar() | 3701 | void CalendarView::takeOverCalendar() |
3663 | { | 3702 | { |
3664 | // TODO: Create Calendar::allIncidences() function and use it here | 3703 | // TODO: Create Calendar::allIncidences() function and use it here |
3665 | 3704 | ||
3666 | QPtrList<Event> events = mCalendar->events(); | 3705 | QPtrList<Event> events = mCalendar->events(); |
3667 | for(uint i=0; i<events.count(); ++i) { | 3706 | for(uint i=0; i<events.count(); ++i) { |
3668 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3707 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3669 | events.at(i)->recreate(); | 3708 | events.at(i)->recreate(); |
3670 | events.at(i)->setReadOnly(false); | 3709 | events.at(i)->setReadOnly(false); |
3671 | } | 3710 | } |
3672 | 3711 | ||
3673 | QPtrList<Todo> todos = mCalendar->todos(); | 3712 | QPtrList<Todo> todos = mCalendar->todos(); |
3674 | for(uint i=0; i<todos.count(); ++i) { | 3713 | for(uint i=0; i<todos.count(); ++i) { |
3675 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3714 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3676 | todos.at(i)->recreate(); | 3715 | todos.at(i)->recreate(); |
3677 | todos.at(i)->setReadOnly(false); | 3716 | todos.at(i)->setReadOnly(false); |
3678 | } | 3717 | } |
3679 | 3718 | ||
3680 | QPtrList<Journal> journals = mCalendar->journals(); | 3719 | QPtrList<Journal> journals = mCalendar->journals(); |
3681 | for(uint i=0; i<journals.count(); ++i) { | 3720 | for(uint i=0; i<journals.count(); ++i) { |
3682 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3721 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3683 | journals.at(i)->recreate(); | 3722 | journals.at(i)->recreate(); |
3684 | journals.at(i)->setReadOnly(false); | 3723 | journals.at(i)->setReadOnly(false); |
3685 | } | 3724 | } |
3686 | 3725 | ||
3687 | updateView(); | 3726 | updateView(); |
3688 | } | 3727 | } |
3689 | 3728 | ||
3690 | void CalendarView::showIntro() | 3729 | void CalendarView::showIntro() |
3691 | { | 3730 | { |
3692 | kdDebug() << "To be implemented." << endl; | 3731 | kdDebug() << "To be implemented." << endl; |
3693 | } | 3732 | } |
3694 | 3733 | ||
3695 | QWidgetStack *CalendarView::viewStack() | 3734 | QWidgetStack *CalendarView::viewStack() |
3696 | { | 3735 | { |
3697 | return mRightFrame; | 3736 | return mRightFrame; |
3698 | } | 3737 | } |
3699 | 3738 | ||
3700 | QWidget *CalendarView::leftFrame() | 3739 | QWidget *CalendarView::leftFrame() |
3701 | { | 3740 | { |
3702 | return ( QWidget *)mLeftFrame; | 3741 | return ( QWidget *)mLeftFrame; |
3703 | } | 3742 | } |
3704 | 3743 | ||
3705 | DateNavigator *CalendarView::dateNavigator() | 3744 | DateNavigator *CalendarView::dateNavigator() |
3706 | { | 3745 | { |
3707 | return mNavigator; | 3746 | return mNavigator; |
3708 | } | 3747 | } |
3709 | 3748 | ||
3710 | KDateNavigator* CalendarView::dateNavigatorWidget() | 3749 | KDateNavigator* CalendarView::dateNavigatorWidget() |
3711 | { | 3750 | { |
3712 | return mDateNavigator->navigatorView(); | 3751 | return mDateNavigator->navigatorView(); |
3713 | } | 3752 | } |
3714 | void CalendarView::toggleDateNavigatorWidget() | 3753 | void CalendarView::toggleDateNavigatorWidget() |
3715 | { | 3754 | { |
3716 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 3755 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
3717 | mLeftFrame->toggle(); | 3756 | |
3718 | // FIXME mShowDateNavigator is not the toggle state of mLeftFrame | ||
3719 | #if 0 | ||
3720 | if (!KOPrefs::instance()->mShowDateNavigator ) | 3757 | if (!KOPrefs::instance()->mShowDateNavigator ) |
3721 | mDateNavigator->hide(); | 3758 | mDateNavigator->hide(); |
3722 | else | 3759 | else |
3723 | mDateNavigator->show(); | 3760 | mDateNavigator->show(); |
3724 | #endif | ||
3725 | } | 3761 | } |
3726 | void CalendarView::addView(KOrg::BaseView *view) | 3762 | void CalendarView::addView(KOrg::BaseView *view) |
3727 | { | 3763 | { |
3728 | mViewManager->addView(view); | 3764 | mViewManager->addView(view); |
3729 | } | 3765 | } |
3730 | 3766 | ||
3731 | void CalendarView::showView(KOrg::BaseView *view) | 3767 | void CalendarView::showView(KOrg::BaseView *view) |
3732 | { | 3768 | { |
3733 | mViewManager->showView(view, mLeftFrame->isVisible()); | 3769 | mViewManager->showView(view, mLeftFrame->isVisible()); |
3734 | } | 3770 | } |
3735 | 3771 | ||
3736 | Incidence *CalendarView::currentSelection() | 3772 | Incidence *CalendarView::currentSelection() |
3737 | { | 3773 | { |
3738 | return mViewManager->currentSelection(); | 3774 | return mViewManager->currentSelection(); |
3739 | } | 3775 | } |
3740 | void CalendarView::toggleAllDaySize() | 3776 | void CalendarView::toggleAllDaySize() |
3741 | { | 3777 | { |
3742 | /* | 3778 | /* |
3743 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 3779 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
3744 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 3780 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
3745 | else | 3781 | else |
3746 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 3782 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
3747 | */ | 3783 | */ |
3748 | viewManager()->agendaView()->toggleAllDay(); | 3784 | viewManager()->agendaView()->toggleAllDay(); |
3749 | } | 3785 | } |
3750 | void CalendarView::toggleExpand() | 3786 | void CalendarView::toggleExpand() |
3751 | { | 3787 | { |
3752 | // if ( mLeftFrame->isHidden() ) { | 3788 | // if ( mLeftFrame->isHidden() ) { |
3753 | // mLeftFrame->show(); | 3789 | // mLeftFrame->show(); |
3754 | // emit calendarViewExpanded( false ); | 3790 | // emit calendarViewExpanded( false ); |
3755 | // } else { | 3791 | // } else { |
3756 | // mLeftFrame->hide(); | 3792 | // mLeftFrame->hide(); |
3757 | // emit calendarViewExpanded( true ); | 3793 | // emit calendarViewExpanded( true ); |
3758 | // } | 3794 | // } |
3759 | //qDebug(" CalendarView::toggleExpand()"); | 3795 | //qDebug(" CalendarView::toggleExpand()"); |
3760 | globalFlagBlockAgenda = 1; | 3796 | globalFlagBlockAgenda = 1; |
3761 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 3797 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
3762 | globalFlagBlockAgenda = 5; | 3798 | globalFlagBlockAgenda = 5; |
3763 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 3799 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
3764 | //mViewManager->showView( 0, true ); | 3800 | //mViewManager->showView( 0, true ); |
3765 | } | 3801 | } |
3766 | 3802 | ||
3767 | void CalendarView::calendarModified( bool modified, Calendar * ) | 3803 | void CalendarView::calendarModified( bool modified, Calendar * ) |
3768 | { | 3804 | { |
3769 | setModified( modified ); | 3805 | setModified( modified ); |
3770 | } | 3806 | } |
3771 | 3807 | ||
3772 | Todo *CalendarView::selectedTodo() | 3808 | Todo *CalendarView::selectedTodo() |
3773 | { | 3809 | { |
3774 | Incidence *incidence = currentSelection(); | 3810 | Incidence *incidence = currentSelection(); |
3775 | if ( incidence && incidence->type() == "Todo" ) { | 3811 | if ( incidence && incidence->type() == "Todo" ) { |
3776 | return static_cast<Todo *>( incidence ); | 3812 | return static_cast<Todo *>( incidence ); |
3777 | } | 3813 | } |
3778 | 3814 | ||
3779 | incidence = mTodoList->selectedIncidences().first(); | 3815 | incidence = mTodoList->selectedIncidences().first(); |
3780 | if ( incidence && incidence->type() == "Todo" ) { | 3816 | if ( incidence && incidence->type() == "Todo" ) { |
3781 | return static_cast<Todo *>( incidence ); | 3817 | return static_cast<Todo *>( incidence ); |
3782 | } | 3818 | } |
3783 | 3819 | ||
3784 | return 0; | 3820 | return 0; |
3785 | } | 3821 | } |
3786 | 3822 | ||
3787 | void CalendarView::dialogClosing(Incidence *in) | 3823 | void CalendarView::dialogClosing(Incidence *in) |
3788 | { | 3824 | { |
3789 | // mDialogList.remove(in); | 3825 | // mDialogList.remove(in); |
3790 | } | 3826 | } |
3791 | 3827 | ||
3792 | void CalendarView::showIncidence() | 3828 | void CalendarView::showIncidence() |
3793 | { | 3829 | { |
3794 | mViewerCallerIsSearchDialog = false; | 3830 | mViewerCallerIsSearchDialog = false; |
3795 | Incidence *incidence = currentSelection(); | 3831 | Incidence *incidence = currentSelection(); |
3796 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3832 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3797 | if ( incidence ) { | 3833 | if ( incidence ) { |
3798 | ShowIncidenceVisitor v; | 3834 | ShowIncidenceVisitor v; |
3799 | v.act( incidence, this ); | 3835 | v.act( incidence, this ); |
3800 | } | 3836 | } |
3801 | } | 3837 | } |
3802 | void CalendarView::editIncidenceDescription() | 3838 | void CalendarView::editIncidenceDescription() |
3803 | { | 3839 | { |
3804 | mFlagEditDescription = true; | 3840 | mFlagEditDescription = true; |
3805 | editIncidence(); | 3841 | editIncidence(); |
3806 | mFlagEditDescription = false; | 3842 | mFlagEditDescription = false; |
3807 | } | 3843 | } |
3808 | void CalendarView::editIncidence() | 3844 | void CalendarView::editIncidence() |
3809 | { | 3845 | { |
3810 | // qDebug("editIncidence() "); | 3846 | // qDebug("editIncidence() "); |
3811 | Incidence *incidence = currentSelection(); | 3847 | Incidence *incidence = currentSelection(); |
3812 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3848 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3813 | if ( incidence ) { | 3849 | if ( incidence ) { |
3814 | EditIncidenceVisitor v; | 3850 | EditIncidenceVisitor v; |
3815 | v.act( incidence, this ); | 3851 | v.act( incidence, this ); |
3816 | } | 3852 | } |
3817 | } | 3853 | } |
3818 | 3854 | ||
3819 | void CalendarView::deleteIncidence() | 3855 | void CalendarView::deleteIncidence() |
3820 | { | 3856 | { |
3821 | Incidence *incidence = currentSelection(); | 3857 | Incidence *incidence = currentSelection(); |
3822 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3858 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3823 | if ( incidence ) { | 3859 | if ( incidence ) { |
3824 | deleteIncidence(incidence); | 3860 | deleteIncidence(incidence); |
3825 | } | 3861 | } |
3826 | } | 3862 | } |
3827 | 3863 | ||
3828 | void CalendarView::showIncidence(Incidence *incidence) | 3864 | void CalendarView::showIncidence(Incidence *incidence) |
3829 | { | 3865 | { |
3830 | mViewerCallerIsSearchDialog = false; | 3866 | mViewerCallerIsSearchDialog = false; |
3831 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); | 3867 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); |
3832 | if ( sender() && mDialogManager->getSearchDialog() ) { | 3868 | if ( sender() && mDialogManager->getSearchDialog() ) { |
3833 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { | 3869 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { |
3834 | mViewerCallerIsSearchDialog = true; | 3870 | mViewerCallerIsSearchDialog = true; |
3835 | } | 3871 | } |
3836 | } | 3872 | } |
3837 | if ( incidence ) { | 3873 | if ( incidence ) { |
3838 | ShowIncidenceVisitor v; | 3874 | ShowIncidenceVisitor v; |
3839 | v.act( incidence, this ); | 3875 | v.act( incidence, this ); |
3840 | } | 3876 | } |
3841 | } | 3877 | } |
3842 | 3878 | ||
3843 | void CalendarView::editIncidence(Incidence *incidence) | 3879 | void CalendarView::editIncidence(Incidence *incidence) |
3844 | { | 3880 | { |
3845 | if ( incidence ) { | 3881 | if ( incidence ) { |
3846 | 3882 | ||
3847 | EditIncidenceVisitor v; | 3883 | EditIncidenceVisitor v; |
3848 | v.act( incidence, this ); | 3884 | v.act( incidence, this ); |
3849 | 3885 | ||
3850 | } | 3886 | } |
3851 | } | 3887 | } |
3852 | 3888 | ||
3853 | void CalendarView::deleteIncidence(Incidence *incidence) | 3889 | void CalendarView::deleteIncidence(Incidence *incidence) |
3854 | { | 3890 | { |
3855 | //qDebug(" CalendarView::deleteIncidence "); | 3891 | //qDebug(" CalendarView::deleteIncidence "); |
3856 | if ( incidence ) { | 3892 | if ( incidence ) { |
3857 | DeleteIncidenceVisitor v; | 3893 | DeleteIncidenceVisitor v; |
3858 | v.act( incidence, this ); | 3894 | v.act( incidence, this ); |
3859 | } | 3895 | } |
3860 | } | 3896 | } |
3861 | 3897 | ||
3862 | 3898 | ||
3863 | void CalendarView::lookForOutgoingMessages() | 3899 | void CalendarView::lookForOutgoingMessages() |
3864 | { | 3900 | { |
3865 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 3901 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
3866 | ogd->loadMessages(); | 3902 | ogd->loadMessages(); |
3867 | } | 3903 | } |
3868 | 3904 | ||
3869 | void CalendarView::lookForIncomingMessages() | 3905 | void CalendarView::lookForIncomingMessages() |
3870 | { | 3906 | { |
3871 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 3907 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
3872 | icd->retrieve(); | 3908 | icd->retrieve(); |
3873 | } | 3909 | } |
3874 | 3910 | ||
3875 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 3911 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
3876 | { | 3912 | { |
3877 | bool deleteTodo = true; | 3913 | bool deleteTodo = true; |
3878 | QPtrList<Incidence> subTodos; | 3914 | QPtrList<Incidence> subTodos; |
3879 | Incidence *aTodo; | 3915 | Incidence *aTodo; |
3880 | subTodos = t->relations(); | 3916 | subTodos = t->relations(); |
3881 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 3917 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
3882 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 3918 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
3883 | deleteTodo = false; | 3919 | deleteTodo = false; |
3884 | } | 3920 | } |
3885 | if ( deleteTodo ) { | 3921 | if ( deleteTodo ) { |
3886 | if ( t->isCompleted() && !t->doesRecur()) { | 3922 | if ( t->isCompleted() && !t->doesRecur()) { |
3887 | checkExternalId( t ); | 3923 | checkExternalId( t ); |
3888 | mCalendar->deleteTodo( t ); | 3924 | mCalendar->deleteTodo( t ); |
3889 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 3925 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
3890 | } | 3926 | } |
3891 | else | 3927 | else |
3892 | deleteTodo = false; | 3928 | deleteTodo = false; |
3893 | } | 3929 | } |
3894 | return deleteTodo; | 3930 | return deleteTodo; |
3895 | 3931 | ||
3896 | } | 3932 | } |
3897 | void CalendarView::purgeCompleted() | 3933 | void CalendarView::purgeCompleted() |
3898 | { | 3934 | { |
3899 | int result = KMessageBox::warningContinueCancel(this, | 3935 | int result = KMessageBox::warningContinueCancel(this, |
3900 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); | 3936 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); |
3901 | 3937 | ||
3902 | if (result == KMessageBox::Continue) { | 3938 | if (result == KMessageBox::Continue) { |
3903 | 3939 | ||
3904 | QPtrList<Todo> todoCal; | 3940 | QPtrList<Todo> todoCal; |
3905 | QPtrList<Todo> rootTodos; | 3941 | QPtrList<Todo> rootTodos; |
3906 | //QPtrList<Incidence> rel; | 3942 | //QPtrList<Incidence> rel; |
3907 | Todo *aTodo;//, *rTodo; | 3943 | Todo *aTodo;//, *rTodo; |
3908 | Incidence *rIncidence; | 3944 | Incidence *rIncidence; |
3909 | bool childDelete = false; | 3945 | bool childDelete = false; |
3910 | bool deletedOne = true; | 3946 | bool deletedOne = true; |
3911 | todoCal = calendar()->todos(); | 3947 | todoCal = calendar()->todos(); |
3912 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 3948 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
3913 | if ( !aTodo->relatedTo() ) | 3949 | if ( !aTodo->relatedTo() ) |
3914 | rootTodos.append( aTodo ); | 3950 | rootTodos.append( aTodo ); |
3915 | } | 3951 | } |
3916 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 3952 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |