summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-01-19 22:57:42 (UTC)
committer zautrix <zautrix>2005-01-19 22:57:42 (UTC)
commitade7e8fcdcf45d5bc73ea73da6f9a1b06964a64e (patch) (unidiff)
tree990ed560fbf9126fba2abdaf98c036cddad2d94f /korganizer
parenta9f8ad6916ea1a849a43fe49c4085f6c44b5c47b (diff)
downloadkdepimpi-ade7e8fcdcf45d5bc73ea73da6f9a1b06964a64e.zip
kdepimpi-ade7e8fcdcf45d5bc73ea73da6f9a1b06964a64e.tar.gz
kdepimpi-ade7e8fcdcf45d5bc73ea73da6f9a1b06964a64e.tar.bz2
many view fixes
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp22
-rw-r--r--korganizer/calendarview.h2
-rw-r--r--korganizer/komonthview.cpp89
-rw-r--r--korganizer/komonthview.h8
-rw-r--r--korganizer/koviewmanager.cpp6
5 files changed, 85 insertions, 42 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 12af655..f9af769 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -140,632 +140,637 @@ extern int globalFlagBlockStartup;
140 140
141class KOBeamPrefs : public QDialog 141class KOBeamPrefs : public QDialog
142{ 142{
143 public: 143 public:
144 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 144 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
145 QDialog( parent, name, true ) 145 QDialog( parent, name, true )
146 { 146 {
147 setCaption( i18n("Beam Options") ); 147 setCaption( i18n("Beam Options") );
148 QVBoxLayout* lay = new QVBoxLayout( this ); 148 QVBoxLayout* lay = new QVBoxLayout( this );
149 lay->setSpacing( 3 ); 149 lay->setSpacing( 3 );
150 lay->setMargin( 3 ); 150 lay->setMargin( 3 );
151 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 151 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
152 lay->addWidget( format ); 152 lay->addWidget( format );
153 format->setExclusive ( true ) ; 153 format->setExclusive ( true ) ;
154 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 154 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
155 lay->addWidget( time ); time->setExclusive ( true ) ; 155 lay->addWidget( time ); time->setExclusive ( true ) ;
156 vcal = new QRadioButton(" vCalendar ", format ); 156 vcal = new QRadioButton(" vCalendar ", format );
157 ical = new QRadioButton(" iCalendar ", format ); 157 ical = new QRadioButton(" iCalendar ", format );
158 vcal->setChecked( true ); 158 vcal->setChecked( true );
159 tz = new QRadioButton(i18n(" With timezone "), time ); 159 tz = new QRadioButton(i18n(" With timezone "), time );
160 local = new QRadioButton(i18n(" Local time "), time ); 160 local = new QRadioButton(i18n(" Local time "), time );
161 tz->setChecked( true ); 161 tz->setChecked( true );
162 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 162 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
163 lay->addWidget( ok ); 163 lay->addWidget( ok );
164 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 164 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
165 lay->addWidget( cancel ); 165 lay->addWidget( cancel );
166 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 166 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
167 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 167 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
168 resize( 200, 200 ); 168 resize( 200, 200 );
169 } 169 }
170 170
171 bool beamVcal() { return vcal->isChecked(); } 171 bool beamVcal() { return vcal->isChecked(); }
172 bool beamLocal() { return local->isChecked(); } 172 bool beamLocal() { return local->isChecked(); }
173private: 173private:
174 QRadioButton* vcal, *ical, *local, *tz; 174 QRadioButton* vcal, *ical, *local, *tz;
175}; 175};
176class KOCatPrefs : public QDialog 176class KOCatPrefs : public QDialog
177{ 177{
178 public: 178 public:
179 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 179 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
180 QDialog( parent, name, true ) 180 QDialog( parent, name, true )
181 { 181 {
182 setCaption( i18n("Manage new Categories") ); 182 setCaption( i18n("Manage new Categories") );
183 QVBoxLayout* lay = new QVBoxLayout( this ); 183 QVBoxLayout* lay = new QVBoxLayout( this );
184 lay->setSpacing( 3 ); 184 lay->setSpacing( 3 );
185 lay->setMargin( 3 ); 185 lay->setMargin( 3 );
186 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 ); 186 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 lay->addWidget( lab ); 187 lay->addWidget( lab );
188 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 188 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
189 lay->addWidget( format ); 189 lay->addWidget( format );
190 format->setExclusive ( true ) ; 190 format->setExclusive ( true ) ;
191 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 191 addCatBut = new QRadioButton(i18n("Add to category list"), format );
192 new QRadioButton(i18n("Remove from Events/Todos"), format ); 192 new QRadioButton(i18n("Remove from Events/Todos"), format );
193 addCatBut->setChecked( true ); 193 addCatBut->setChecked( true );
194 QPushButton * ok = new QPushButton( i18n("OK"), this ); 194 QPushButton * ok = new QPushButton( i18n("OK"), this );
195 lay->addWidget( ok ); 195 lay->addWidget( ok );
196 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 196 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
197 lay->addWidget( cancel ); 197 lay->addWidget( cancel );
198 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 198 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
199 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 199 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
200 resize( 200, 200 ); 200 resize( 200, 200 );
201 } 201 }
202 202
203 bool addCat() { return addCatBut->isChecked(); } 203 bool addCat() { return addCatBut->isChecked(); }
204private: 204private:
205 QRadioButton* addCatBut; 205 QRadioButton* addCatBut;
206}; 206};
207 207
208 208
209 209
210CalendarView::CalendarView( CalendarResources *calendar, 210CalendarView::CalendarView( CalendarResources *calendar,
211 QWidget *parent, const char *name ) 211 QWidget *parent, const char *name )
212 : CalendarViewBase( parent, name ), 212 : CalendarViewBase( parent, name ),
213 mCalendar( calendar ), 213 mCalendar( calendar ),
214 mResourceManager( calendar->resourceManager() ) 214 mResourceManager( calendar->resourceManager() )
215{ 215{
216 216
217 mEventEditor = 0; 217 mEventEditor = 0;
218 mTodoEditor = 0; 218 mTodoEditor = 0;
219 219
220 init(); 220 init();
221} 221}
222 222
223CalendarView::CalendarView( Calendar *calendar, 223CalendarView::CalendarView( Calendar *calendar,
224 QWidget *parent, const char *name ) 224 QWidget *parent, const char *name )
225 : CalendarViewBase( parent, name ), 225 : CalendarViewBase( parent, name ),
226 mCalendar( calendar ), 226 mCalendar( calendar ),
227 mResourceManager( 0 ) 227 mResourceManager( 0 )
228{ 228{
229 229
230 mEventEditor = 0; 230 mEventEditor = 0;
231 mTodoEditor = 0; 231 mTodoEditor = 0;
232 init();} 232 init();}
233 233
234void CalendarView::init() 234void CalendarView::init()
235{ 235{
236 mBlockShowDates = false;
236 beamDialog = new KOBeamPrefs(); 237 beamDialog = new KOBeamPrefs();
237 mDatePickerMode = 0; 238 mDatePickerMode = 0;
238 mCurrentSyncDevice = ""; 239 mCurrentSyncDevice = "";
239 writeLocale(); 240 writeLocale();
240 mViewManager = new KOViewManager( this ); 241 mViewManager = new KOViewManager( this );
241 mDialogManager = new KODialogManager( this ); 242 mDialogManager = new KODialogManager( this );
242 mEventViewerDialog = 0; 243 mEventViewerDialog = 0;
243 mModified = false; 244 mModified = false;
244 mReadOnly = false; 245 mReadOnly = false;
245 mSelectedIncidence = 0; 246 mSelectedIncidence = 0;
246 mCalPrinter = 0; 247 mCalPrinter = 0;
247 mFilters.setAutoDelete(true); 248 mFilters.setAutoDelete(true);
248 249
249 mCalendar->registerObserver( this ); 250 mCalendar->registerObserver( this );
250 // TODO: Make sure that view is updated, when calendar is changed. 251 // TODO: Make sure that view is updated, when calendar is changed.
251 252
252 mStorage = new FileStorage( mCalendar ); 253 mStorage = new FileStorage( mCalendar );
253 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 254 mNavigator = new DateNavigator( this, "datevav", mViewManager );
254 255
255 QBoxLayout *topLayout = (QBoxLayout*)layout(); 256 QBoxLayout *topLayout = (QBoxLayout*)layout();
256#ifndef KORG_NOSPLITTER 257#ifndef KORG_NOSPLITTER
257 // create the main layout frames. 258 // create the main layout frames.
258 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 259 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
259 topLayout->addWidget(mPanner); 260 topLayout->addWidget(mPanner);
260 261
261 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 262 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
262 "CalendarView::LeftFrame"); 263 "CalendarView::LeftFrame");
263 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 264 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
264 265
265 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, 266 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE,
266 "CalendarView::DateNavigator", QDate::currentDate() ); 267 "CalendarView::DateNavigator", QDate::currentDate() );
267 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 268 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
268 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 269 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
269 mTodoList->setNavigator( mNavigator ); 270 mTodoList->setNavigator( mNavigator );
270 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 271 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
271 272
272#ifdef KORG_NORESOURCEVIEW 273#ifdef KORG_NORESOURCEVIEW
273 mResourceView = 0; 274 mResourceView = 0;
274#else 275#else
275 if ( mResourceManager ) { 276 if ( mResourceManager ) {
276 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 277 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
277 mResourceView->updateView(); 278 mResourceView->updateView();
278 connect( mResourceView, SIGNAL( resourcesChanged() ), 279 connect( mResourceView, SIGNAL( resourcesChanged() ),
279 SLOT( updateView() ) ); 280 SLOT( updateView() ) );
280 } else { 281 } else {
281 mResourceView = 0; 282 mResourceView = 0;
282 } 283 }
283#endif 284#endif
284 QWidget *rightBox = new QWidget( mPanner ); 285 QWidget *rightBox = new QWidget( mPanner );
285 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 286 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
286 287
287 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 288 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
288 rightLayout->addWidget( mNavigatorBar ); 289 rightLayout->addWidget( mNavigatorBar );
289 290
290 mRightFrame = new QWidgetStack( rightBox ); 291 mRightFrame = new QWidgetStack( rightBox );
291 rightLayout->addWidget( mRightFrame, 1 ); 292 rightLayout->addWidget( mRightFrame, 1 );
292 293
293 mLeftFrame = mLeftSplitter; 294 mLeftFrame = mLeftSplitter;
294#else 295#else
295 QWidget *mainBox = new QWidget( this ); 296 QWidget *mainBox = new QWidget( this );
296 QWidget *leftFrame = new QWidget( mainBox ); 297 QWidget *leftFrame = new QWidget( mainBox );
297 298
298 QBoxLayout * mainBoxLayout; 299 QBoxLayout * mainBoxLayout;
299 QBoxLayout * leftFrameLayout; 300 QBoxLayout * leftFrameLayout;
300 if ( KOPrefs::instance()->mVerticalScreen ) { 301 if ( KOPrefs::instance()->mVerticalScreen ) {
301 mainBoxLayout = new QVBoxLayout(mainBox); 302 mainBoxLayout = new QVBoxLayout(mainBox);
302 leftFrameLayout = new QHBoxLayout(leftFrame ); 303 leftFrameLayout = new QHBoxLayout(leftFrame );
303 } else { 304 } else {
304 mainBoxLayout = new QHBoxLayout(mainBox); 305 mainBoxLayout = new QHBoxLayout(mainBox);
305 leftFrameLayout = new QVBoxLayout(leftFrame ); 306 leftFrameLayout = new QVBoxLayout(leftFrame );
306 } 307 }
307 topLayout->addWidget( mainBox ); 308 topLayout->addWidget( mainBox );
308 mainBoxLayout->addWidget (leftFrame); 309 mainBoxLayout->addWidget (leftFrame);
309 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, 310 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE,
310 "CalendarView::DateNavigator", QDate::currentDate()); 311 "CalendarView::DateNavigator", QDate::currentDate());
311 // mDateNavigator->blockSignals( true ); 312 // mDateNavigator->blockSignals( true );
312 leftFrameLayout->addWidget( mDateNavigator ); 313 leftFrameLayout->addWidget( mDateNavigator );
313 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); 314 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView");
314 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); 315 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall");
315 mTodoList->setNavigator( mNavigator ); 316 mTodoList->setNavigator( mNavigator );
316 317
317 if ( QApplication::desktop()->width() < 480 ) { 318 if ( QApplication::desktop()->width() < 480 ) {
318 leftFrameLayout->addWidget(mFilterView); 319 leftFrameLayout->addWidget(mFilterView);
319 leftFrameLayout->addWidget(mTodoList, 2 ); 320 leftFrameLayout->addWidget(mTodoList, 2 );
320 321
321 } else { 322 } else {
322 leftFrameLayout->addWidget(mTodoList,2 ); 323 leftFrameLayout->addWidget(mTodoList,2 );
323 leftFrameLayout->addWidget(mFilterView ); 324 leftFrameLayout->addWidget(mFilterView );
324 } 325 }
325 mFilterView->hide(); 326 mFilterView->hide();
326 QWidget *rightBox = new QWidget( mainBox ); 327 QWidget *rightBox = new QWidget( mainBox );
327 mainBoxLayout->addWidget ( rightBox, 10 ); 328 mainBoxLayout->addWidget ( rightBox, 10 );
328 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 329 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
329 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 330 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
330 mRightFrame = new QWidgetStack( rightBox ); 331 mRightFrame = new QWidgetStack( rightBox );
331 rightLayout->addWidget( mNavigatorBar ); 332 rightLayout->addWidget( mNavigatorBar );
332 rightLayout->addWidget( mRightFrame, 10 ); 333 rightLayout->addWidget( mRightFrame, 10 );
333 334
334 mLeftFrame = leftFrame; 335 mLeftFrame = leftFrame;
335 if ( KOPrefs::instance()->mVerticalScreen ) { 336 if ( KOPrefs::instance()->mVerticalScreen ) {
336 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 337 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
337 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 338 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
338 } else { 339 } else {
339 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 340 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
340 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 341 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
341 } 342 }
342 if ( !KOPrefs::instance()->mShowDateNavigator) 343 if ( !KOPrefs::instance()->mShowDateNavigator)
343 mDateNavigator->hide(); 344 mDateNavigator->hide();
344 //qDebug("Calendarview Size %d %d ", width(), height()); 345 //qDebug("Calendarview Size %d %d ", width(), height());
345#endif 346#endif
346 347
347 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 348 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
348 SLOT( showDates( const KCal::DateList & ) ) ); 349 SLOT( showDates( const KCal::DateList & ) ) );
350
349 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 351 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
350 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 352 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
351
352 connect( mNavigatorBar, SIGNAL( goPrevYear() ), 353 connect( mNavigatorBar, SIGNAL( goPrevYear() ),
353 mNavigator, SLOT( selectPreviousYear() ) ); 354 mNavigator, SLOT( selectPreviousYear() ) );
354 connect( mNavigatorBar, SIGNAL( goNextYear() ), 355 connect( mNavigatorBar, SIGNAL( goNextYear() ),
355 mNavigator, SLOT( selectNextYear() ) ); 356 mNavigator, SLOT( selectNextYear() ) );
356 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), 357 connect( mNavigatorBar, SIGNAL( goPrevMonth() ),
357 mNavigator, SLOT( selectPreviousMonth() ) ); 358 mNavigator, SLOT( selectPreviousMonth() ) );
358 connect( mNavigatorBar, SIGNAL( goNextMonth() ), 359 connect( mNavigatorBar, SIGNAL( goNextMonth() ),
359 mNavigator, SLOT( selectNextMonth() ) ); 360 mNavigator, SLOT( selectNextMonth() ) );
360 361
361 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 362 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
362 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); 363 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) );
363 364
364 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 365 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
365 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 366 mNavigator, SLOT( selectWeek( const QDate & ) ) );
366 367
367 connect( mDateNavigator, SIGNAL( goPrevYear() ), 368 connect( mDateNavigator, SIGNAL( goPrevYear() ),
368 mNavigator, SLOT( selectPreviousYear() ) ); 369 mNavigator, SLOT( selectPreviousYear() ) );
369 connect( mDateNavigator, SIGNAL( goNextYear() ), 370 connect( mDateNavigator, SIGNAL( goNextYear() ),
370 mNavigator, SLOT( selectNextYear() ) ); 371 mNavigator, SLOT( selectNextYear() ) );
371 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 372 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
372 mNavigator, SLOT( selectPreviousMonth() ) ); 373 mNavigator, SLOT( selectPreviousMonth() ) );
373 connect( mDateNavigator, SIGNAL( goNextMonth() ), 374 connect( mDateNavigator, SIGNAL( goNextMonth() ),
374 mNavigator, SLOT( selectNextMonth() ) ); 375 mNavigator, SLOT( selectNextMonth() ) );
375 376
376 connect( mDateNavigator, SIGNAL( goPrevious() ), 377 connect( mDateNavigator, SIGNAL( goPrevious() ),
377 mNavigator, SLOT( selectPrevious() ) ); 378 mNavigator, SLOT( selectPrevious() ) );
378 connect( mDateNavigator, SIGNAL( goNext() ), 379 connect( mDateNavigator, SIGNAL( goNext() ),
379 mNavigator, SLOT( selectNext() ) ); 380 mNavigator, SLOT( selectNext() ) );
380 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 381 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
381 mNavigator, SLOT( slotMonthSelect( int ) ) ); 382 mNavigator, SLOT( slotMonthSelect( int ) ) );
382 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), 383 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ),
383 mNavigator, SLOT( slotMonthSelect( int ) ) ); 384 mNavigator, SLOT( slotMonthSelect( int ) ) );
384 385
385 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 386 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
386 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 387 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
387 388
388 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 389 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
389 SLOT( eventAdded( Event *) ) ); 390 SLOT( eventAdded( Event *) ) );
390 391
391 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 392 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
392 393
393 connect( this, SIGNAL( configChanged() ), 394 connect( this, SIGNAL( configChanged() ),
394 mDateNavigator, SLOT( updateConfig() ) ); 395 mDateNavigator, SLOT( updateConfig() ) );
395 396
396 connect( mTodoList, SIGNAL( newTodoSignal() ), 397 connect( mTodoList, SIGNAL( newTodoSignal() ),
397 SLOT( newTodo() ) ); 398 SLOT( newTodo() ) );
398 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 399 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
399 SLOT( newSubTodo( Todo * ) ) ); 400 SLOT( newSubTodo( Todo * ) ) );
400 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 401 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
401 SLOT( editTodo( Todo * ) ) ); 402 SLOT( editTodo( Todo * ) ) );
402 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 403 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
403 SLOT( showTodo( Todo *) ) ); 404 SLOT( showTodo( Todo *) ) );
404 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 405 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
405 SLOT( deleteTodo( Todo *) ) ); 406 SLOT( deleteTodo( Todo *) ) );
406 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 407 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
407 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 408 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
408 SLOT( purgeCompleted() ) ); 409 SLOT( purgeCompleted() ) );
409 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 410 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
410 SIGNAL( todoModified( Todo *, int ) ) ); 411 SIGNAL( todoModified( Todo *, int ) ) );
411 412
412 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 413 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
413 this, SLOT ( cloneIncidence( Incidence * ) ) ); 414 this, SLOT ( cloneIncidence( Incidence * ) ) );
414 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 415 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
415 this, SLOT (cancelIncidence( Incidence * ) ) ); 416 this, SLOT (cancelIncidence( Incidence * ) ) );
416 417
417 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 418 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
418 this, SLOT ( moveIncidence( Incidence * ) ) ); 419 this, SLOT ( moveIncidence( Incidence * ) ) );
419 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 420 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
420 this, SLOT ( beamIncidence( Incidence * ) ) ); 421 this, SLOT ( beamIncidence( Incidence * ) ) );
421 422
422 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 423 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
423 this, SLOT ( todo_unsub( Todo * ) ) ); 424 this, SLOT ( todo_unsub( Todo * ) ) );
424 425
425 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 426 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
426 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 427 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
427 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 428 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
428 SLOT( updateTodo( Todo *, int ) ) ); 429 SLOT( updateTodo( Todo *, int ) ) );
429 connect( this, SIGNAL( todoModified( Todo *, int )), this, 430 connect( this, SIGNAL( todoModified( Todo *, int )), this,
430 SLOT( changeTodoDisplay( Todo *, int ) ) ); 431 SLOT( changeTodoDisplay( Todo *, int ) ) );
431 432
432 433
433 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 434 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
434 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 435 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
435 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 436 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
436 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 437 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
437 438
438 439
439 440
440 441
441 442
442 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 443 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
443 SLOT(checkClipboard())); 444 SLOT(checkClipboard()));
444 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 445 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
445 SLOT( processTodoListSelection( Incidence * ) ) ); 446 SLOT( processTodoListSelection( Incidence * ) ) );
446 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 447 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
447 448
448 // kdDebug() << "CalendarView::CalendarView() done" << endl; 449 // kdDebug() << "CalendarView::CalendarView() done" << endl;
449 450
450 mDateFrame = new QVBox(0,0,WType_Popup); 451 mDateFrame = new QVBox(0,0,WType_Popup);
451 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 452 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
452 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 453 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
453 mDateFrame->setLineWidth(3); 454 mDateFrame->setLineWidth(3);
454 mDateFrame->hide(); 455 mDateFrame->hide();
455 mDateFrame->setCaption( i18n( "Pick a date to display")); 456 mDateFrame->setCaption( i18n( "Pick a date to display"));
456 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 457 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
457 458
458 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 459 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
459 460
460 mEventEditor = mDialogManager->getEventEditor(); 461 mEventEditor = mDialogManager->getEventEditor();
461 mTodoEditor = mDialogManager->getTodoEditor(); 462 mTodoEditor = mDialogManager->getTodoEditor();
462 463
463 mFlagEditDescription = false; 464 mFlagEditDescription = false;
464 465
465 mSuspendTimer = new QTimer( this ); 466 mSuspendTimer = new QTimer( this );
466 mAlarmTimer = new QTimer( this ); 467 mAlarmTimer = new QTimer( this );
467 mRecheckAlarmTimer = new QTimer( this ); 468 mRecheckAlarmTimer = new QTimer( this );
468 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 469 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
469 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 470 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
470 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 471 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
471 mAlarmDialog = new AlarmDialog( this ); 472 mAlarmDialog = new AlarmDialog( this );
472 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 473 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
473 mAlarmDialog->setServerNotification( false ); 474 mAlarmDialog->setServerNotification( false );
474 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 475 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
475 476
476 477
477#ifndef DESKTOP_VERSION 478#ifndef DESKTOP_VERSION
478//US listen for arriving address resultsets 479//US listen for arriving address resultsets
479 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 480 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
480 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 481 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
481#endif 482#endif
482 483
483} 484}
484 485
485 486
486CalendarView::~CalendarView() 487CalendarView::~CalendarView()
487{ 488{
488 // kdDebug() << "~CalendarView()" << endl; 489 // kdDebug() << "~CalendarView()" << endl;
489 //qDebug("CalendarView::~CalendarView() "); 490 //qDebug("CalendarView::~CalendarView() ");
490 delete mDialogManager; 491 delete mDialogManager;
491 delete mViewManager; 492 delete mViewManager;
492 delete mStorage; 493 delete mStorage;
493 delete mDateFrame ; 494 delete mDateFrame ;
494 delete beamDialog; 495 delete beamDialog;
495 //kdDebug() << "~CalendarView() done" << endl; 496 //kdDebug() << "~CalendarView() done" << endl;
496} 497}
497 498
498void CalendarView::showDay( QDate d ) 499void CalendarView::showDay( QDate d )
499{ 500{
501 dateNavigator()->blockSignals( true );
500 dateNavigator()->selectDate( d ); 502 dateNavigator()->selectDate( d );
503 dateNavigator()->blockSignals( false );
501 mViewManager->showWeekView(); 504 mViewManager->showWeekView();
502 dateNavigator()->selectDate( d ); 505 dateNavigator()->selectDate( d );
503} 506}
504void CalendarView::timerAlarm() 507void CalendarView::timerAlarm()
505{ 508{
506 //qDebug("CalendarView::timerAlarm() "); 509 //qDebug("CalendarView::timerAlarm() ");
507 computeAlarm(mAlarmNotification ); 510 computeAlarm(mAlarmNotification );
508} 511}
509 512
510void CalendarView::suspendAlarm() 513void CalendarView::suspendAlarm()
511{ 514{
512 //qDebug(" CalendarView::suspendAlarm() "); 515 //qDebug(" CalendarView::suspendAlarm() ");
513 computeAlarm(mSuspendAlarmNotification ); 516 computeAlarm(mSuspendAlarmNotification );
514 517
515} 518}
516 519
517void CalendarView::startAlarm( QString mess , QString filename) 520void CalendarView::startAlarm( QString mess , QString filename)
518{ 521{
519 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 522 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
520 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 523 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
521 524
522} 525}
523 526
524void CalendarView::checkNextTimerAlarm() 527void CalendarView::checkNextTimerAlarm()
525{ 528{
526 mCalendar->checkAlarmForIncidence( 0, true ); 529 mCalendar->checkAlarmForIncidence( 0, true );
527} 530}
528 531
529void CalendarView::computeAlarm( QString msg ) 532void CalendarView::computeAlarm( QString msg )
530{ 533{
531 534
532 QString mess = msg; 535 QString mess = msg;
533 QString mAlarmMessage = mess.mid( 9 ); 536 QString mAlarmMessage = mess.mid( 9 );
534 QString filename = MainWindow::resourcePath(); 537 QString filename = MainWindow::resourcePath();
535 filename += "koalarm.wav"; 538 filename += "koalarm.wav";
536 QString tempfilename; 539 QString tempfilename;
537 if ( mess.left( 13 ) == "suspend_alarm") { 540 if ( mess.left( 13 ) == "suspend_alarm") {
538 bool error = false; 541 bool error = false;
539 int len = mess.mid( 13 ).find("+++"); 542 int len = mess.mid( 13 ).find("+++");
540 if ( len < 2 ) 543 if ( len < 2 )
541 error = true; 544 error = true;
542 else { 545 else {
543 tempfilename = mess.mid( 13, len ); 546 tempfilename = mess.mid( 13, len );
544 if ( !QFile::exists( tempfilename ) ) 547 if ( !QFile::exists( tempfilename ) )
545 error = true; 548 error = true;
546 } 549 }
547 if ( ! error ) { 550 if ( ! error ) {
548 filename = tempfilename; 551 filename = tempfilename;
549 } 552 }
550 mAlarmMessage = mess.mid( 13+len+3 ); 553 mAlarmMessage = mess.mid( 13+len+3 );
551 //qDebug("suspend file %s ",tempfilename.latin1() ); 554 //qDebug("suspend file %s ",tempfilename.latin1() );
552 startAlarm( mAlarmMessage, filename); 555 startAlarm( mAlarmMessage, filename);
553 return; 556 return;
554 } 557 }
555 if ( mess.left( 11 ) == "timer_alarm") { 558 if ( mess.left( 11 ) == "timer_alarm") {
556 //mTimerTime = 0; 559 //mTimerTime = 0;
557 startAlarm( mess.mid( 11 ), filename ); 560 startAlarm( mess.mid( 11 ), filename );
558 return; 561 return;
559 } 562 }
560 if ( mess.left( 10 ) == "proc_alarm") { 563 if ( mess.left( 10 ) == "proc_alarm") {
561 bool error = false; 564 bool error = false;
562 int len = mess.mid( 10 ).find("+++"); 565 int len = mess.mid( 10 ).find("+++");
563 if ( len < 2 ) 566 if ( len < 2 )
564 error = true; 567 error = true;
565 else { 568 else {
566 tempfilename = mess.mid( 10, len ); 569 tempfilename = mess.mid( 10, len );
567 if ( !QFile::exists( tempfilename ) ) 570 if ( !QFile::exists( tempfilename ) )
568 error = true; 571 error = true;
569 } 572 }
570 if ( error ) { 573 if ( error ) {
571 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 574 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
572 mAlarmMessage += mess.mid( 10+len+3+9 ); 575 mAlarmMessage += mess.mid( 10+len+3+9 );
573 } else { 576 } else {
574 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 577 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
575 //qDebug("-----system command %s ",tempfilename.latin1() ); 578 //qDebug("-----system command %s ",tempfilename.latin1() );
576#ifndef _WIN32_ 579#ifndef _WIN32_
577 if ( vfork () == 0 ) { 580 if ( vfork () == 0 ) {
578 execl ( tempfilename.latin1(), 0 ); 581 execl ( tempfilename.latin1(), 0 );
579 return; 582 return;
580 } 583 }
581#else 584#else
582 QProcess* p = new QProcess(); 585 QProcess* p = new QProcess();
583 p->addArgument( tempfilename.latin1() ); 586 p->addArgument( tempfilename.latin1() );
584 p->start(); 587 p->start();
585 return; 588 return;
586#endif 589#endif
587 590
588 return; 591 return;
589 } 592 }
590 593
591 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 594 //qDebug("+++++++system command %s ",tempfilename.latin1() );
592 } 595 }
593 if ( mess.left( 11 ) == "audio_alarm") { 596 if ( mess.left( 11 ) == "audio_alarm") {
594 bool error = false; 597 bool error = false;
595 int len = mess.mid( 11 ).find("+++"); 598 int len = mess.mid( 11 ).find("+++");
596 if ( len < 2 ) 599 if ( len < 2 )
597 error = true; 600 error = true;
598 else { 601 else {
599 tempfilename = mess.mid( 11, len ); 602 tempfilename = mess.mid( 11, len );
600 if ( !QFile::exists( tempfilename ) ) 603 if ( !QFile::exists( tempfilename ) )
601 error = true; 604 error = true;
602 } 605 }
603 if ( ! error ) { 606 if ( ! error ) {
604 filename = tempfilename; 607 filename = tempfilename;
605 } 608 }
606 mAlarmMessage = mess.mid( 11+len+3+9 ); 609 mAlarmMessage = mess.mid( 11+len+3+9 );
607 //qDebug("audio file command %s ",tempfilename.latin1() ); 610 //qDebug("audio file command %s ",tempfilename.latin1() );
608 } 611 }
609 if ( mess.left( 9 ) == "cal_alarm") { 612 if ( mess.left( 9 ) == "cal_alarm") {
610 mAlarmMessage = mess.mid( 9 ) ; 613 mAlarmMessage = mess.mid( 9 ) ;
611 } 614 }
612 615
613 startAlarm( mAlarmMessage, filename ); 616 startAlarm( mAlarmMessage, filename );
614 617
615 618
616} 619}
617 620
618void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 621void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
619{ 622{
620 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 623 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
621 624
622 mSuspendAlarmNotification = noti; 625 mSuspendAlarmNotification = noti;
623 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 626 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
624 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 627 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
625 mSuspendTimer->start( ms , true ); 628 mSuspendTimer->start( ms , true );
626 629
627} 630}
628 631
629void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 632void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
630{ 633{
631 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 634 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
632 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 635 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
633#ifndef DESKTOP_VERSION 636#ifndef DESKTOP_VERSION
634 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 637 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
635#endif 638#endif
636 return; 639 return;
637 } 640 }
638 int maxSec; 641 int maxSec;
639 //maxSec = 5; //testing only 642 //maxSec = 5; //testing only
640 maxSec = 86400+3600; // one day+1hour 643 maxSec = 86400+3600; // one day+1hour
641 mAlarmNotification = noti; 644 mAlarmNotification = noti;
642 int sec = QDateTime::currentDateTime().secsTo( qdt ); 645 int sec = QDateTime::currentDateTime().secsTo( qdt );
643 if ( sec > maxSec ) { 646 if ( sec > maxSec ) {
644 mRecheckAlarmTimer->start( maxSec * 1000 ); 647 mRecheckAlarmTimer->start( maxSec * 1000 );
645 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 648 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
646 return; 649 return;
647 } else { 650 } else {
648 mRecheckAlarmTimer->stop(); 651 mRecheckAlarmTimer->stop();
649 } 652 }
650 //qDebug("Alarm timer started with secs: %d ", sec); 653 //qDebug("Alarm timer started with secs: %d ", sec);
651 mAlarmTimer->start( sec *1000 , true ); 654 mAlarmTimer->start( sec *1000 , true );
652 655
653} 656}
654// called by mRecheckAlarmTimer to get next alarm 657// called by mRecheckAlarmTimer to get next alarm
655// we need this, because a QTimer has only a max range of 25 days 658// we need this, because a QTimer has only a max range of 25 days
656void CalendarView::recheckTimerAlarm() 659void CalendarView::recheckTimerAlarm()
657{ 660{
658 mAlarmTimer->stop(); 661 mAlarmTimer->stop();
659 mRecheckAlarmTimer->stop(); 662 mRecheckAlarmTimer->stop();
660 mCalendar->checkAlarmForIncidence( 0, true ); 663 mCalendar->checkAlarmForIncidence( 0, true );
661} 664}
662void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 665void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
663{ 666{
664 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 667 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
665 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 668 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
666#ifndef DESKTOP_VERSION 669#ifndef DESKTOP_VERSION
667 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 670 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
668#endif 671#endif
669 return; 672 return;
670 } 673 }
671 mAlarmTimer->stop(); 674 mAlarmTimer->stop();
672} 675}
673void CalendarView::selectWeekNum ( int num ) 676void CalendarView::selectWeekNum ( int num )
674{ 677{
678 dateNavigator()->blockSignals( true );
675 dateNavigator()->selectWeek( num ); 679 dateNavigator()->selectWeek( num );
680 dateNavigator()->blockSignals( false );
676 mViewManager->showWeekView(); 681 mViewManager->showWeekView();
677} 682}
678KOViewManager *CalendarView::viewManager() 683KOViewManager *CalendarView::viewManager()
679{ 684{
680 return mViewManager; 685 return mViewManager;
681} 686}
682 687
683KODialogManager *CalendarView::dialogManager() 688KODialogManager *CalendarView::dialogManager()
684{ 689{
685 return mDialogManager; 690 return mDialogManager;
686} 691}
687 692
688QDate CalendarView::startDate() 693QDate CalendarView::startDate()
689{ 694{
690 DateList dates = mNavigator->selectedDates(); 695 DateList dates = mNavigator->selectedDates();
691 696
692 return dates.first(); 697 return dates.first();
693} 698}
694 699
695QDate CalendarView::endDate() 700QDate CalendarView::endDate()
696{ 701{
697 DateList dates = mNavigator->selectedDates(); 702 DateList dates = mNavigator->selectedDates();
698 703
699 return dates.last(); 704 return dates.last();
700} 705}
701 706
702 707
703void CalendarView::createPrinter() 708void CalendarView::createPrinter()
704{ 709{
705#ifndef KORG_NOPRINTER 710#ifndef KORG_NOPRINTER
706 if (!mCalPrinter) { 711 if (!mCalPrinter) {
707 mCalPrinter = new CalPrinter(this, mCalendar); 712 mCalPrinter = new CalPrinter(this, mCalendar);
708 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 713 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
709 } 714 }
710#endif 715#endif
711} 716}
712 717
713 718
714//KOPrefs::instance()->mWriteBackFile 719//KOPrefs::instance()->mWriteBackFile
715//KOPrefs::instance()->mWriteBackExistingOnly 720//KOPrefs::instance()->mWriteBackExistingOnly
716 721
717// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 722// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
718// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 723// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
719// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 724// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
720// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 725// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
721// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 726// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
722// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 727// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
723 728
724int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 729int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
725{ 730{
726 731
727 // 0 equal 732 // 0 equal
728 // 1 take local 733 // 1 take local
729 // 2 take remote 734 // 2 take remote
730 // 3 cancel 735 // 3 cancel
731 QDateTime lastSync = mLastCalendarSync; 736 QDateTime lastSync = mLastCalendarSync;
732 QDateTime localMod = local->lastModified(); 737 QDateTime localMod = local->lastModified();
733 QDateTime remoteMod = remote->lastModified(); 738 QDateTime remoteMod = remote->lastModified();
734 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 739 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
735 bool remCh, locCh; 740 bool remCh, locCh;
736 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 741 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
737 //if ( remCh ) 742 //if ( remCh )
738 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 743 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
739 locCh = ( localMod > mLastCalendarSync ); 744 locCh = ( localMod > mLastCalendarSync );
740 if ( !remCh && ! locCh ) { 745 if ( !remCh && ! locCh ) {
741 //qDebug("both not changed "); 746 //qDebug("both not changed ");
742 lastSync = localMod.addDays(1); 747 lastSync = localMod.addDays(1);
743 if ( mode <= SYNC_PREF_ASK ) 748 if ( mode <= SYNC_PREF_ASK )
744 return 0; 749 return 0;
745 } else { 750 } else {
746 if ( locCh ) { 751 if ( locCh ) {
747 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 752 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
748 lastSync = localMod.addDays( -1 ); 753 lastSync = localMod.addDays( -1 );
749 if ( !remCh ) 754 if ( !remCh )
750 remoteMod = ( lastSync.addDays( -1 ) ); 755 remoteMod = ( lastSync.addDays( -1 ) );
751 } else { 756 } else {
752 //qDebug(" not loc changed "); 757 //qDebug(" not loc changed ");
753 lastSync = localMod.addDays( 1 ); 758 lastSync = localMod.addDays( 1 );
754 if ( remCh ) 759 if ( remCh )
755 remoteMod =( lastSync.addDays( 1 ) ); 760 remoteMod =( lastSync.addDays( 1 ) );
756 761
757 } 762 }
758 } 763 }
759 full = true; 764 full = true;
760 if ( mode < SYNC_PREF_ASK ) 765 if ( mode < SYNC_PREF_ASK )
761 mode = SYNC_PREF_ASK; 766 mode = SYNC_PREF_ASK;
762 } else { 767 } else {
763 if ( localMod == remoteMod ) 768 if ( localMod == remoteMod )
764 // if ( local->revision() == remote->revision() ) 769 // if ( local->revision() == remote->revision() )
765 return 0; 770 return 0;
766 771
767 } 772 }
768 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 773 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
769 774
770 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 775 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
771 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 776 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
@@ -3372,196 +3377,199 @@ void CalendarView::adaptNavigationUnits()
3372{ 3377{
3373 if (mViewManager->currentView()->isEventView()) { 3378 if (mViewManager->currentView()->isEventView()) {
3374 int days = mViewManager->currentView()->currentDateCount(); 3379 int days = mViewManager->currentView()->currentDateCount();
3375 if (days == 1) { 3380 if (days == 1) {
3376 emit changeNavStringPrev(i18n("&Previous Day")); 3381 emit changeNavStringPrev(i18n("&Previous Day"));
3377 emit changeNavStringNext(i18n("&Next Day")); 3382 emit changeNavStringNext(i18n("&Next Day"));
3378 } else { 3383 } else {
3379 emit changeNavStringPrev(i18n("&Previous Week")); 3384 emit changeNavStringPrev(i18n("&Previous Week"));
3380 emit changeNavStringNext(i18n("&Next Week")); 3385 emit changeNavStringNext(i18n("&Next Week"));
3381 } 3386 }
3382 } 3387 }
3383} 3388}
3384 3389
3385void CalendarView::processMainViewSelection( Incidence *incidence ) 3390void CalendarView::processMainViewSelection( Incidence *incidence )
3386{ 3391{
3387 if ( incidence ) mTodoList->clearSelection(); 3392 if ( incidence ) mTodoList->clearSelection();
3388 processIncidenceSelection( incidence ); 3393 processIncidenceSelection( incidence );
3389} 3394}
3390 3395
3391void CalendarView::processTodoListSelection( Incidence *incidence ) 3396void CalendarView::processTodoListSelection( Incidence *incidence )
3392{ 3397{
3393 if ( incidence && mViewManager->currentView() ) { 3398 if ( incidence && mViewManager->currentView() ) {
3394 mViewManager->currentView()->clearSelection(); 3399 mViewManager->currentView()->clearSelection();
3395 } 3400 }
3396 processIncidenceSelection( incidence ); 3401 processIncidenceSelection( incidence );
3397} 3402}
3398 3403
3399void CalendarView::processIncidenceSelection( Incidence *incidence ) 3404void CalendarView::processIncidenceSelection( Incidence *incidence )
3400{ 3405{
3401 if ( incidence == mSelectedIncidence ) return; 3406 if ( incidence == mSelectedIncidence ) return;
3402 3407
3403 mSelectedIncidence = incidence; 3408 mSelectedIncidence = incidence;
3404 3409
3405 emit incidenceSelected( mSelectedIncidence ); 3410 emit incidenceSelected( mSelectedIncidence );
3406 3411
3407 if ( incidence && incidence->type() == "Event" ) { 3412 if ( incidence && incidence->type() == "Event" ) {
3408 Event *event = static_cast<Event *>( incidence ); 3413 Event *event = static_cast<Event *>( incidence );
3409 if ( event->organizer() == KOPrefs::instance()->email() ) { 3414 if ( event->organizer() == KOPrefs::instance()->email() ) {
3410 emit organizerEventsSelected( true ); 3415 emit organizerEventsSelected( true );
3411 } else { 3416 } else {
3412 emit organizerEventsSelected(false); 3417 emit organizerEventsSelected(false);
3413 } 3418 }
3414 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3419 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3415 KOPrefs::instance()->email() ) ) { 3420 KOPrefs::instance()->email() ) ) {
3416 emit groupEventsSelected( true ); 3421 emit groupEventsSelected( true );
3417 } else { 3422 } else {
3418 emit groupEventsSelected(false); 3423 emit groupEventsSelected(false);
3419 } 3424 }
3420 return; 3425 return;
3421 } else { 3426 } else {
3422 if ( incidence && incidence->type() == "Todo" ) { 3427 if ( incidence && incidence->type() == "Todo" ) {
3423 emit todoSelected( true ); 3428 emit todoSelected( true );
3424 Todo *event = static_cast<Todo *>( incidence ); 3429 Todo *event = static_cast<Todo *>( incidence );
3425 if ( event->organizer() == KOPrefs::instance()->email() ) { 3430 if ( event->organizer() == KOPrefs::instance()->email() ) {
3426 emit organizerEventsSelected( true ); 3431 emit organizerEventsSelected( true );
3427 } else { 3432 } else {
3428 emit organizerEventsSelected(false); 3433 emit organizerEventsSelected(false);
3429 } 3434 }
3430 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3435 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3431 KOPrefs::instance()->email() ) ) { 3436 KOPrefs::instance()->email() ) ) {
3432 emit groupEventsSelected( true ); 3437 emit groupEventsSelected( true );
3433 } else { 3438 } else {
3434 emit groupEventsSelected(false); 3439 emit groupEventsSelected(false);
3435 } 3440 }
3436 return; 3441 return;
3437 } else { 3442 } else {
3438 emit todoSelected( false ); 3443 emit todoSelected( false );
3439 emit organizerEventsSelected(false); 3444 emit organizerEventsSelected(false);
3440 emit groupEventsSelected(false); 3445 emit groupEventsSelected(false);
3441 } 3446 }
3442 return; 3447 return;
3443 } 3448 }
3444 3449
3445 /* if ( incidence && incidence->type() == "Todo" ) { 3450 /* if ( incidence && incidence->type() == "Todo" ) {
3446 emit todoSelected( true ); 3451 emit todoSelected( true );
3447 } else { 3452 } else {
3448 emit todoSelected( false ); 3453 emit todoSelected( false );
3449 }*/ 3454 }*/
3450} 3455}
3451 3456
3452 3457
3453void CalendarView::checkClipboard() 3458void CalendarView::checkClipboard()
3454{ 3459{
3455#ifndef KORG_NODND 3460#ifndef KORG_NODND
3456 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3461 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3457 emit pasteEnabled(true); 3462 emit pasteEnabled(true);
3458 } else { 3463 } else {
3459 emit pasteEnabled(false); 3464 emit pasteEnabled(false);
3460 } 3465 }
3461#endif 3466#endif
3462} 3467}
3463 3468
3464void CalendarView::showDates(const DateList &selectedDates) 3469void CalendarView::showDates(const DateList &selectedDates)
3465{ 3470{
3466 // kdDebug() << "CalendarView::selectDates()" << endl; 3471 // kdDebug() << "CalendarView::selectDates()" << endl;
3467 3472
3468 if ( mViewManager->currentView() ) { 3473
3469 updateView( selectedDates.first(), selectedDates.last() ); 3474 if ( !mBlockShowDates ) {
3470 } else { 3475 if ( mViewManager->currentView() ) {
3471 mViewManager->showAgendaView(); 3476 updateView( selectedDates.first(), selectedDates.last() );
3477 } else {
3478 mViewManager->showAgendaView();
3479 }
3472 } 3480 }
3473 3481
3474 QString selDates; 3482 QString selDates;
3475 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); 3483 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true);
3476 if (selectedDates.first() < selectedDates.last() ) 3484 if (selectedDates.first() < selectedDates.last() )
3477 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3485 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3478 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3486 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3479 3487
3480} 3488}
3481 3489
3482QPtrList<CalFilter> CalendarView::filters() 3490QPtrList<CalFilter> CalendarView::filters()
3483{ 3491{
3484 return mFilters; 3492 return mFilters;
3485 3493
3486} 3494}
3487void CalendarView::editFilters() 3495void CalendarView::editFilters()
3488{ 3496{
3489 // kdDebug() << "CalendarView::editFilters()" << endl; 3497 // kdDebug() << "CalendarView::editFilters()" << endl;
3490 3498
3491 CalFilter *filter = mFilters.first(); 3499 CalFilter *filter = mFilters.first();
3492 while(filter) { 3500 while(filter) {
3493 kdDebug() << " Filter: " << filter->name() << endl; 3501 kdDebug() << " Filter: " << filter->name() << endl;
3494 filter = mFilters.next(); 3502 filter = mFilters.next();
3495 } 3503 }
3496 3504
3497 mDialogManager->showFilterEditDialog(&mFilters); 3505 mDialogManager->showFilterEditDialog(&mFilters);
3498} 3506}
3499void CalendarView::toggleFilter() 3507void CalendarView::toggleFilter()
3500{ 3508{
3501 showFilter(! mFilterView->isVisible()); 3509 showFilter(! mFilterView->isVisible());
3502} 3510}
3503 3511
3504KOFilterView *CalendarView::filterView() 3512KOFilterView *CalendarView::filterView()
3505{ 3513{
3506 return mFilterView; 3514 return mFilterView;
3507} 3515}
3508void CalendarView::selectFilter( int fil ) 3516void CalendarView::selectFilter( int fil )
3509{ 3517{
3510 mFilterView->setSelectedFilter( fil ); 3518 mFilterView->setSelectedFilter( fil );
3511} 3519}
3512void CalendarView::showFilter(bool visible) 3520void CalendarView::showFilter(bool visible)
3513{ 3521{
3514 if (visible) mFilterView->show(); 3522 if (visible) mFilterView->show();
3515 else mFilterView->hide(); 3523 else mFilterView->hide();
3516} 3524}
3517void CalendarView::toggleFilerEnabled( ) 3525void CalendarView::toggleFilerEnabled( )
3518{ 3526{
3519 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3527 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3520 if ( !mFilterView->filtersEnabled() ) 3528 if ( !mFilterView->filtersEnabled() )
3521 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3529 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3522 3530
3523} 3531}
3524void CalendarView::updateFilter() 3532void CalendarView::updateFilter()
3525{ 3533{
3526 CalFilter *filter = mFilterView->selectedFilter(); 3534 CalFilter *filter = mFilterView->selectedFilter();
3527 if (filter) { 3535 if (filter) {
3528 if (mFilterView->filtersEnabled()) { 3536 if (mFilterView->filtersEnabled()) {
3529 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); 3537 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() );
3530 filter->setEnabled(true); 3538 filter->setEnabled(true);
3531 } 3539 }
3532 else filter->setEnabled(false); 3540 else filter->setEnabled(false);
3533 mCalendar->setFilter(filter); 3541 mCalendar->setFilter(filter);
3534 updateView(); 3542 updateView();
3535 } 3543 }
3536} 3544}
3537 3545
3538void CalendarView::filterEdited() 3546void CalendarView::filterEdited()
3539{ 3547{
3540 mFilterView->updateFilters(); 3548 mFilterView->updateFilters();
3541 updateFilter(); 3549 updateFilter();
3542 writeSettings(); 3550 writeSettings();
3543} 3551}
3544 3552
3545 3553
3546void CalendarView::takeOverEvent() 3554void CalendarView::takeOverEvent()
3547{ 3555{
3548 Incidence *incidence = currentSelection(); 3556 Incidence *incidence = currentSelection();
3549 3557
3550 if (!incidence) return; 3558 if (!incidence) return;
3551 3559
3552 incidence->setOrganizer(KOPrefs::instance()->email()); 3560 incidence->setOrganizer(KOPrefs::instance()->email());
3553 incidence->recreate(); 3561 incidence->recreate();
3554 incidence->setReadOnly(false); 3562 incidence->setReadOnly(false);
3555 3563
3556 updateView(); 3564 updateView();
3557} 3565}
3558 3566
3559void CalendarView::takeOverCalendar() 3567void CalendarView::takeOverCalendar()
3560{ 3568{
3561 // TODO: Create Calendar::allIncidences() function and use it here 3569 // TODO: Create Calendar::allIncidences() function and use it here
3562 3570
3563 QPtrList<Event> events = mCalendar->events(); 3571 QPtrList<Event> events = mCalendar->events();
3564 for(uint i=0; i<events.count(); ++i) { 3572 for(uint i=0; i<events.count(); ++i) {
3565 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3573 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3566 events.at(i)->recreate(); 3574 events.at(i)->recreate();
3567 events.at(i)->setReadOnly(false); 3575 events.at(i)->setReadOnly(false);
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 646973d..e27da9a 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -387,203 +387,205 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
387 void schedule_publish_freebusy(int daysToPublish = 30); 387 void schedule_publish_freebusy(int daysToPublish = 30);
388 388
389 void openAddressbook(); 389 void openAddressbook();
390 390
391 void editFilters(); 391 void editFilters();
392 void toggleFilerEnabled(); 392 void toggleFilerEnabled();
393 QPtrList<CalFilter> filters(); 393 QPtrList<CalFilter> filters();
394 void toggleFilter(); 394 void toggleFilter();
395 void showFilter(bool visible); 395 void showFilter(bool visible);
396 void updateFilter(); 396 void updateFilter();
397 void filterEdited(); 397 void filterEdited();
398 void selectFilter( int ); 398 void selectFilter( int );
399 KOFilterView *filterView(); 399 KOFilterView *filterView();
400 400
401 void showIntro(); 401 void showIntro();
402 402
403 /** Move the curdatepient view date to today */ 403 /** Move the curdatepient view date to today */
404 void goToday(); 404 void goToday();
405 405
406 /** Move to the next date(s) in the current view */ 406 /** Move to the next date(s) in the current view */
407 void goNext(); 407 void goNext();
408 408
409 /** Move to the previous date(s) in the current view */ 409 /** Move to the previous date(s) in the current view */
410 void goPrevious(); 410 void goPrevious();
411 /** Move to the next date(s) in the current view */ 411 /** Move to the next date(s) in the current view */
412 void goNextMonth(); 412 void goNextMonth();
413 413
414 /** Move to the previous date(s) in the current view */ 414 /** Move to the previous date(s) in the current view */
415 void goPreviousMonth(); 415 void goPreviousMonth();
416 416
417 void toggleExpand(); 417 void toggleExpand();
418 void toggleDateNavigatorWidget(); 418 void toggleDateNavigatorWidget();
419 void toggleAllDaySize(); 419 void toggleAllDaySize();
420 void dialogClosing(Incidence *); 420 void dialogClosing(Incidence *);
421 421
422 /** Look for new messages in the inbox */ 422 /** Look for new messages in the inbox */
423 void lookForIncomingMessages(); 423 void lookForIncomingMessages();
424 /** Look for new messages in the outbox */ 424 /** Look for new messages in the outbox */
425 void lookForOutgoingMessages(); 425 void lookForOutgoingMessages();
426 426
427 void processMainViewSelection( Incidence * ); 427 void processMainViewSelection( Incidence * );
428 void processTodoListSelection( Incidence * ); 428 void processTodoListSelection( Incidence * );
429 429
430 void processIncidenceSelection( Incidence * ); 430 void processIncidenceSelection( Incidence * );
431 431
432 void purgeCompleted(); 432 void purgeCompleted();
433 bool removeCompletedSubTodos( Todo* ); 433 bool removeCompletedSubTodos( Todo* );
434 void slotCalendarChanged(); 434 void slotCalendarChanged();
435 bool importBday(); 435 bool importBday();
436 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); 436 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday );
437 bool importQtopia( const QString &categoriesFile, 437 bool importQtopia( const QString &categoriesFile,
438 const QString &datebookFile, 438 const QString &datebookFile,
439 const QString &tasklistFile ); 439 const QString &tasklistFile );
440 void syncExternal( int mode ); 440 void syncExternal( int mode );
441 void slotSelectPickerDate( QDate ) ; 441 void slotSelectPickerDate( QDate ) ;
442 void showDatePicker( ) ; 442 void showDatePicker( ) ;
443 void moveIncidence(Incidence *) ; 443 void moveIncidence(Incidence *) ;
444 void beamIncidence(Incidence *) ; 444 void beamIncidence(Incidence *) ;
445 void beamCalendar() ; 445 void beamCalendar() ;
446 void beamFilteredCalendar() ; 446 void beamFilteredCalendar() ;
447 void beamIncidenceList(QPtrList<Incidence>) ; 447 void beamIncidenceList(QPtrList<Incidence>) ;
448 void manageCategories(); 448 void manageCategories();
449 int addCategories(); 449 int addCategories();
450 void removeCategories(); 450 void removeCategories();
451 void setSyncDevice( QString ); 451 void setSyncDevice( QString );
452 void setSyncName( QString ); 452 void setSyncName( QString );
453 void showDay( QDate ); 453 void showDay( QDate );
454 void undo_delete(); 454 void undo_delete();
455 protected slots: 455 protected slots:
456 void timerAlarm(); 456 void timerAlarm();
457 void suspendAlarm(); 457 void suspendAlarm();
458 void beamDone( Ir *ir ); 458 void beamDone( Ir *ir );
459 /** Select a view or adapt the current view to display the specified dates. */ 459 /** Select a view or adapt the current view to display the specified dates. */
460 void showDates( const KCal::DateList & ); 460 void showDates( const KCal::DateList & );
461 void selectWeekNum ( int ); 461 void selectWeekNum ( int );
462 462
463 public: 463 public:
464 // show a standard warning 464 // show a standard warning
465 // returns KMsgBox::yesNoCancel() 465 // returns KMsgBox::yesNoCancel()
466 int msgCalModified(); 466 int msgCalModified();
467 virtual bool sync(KSyncManager* manager, QString filename, int mode); 467 virtual bool sync(KSyncManager* manager, QString filename, int mode);
468 468
469 virtual bool syncExternal(KSyncManager* manager, QString resource); 469 virtual bool syncExternal(KSyncManager* manager, QString resource);
470 virtual void removeSyncInfo( QString syncProfile); 470 virtual void removeSyncInfo( QString syncProfile);
471 void setSyncManager(KSyncManager* manager); 471 void setSyncManager(KSyncManager* manager);
472 void setLoadedFileVersion(QDateTime); 472 void setLoadedFileVersion(QDateTime);
473 bool checkFileVersion(QString fn); 473 bool checkFileVersion(QString fn);
474 bool checkFileChanged(QString fn); 474 bool checkFileChanged(QString fn);
475 Event* getLastSyncEvent(); 475 Event* getLastSyncEvent();
476 /** Adapt navigation units correpsonding to step size of navigation of the 476 /** Adapt navigation units correpsonding to step size of navigation of the
477 * current view. 477 * current view.
478 */ 478 */
479 void adaptNavigationUnits(); 479 void adaptNavigationUnits();
480 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); 480 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
481 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 481 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
482 //Attendee* getYourAttendee(Event *event); 482 //Attendee* getYourAttendee(Event *event);
483 void setBlockShowDates( bool b ) { mBlockShowDates = b ;}
483 protected: 484 protected:
484 void schedule(Scheduler::Method, Incidence *incidence = 0); 485 void schedule(Scheduler::Method, Incidence *incidence = 0);
485 486
486 // returns KMsgBox::OKCandel() 487 // returns KMsgBox::OKCandel()
487 int msgItemDelete(); 488 int msgItemDelete();
488 void showEventEditor(); 489 void showEventEditor();
489 void showTodoEditor(); 490 void showTodoEditor();
490 void writeLocale(); 491 void writeLocale();
491 Todo *selectedTodo(); 492 Todo *selectedTodo();
492 493
493 private: 494 private:
495 bool mBlockShowDates;
494 KSyncManager* mSyncManager; 496 KSyncManager* mSyncManager;
495 AlarmDialog * mAlarmDialog; 497 AlarmDialog * mAlarmDialog;
496 QString mAlarmNotification; 498 QString mAlarmNotification;
497 QString mSuspendAlarmNotification; 499 QString mSuspendAlarmNotification;
498 QTimer* mSuspendTimer; 500 QTimer* mSuspendTimer;
499 QTimer* mAlarmTimer; 501 QTimer* mAlarmTimer;
500 QTimer* mRecheckAlarmTimer; 502 QTimer* mRecheckAlarmTimer;
501 void computeAlarm( QString ); 503 void computeAlarm( QString );
502 void startAlarm( QString, QString ); 504 void startAlarm( QString, QString );
503 void setSyncEventsReadOnly(); 505 void setSyncEventsReadOnly();
504 506
505 QDateTime loadedFileVersion; 507 QDateTime loadedFileVersion;
506 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); 508 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete );
507 void checkExternalId( Incidence * inc ); 509 void checkExternalId( Incidence * inc );
508 int mGlobalSyncMode; 510 int mGlobalSyncMode;
509 QString mCurrentSyncDevice; 511 QString mCurrentSyncDevice;
510 QString mCurrentSyncName; 512 QString mCurrentSyncName;
511 KOBeamPrefs* beamDialog; 513 KOBeamPrefs* beamDialog;
512 void init(); 514 void init();
513 int mDatePickerMode; 515 int mDatePickerMode;
514 bool mFlagEditDescription; 516 bool mFlagEditDescription;
515 QDateTime mLastCalendarSync; 517 QDateTime mLastCalendarSync;
516 void createPrinter(); 518 void createPrinter();
517 519
518 void calendarModified( bool, Calendar * ); 520 void calendarModified( bool, Calendar * );
519 521
520 CalPrinter *mCalPrinter; 522 CalPrinter *mCalPrinter;
521 523
522 QSplitter *mPanner; 524 QSplitter *mPanner;
523 QSplitter *mLeftSplitter; 525 QSplitter *mLeftSplitter;
524 QWidget *mLeftFrame; 526 QWidget *mLeftFrame;
525 QWidgetStack *mRightFrame; 527 QWidgetStack *mRightFrame;
526 528
527 KDatePicker* mDatePicker; 529 KDatePicker* mDatePicker;
528 QVBox* mDateFrame; 530 QVBox* mDateFrame;
529 NavigatorBar *mNavigatorBar; 531 NavigatorBar *mNavigatorBar;
530 532
531 KDateNavigator *mDateNavigator; // widget showing small month view. 533 KDateNavigator *mDateNavigator; // widget showing small month view.
532 534
533 KOFilterView *mFilterView; 535 KOFilterView *mFilterView;
534 536
535 ResourceView *mResourceView; 537 ResourceView *mResourceView;
536 538
537 // calendar object for this viewing instance 539 // calendar object for this viewing instance
538 Calendar *mCalendar; 540 Calendar *mCalendar;
539 541
540 CalendarResourceManager *mResourceManager; 542 CalendarResourceManager *mResourceManager;
541 543
542 FileStorage *mStorage; 544 FileStorage *mStorage;
543 545
544 DateNavigator *mNavigator; 546 DateNavigator *mNavigator;
545 547
546 KOViewManager *mViewManager; 548 KOViewManager *mViewManager;
547 KODialogManager *mDialogManager; 549 KODialogManager *mDialogManager;
548 550
549 // Calendar filters 551 // Calendar filters
550 QPtrList<CalFilter> mFilters; 552 QPtrList<CalFilter> mFilters;
551 553
552 // various housekeeping variables. 554 // various housekeeping variables.
553 bool mModified; // flag indicating if calendar is modified 555 bool mModified; // flag indicating if calendar is modified
554 bool mReadOnly; // flag indicating if calendar is read-only 556 bool mReadOnly; // flag indicating if calendar is read-only
555 QDate mSaveSingleDate; 557 QDate mSaveSingleDate;
556 558
557 Incidence *mSelectedIncidence; 559 Incidence *mSelectedIncidence;
558 Incidence *mMoveIncidence; 560 Incidence *mMoveIncidence;
559 QDate mMoveIncidenceOldDate; 561 QDate mMoveIncidenceOldDate;
560 KOTodoView *mTodoList; 562 KOTodoView *mTodoList;
561 KOEventEditor * mEventEditor; 563 KOEventEditor * mEventEditor;
562 KOTodoEditor * mTodoEditor; 564 KOTodoEditor * mTodoEditor;
563 KOEventViewerDialog * mEventViewerDialog; 565 KOEventViewerDialog * mEventViewerDialog;
564 void keyPressEvent ( QKeyEvent *e) ; 566 void keyPressEvent ( QKeyEvent *e) ;
565 //QMap<Incidence*,KOIncidenceEditor*> mDialogList; 567 //QMap<Incidence*,KOIncidenceEditor*> mDialogList;
566}; 568};
567 569
568 570
569class CalendarViewVisitor : public Incidence::Visitor 571class CalendarViewVisitor : public Incidence::Visitor
570{ 572{
571 public: 573 public:
572 CalendarViewVisitor() : mView( 0 ) {} 574 CalendarViewVisitor() : mView( 0 ) {}
573 575
574 bool act( Incidence *incidence, CalendarView *view ) 576 bool act( Incidence *incidence, CalendarView *view )
575 { 577 {
576 mView = view; 578 mView = view;
577 return incidence->accept( *this ); 579 return incidence->accept( *this );
578 } 580 }
579 581
580 protected: 582 protected:
581 CalendarView *mView; 583 CalendarView *mView;
582}; 584};
583 585
584class ShowIncidenceVisitor : public CalendarViewVisitor 586class ShowIncidenceVisitor : public CalendarViewVisitor
585{ 587{
586 protected: 588 protected:
587 bool visit( Event *event ) { mView->showEvent( event ); return true; } 589 bool visit( Event *event ) { mView->showEvent( event ); return true; }
588 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } 590 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; }
589 bool visit( Journal * j ) { mView->showJournal( j );return true; } 591 bool visit( Journal * j ) { mView->showJournal( j );return true; }
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 9344567..842f6eb 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -1,180 +1,183 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <qpopupmenu.h> 20#include <qpopupmenu.h>
21#include <qfont.h> 21#include <qfont.h>
22#include <qfontmetrics.h> 22#include <qfontmetrics.h>
23#include <qkeycode.h> 23#include <qkeycode.h>
24#include <qhbox.h> 24#include <qhbox.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qpushbutton.h> 26#include <qpushbutton.h>
27#include <qtooltip.h> 27#include <qtooltip.h>
28#include <qpainter.h> 28#include <qpainter.h>
29#include <qwhatsthis.h> 29#include <qwhatsthis.h>
30#ifndef DESKTOP_VERSION 30#ifndef DESKTOP_VERSION
31#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
32#else 32#else
33#include <qapplication.h> 33#include <qapplication.h>
34#endif 34#endif
35 35
36#include <kdebug.h> 36#include <kdebug.h>
37#include <klocale.h> 37#include <klocale.h>
38#include <kglobal.h> 38#include <kglobal.h>
39#include <kconfig.h> 39#include <kconfig.h>
40#include <kiconloader.h> 40#include <kiconloader.h>
41 41
42#include <kcalendarsystem.h> 42#include <kcalendarsystem.h>
43 43
44#ifndef KORG_NOPRINTER 44#ifndef KORG_NOPRINTER
45#include "calprinter.h" 45#include "calprinter.h"
46#endif 46#endif
47#include "koprefs.h" 47#include "koprefs.h"
48#ifndef KORG_NOPLUGINS 48#ifndef KORG_NOPLUGINS
49#include "kocore.h" 49#include "kocore.h"
50#endif 50#endif
51#include "koglobals.h" 51#include "koglobals.h"
52#include <libkcal/kincidenceformatter.h> 52#include <libkcal/kincidenceformatter.h>
53 53
54#include "komonthview.h" 54#include "komonthview.h"
55 55
56#define PIXMAP_SIZE 5 56#define PIXMAP_SIZE 5
57#ifdef DESKTOP_VERSION 57#ifdef DESKTOP_VERSION
58 QToolTipGroup *MonthViewCell::mToolTipGroup = 0; 58 QToolTipGroup *MonthViewCell::mToolTipGroup = 0;
59#endif 59#endif
60class KNOWhatsThis :public QWhatsThis 60class KNOWhatsThis :public QWhatsThis
61{ 61{
62public: 62public:
63 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; 63 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { };
64 64
65protected: 65protected:
66 virtual QString text( const QPoint& p) 66 virtual QString text( const QPoint& p)
67 { 67 {
68 return _wid->getWhatsThisText(p) ; 68 return _wid->getWhatsThisText(p) ;
69 }; 69 };
70private: 70private:
71 KNoScrollListBox* _wid; 71 KNoScrollListBox* _wid;
72 72
73}; 73};
74 74
75 75
76KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) 76KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name)
77 : QListBox(parent, name) 77 : QListBox(parent, name)
78{ 78{
79#ifndef DESKTOP_VERSION 79#ifndef DESKTOP_VERSION
80 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 80 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
81#endif 81#endif
82 new KNOWhatsThis(this); 82 mWT = new KNOWhatsThis(this);
83}
84KNoScrollListBox::~KNoScrollListBox()
85{
86 delete mWT;
83} 87}
84
85QString KNoScrollListBox::getWhatsThisText(QPoint p) 88QString KNoScrollListBox::getWhatsThisText(QPoint p)
86{ 89{
87 QListBoxItem* item = itemAt ( p ); 90 QListBoxItem* item = itemAt ( p );
88 if ( ! item ) { 91 if ( ! item ) {
89 return i18n("Click in the cell\nto add an event!"); 92 return i18n("Click in the cell\nto add an event!");
90 } 93 }
91 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); 94 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence());
92} 95}
93void KNoScrollListBox::keyPressEvent(QKeyEvent *e) 96void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
94{ 97{
95 98
96 switch(e->key()) { 99 switch(e->key()) {
97 case Key_Right: 100 case Key_Right:
98 // if ( e->state() == Qt::ControlButton ) 101 // if ( e->state() == Qt::ControlButton )
99 { 102 {
100 e->ignore(); 103 e->ignore();
101 return; 104 return;
102 } 105 }
103 scrollBy(4,0); 106 scrollBy(4,0);
104 break; 107 break;
105 case Key_Left: 108 case Key_Left:
106 // if ( e->state() == Qt::ControlButton ) 109 // if ( e->state() == Qt::ControlButton )
107 { 110 {
108 e->ignore(); 111 e->ignore();
109 return; 112 return;
110 } 113 }
111 scrollBy(-4,0); 114 scrollBy(-4,0);
112 break; 115 break;
113 case Key_Up: 116 case Key_Up:
114 if(!count()) break; 117 if(!count()) break;
115 setCurrentItem((currentItem()+count()-1)%count()); 118 setCurrentItem((currentItem()+count()-1)%count());
116 if(!itemVisible(currentItem())) { 119 if(!itemVisible(currentItem())) {
117 if((unsigned int) currentItem() == (count()-1)) { 120 if((unsigned int) currentItem() == (count()-1)) {
118 setTopItem(currentItem()-numItemsVisible()+1); 121 setTopItem(currentItem()-numItemsVisible()+1);
119 } else { 122 } else {
120 setTopItem(topItem()-1); 123 setTopItem(topItem()-1);
121 } 124 }
122 } 125 }
123 break; 126 break;
124 case Key_Down: 127 case Key_Down:
125 if(!count()) break; 128 if(!count()) break;
126 setCurrentItem((currentItem()+1)%count()); 129 setCurrentItem((currentItem()+1)%count());
127 if(!itemVisible(currentItem())) { 130 if(!itemVisible(currentItem())) {
128 if(currentItem() == 0) { 131 if(currentItem() == 0) {
129 setTopItem(0); 132 setTopItem(0);
130 } else { 133 } else {
131 setTopItem(topItem()+1); 134 setTopItem(topItem()+1);
132 } 135 }
133 } 136 }
134 break; 137 break;
135 case Key_Shift: 138 case Key_Shift:
136 emit shiftDown(); 139 emit shiftDown();
137 break; 140 break;
138 default: 141 default:
139 e->ignore(); 142 e->ignore();
140 break; 143 break;
141 } 144 }
142} 145}
143 146
144void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) 147void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
145{ 148{
146 switch(e->key()) { 149 switch(e->key()) {
147 case Key_Shift: 150 case Key_Shift:
148 emit shiftUp(); 151 emit shiftUp();
149 break; 152 break;
150 default: 153 default:
151 break; 154 break;
152 } 155 }
153} 156}
154 157
155void KNoScrollListBox::mousePressEvent(QMouseEvent *e) 158void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
156{ 159{
157 QListBox::mousePressEvent(e); 160 QListBox::mousePressEvent(e);
158 161
159 if(e->button() == RightButton) { 162 if(e->button() == RightButton) {
160 emit rightClick(); 163 emit rightClick();
161 } 164 }
162} 165}
163 166
164MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) 167MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
165 : QListBoxItem() 168 : QListBoxItem()
166{ 169{
167 setText( s ); 170 setText( s );
168 171
169 mIncidence = incidence; 172 mIncidence = incidence;
170 mDate = qd; 173 mDate = qd;
171 // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); 174 // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence ));
172 mRecur = false; 175 mRecur = false;
173 mAlarm = false; 176 mAlarm = false;
174 mReply = false; 177 mReply = false;
175 mInfo = false; 178 mInfo = false;
176} 179}
177 180
178void MonthViewItem::paint(QPainter *p) 181void MonthViewItem::paint(QPainter *p)
179{ 182{
180#if QT_VERSION >= 0x030000 183#if QT_VERSION >= 0x030000
@@ -215,597 +218,610 @@ void MonthViewItem::paint(QPainter *p)
215 } 218 }
216 QFontMetrics fm = p->fontMetrics(); 219 QFontMetrics fm = p->fontMetrics();
217 int yPos; 220 int yPos;
218 int pmheight = size; 221 int pmheight = size;
219 if( pmheight < fm.height() ) 222 if( pmheight < fm.height() )
220 yPos = fm.ascent() + fm.leading()/2; 223 yPos = fm.ascent() + fm.leading()/2;
221 else 224 else
222 yPos = pmheight/2 - fm.height()/2 + fm.ascent(); 225 yPos = pmheight/2 - fm.height()/2 + fm.ascent();
223 p->setPen( palette().color( QPalette::Normal, sel ? \ 226 p->setPen( palette().color( QPalette::Normal, sel ? \
224 QColorGroup::HighlightedText : QColorGroup::Foreground ) ); 227 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
225 p->drawText( x, yPos, text() ); 228 p->drawText( x, yPos, text() );
226 if ( mIncidence->cancelled() ) { 229 if ( mIncidence->cancelled() ) {
227 int wid = fm.width( text() ); 230 int wid = fm.width( text() );
228 p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2); 231 p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2);
229 } 232 }
230 233
231} 234}
232 235
233int MonthViewItem::height(const QListBox *lb) const 236int MonthViewItem::height(const QListBox *lb) const
234{ 237{
235 return lb->fontMetrics().lineSpacing()+1; 238 return lb->fontMetrics().lineSpacing()+1;
236} 239}
237 240
238int MonthViewItem::width(const QListBox *lb) const 241int MonthViewItem::width(const QListBox *lb) const
239{ 242{
240 int size = PIXMAP_SIZE; 243 int size = PIXMAP_SIZE;
241 if ( QApplication::desktop()->width() < 300 ) 244 if ( QApplication::desktop()->width() < 300 )
242 size = 3; 245 size = 3;
243 int x = 1; 246 int x = 1;
244 if ( mInfo ) { 247 if ( mInfo ) {
245 x += size + 1; 248 x += size + 1;
246 } 249 }
247 if( mRecur ) { 250 if( mRecur ) {
248 x += size+1; 251 x += size+1;
249 } 252 }
250 if( mAlarm ) { 253 if( mAlarm ) {
251 x += size+1; 254 x += size+1;
252 } 255 }
253 if( mReply ) { 256 if( mReply ) {
254 x += size+1; 257 x += size+1;
255 } 258 }
256 259
257 return( x + lb->fontMetrics().width( text() ) + 1 ); 260 return( x + lb->fontMetrics().width( text() ) + 1 );
258} 261}
259 262
260 263
261MonthViewCell::MonthViewCell( KOMonthView *parent) 264MonthViewCell::MonthViewCell( KOMonthView *parent)
262 : QWidget( parent ), 265 : QWidget( parent ),
263 mMonthView( parent ) 266 mMonthView( parent )
264{ 267{
265 268
266 QVBoxLayout *topLayout = new QVBoxLayout( this ); 269 QVBoxLayout *topLayout = new QVBoxLayout( this );
267 270
268 // mLabel = new QLabel( this );QPushButton 271 // mLabel = new QLabel( this );QPushButton
269 mLabel = new QPushButton( this ); 272 mLabel = new QPushButton( this );
270 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); 273 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
271 //mLabel->setLineWidth( 1 ); 274 //mLabel->setLineWidth( 1 );
272 //mLabel->setAlignment( AlignCenter ); 275 //mLabel->setAlignment( AlignCenter );
273 mLabel->setFlat( true ); 276 mLabel->setFlat( true );
274 mItemList = new KNoScrollListBox( this ); 277 mItemList = new KNoScrollListBox( this );
275 mItemList->setMinimumSize( 10, 10 ); 278 mItemList->setMinimumSize( 10, 10 );
276 mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); 279 mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain );
277 mItemList->setLineWidth( 1 ); 280 mItemList->setLineWidth( 1 );
278 topLayout->addWidget( mItemList ); 281 topLayout->addWidget( mItemList );
279 mLabel->raise(); 282 mLabel->raise();
280 // QColor( 0,0,255 ) QColor( 160,1600,255 ) 283 // QColor( 0,0,255 ) QColor( 160,1600,255 )
281 mStandardPalette = palette(); 284 mStandardPalette = palette();
282 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); 285 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) );
283 286
284 enableScrollBars( false ); 287 enableScrollBars( false );
285 updateConfig(); 288 updateConfig();
286 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); 289 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() ));
287 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); 290 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() ));
288 connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), 291 connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ),
289 SLOT( defaultAction( QListBoxItem * ) ) ); 292 SLOT( defaultAction( QListBoxItem * ) ) );
290 connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, 293 connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *,
291 const QPoint &) ), 294 const QPoint &) ),
292 SLOT( contextMenu( QListBoxItem * ) ) ); 295 SLOT( contextMenu( QListBoxItem * ) ) );
293 connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), 296 connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ),
294 SLOT( selection( QListBoxItem * ) ) ); 297 SLOT( selection( QListBoxItem * ) ) );
295 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), 298 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
296 SLOT( cellClicked( QListBoxItem * ) ) ); 299 SLOT( cellClicked( QListBoxItem * ) ) );
297 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), 300 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
298 SLOT( selection( QListBoxItem * ) ) ); 301 SLOT( selection( QListBoxItem * ) ) );
299} 302}
300#ifdef DESKTOP_VERSION 303#ifdef DESKTOP_VERSION
301QToolTipGroup *MonthViewCell::toolTipGroup() 304QToolTipGroup *MonthViewCell::toolTipGroup()
302{ 305{
303 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 306 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
304 return mToolTipGroup; 307 return mToolTipGroup;
305} 308}
306#endif 309#endif
307 310
308void MonthViewCell::setDate( const QDate &date ) 311void MonthViewCell::setDate( const QDate &date )
309{ 312{
310// kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; 313// kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
311
312 mDate = date; 314 mDate = date;
313 315
314 QString text; 316
315 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
316 if ( KOGlobals::self()->calendarSystem()->day( date ) == 1 || (date.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
317 text = KOGlobals::self()->calendarSystem()->monthName( date, true ) + " ";
318 mLabel->resize( mLabelBigSize );
319 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
320 } else {
321 mLabel->resize( mLabelSize );
322 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
323 }
324 mLabel->setText( text );
325 317
326 //resizeEvent( 0 ); 318 //resizeEvent( 0 );
327} 319}
328 320
329QDate MonthViewCell::date() const 321QDate MonthViewCell::date() const
330{ 322{
331 return mDate; 323 return mDate;
332} 324}
333 325
334void MonthViewCell::setPrimary( bool primary ) 326void MonthViewCell::setPrimary( bool primary )
335{ 327{
336 mPrimary = primary; 328 mPrimary = primary;
337 //setMyPalette(); 329 //setMyPalette();
338} 330}
339void MonthViewCell::setMyPalette() 331void MonthViewCell::setMyPalette()
340{ 332{
341 333
342 if ( mHoliday) { 334 if ( mHoliday) {
343 setPalette( mHolidayPalette ); 335 setPalette( mHolidayPalette );
344 } else { 336 } else {
345 if ( mPrimary ) { 337 if ( mPrimary ) {
346 setPalette( mPrimaryPalette ); 338 setPalette( mPrimaryPalette );
347 } else { 339 } else {
348 setPalette( mNonPrimaryPalette ); 340 setPalette( mNonPrimaryPalette );
349 } 341 }
350 } 342 }
351 QPalette pal = palette(); 343 QPalette pal = palette();
352 344
353 mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); 345 mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) ));
354} 346}
355QPalette MonthViewCell::getPalette () 347QPalette MonthViewCell::getPalette ()
356{ 348{
357 if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) 349 if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
358 return mStandardPalette; 350 return mStandardPalette;
359 if ( mHoliday) { 351 if ( mHoliday) {
360 return mHolidayPalette ; 352 return mHolidayPalette ;
361 } else { 353 } else {
362 if ( mPrimary ) { 354 if ( mPrimary ) {
363 return mPrimaryPalette ; 355 return mPrimaryPalette ;
364 } 356 }
365 } 357 }
366 return mNonPrimaryPalette; 358 return mNonPrimaryPalette;
367} 359}
368bool MonthViewCell::isPrimary() const 360bool MonthViewCell::isPrimary() const
369{ 361{
370 return mPrimary; 362 return mPrimary;
371} 363}
372 364
373void MonthViewCell::setHoliday( bool holiday ) 365void MonthViewCell::setHoliday( bool holiday )
374{ 366{
375 mHoliday = holiday; 367 mHoliday = holiday;
376 //setMyPalette(); 368 //setMyPalette();
377} 369}
378 370
379void MonthViewCell::setHoliday( const QString &holiday ) 371void MonthViewCell::setHoliday( const QString &holiday )
380{ 372{
381 mHolidayString = holiday; 373 mHolidayString = holiday;
382 374
383 if ( !holiday.isEmpty() ) { 375 if ( !holiday.isEmpty() ) {
384 setHoliday( true ); 376 setHoliday( true );
385 } 377 }
386} 378}
387void MonthViewCell::keyPressEvent ( QKeyEvent * e ) 379void MonthViewCell::keyPressEvent ( QKeyEvent * e )
388{ 380{
389 381
390 e->ignore(); 382 e->ignore();
391 383
392} 384}
393void MonthViewCell::updateCell() 385void MonthViewCell::updateCell()
394{ 386{
395 387 if ( !mMonthView->isUpdatePossible() )
388 return;
389 if ( !isVisible() ){
390 return;
391 }
396 setPrimary( mDate.month()%2 ); 392 setPrimary( mDate.month()%2 );
397 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); 393 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
398 if ( mDate == QDate::currentDate() ) { 394 if ( mDate == QDate::currentDate() ) {
399 mItemList->setLineWidth( 3 ); 395 mItemList->setLineWidth( 3 );
400 } else { 396 } else {
401 mItemList->setLineWidth( 1 ); 397 mItemList->setLineWidth( 1 );
402 } 398 }
403 mItemList->clear(); 399 mItemList->clear();
400
401
402
404#ifdef DESKTOP_VERSION 403#ifdef DESKTOP_VERSION
405 QToolTip::remove(this); 404 QToolTip::remove(this);
406#endif 405#endif
407 QString tipText(""); 406 QString tipText("");
408 //qApp->processEvents(); 407 //qApp->processEvents();
409 if ( !mHolidayString.isEmpty() ) { 408 if ( !mHolidayString.isEmpty() ) {
410 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 409 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
411 item->setPalette( mHolidayPalette ); 410 item->setPalette( mHolidayPalette );
412 mItemList->insertItem( item ); 411 mItemList->insertItem( item );
413 tipText += mHolidayString+"\n"; 412 tipText += mHolidayString+"\n";
414 } 413 }
415 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 414 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
416 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 415 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
417 Event *event; 416 Event *event;
418 for( event = events.first(); event; event = events.next() ) { 417 for( event = events.first(); event; event = events.next() ) { // for event
418
419 if ( !(event->doesRecur() == Recurrence::rNone) ) {
420 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
421 continue;
422 else
423 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
424 continue;
425 }
426
419 if ( event->categories().contains("Holiday") || 427 if ( event->categories().contains("Holiday") ||
420 event->categories().contains(i18n("Holiday"))) { 428 event->categories().contains(i18n("Holiday"))) {
421 setHoliday( true ); 429 setHoliday( true );
422 if ( mDate.dayOfWeek() == 7 ) 430 if ( mDate.dayOfWeek() == 7 )
423 mItemList->setLineWidth( 3 ); 431 mItemList->setLineWidth( 3 );
424 } 432 }
425 QString text; 433 QString text;
426 if (event->isMultiDay()) { 434 if (event->isMultiDay()) {
427 QString prefix = "<->"; 435 QString prefix = "<->";
428 if ( event->doesRecur() ) { 436 if ( event->doesRecur() ) {
429 if ( event->recursOn( mDate) ) 437 if ( event->recursOn( mDate) )
430 prefix ="->" ; 438 prefix ="->" ;
431 else { 439 else {
432 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 440 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
433 if ( event->recursOn( mDate.addDays( -days)) ) 441 if ( event->recursOn( mDate.addDays( -days)) )
434 prefix ="<-" ; 442 prefix ="<-" ;
435 } 443 }
436 444
437 } else { 445 } else {
438 if (mDate == event->dtStart().date()) { 446 if (mDate == event->dtStart().date()) {
439 prefix ="->" ; 447 prefix ="->" ;
440 } else if (mDate == event->dtEnd().date()) { 448 } else if (mDate == event->dtEnd().date()) {
441 prefix ="<-" ; 449 prefix ="<-" ;
442 } 450 }
443 } 451 }
444 text = prefix + event->summary(); 452 text = prefix + event->summary();
445 tipText += text; 453 tipText += text;
446 } else { 454 } else {
447 if (event->doesFloat()) { 455 if (event->doesFloat()) {
448 text = event->summary(); 456 text = event->summary();
449 tipText += text; 457 tipText += text;
450 } 458 }
451 else { 459 else {
452 text = KGlobal::locale()->formatTime(event->dtStart().time()); 460 text = KGlobal::locale()->formatTime(event->dtStart().time());
453 text += " " + event->summary(); 461 text += " " + event->summary();
454 tipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 462 tipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
455 } 463 }
456 } 464 }
457 465
458 MonthViewItem *item = new MonthViewItem( event, mDate, text ); 466 MonthViewItem *item = new MonthViewItem( event, mDate, text );
459 QPalette pal; 467 QPalette pal;
460 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 468 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
461 QStringList categories = event->categories(); 469 QStringList categories = event->categories();
462 QString cat = categories.first(); 470 QString cat = categories.first();
463 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 471 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
464 pal = getPalette(); 472 pal = getPalette();
465 if (cat.isEmpty()) { 473 if (cat.isEmpty()) {
466 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 474 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
467 } else { 475 } else {
468 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 476 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
469 } 477 }
470 478
471 } else { 479 } else {
472 if (cat.isEmpty()) { 480 if (cat.isEmpty()) {
473 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 481 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
474 } else { 482 } else {
475 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 483 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
476 } 484 }
477 } 485 }
478 486
479 } else { 487 } else {
480 pal = mStandardPalette ; 488 pal = mStandardPalette ;
481 } 489 }
482 item->setPalette( pal ); 490 item->setPalette( pal );
483 item->setRecur( event->recurrence()->doesRecur() ); 491 item->setRecur( event->recurrence()->doesRecur() );
484 item->setAlarm( event->isAlarmEnabled() ); 492 item->setAlarm( event->isAlarmEnabled() );
485 item->setMoreInfo( event->description().length() > 0 ); 493 item->setMoreInfo( event->description().length() > 0 );
494#ifdef DESKTOP_VERSION
486 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, 495 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
487 KOPrefs::instance()->email()); 496 KOPrefs::instance()->email());
488 if ( me != 0 ) { 497 if ( me != 0 ) {
489 if ( me->status() == Attendee::NeedsAction && me->RSVP()) 498 if ( me->status() == Attendee::NeedsAction && me->RSVP())
490 item->setReply(true); 499 item->setReply(true);
491 else 500 else
492 item->setReply(false); 501 item->setReply(false);
493 } else 502 } else
494 item->setReply(false); 503 item->setReply(false);
495 bool insert = true; 504#endif
496 if ( !(event->doesRecur() == Recurrence::rNone) ) { 505 mItemList->insertItem( item );
497 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 506 tipText += "\n";
498 insert = false; 507
499 else
500 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
501 insert = false;
502
503 }
504 if ( insert ) {
505 mItemList->insertItem( item );
506 tipText += "\n";
507 } else
508 tipText = "";
509 } 508 }
510 509
511 // insert due todos 510 // insert due todos
512 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 511 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
513 Todo *todo; 512 Todo *todo;
514 for(todo = todos.first(); todo; todo = todos.next()) { 513 for(todo = todos.first(); todo; todo = todos.next()) {
515 QString text; 514 QString text;
516 if (todo->hasDueDate()) { 515 if (todo->hasDueDate()) {
517 if (!todo->doesFloat()) { 516 if (!todo->doesFloat()) {
518 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 517 text += KGlobal::locale()->formatTime(todo->dtDue().time());
519 text += " "; 518 text += " ";
520 } 519 }
521 } 520 }
522 text += i18n("To-Do: %1").arg(todo->summary()); 521 text += i18n("To-Do: %1").arg(todo->summary());
523 522
524 MonthViewItem *item = new MonthViewItem( todo, mDate, text ); 523 MonthViewItem *item = new MonthViewItem( todo, mDate, text );
525 //item->setPalette( mStandardPalette ); 524 //item->setPalette( mStandardPalette );
526 QPalette pal; 525 QPalette pal;
527 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 526 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
528 QStringList categories = todo->categories(); 527 QStringList categories = todo->categories();
529 QString cat = categories.first(); 528 QString cat = categories.first();
530 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 529 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
531 pal = getPalette(); 530 pal = getPalette();
532 if (cat.isEmpty()) { 531 if (cat.isEmpty()) {
533 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 532 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
534 } else { 533 } else {
535 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 534 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
536 } 535 }
537 536
538 } else { 537 } else {
539 if (cat.isEmpty()) { 538 if (cat.isEmpty()) {
540 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 539 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
541 } else { 540 } else {
542 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 541 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
543 } 542 }
544 } 543 }
545 544
546 } else { 545 } else {
547 pal = mStandardPalette ; 546 pal = mStandardPalette ;
548 } 547 }
549 item->setPalette( pal ); 548 item->setPalette( pal );
550 mItemList->insertItem( item ); 549 mItemList->insertItem( item );
551 tipText += text+"\n"; 550 tipText += text+"\n";
552 } 551 }
553#ifdef DESKTOP_VERSION 552#ifdef DESKTOP_VERSION
554 if (tipText != "") 553 if (tipText != "")
555 QToolTip::add(this,tipText,toolTipGroup(),""); 554 QToolTip::add(this,tipText,toolTipGroup(),"");
556#endif 555#endif
557 556
558 //setMyPalette(); 557 //setMyPalette();
559 setMyPalette(); 558 setMyPalette();
559 QString text;
560 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
561 if ( KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
562 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
563 mLabel->resize( mLabelBigSize );
564 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
565 } else {
566 mLabel->resize( mLabelSize );
567 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
568 }
569 mLabel->setText( text );
560 resizeEvent( 0 ); 570 resizeEvent( 0 );
561 // if ( isVisible()) 571 // if ( isVisible())
562 // qApp->processEvents(); 572 qApp->processEvents();
563} 573}
564 574
565void MonthViewCell::updateConfig() 575void MonthViewCell::updateConfig()
566{ 576{
567 577
568 setFont( KOPrefs::instance()->mMonthViewFont ); 578 setFont( KOPrefs::instance()->mMonthViewFont );
569 579
570 QFontMetrics fm( font() ); 580 QFontMetrics fm( font() );
571 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 581 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
572 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 582 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
573 mHolidayPalette = mStandardPalette; 583 mHolidayPalette = mStandardPalette;
574 mPrimaryPalette = mStandardPalette; 584 mPrimaryPalette = mStandardPalette;
575 mNonPrimaryPalette = mStandardPalette; 585 mNonPrimaryPalette = mStandardPalette;
576 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 586 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
577 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 587 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
578 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 588 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
579 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 589 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
580 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 590 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
581 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 591 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
582 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 592 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
583 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 593 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
584 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 594 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
585 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 595 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
586 } 596 }
587 updateCell(); 597 updateCell();
588} 598}
589 599
590void MonthViewCell::enableScrollBars( bool enabled ) 600void MonthViewCell::enableScrollBars( bool enabled )
591{ 601{
592 if ( enabled ) { 602 if ( enabled ) {
593 mItemList->setVScrollBarMode(QScrollView::Auto); 603 mItemList->setVScrollBarMode(QScrollView::Auto);
594 mItemList->setHScrollBarMode(QScrollView::Auto); 604 mItemList->setHScrollBarMode(QScrollView::Auto);
595 } else { 605 } else {
596 mItemList->setVScrollBarMode(QScrollView::AlwaysOff); 606 mItemList->setVScrollBarMode(QScrollView::AlwaysOff);
597 mItemList->setHScrollBarMode(QScrollView::AlwaysOff); 607 mItemList->setHScrollBarMode(QScrollView::AlwaysOff);
598 } 608 }
599} 609}
600 610
601Incidence *MonthViewCell::selectedIncidence() 611Incidence *MonthViewCell::selectedIncidence()
602{ 612{
603 int index = mItemList->currentItem(); 613 int index = mItemList->currentItem();
604 if ( index < 0 ) return 0; 614 if ( index < 0 ) return 0;
605 615
606 MonthViewItem *item = 616 MonthViewItem *item =
607 static_cast<MonthViewItem *>( mItemList->item( index ) ); 617 static_cast<MonthViewItem *>( mItemList->item( index ) );
608 618
609 if ( !item ) return 0; 619 if ( !item ) return 0;
610 620
611 return item->incidence(); 621 return item->incidence();
612} 622}
613 623
614QDate MonthViewCell::selectedIncidenceDate() 624QDate MonthViewCell::selectedIncidenceDate()
615{ 625{
616 QDate qd; 626 QDate qd;
617 int index = mItemList->currentItem(); 627 int index = mItemList->currentItem();
618 if ( index < 0 ) return qd; 628 if ( index < 0 ) return qd;
619 629
620 MonthViewItem *item = 630 MonthViewItem *item =
621 static_cast<MonthViewItem *>( mItemList->item( index ) ); 631 static_cast<MonthViewItem *>( mItemList->item( index ) );
622 632
623 if ( !item ) return qd; 633 if ( !item ) return qd;
624 634
625 return item->incidenceDate(); 635 return item->incidenceDate();
626} 636}
627 637
628void MonthViewCell::deselect() 638void MonthViewCell::deselect()
629{ 639{
630 mItemList->clearSelection(); 640 mItemList->clearSelection();
631 enableScrollBars( false ); 641 enableScrollBars( false );
632 // updateCell(); 642 // updateCell();
633} 643}
634void MonthViewCell::select() 644void MonthViewCell::select()
635{ 645{
636 ;// updateCell(); 646 ;// updateCell();
637} 647}
638 648
639void MonthViewCell::resizeEvent ( QResizeEvent * ) 649void MonthViewCell::resizeEvent ( QResizeEvent * )
640{ 650{
651 if ( !mMonthView->isUpdatePossible() )
652 return;
653 if ( !isVisible() ){
654 return;
655 }
641 int size = height() - mLabel->height(); 656 int size = height() - mLabel->height();
642 if ( size > 0 ) 657 if ( size > 0 )
643 mItemList->verticalScrollBar()->setMaximumHeight( size ); 658 mItemList->verticalScrollBar()->setMaximumHeight( size );
644 size = width() - mLabel->width(); 659 size = width() - mLabel->width();
645 if ( size > 0 ) 660 if ( size > 0 )
646 mItemList->horizontalScrollBar()->setMaximumWidth( size ); 661 mItemList->horizontalScrollBar()->setMaximumWidth( size );
647 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); 662 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() );
648 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 663 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
649} 664}
650 665
651void MonthViewCell::defaultAction( QListBoxItem *item ) 666void MonthViewCell::defaultAction( QListBoxItem *item )
652{ 667{
653 if ( !item ) return; 668 if ( !item ) return;
654 669
655 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 670 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
656 Incidence *incidence = eventItem->incidence(); 671 Incidence *incidence = eventItem->incidence();
657 if ( incidence ) mMonthView->defaultAction( incidence ); 672 if ( incidence ) mMonthView->defaultAction( incidence );
658} 673}
659void MonthViewCell::showDay() 674void MonthViewCell::showDay()
660{ 675{
661 emit showDaySignal( date() ); 676 emit showDaySignal( date() );
662} 677}
663void MonthViewCell::newEvent() 678void MonthViewCell::newEvent()
664{ 679{
665 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 680 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
666 emit newEventSignal( dt ); 681 emit newEventSignal( dt );
667} 682}
668void MonthViewCell::cellClicked( QListBoxItem *item ) 683void MonthViewCell::cellClicked( QListBoxItem *item )
669{ 684{
670 static QListBoxItem * lastClicked = 0; 685 static QListBoxItem * lastClicked = 0;
671 if ( item == 0 ) { 686 if ( item == 0 ) {
672 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 687 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
673 emit newEventSignal( dt ); 688 emit newEventSignal( dt );
674 return; 689 return;
675 } 690 }
676 /* 691 /*
677 if ( lastClicked ) 692 if ( lastClicked )
678 if ( ! item ) { 693 if ( ! item ) {
679 if ( lastClicked->listBox() != item->listBox() ) 694 if ( lastClicked->listBox() != item->listBox() )
680 lastClicked->listBox()->clearSelection(); 695 lastClicked->listBox()->clearSelection();
681 } 696 }
682 */ 697 */
683 698
684 mMonthView->setSelectedCell( this ); 699 mMonthView->setSelectedCell( this );
685 if( KOPrefs::instance()->mEnableMonthScroll ) enableScrollBars( true ); 700 if( KOPrefs::instance()->mEnableMonthScroll ) enableScrollBars( true );
686 select(); 701 select();
687} 702}
688 703
689void MonthViewCell::contextMenu( QListBoxItem *item ) 704void MonthViewCell::contextMenu( QListBoxItem *item )
690{ 705{
691 if ( !item ) return; 706 if ( !item ) return;
692 707
693 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 708 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
694 Incidence *incidence = eventItem->incidence(); 709 Incidence *incidence = eventItem->incidence();
695 if ( incidence ) mMonthView->showContextMenu( incidence ); 710 if ( incidence ) mMonthView->showContextMenu( incidence );
696} 711}
697 712
698void MonthViewCell::selection( QListBoxItem *item ) 713void MonthViewCell::selection( QListBoxItem *item )
699{ 714{
700 if ( !item ) return; 715 if ( !item ) return;
701 716
702 mMonthView->setSelectedCell( this ); 717 mMonthView->setSelectedCell( this );
703} 718}
704 719
705 720
706// ******************************************************************************* 721// *******************************************************************************
707// ******************************************************************************* 722// *******************************************************************************
708// ******************************************************************************* 723// *******************************************************************************
709 724
710 725
711KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) 726KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
712 : KOEventView( calendar, parent, name ), 727 : KOEventView( calendar, parent, name ),
713 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), 728 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
714 mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) 729 mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
715{ 730{
731 updatePossible = false;
716 mCells.setAutoDelete( true ); 732 mCells.setAutoDelete( true );
717 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 733 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
718 // mDayLayout = new QGridLayout( this ); 734 // mDayLayout = new QGridLayout( this );
719 // create the day of the week labels (Sun, Mon, etc) and add them to 735 // create the day of the week labels (Sun, Mon, etc) and add them to
720 // the layout. 736 // the layout.
721 mDayLabels.resize( mDaysPerWeek ); 737 mDayLabels.resize( mDaysPerWeek );
722 QFont bfont = font(); 738 QFont bfont = font();
723 if ( QApplication::desktop()->width() < 650 ) { 739 if ( QApplication::desktop()->width() < 650 ) {
724 bfont.setPointSize( bfont.pointSize() - 2 ); 740 bfont.setPointSize( bfont.pointSize() - 2 );
725 } 741 }
726 bfont.setBold( true ); 742 bfont.setBold( true );
727 int i; 743 int i;
728 744
729 for( i = 0; i < mDaysPerWeek; i++ ) { 745 for( i = 0; i < mDaysPerWeek; i++ ) {
730 QLabel *label = new QLabel( this ); 746 QLabel *label = new QLabel( this );
731 label->setFont(bfont); 747 label->setFont(bfont);
732 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 748 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
733 label->setLineWidth(1); 749 label->setLineWidth(1);
734 label->setAlignment(AlignCenter); 750 label->setAlignment(AlignCenter);
735 mDayLabels.insert( i, label ); 751 mDayLabels.insert( i, label );
736 } 752 }
737 753
738 bfont.setBold( false ); 754 bfont.setBold( false );
739 mWeekLabels.resize( mNumWeeks+1 ); 755 mWeekLabels.resize( mNumWeeks+1 );
740 for( i = 0; i < mNumWeeks+1; i++ ) { 756 for( i = 0; i < mNumWeeks+1; i++ ) {
741 KOWeekButton *label = new KOWeekButton( this ); 757 KOWeekButton *label = new KOWeekButton( this );
742 label->setFont(bfont); 758 label->setFont(bfont);
743 connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) ); 759 connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) );
744 label->setFlat(true); 760 label->setFlat(true);
745 QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view")); 761 QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view"));
746 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 762 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
747 //label->setLineWidth(1); 763 //label->setLineWidth(1);
748 //label->setAlignment(AlignCenter); 764 //label->setAlignment(AlignCenter);
749 mWeekLabels.insert( i, label ); 765 mWeekLabels.insert( i, label );
750 } 766 }
751 mWeekLabels[mNumWeeks]->setText( i18n("W")); 767 mWeekLabels[mNumWeeks]->setText( i18n("W"));
752 int row, col; 768 int row, col;
753 mCells.resize( mNumCells ); 769 mCells.resize( mNumCells );
754 for( row = 0; row < mNumWeeks; ++row ) { 770 for( row = 0; row < mNumWeeks; ++row ) {
755 for( col = 0; col < mDaysPerWeek; ++col ) { 771 for( col = 0; col < mDaysPerWeek; ++col ) {
756 MonthViewCell *cell = new MonthViewCell( this ); 772 MonthViewCell *cell = new MonthViewCell( this );
757 mCells.insert( row * mDaysPerWeek + col, cell ); 773 mCells.insert( row * mDaysPerWeek + col, cell );
758 774
759 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 775 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
760 SLOT( defaultAction( Incidence * ) ) ); 776 SLOT( defaultAction( Incidence * ) ) );
761 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 777 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
762 SIGNAL( newEventSignal( QDateTime ) ) ); 778 SIGNAL( newEventSignal( QDateTime ) ) );
763 connect( cell, SIGNAL( showDaySignal( QDate ) ), 779 connect( cell, SIGNAL( showDaySignal( QDate ) ),
764 SIGNAL( showDaySignal( QDate ) ) ); 780 SIGNAL( showDaySignal( QDate ) ) );
765 } 781 }
766 } 782 }
767 783
768 mContextMenu = eventPopup(); 784 mContextMenu = eventPopup();
769 // updateConfig(); //useless here 785 // updateConfig(); //useless here
770 786
771 emit incidenceSelected( 0 ); 787 emit incidenceSelected( 0 );
772} 788}
773 789
774KOMonthView::~KOMonthView() 790KOMonthView::~KOMonthView()
775{ 791{
776 delete mContextMenu; 792 delete mContextMenu;
777} 793}
778 794
779int KOMonthView::maxDatesHint() 795int KOMonthView::maxDatesHint()
780{ 796{
781 return mNumCells; 797 return mNumCells;
782} 798}
783 799
784int KOMonthView::currentDateCount() 800int KOMonthView::currentDateCount()
785{ 801{
786 return mNumCells; 802 return mNumCells;
787} 803}
788 804
789QPtrList<Incidence> KOMonthView::selectedIncidences() 805QPtrList<Incidence> KOMonthView::selectedIncidences()
790{ 806{
791 QPtrList<Incidence> selected; 807 QPtrList<Incidence> selected;
792 808
793 if ( mSelectedCell ) { 809 if ( mSelectedCell ) {
794 Incidence *incidence = mSelectedCell->selectedIncidence(); 810 Incidence *incidence = mSelectedCell->selectedIncidence();
795 if ( incidence ) selected.append( incidence ); 811 if ( incidence ) selected.append( incidence );
796 } 812 }
797 813
798 return selected; 814 return selected;
799} 815}
800 816
801DateList KOMonthView::selectedDates() 817DateList KOMonthView::selectedDates()
802{ 818{
803 DateList selected; 819 DateList selected;
804 820
805 if ( mSelectedCell ) { 821 if ( mSelectedCell ) {
806 QDate qd = mSelectedCell->selectedIncidenceDate(); 822 QDate qd = mSelectedCell->selectedIncidenceDate();
807 if ( qd.isValid() ) selected.append( qd ); 823 if ( qd.isValid() ) selected.append( qd );
808 } 824 }
809 825
810 return selected; 826 return selected;
811} 827}
@@ -827,266 +843,273 @@ void KOMonthView::updateConfig()
827 mWidthLongDayLabel = 0; 843 mWidthLongDayLabel = 0;
828 844
829 for (int i = 0; i < 7; i++) { 845 for (int i = 0; i < 7; i++) {
830 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 846 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
831 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 847 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
832 } 848 }
833 bool temp = mShowSatSunComp ; 849 bool temp = mShowSatSunComp ;
834 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 850 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
835 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) 851 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog )
836 computeLayout(); 852 computeLayout();
837 updateDayLabels(); 853 updateDayLabels();
838 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); 854 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks);
839 int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; 855 int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
840 //resizeEvent( 0 ); 856 //resizeEvent( 0 );
841 for (uint i = 0; i < mCells.count(); ++i) { 857 for (uint i = 0; i < mCells.count(); ++i) {
842 mCells[i]->updateConfig(); 858 mCells[i]->updateConfig();
843 } 859 }
844#ifdef DESKTOP_VERSION 860#ifdef DESKTOP_VERSION
845 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); 861 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips);
846#endif 862#endif
847} 863}
848 864
849void KOMonthView::updateDayLabels() 865void KOMonthView::updateDayLabels()
850{ 866{
851 867
852 for (int i = 0; i < 7; i++) { 868 for (int i = 0; i < 7; i++) {
853 if (mWeekStartsMonday) { 869 if (mWeekStartsMonday) {
854 bool show = mShortDayLabels; 870 bool show = mShortDayLabels;
855 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) 871 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() )
856 show = true; 872 show = true;
857 mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 873 mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
858 } else { 874 } else {
859 if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); 875 if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels));
860 else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); 876 else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels));
861 877
862 } 878 }
863 } 879 }
864} 880}
865 881
866void KOMonthView::showDates(const QDate &start, const QDate &) 882void KOMonthView::showDates(const QDate &start, const QDate &)
867{ 883{
868// kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; 884// kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
869 885
870 886
871 mStartDate = start; 887 mStartDate = start;
872 888
873 int startWeekDay = mWeekStartsMonday ? 1 : 7; 889 int startWeekDay = mWeekStartsMonday ? 1 : 7;
874 890
875 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { 891 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
876 mStartDate = mStartDate.addDays( -1 ); 892 mStartDate = mStartDate.addDays( -1 );
877 } 893 }
878 894
879 bool primary = false; 895 bool primary = false;
880 uint i; 896 uint i;
881 for( i = 0; i < mCells.size(); ++i ) { 897 for( i = 0; i < mCells.size(); ++i ) {
882 QDate date = mStartDate.addDays( i ); 898 QDate date = mStartDate.addDays( i );
883 mCells[i]->setDate( date ); 899 mCells[i]->setDate( date );
884 900
885#ifndef KORG_NOPLUGINS 901#ifndef KORG_NOPLUGINS
886 // add holiday, if present 902 // add holiday, if present
887 QString hstring(KOCore::self()->holiday(date)); 903 QString hstring(KOCore::self()->holiday(date));
888 mCells[i]->setHoliday( hstring ); 904 mCells[i]->setHoliday( hstring );
889#endif 905#endif
890 906
891 } 907 }
892 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); 908 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
893 for( i = 0; i < 6; ++i ) { 909 for( i = 0; i < 6; ++i ) {
894 int wno; 910 int wno;
895 // remember, according to ISO 8601, the first week of the year is the 911 // remember, according to ISO 8601, the first week of the year is the
896 // first week that contains a thursday. Thus we must subtract off 4, 912 // first week that contains a thursday. Thus we must subtract off 4,
897 // not just 1. 913 // not just 1.
898 int dayOfYear = date.dayOfYear(); 914 int dayOfYear = date.dayOfYear();
899 if (dayOfYear % 7 != 0) 915 if (dayOfYear % 7 != 0)
900 wno = dayOfYear / 7 + 1; 916 wno = dayOfYear / 7 + 1;
901 else 917 else
902 wno =dayOfYear / 7; 918 wno =dayOfYear / 7;
903 mWeekLabels[i]->setWeekNum( wno ); 919 mWeekLabels[i]->setWeekNum( wno );
904 date = date.addDays( 7 ); 920 date = date.addDays( 7 );
905 } 921 }
906 updateView(); 922 updateView();
907} 923}
908 924
909void KOMonthView::showEvents(QPtrList<Event>) 925void KOMonthView::showEvents(QPtrList<Event>)
910{ 926{
911 qDebug("KOMonthView::selectEvents is not implemented yet. "); 927 qDebug("KOMonthView::selectEvents is not implemented yet. ");
912} 928}
913 929
914void KOMonthView::changeEventDisplay(Event *, int) 930void KOMonthView::changeEventDisplay(Event *, int)
915{ 931{
916 // this should be re-written to be much more efficient, but this 932 // this should be re-written to be much more efficient, but this
917 // quick-and-dirty-hack gets the job done for right now. 933 // quick-and-dirty-hack gets the job done for right now.
918 updateView(); 934 updateView();
919} 935}
920 936
921void KOMonthView::updateView() 937void KOMonthView::updateView()
922{ 938{
923 939 static int iii = 0;
940 ++iii;
941 if ( !updatePossible )
942 return;
924 uint i; 943 uint i;
925 for( i = 0; i < mCells.count(); ++i ) { 944 for( i = 0; i < mCells.count(); ++i ) {
926 mCells[i]->updateCell(); 945 mCells[i]->updateCell();
927 } 946 }
928 //qDebug("KOMonthView::updateView() "); 947 //qDebug("KOMonthView::updateView() ");
929 processSelectionChange(); 948 processSelectionChange();
930} 949}
931 950
932void KOMonthView::resizeEvent(QResizeEvent * e) 951void KOMonthView::resizeEvent(QResizeEvent * e)
933{ 952{
934 computeLayout(); 953 computeLayout();
935} 954}
936void KOMonthView::computeLayout() 955void KOMonthView::computeLayout()
937{ 956{
938 // select the appropriate heading string size. E.g. "Wednesday" or "Wed". 957 // select the appropriate heading string size. E.g. "Wednesday" or "Wed".
939 // note this only changes the text if the requested size crosses the 958 // note this only changes the text if the requested size crosses the
940 // threshold between big enough to support the full name and not big 959 // threshold between big enough to support the full name and not big
941 // enough. 960 // enough.
942 961
943 int daysToShow = 7; 962 int daysToShow = 7;
944 bool combinedSatSun = false; 963 bool combinedSatSun = false;
945 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 964 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
946 daysToShow = 6; 965 daysToShow = 6;
947 combinedSatSun = true; 966 combinedSatSun = true;
948 } 967 }
949 int tWid = topLevelWidget()->size().width(); 968 int tWid = topLevelWidget()->size().width();
950 int tHei = topLevelWidget()->size().height(); 969 int tHei = topLevelWidget()->size().height();
951 970
952 int wid = size().width();//e 971 int wid = size().width();//e
953 int hei = size().height()-1; 972 int hei = size().height()-1;
954 973
955 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 974 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
956 return; 975 return;
957 976 //qDebug("KOMonthView::computeLayout()------------------------------------ ");
958 QFontMetrics fm ( mWeekLabels[0]->font() ); 977 QFontMetrics fm ( mWeekLabels[0]->font() );
959 int weeklabelwid = fm.width( "888" ); 978 int weeklabelwid = fm.width( "888" );
960 wid -= weeklabelwid; 979 wid -= weeklabelwid;
961 980
962 int colWid = wid / daysToShow; 981 int colWid = wid / daysToShow;
963 int lastCol = wid - ( colWid*6 ); 982 int lastCol = wid - ( colWid*6 );
964 int dayLabelHei = mDayLabels[0]->sizeHint().height(); 983 int dayLabelHei = mDayLabels[0]->sizeHint().height();
965 int cellHei = (hei - dayLabelHei) /6; 984 int cellHei = (hei - dayLabelHei) /6;
966 int colModulo = wid % daysToShow; 985 int colModulo = wid % daysToShow;
967 int rowModulo = (hei- dayLabelHei) % 6; 986 int rowModulo = (hei- dayLabelHei) % 6;
968 //qDebug("rowmod %d ", rowModulo); 987 //qDebug("rowmod %d ", rowModulo);
969 int i; 988 int i;
970 int x,y,w,h; 989 int x,y,w,h;
971 x= 0; 990 x= 0;
972 y= 0; 991 y= 0;
973 w = colWid; 992 w = colWid;
974 h = dayLabelHei ; 993 h = dayLabelHei ;
975 for ( i = 0; i < 7; i++) { 994 for ( i = 0; i < 7; i++) {
976 if ( i == daysToShow-colModulo ) 995 if ( i == daysToShow-colModulo )
977 ++w; 996 ++w;
978 if ( combinedSatSun ) { 997 if ( combinedSatSun ) {
979 if ( i >= daysToShow-1 ) { 998 if ( i >= daysToShow-1 ) {
980 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); 999 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h);
981 x -= w/2 ; 1000 x -= w/2 ;
982 } 1001 }
983 else 1002 else
984 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1003 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
985 } else 1004 } else
986 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1005 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
987 x += w; 1006 x += w;
988 } 1007 }
989 x= 0; 1008 x= 0;
990 y= dayLabelHei; 1009 y= dayLabelHei;
991 w = colWid; 1010 w = colWid;
992 h = cellHei ; 1011 h = cellHei ;
993 for ( i = 0; i < mCells.count(); ++i) { 1012 for ( i = 0; i < mCells.count(); ++i) {
994 1013
995 w = colWid; 1014 w = colWid;
996 if ( ((i) % 7) >= 7-colModulo ) { 1015 if ( ((i) % 7) >= 7-colModulo ) {
997 ++w; 1016 ++w;
998 } 1017 }
999 if ( i == (6-rowModulo)*7) 1018 if ( i == (6-rowModulo)*7)
1000 ++h; 1019 ++h;
1001 if ( combinedSatSun ) { 1020 if ( combinedSatSun ) {
1002 if ( (i)%7 >= daysToShow-1 ) { 1021 if ( (i)%7 >= daysToShow-1 ) {
1003 if ( (i)%7 == daysToShow-1 ) { 1022 if ( (i)%7 == daysToShow-1 ) {
1004 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); 1023 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 );
1005 x -= w ;y += h/2; 1024 x -= w ;y += h/2;
1006 } else { 1025 } else {
1007 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); 1026 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 );
1008 y -= h/2; 1027 y -= h/2;
1009 } 1028 }
1010 } else 1029 } else
1011 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1030 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1012 1031
1013 } 1032 }
1014 else 1033 else
1015 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1034 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1016 x += w; 1035 x += w;
1017 if ( x + w/2 > wid ) { 1036 if ( x + w/2 > wid ) {
1018 x = 0; 1037 x = 0;
1019 y += h; 1038 y += h;
1020 } 1039 }
1021 } 1040 }
1022 y= dayLabelHei; 1041 y= dayLabelHei;
1023 h = cellHei ; 1042 h = cellHei ;
1024 for ( i = 0; i < 6; i++) { 1043 for ( i = 0; i < 6; i++) {
1025 if ( i == (6-rowModulo)) 1044 if ( i == (6-rowModulo))
1026 ++h; 1045 ++h;
1027 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); 1046 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h);
1028 y += h; 1047 y += h;
1029 } 1048 }
1030 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1049 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1031 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1050 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1032 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1051 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1033 mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; 1052 mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ;
1034 updateDayLabels(); 1053 updateDayLabels();
1054 bool forceUpdate = !updatePossible;
1055 updatePossible = true;
1056 if ( forceUpdate )
1057 updateView();
1035} 1058}
1036 1059
1037void KOMonthView::showContextMenu( Incidence *incidence ) 1060void KOMonthView::showContextMenu( Incidence *incidence )
1038{ 1061{
1039 mContextMenu->showIncidencePopup(incidence); 1062 mContextMenu->showIncidencePopup(incidence);
1040 /* 1063 /*
1041 if( incidence && incidence->type() == "Event" ) { 1064 if( incidence && incidence->type() == "Event" ) {
1042 Event *event = static_cast<Event *>(incidence); 1065 Event *event = static_cast<Event *>(incidence);
1043 mContextMenu->showEventPopup(event); 1066 mContextMenu->showEventPopup(event);
1044 } else { 1067 } else {
1045 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; 1068 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl;
1046 } 1069 }
1047 */ 1070 */
1048} 1071}
1049MonthViewCell * KOMonthView::selectedCell( ) 1072MonthViewCell * KOMonthView::selectedCell( )
1050{ 1073{
1051 return mSelectedCell; 1074 return mSelectedCell;
1052} 1075}
1053void KOMonthView::setSelectedCell( MonthViewCell *cell ) 1076void KOMonthView::setSelectedCell( MonthViewCell *cell )
1054{ 1077{
1055 // qDebug("KOMonthView::setSelectedCell "); 1078 // qDebug("KOMonthView::setSelectedCell ");
1056 if ( mSelectedCell && mSelectedCell != cell ) { 1079 if ( mSelectedCell && mSelectedCell != cell ) {
1057 MonthViewCell * mvc = mSelectedCell; 1080 MonthViewCell * mvc = mSelectedCell;
1058 mSelectedCell = cell; 1081 mSelectedCell = cell;
1059 mvc->deselect(); 1082 mvc->deselect();
1060 } else 1083 } else
1061 mSelectedCell = cell; 1084 mSelectedCell = cell;
1062 // if ( mSelectedCell ) 1085 // if ( mSelectedCell )
1063// mSelectedCell->select(); 1086// mSelectedCell->select();
1064 if ( !mSelectedCell ) 1087 if ( !mSelectedCell )
1065 emit incidenceSelected( 0 ); 1088 emit incidenceSelected( 0 );
1066 else 1089 else
1067 emit incidenceSelected( mSelectedCell->selectedIncidence() ); 1090 emit incidenceSelected( mSelectedCell->selectedIncidence() );
1068} 1091}
1069 1092
1070void KOMonthView::processSelectionChange() 1093void KOMonthView::processSelectionChange()
1071{ 1094{
1072 QPtrList<Incidence> incidences = selectedIncidences(); 1095 QPtrList<Incidence> incidences = selectedIncidences();
1073 if (incidences.count() > 0) { 1096 if (incidences.count() > 0) {
1074 emit incidenceSelected( incidences.first() ); 1097 emit incidenceSelected( incidences.first() );
1075 } else { 1098 } else {
1076 emit incidenceSelected( 0 ); 1099 emit incidenceSelected( 0 );
1077 } 1100 }
1078} 1101}
1079 1102
1080void KOMonthView::clearSelection() 1103void KOMonthView::clearSelection()
1081{ 1104{
1082 if ( mSelectedCell ) { 1105 if ( mSelectedCell ) {
1083 mSelectedCell->deselect(); 1106 mSelectedCell->deselect();
1084 mSelectedCell = 0; 1107 mSelectedCell = 0;
1085 } 1108 }
1086} 1109}
1087void KOMonthView::keyPressEvent ( QKeyEvent * e ) 1110void KOMonthView::keyPressEvent ( QKeyEvent * e )
1088{ 1111{
1089 1112
1090 e->ignore(); 1113 e->ignore();
1091 1114
1092} 1115}
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index 4c1567c..727f511 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -1,265 +1,271 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#ifndef _KOMONTHVIEW_H 20#ifndef _KOMONTHVIEW_H
21#define _KOMONTHVIEW_H 21#define _KOMONTHVIEW_H
22 22
23#include <qlabel.h> 23#include <qlabel.h>
24#include <qframe.h> 24#include <qframe.h>
25#include <qdatetime.h> 25#include <qdatetime.h>
26#include <qlistbox.h> 26#include <qlistbox.h>
27#include <qpoint.h> 27#include <qpoint.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qintdict.h> 29#include <qintdict.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31#include <qvaluelist.h> 31#include <qvaluelist.h>
32#include <qptrvector.h> 32#include <qptrvector.h>
33 33
34#include <libkcal/calendar.h> 34#include <libkcal/calendar.h>
35#include <libkcal/event.h> 35#include <libkcal/event.h>
36 36
37#include "koeventview.h" 37#include "koeventview.h"
38 38
39#ifdef DESKTOP_VERSION 39#ifdef DESKTOP_VERSION
40class QToolTipGroup; 40class QToolTipGroup;
41#endif 41#endif
42 42
43class KNOWhatsThis;
43class KOWeekButton : public QPushButton 44class KOWeekButton : public QPushButton
44{ 45{
45 Q_OBJECT 46 Q_OBJECT
46 public: 47 public:
47 KOWeekButton( QWidget *parent=0, const char *name=0 ) : 48 KOWeekButton( QWidget *parent=0, const char *name=0 ) :
48 QPushButton( parent, name) 49 QPushButton( parent, name)
49 { 50 {
50 connect( this, SIGNAL( clicked() ), 51 connect( this, SIGNAL( clicked() ),
51 SLOT( bottonClicked() )); 52 SLOT( bottonClicked() ));
52 mNumber = -1; 53 mNumber = -1;
53 } 54 }
54 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} 55 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));}
55 signals: 56 signals:
56 void selectWeekNum ( int ); 57 void selectWeekNum ( int );
57private: 58private:
58 int mNumber; 59 int mNumber;
59private slots : 60private slots :
60 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } 61 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); }
61}; 62};
62 63
63class KNoScrollListBox: public QListBox 64class KNoScrollListBox: public QListBox
64{ 65{
65 Q_OBJECT 66 Q_OBJECT
66 public: 67 public:
67 KNoScrollListBox(QWidget *parent=0, const char *name=0); 68 KNoScrollListBox(QWidget *parent=0, const char *name=0);
68 ~KNoScrollListBox() {} 69 ~KNoScrollListBox();
69 QString getWhatsThisText(QPoint p) ; 70 QString getWhatsThisText(QPoint p) ;
70 71
71 signals: 72 signals:
72 void shiftDown(); 73 void shiftDown();
73 void shiftUp(); 74 void shiftUp();
74 void rightClick(); 75 void rightClick();
75 76
76 protected slots: 77 protected slots:
77 void keyPressEvent(QKeyEvent *); 78 void keyPressEvent(QKeyEvent *);
78 void keyReleaseEvent(QKeyEvent *); 79 void keyReleaseEvent(QKeyEvent *);
79 void mousePressEvent(QMouseEvent *); 80 void mousePressEvent(QMouseEvent *);
81
82 private:
83 KNOWhatsThis * mWT;
80}; 84};
81 85
82 86
83class MonthViewItem: public QListBoxItem 87class MonthViewItem: public QListBoxItem
84{ 88{
85 public: 89 public:
86 MonthViewItem( Incidence *, QDate qd, const QString & title ); 90 MonthViewItem( Incidence *, QDate qd, const QString & title );
87 91
88 void setRecur(bool on) { mRecur = on; } 92 void setRecur(bool on) { mRecur = on; }
89 void setAlarm(bool on) { mAlarm = on; } 93 void setAlarm(bool on) { mAlarm = on; }
90 void setReply(bool on) { mReply = on; } 94 void setReply(bool on) { mReply = on; }
91 void setMoreInfo(bool on) { mInfo = on; } 95 void setMoreInfo(bool on) { mInfo = on; }
92 96
93 97
94 void setPalette(const QPalette &p) { mPalette = p; } 98 void setPalette(const QPalette &p) { mPalette = p; }
95 QPalette palette() const { return mPalette; } 99 QPalette palette() const { return mPalette; }
96 100
97 Incidence *incidence() const { return mIncidence; } 101 Incidence *incidence() const { return mIncidence; }
98 QDate incidenceDate() { return mDate; } 102 QDate incidenceDate() { return mDate; }
99 103
100 protected: 104 protected:
101 virtual void paint(QPainter *); 105 virtual void paint(QPainter *);
102 virtual int height(const QListBox *) const; 106 virtual int height(const QListBox *) const;
103 virtual int width(const QListBox *) const; 107 virtual int width(const QListBox *) const;
104 108
105 private: 109 private:
106 bool mRecur; 110 bool mRecur;
107 bool mAlarm; 111 bool mAlarm;
108 bool mReply; 112 bool mReply;
109 bool mInfo; 113 bool mInfo;
110 114
111 QPalette mPalette; 115 QPalette mPalette;
112 QDate mDate; 116 QDate mDate;
113 117
114 Incidence *mIncidence; 118 Incidence *mIncidence;
115}; 119};
116 120
117 121
118class KOMonthView; 122class KOMonthView;
119 123
120class MonthViewCell : public QWidget 124class MonthViewCell : public QWidget
121{ 125{
122 Q_OBJECT 126 Q_OBJECT
123 public: 127 public:
124 MonthViewCell( KOMonthView * ); 128 MonthViewCell( KOMonthView * );
125 129
126 void setDate( const QDate & ); 130 void setDate( const QDate & );
127 QDate date() const; 131 QDate date() const;
128 132
129 void setPrimary( bool ); 133 void setPrimary( bool );
130 bool isPrimary() const; 134 bool isPrimary() const;
131 135
132 void setHoliday( bool ); 136 void setHoliday( bool );
133 void setHoliday( const QString & ); 137 void setHoliday( const QString & );
134 138
135 void updateCell(); 139 void updateCell();
136 140
137 void updateConfig(); 141 void updateConfig();
138 142
139 void enableScrollBars( bool ); 143 void enableScrollBars( bool );
140 144
141 Incidence *selectedIncidence(); 145 Incidence *selectedIncidence();
142 QDate selectedIncidenceDate(); 146 QDate selectedIncidenceDate();
143 147
144 void deselect(); 148 void deselect();
145 void select(); 149 void select();
146 150
147#ifdef DESKTOP_VERSION 151#ifdef DESKTOP_VERSION
148 static QToolTipGroup *toolTipGroup(); 152 static QToolTipGroup *toolTipGroup();
149#endif 153#endif
150 signals: 154 signals:
151 void defaultAction( Incidence * ); 155 void defaultAction( Incidence * );
152 void newEventSignal( QDateTime ); 156 void newEventSignal( QDateTime );
153 void showDaySignal( QDate ); 157 void showDaySignal( QDate );
154 158
155 protected: 159 protected:
156 void resizeEvent( QResizeEvent * ); 160 void resizeEvent( QResizeEvent * );
157 161
158 protected slots: 162 protected slots:
159 void defaultAction( QListBoxItem * ); 163 void defaultAction( QListBoxItem * );
160 void contextMenu( QListBoxItem * ); 164 void contextMenu( QListBoxItem * );
161 void selection( QListBoxItem * ); 165 void selection( QListBoxItem * );
162 void cellClicked( QListBoxItem * ); 166 void cellClicked( QListBoxItem * );
163 void newEvent(); 167 void newEvent();
164 void showDay(); 168 void showDay();
165 169
166 private: 170 private:
167 KOMonthView *mMonthView; 171 KOMonthView *mMonthView;
168 172
169 QDate mDate; 173 QDate mDate;
170 bool mPrimary; 174 bool mPrimary;
171 bool mHoliday; 175 bool mHoliday;
172 QString mHolidayString; 176 QString mHolidayString;
173 177
174 //QLabel *mLabel; 178 //QLabel *mLabel;
175 QPushButton *mLabel; 179 QPushButton *mLabel;
176 QListBox *mItemList; 180 QListBox *mItemList;
177#ifdef DESKTOP_VERSION 181#ifdef DESKTOP_VERSION
178 static QToolTipGroup *mToolTipGroup; 182 static QToolTipGroup *mToolTipGroup;
179#endif 183#endif
180 QSize mLabelSize; 184 QSize mLabelSize;
181 QSize mLabelBigSize; 185 QSize mLabelBigSize;
182 QPalette mHolidayPalette; 186 QPalette mHolidayPalette;
183 QPalette mStandardPalette; 187 QPalette mStandardPalette;
184 QPalette mPrimaryPalette; 188 QPalette mPrimaryPalette;
185 QPalette mNonPrimaryPalette; 189 QPalette mNonPrimaryPalette;
186 void setMyPalette(); 190 void setMyPalette();
187 QPalette getPalette (); 191 QPalette getPalette ();
188 void keyPressEvent ( QKeyEvent * ) ; 192 void keyPressEvent ( QKeyEvent * ) ;
189 193
190}; 194};
191 195
192 196
193class KOMonthView: public KOEventView 197class KOMonthView: public KOEventView
194{ 198{
195 Q_OBJECT 199 Q_OBJECT
196 public: 200 public:
197 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); 201 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 );
198 ~KOMonthView(); 202 ~KOMonthView();
199 203
200 /** Returns maximum number of days supported by the komonthview */ 204 /** Returns maximum number of days supported by the komonthview */
201 virtual int maxDatesHint(); 205 virtual int maxDatesHint();
202 206
203 /** Returns number of currently shown dates. */ 207 /** Returns number of currently shown dates. */
204 virtual int currentDateCount(); 208 virtual int currentDateCount();
205 209
206 /** returns the currently selected events */ 210 /** returns the currently selected events */
207 virtual QPtrList<Incidence> selectedIncidences(); 211 virtual QPtrList<Incidence> selectedIncidences();
208 212
209 /** returns dates of the currently selected events */ 213 /** returns dates of the currently selected events */
210 virtual DateList selectedDates(); 214 virtual DateList selectedDates();
211 215
212 virtual void printPreview(CalPrinter *calPrinter, 216 virtual void printPreview(CalPrinter *calPrinter,
213 const QDate &, const QDate &); 217 const QDate &, const QDate &);
214 bool isMonthView() { return true; } 218 bool isMonthView() { return true; }
219 bool isUpdatePossible() { return updatePossible; }
215 220
216 MonthViewCell * selectedCell(); 221 MonthViewCell * selectedCell();
217 public slots: 222 public slots:
218 virtual void updateView(); 223 virtual void updateView();
219 virtual void updateConfig(); 224 virtual void updateConfig();
220 virtual void showDates(const QDate &start, const QDate &end); 225 virtual void showDates(const QDate &start, const QDate &end);
221 virtual void showEvents(QPtrList<Event> eventList); 226 virtual void showEvents(QPtrList<Event> eventList);
222 227
223 void changeEventDisplay(Event *, int); 228 void changeEventDisplay(Event *, int);
224 229
225 void clearSelection(); 230 void clearSelection();
226 231
227 void showContextMenu( Incidence * ); 232 void showContextMenu( Incidence * );
228 233
229 void setSelectedCell( MonthViewCell * ); 234 void setSelectedCell( MonthViewCell * );
230 235
231 protected slots: 236 protected slots:
232 void processSelectionChange(); 237 void processSelectionChange();
233 signals: 238 signals:
234 void selectWeekNum ( int ); 239 void selectWeekNum ( int );
235 void showDaySignal( QDate ); 240 void showDaySignal( QDate );
236 protected: 241 protected:
237 void resizeEvent(QResizeEvent *); 242 void resizeEvent(QResizeEvent *);
238 void viewChanged(); 243 void viewChanged();
239 void updateDayLabels(); 244 void updateDayLabels();
240 245
241 private: 246 private:
247 bool updatePossible;
242 int mDaysPerWeek; 248 int mDaysPerWeek;
243 int mNumWeeks; 249 int mNumWeeks;
244 int mNumCells; 250 int mNumCells;
245 bool mWeekStartsMonday; 251 bool mWeekStartsMonday;
246 bool mShowSatSunComp; 252 bool mShowSatSunComp;
247 void computeLayout(); 253 void computeLayout();
248 254
249 QPtrVector<MonthViewCell> mCells; 255 QPtrVector<MonthViewCell> mCells;
250 QPtrVector<QLabel> mDayLabels; 256 QPtrVector<QLabel> mDayLabels;
251 QPtrVector<KOWeekButton> mWeekLabels; 257 QPtrVector<KOWeekButton> mWeekLabels;
252 258
253 bool mShortDayLabels; 259 bool mShortDayLabels;
254 int mWidthLongDayLabel; 260 int mWidthLongDayLabel;
255 261
256 QDate mStartDate; 262 QDate mStartDate;
257 263
258 MonthViewCell *mSelectedCell; 264 MonthViewCell *mSelectedCell;
259 265
260 KOEventPopupMenu *mContextMenu; 266 KOEventPopupMenu *mContextMenu;
261 void keyPressEvent ( QKeyEvent * ) ; 267 void keyPressEvent ( QKeyEvent * ) ;
262 268
263}; 269};
264 270
265#endif 271#endif
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index cf56fcf..00a5842 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -1,143 +1,144 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Copyright (c) 2001 4 Copyright (c) 2001
5 Cornelius Schumacher <schumacher@kde.org> 5 Cornelius Schumacher <schumacher@kde.org>
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 20
21 As a special exception, permission is given to link this program 21 As a special exception, permission is given to link this program
22 with any edition of Qt, and distribute the resulting executable, 22 with any edition of Qt, and distribute the resulting executable,
23 without including the source code for Qt in the source distribution. 23 without including the source code for Qt in the source distribution.
24*/ 24*/
25 25
26#include <qwidgetstack.h> 26#include <qwidgetstack.h>
27 27
28#include <kconfig.h> 28#include <kconfig.h>
29#include <kglobal.h> 29#include <kglobal.h>
30#ifndef DESKTOP_VERSION 30#ifndef DESKTOP_VERSION
31#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
32#else 32#else
33#include <qapplication.h> 33#include <qapplication.h>
34#endif 34#endif
35#include <qdatetime.h> 35#include <qdatetime.h>
36#include "calendarview.h" 36#include "calendarview.h"
37#include "datenavigator.h" 37#include "datenavigator.h"
38#include "kotodoview.h" 38#include "kotodoview.h"
39#include "koagendaview.h" 39#include "koagendaview.h"
40#include "kodialogmanager.h" 40#include "kodialogmanager.h"
41#include "komonthview.h" 41#include "komonthview.h"
42#include "kolistview.h" 42#include "kolistview.h"
43#include "kowhatsnextview.h" 43#include "kowhatsnextview.h"
44#include "kojournalview.h" 44#include "kojournalview.h"
45#include "kotimespanview.h" 45#include "kotimespanview.h"
46#include "koprefs.h" 46#include "koprefs.h"
47#include "navigatorbar.h" 47#include "navigatorbar.h"
48#include "kdatenavigator.h"
48 49
49#include "koviewmanager.h" 50#include "koviewmanager.h"
50//extern bool externFlagMonthviewBlockPainting; 51//extern bool externFlagMonthviewBlockPainting;
51 52
52//bool globalFlagBlockPainting = false; 53//bool globalFlagBlockPainting = false;
53int globalFlagBlockAgenda = 0; 54int globalFlagBlockAgenda = 0;
54int globalFlagBlockLabel = 0; 55int globalFlagBlockLabel = 0;
55int globalFlagBlockAgendaItemPaint = 1; 56int globalFlagBlockAgendaItemPaint = 1;
56int globalFlagBlockAgendaItemUpdate = 1; 57int globalFlagBlockAgendaItemUpdate = 1;
57 58
58 59
59KOViewManager::KOViewManager( CalendarView *mainView ) : 60KOViewManager::KOViewManager( CalendarView *mainView ) :
60 QObject(), mMainView( mainView ) 61 QObject(), mMainView( mainView )
61{ 62{
62 mCurrentView = 0; 63 mCurrentView = 0;
63 64
64 mWhatsNextView = 0; 65 mWhatsNextView = 0;
65 mTodoView = 0; 66 mTodoView = 0;
66 mAgendaView = 0; 67 mAgendaView = 0;
67 mMonthView = 0; 68 mMonthView = 0;
68 mListView = 0; 69 mListView = 0;
69 mJournalView = 0; 70 mJournalView = 0;
70 mTimeSpanView = 0; 71 mTimeSpanView = 0;
71 mCurrentAgendaView = 0 ; 72 mCurrentAgendaView = 0 ;
72 mFlagShowNextxDays = false; 73 mFlagShowNextxDays = false;
73} 74}
74 75
75KOViewManager::~KOViewManager() 76KOViewManager::~KOViewManager()
76{ 77{
77} 78}
78 79
79 80
80KOrg::BaseView *KOViewManager::currentView() 81KOrg::BaseView *KOViewManager::currentView()
81{ 82{
82 return mCurrentView; 83 return mCurrentView;
83} 84}
84 85
85void KOViewManager::readSettings(KConfig *config) 86void KOViewManager::readSettings(KConfig *config)
86{ 87{
87 config->setGroup("General"); 88 config->setGroup("General");
88 QString view = config->readEntry("Current View"); 89 QString view = config->readEntry("Current View");
89 if (view == "WhatsNext") showWhatsNextView(); 90 if (view == "WhatsNext") showWhatsNextView();
90 else if (view == "Month") showMonthView(); 91 else if (view == "Month") showMonthView();
91 else if (view == "List") showListView(); 92 else if (view == "List") showListView();
92 else if (view == "Journal") showJournalView(); 93 else if (view == "Journal") showJournalView();
93 else if (view == "TimeSpan") showTimeSpanView(); 94 else if (view == "TimeSpan") showTimeSpanView();
94 else if (view == "Todo") showTodoView(); 95 else if (view == "Todo") showTodoView();
95 else { 96 else {
96 showAgendaView(); 97 showAgendaView();
97 } 98 }
98} 99}
99 100
100void KOViewManager::writeSettings(KConfig *config) 101void KOViewManager::writeSettings(KConfig *config)
101{ 102{
102 config->setGroup("General"); 103 config->setGroup("General");
103 104
104 QString view; 105 QString view;
105 if (mCurrentView == mWhatsNextView) view = "WhatsNext"; 106 if (mCurrentView == mWhatsNextView) view = "WhatsNext";
106 else if (mCurrentView == mMonthView) view = "Month"; 107 else if (mCurrentView == mMonthView) view = "Month";
107 else if (mCurrentView == mListView) view = "List"; 108 else if (mCurrentView == mListView) view = "List";
108 else if (mCurrentView == mJournalView) view = "Journal"; 109 else if (mCurrentView == mJournalView) view = "Journal";
109 else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; 110 else if (mCurrentView == mTimeSpanView) view = "TimeSpan";
110 else if (mCurrentView == mTodoView) view = "Todo"; 111 else if (mCurrentView == mTodoView) view = "Todo";
111 else view = "Agenda"; 112 else view = "Agenda";
112 113
113 config->writeEntry("Current View",view); 114 config->writeEntry("Current View",view);
114 115
115 if (mAgendaView) { 116 if (mAgendaView) {
116 mAgendaView->writeSettings(config); 117 mAgendaView->writeSettings(config);
117 } 118 }
118 if (mTimeSpanView) { 119 if (mTimeSpanView) {
119 mTimeSpanView->writeSettings(config); 120 mTimeSpanView->writeSettings(config);
120 } 121 }
121 if (mListView) { 122 if (mListView) {
122 mListView->writeSettings(config); 123 mListView->writeSettings(config);
123 } 124 }
124 if (mTodoView) { 125 if (mTodoView) {
125 mTodoView->saveLayout(config,"Todo View"); 126 mTodoView->saveLayout(config,"Todo View");
126 } 127 }
127} 128}
128 129
129void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) 130void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen )
130{ 131{
131 132
132 //mFlagShowNextxDays = false; 133 //mFlagShowNextxDays = false;
133 //if(view == mCurrentView) return; 134 //if(view == mCurrentView) return;
134 if ( view == 0 ) { 135 if ( view == 0 ) {
135 view = mCurrentView; 136 view = mCurrentView;
136 if ( view == 0 ) 137 if ( view == 0 )
137 return; 138 return;
138 } 139 }
139 bool full = fullScreen; 140 bool full = fullScreen;
140 if(view == mCurrentView && view != mWhatsNextView ) { 141 if(view == mCurrentView && view != mWhatsNextView ) {
141 if ( mCurrentAgendaView < 0 ) 142 if ( mCurrentAgendaView < 0 )
142 return; 143 return;
143 full = mMainView->leftFrame()->isVisible(); 144 full = mMainView->leftFrame()->isVisible();
@@ -183,194 +184,197 @@ void KOViewManager::raiseCurrentView( bool fullScreen )
183 184
184 if ( globalFlagBlockAgenda == 5 ) { 185 if ( globalFlagBlockAgenda == 5 ) {
185 globalFlagBlockAgenda = 4; 186 globalFlagBlockAgenda = 4;
186 globalFlagBlockAgendaItemPaint = 1; 187 globalFlagBlockAgendaItemPaint = 1;
187 } 188 }
188 mMainView->viewStack()->raiseWidget(mCurrentView); 189 mMainView->viewStack()->raiseWidget(mCurrentView);
189 if ( globalFlagBlockAgenda == 4 ) { 190 if ( globalFlagBlockAgenda == 4 ) {
190 if ( mCurrentView == mAgendaView ) { 191 if ( mCurrentView == mAgendaView ) {
191 //globalFlagBlockAgenda =1 ; 192 //globalFlagBlockAgenda =1 ;
192 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 193 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
193 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); 194 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins );
194 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 195 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
195 mAgendaView->setStartHour( QTime::currentTime ().hour() ); 196 mAgendaView->setStartHour( QTime::currentTime ().hour() );
196 qApp->processEvents(); 197 qApp->processEvents();
197 //qDebug("qApp->processEvents() "); 198 //qDebug("qApp->processEvents() ");
198 globalFlagBlockAgenda = 0; 199 globalFlagBlockAgenda = 0;
199 mAgendaView->repaintAgenda(); 200 mAgendaView->repaintAgenda();
200 201
201 } 202 }
202 globalFlagBlockAgenda = 0; 203 globalFlagBlockAgenda = 0;
203 } 204 }
204 //qDebug("raiseCurrentView ende "); 205 //qDebug("raiseCurrentView ende ");
205} 206}
206 207
207void KOViewManager::updateView() 208void KOViewManager::updateView()
208{ 209{
209 // qDebug("KOViewManager::updateView() "); 210 // qDebug("KOViewManager::updateView() ");
210 // if we are updating mTodoView, we get endless recursion 211 // if we are updating mTodoView, we get endless recursion
211 if ( mTodoView == mCurrentView ) 212 if ( mTodoView == mCurrentView )
212 return; 213 return;
213 if ( mCurrentView ) mCurrentView->updateView(); 214 if ( mCurrentView ) mCurrentView->updateView();
214 215
215} 216}
216 217
217void KOViewManager::updateView(const QDate &start, const QDate &end) 218void KOViewManager::updateView(const QDate &start, const QDate &end)
218{ 219{
219 // kdDebug() << "KOViewManager::updateView()" << endl; 220 // kdDebug() << "KOViewManager::updateView()" << endl;
220 221
221 if (mCurrentView) mCurrentView->showDates(start, end); 222 if (mCurrentView) mCurrentView->showDates(start, end);
222 223
223 if (mTodoView) mTodoView->updateView(); 224 if (mTodoView) mTodoView->updateView();
224} 225}
225 226
226 227
227void KOViewManager::updateWNview() 228void KOViewManager::updateWNview()
228{ 229{
229 if ( mCurrentView == mWhatsNextView && mWhatsNextView ) 230 if ( mCurrentView == mWhatsNextView && mWhatsNextView )
230 mWhatsNextView->updateView(); 231 mWhatsNextView->updateView();
231 232
232} 233}
233void KOViewManager::showWhatsNextView() 234void KOViewManager::showWhatsNextView()
234{ 235{
235 if (!mWhatsNextView) { 236 if (!mWhatsNextView) {
236 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), 237 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(),
237 "KOViewManager::WhatsNextView"); 238 "KOViewManager::WhatsNextView");
238 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); 239 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog());
239 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); 240 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig()));
240 addView(mWhatsNextView); 241 addView(mWhatsNextView);
241 connect(this, SIGNAL( printWNV() ), 242 connect(this, SIGNAL( printWNV() ),
242 mWhatsNextView, SLOT( printMe() ) ); 243 mWhatsNextView, SLOT( printMe() ) );
243 } 244 }
244 globalFlagBlockAgenda = 1; 245 globalFlagBlockAgenda = 1;
245 showView(mWhatsNextView, true ); 246 showView(mWhatsNextView, true );
246 //mWhatsNextView->updateView(); 247 //mWhatsNextView->updateView();
247 248
248} 249}
249 250
250void KOViewManager::showListView() 251void KOViewManager::showListView()
251{ 252{
252 if (!mListView) { 253 if (!mListView) {
253 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); 254 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView");
254 addView(mListView); 255 addView(mListView);
255 256
256 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), 257 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)),
257 mMainView, SLOT(showIncidence(Incidence *))); 258 mMainView, SLOT(showIncidence(Incidence *)));
258 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), 259 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)),
259 mMainView, SLOT(editIncidence(Incidence *))); 260 mMainView, SLOT(editIncidence(Incidence *)));
260 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), 261 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)),
261 mMainView, SLOT(deleteIncidence(Incidence *))); 262 mMainView, SLOT(deleteIncidence(Incidence *)));
262 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), 263 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ),
263 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 264 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
264 connect( mListView, SIGNAL( signalNewEvent() ), 265 connect( mListView, SIGNAL( signalNewEvent() ),
265 mMainView, SLOT( newEvent() ) ); 266 mMainView, SLOT( newEvent() ) );
266 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); 267 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig()));
267 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 268 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
268 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 269 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
269 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 270 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
270 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 271 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
271 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 272 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
272 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 273 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
273 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 274 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
274 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 275 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
275 } 276 }
276 // bool temp = mFlagShowNextxDays; 277 // bool temp = mFlagShowNextxDays;
277 //globalFlagBlockPainting = true; 278 //globalFlagBlockPainting = true;
278 globalFlagBlockAgenda = 1; 279 globalFlagBlockAgenda = 1;
279 if ( KOPrefs::instance()->mListViewMonthTimespan ) 280 if ( KOPrefs::instance()->mListViewMonthTimespan ) {
281 mMainView->setBlockShowDates( true );
280 mMainView->dateNavigator()->selectMonth(); 282 mMainView->dateNavigator()->selectMonth();
283 mMainView->setBlockShowDates( false );
284 }
281 showView(mListView, KOPrefs::instance()->mFullViewTodo); 285 showView(mListView, KOPrefs::instance()->mFullViewTodo);
282 //mFlagShowNextxDays = temp; 286 //mFlagShowNextxDays = temp;
283} 287}
284 288
285void KOViewManager::showAgendaView( bool fullScreen ) 289void KOViewManager::showAgendaView( bool fullScreen )
286{ 290{
287 291
288 mMainView->dialogManager()->hideSearchDialog(); 292 mMainView->dialogManager()->hideSearchDialog();
289 // qDebug("KOViewManager::showAgendaView "); 293 // qDebug("KOViewManager::showAgendaView ");
290 bool full; 294 bool full;
291 full = fullScreen; 295 full = fullScreen;
292 if (!mAgendaView) { 296 if (!mAgendaView) {
293 full = false; 297 full = false;
294 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); 298 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView");
295 addView(mAgendaView); 299 addView(mAgendaView);
296#ifndef DESKTOP_VERSION 300#ifndef DESKTOP_VERSION
297 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); 301 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold );
298#endif 302#endif
299 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), 303 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )),
300 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); 304 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) ));
301 305
302 // SIGNALS/SLOTS FOR DAY/WEEK VIEW 306 // SIGNALS/SLOTS FOR DAY/WEEK VIEW
303 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), 307 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)),
304 mMainView, SLOT(newEvent(QDateTime))); 308 mMainView, SLOT(newEvent(QDateTime)));
305 // connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), 309 // connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)),
306 // mMainView, SLOT(newEvent(QDateTime,QDateTime))); 310 // mMainView, SLOT(newEvent(QDateTime,QDateTime)));
307 connect(mAgendaView,SIGNAL(newEventSignal(QDate)), 311 connect(mAgendaView,SIGNAL(newEventSignal(QDate)),
308 mMainView, SLOT(newEvent(QDate))); 312 mMainView, SLOT(newEvent(QDate)));
309 313
310 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), 314 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)),
311 mMainView, SLOT(editIncidence(Incidence *))); 315 mMainView, SLOT(editIncidence(Incidence *)));
312 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), 316 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)),
313 mMainView, SLOT(showIncidence(Incidence *))); 317 mMainView, SLOT(showIncidence(Incidence *)));
314 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), 318 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)),
315 mMainView, SLOT(deleteIncidence(Incidence *))); 319 mMainView, SLOT(deleteIncidence(Incidence *)));
316 320
317 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), 321 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ),
318 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 322 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
319 323
320 connect(mAgendaView, SIGNAL( toggleExpand() ), 324 connect(mAgendaView, SIGNAL( toggleExpand() ),
321 mMainView, SLOT( toggleExpand() ) ); 325 mMainView, SLOT( toggleExpand() ) );
322 326
323 connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ), 327 connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ),
324 mAgendaView, SLOT( setExpandedButton( bool ) ) ); 328 mAgendaView, SLOT( setExpandedButton( bool ) ) );
325 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), 329 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ),
326 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; 330 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ;
327 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), 331 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ),
328 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; 332 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ;
329 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); 333 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig()));
330 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, 334 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView,
331 SLOT( updateTodo( Todo *, int ) ) ); 335 SLOT( updateTodo( Todo *, int ) ) );
332 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), 336 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )),
333 mMainView, SIGNAL( todoModified( Todo *, int ))); 337 mMainView, SIGNAL( todoModified( Todo *, int )));
334 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 338 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
335 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 339 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
336 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 340 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
337 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 341 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
338 mAgendaView->readSettings(); 342 mAgendaView->readSettings();
339 mAgendaView->updateConfig(); 343 mAgendaView->updateConfig();
340 } 344 }
341 345
342 showView( mAgendaView, full); 346 showView( mAgendaView, full);
343 347
344} 348}
345 349
346void KOViewManager::showDayView() 350void KOViewManager::showDayView()
347{ 351{
348 mFlagShowNextxDays = false; 352 mFlagShowNextxDays = false;
349 globalFlagBlockLabel = 1; 353 globalFlagBlockLabel = 1;
350 globalFlagBlockAgenda = 1; 354 globalFlagBlockAgenda = 1;
351 if ( mCurrentAgendaView != 1 ) 355 if ( mCurrentAgendaView != 1 )
352 mCurrentAgendaView = -1; 356 mCurrentAgendaView = -1;
353 showAgendaView(); 357 showAgendaView();
354 qApp->processEvents(); 358 qApp->processEvents();
355 globalFlagBlockAgenda = 2; 359 globalFlagBlockAgenda = 2;
356 globalFlagBlockLabel = 0; 360 globalFlagBlockLabel = 0;
357 mMainView->dateNavigator()->selectDates( 1 ); 361 mMainView->dateNavigator()->selectDates( 1 );
358 mCurrentAgendaView = 1 ; 362 mCurrentAgendaView = 1 ;
359 363
360} 364}
361 365
362void KOViewManager::showWorkWeekView() 366void KOViewManager::showWorkWeekView()
363{ 367{
364 mFlagShowNextxDays = false; 368 mFlagShowNextxDays = false;
365 globalFlagBlockAgenda = 1; 369 globalFlagBlockAgenda = 1;
366 globalFlagBlockLabel = 1; 370 globalFlagBlockLabel = 1;
367 if ( mCurrentAgendaView != 5 ) 371 if ( mCurrentAgendaView != 5 )
368 mCurrentAgendaView = -1; 372 mCurrentAgendaView = -1;
369 showAgendaView(); 373 showAgendaView();
370 qApp->processEvents(); 374 qApp->processEvents();
371 globalFlagBlockAgenda = 2; 375 globalFlagBlockAgenda = 2;
372 globalFlagBlockLabel = 0; 376 globalFlagBlockLabel = 0;
373 mMainView->dateNavigator()->selectWorkWeek(); 377 mMainView->dateNavigator()->selectWorkWeek();
374 mCurrentAgendaView = 5 ; 378 mCurrentAgendaView = 5 ;
375 379
376} 380}