summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-02-04 17:51:45 (UTC)
committer zautrix <zautrix>2005-02-04 17:51:45 (UTC)
commit4659ee80518c7d5108c21ba04a12a25eab783113 (patch) (unidiff)
tree50a9b0e55ca68c58d6159b7617db0b2d19d9338a /korganizer
parentf4c3a3e3da57e957b920fe4662c6decd6764f0ee (diff)
downloadkdepimpi-4659ee80518c7d5108c21ba04a12a25eab783113.zip
kdepimpi-4659ee80518c7d5108c21ba04a12a25eab783113.tar.gz
kdepimpi-4659ee80518c7d5108c21ba04a12a25eab783113.tar.bz2
nochn fix
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 1908b1c..36c66ea 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -174,515 +174,516 @@ int TimeLabels::minimumWidth() const
174 174
175 return width; 175 return width;
176} 176}
177 177
178/** updates widget's internal state */ 178/** updates widget's internal state */
179void TimeLabels::updateConfig() 179void TimeLabels::updateConfig()
180{ 180{
181 // set the font 181 // set the font
182 // config->setGroup("Fonts"); 182 // config->setGroup("Fonts");
183 // QFont font = config->readFontEntry("TimeBar Font"); 183 // QFont font = config->readFontEntry("TimeBar Font");
184 setFont(KOPrefs::instance()->mTimeBarFont); 184 setFont(KOPrefs::instance()->mTimeBarFont);
185 185
186 // update geometry restrictions based on new settings 186 // update geometry restrictions based on new settings
187 setFixedWidth(minimumWidth()); 187 setFixedWidth(minimumWidth());
188 188
189 // update HourSize 189 // update HourSize
190 mCellHeight = KOPrefs::instance()->mHourSize*4; 190 mCellHeight = KOPrefs::instance()->mHourSize*4;
191 resizeContents(50,mRows * mCellHeight); 191 resizeContents(50,mRows * mCellHeight);
192} 192}
193 193
194/** update time label positions */ 194/** update time label positions */
195void TimeLabels::positionChanged() 195void TimeLabels::positionChanged()
196{ 196{
197 int adjustment = mAgenda->contentsY(); 197 int adjustment = mAgenda->contentsY();
198 setContentsPos(0, adjustment); 198 setContentsPos(0, adjustment);
199} 199}
200 200
201/** */ 201/** */
202void TimeLabels::setAgenda(KOAgenda* agenda) 202void TimeLabels::setAgenda(KOAgenda* agenda)
203{ 203{
204 mAgenda = agenda; 204 mAgenda = agenda;
205} 205}
206 206
207void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) 207void TimeLabels::contentsMousePressEvent ( QMouseEvent * e)
208{ 208{
209 mMouseDownY = e->pos().y(); 209 mMouseDownY = e->pos().y();
210 mOrgCap = topLevelWidget()->caption(); 210 mOrgCap = topLevelWidget()->caption();
211} 211}
212 212
213void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) 213void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e )
214{ 214{
215 int diff = mMouseDownY - e->pos().y(); 215 int diff = mMouseDownY - e->pos().y();
216 if ( diff < 10 && diff > -10 ) 216 if ( diff < 10 && diff > -10 )
217 return; 217 return;
218 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; 218 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ;
219 if ( tSize < 4 ) 219 if ( tSize < 4 )
220 tSize = 4; 220 tSize = 4;
221 if ( tSize > 22 ) 221 if ( tSize > 22 )
222 tSize = 22; 222 tSize = 22;
223 tSize = (tSize-2)/2; 223 tSize = (tSize-2)/2;
224 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); 224 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize));
225 225
226} 226}
227void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) 227void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e )
228{ 228{
229 topLevelWidget()->setCaption( mOrgCap ); 229 topLevelWidget()->setCaption( mOrgCap );
230 int diff = mMouseDownY - e->pos().y(); 230 int diff = mMouseDownY - e->pos().y();
231 if ( diff < 10 && diff > -10 ) 231 if ( diff < 10 && diff > -10 )
232 return; 232 return;
233 int tSize = KOPrefs::instance()->mHourSize + (diff/10); 233 int tSize = KOPrefs::instance()->mHourSize + (diff/10);
234 if ( tSize < 4 ) 234 if ( tSize < 4 )
235 tSize = 4; 235 tSize = 4;
236 if ( tSize > 22 ) 236 if ( tSize > 22 )
237 tSize = 22; 237 tSize = 22;
238 tSize = (tSize/2)*2; 238 tSize = (tSize/2)*2;
239 if ( tSize == KOPrefs::instance()->mHourSize ) 239 if ( tSize == KOPrefs::instance()->mHourSize )
240 return; 240 return;
241 KOPrefs::instance()->mHourSize = tSize; 241 KOPrefs::instance()->mHourSize = tSize;
242 emit scaleChanged(); 242 emit scaleChanged();
243} 243}
244 244
245/** This is called in response to repaint() */ 245/** This is called in response to repaint() */
246void TimeLabels::paintEvent(QPaintEvent*) 246void TimeLabels::paintEvent(QPaintEvent*)
247{ 247{
248 248
249 // kdDebug() << "paintevent..." << endl; 249 // kdDebug() << "paintevent..." << endl;
250 // this is another hack! 250 // this is another hack!
251 // QPainter painter(this); 251 // QPainter painter(this);
252 //QString c 252 //QString c
253 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); 253 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight());
254} 254}
255 255
256//////////////////////////////////////////////////////////////////////////// 256////////////////////////////////////////////////////////////////////////////
257 257
258EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) 258EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name)
259 : QFrame(parent,name) 259 : QFrame(parent,name)
260{ 260{
261 mColumns = 1; 261 mColumns = 1;
262 mTopBox = 0; 262 mTopBox = 0;
263 mLocation = loc; 263 mLocation = loc;
264 mTopLayout = 0; 264 mTopLayout = 0;
265 mPaintWidget = 0; 265 mPaintWidget = 0;
266 mXOffset = 0; 266 mXOffset = 0;
267 if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); 267 if (mLocation == Top) mPixmap = SmallIcon("1uparrow");
268 else mPixmap = SmallIcon("1downarrow"); 268 else mPixmap = SmallIcon("1downarrow");
269 mEnabled.resize(mColumns); 269 mEnabled.resize(mColumns);
270 if (mLocation == Top) 270 if (mLocation == Top)
271 setMaximumHeight(0); 271 setMaximumHeight(0);
272 else 272 else
273 setMinimumHeight(mPixmap.height()); 273 setMinimumHeight(mPixmap.height());
274} 274}
275 275
276EventIndicator::~EventIndicator() 276EventIndicator::~EventIndicator()
277{ 277{
278} 278}
279 279
280void EventIndicator::drawContents(QPainter *p) 280void EventIndicator::drawContents(QPainter *p)
281{ 281{
282 282
283 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; 283 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl;
284 KDGanttSplitterHandle* han = 0; 284 KDGanttSplitterHandle* han = 0;
285 if ( mPaintWidget ) 285 if ( mPaintWidget )
286 han = mPaintWidget->firstHandle(); 286 han = mPaintWidget->firstHandle();
287 if ( ! han ) { 287 if ( ! han ) {
288 int i; 288 int i;
289 for(i=0;i<mColumns;++i) { 289 for(i=0;i<mColumns;++i) {
290 if (mEnabled[i]) { 290 if (mEnabled[i]) {
291 int cellWidth = contentsRect().right()/mColumns; 291 int cellWidth = contentsRect().right()/mColumns;
292 int xOffset = KOGlobals::self()->reverseLayout() ? 292 int xOffset = KOGlobals::self()->reverseLayout() ?
293 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 293 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
294 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 294 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
295 p->drawPixmap(QPoint(xOffset,0),mPixmap); 295 p->drawPixmap(QPoint(xOffset,0),mPixmap);
296 } 296 }
297 } 297 }
298 } else { 298 } else {
299 han->repaint(); 299 han->repaint();
300 //mPaintWidget->setBackgroundColor( red ); 300 //mPaintWidget->setBackgroundColor( red );
301 301
302 QPainter pa( han ); 302 QPainter pa( han );
303 int i; 303 int i;
304 bool setColor = false; 304 bool setColor = false;
305 for(i=0;i<mColumns;++i) { 305 for(i=0;i<mColumns;++i) {
306 if (mEnabled[i]) { 306 if (mEnabled[i]) {
307 setColor = true; 307 setColor = true;
308 308
309 int cellWidth = contentsRect().right()/mColumns; 309 int cellWidth = contentsRect().right()/mColumns;
310 int xOffset = KOGlobals::self()->reverseLayout() ? 310 int xOffset = KOGlobals::self()->reverseLayout() ?
311 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 311 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
312 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 312 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
313 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); 313 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap);
314 //qDebug("222draw pix %d ",xOffset ); 314 //qDebug("222draw pix %d ",xOffset );
315 315
316 } 316 }
317 317
318 } 318 }
319 pa.end(); 319 pa.end();
320 320
321 } 321 }
322} 322}
323 323
324void EventIndicator::setXOffset( int x ) 324void EventIndicator::setXOffset( int x )
325{ 325{
326 mXOffset = x; 326 mXOffset = x;
327} 327}
328void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) 328void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w )
329{ 329{
330 mPaintWidget = w; 330 mPaintWidget = w;
331} 331}
332void EventIndicator::changeColumns(int columns) 332void EventIndicator::changeColumns(int columns)
333{ 333{
334 mColumns = columns; 334 mColumns = columns;
335 mEnabled.resize(mColumns); 335 mEnabled.resize(mColumns);
336 336
337 update(); 337 update();
338} 338}
339 339
340void EventIndicator::enableColumn(int column, bool enable) 340void EventIndicator::enableColumn(int column, bool enable)
341{ 341{
342 mEnabled[column] = enable; 342 mEnabled[column] = enable;
343} 343}
344 344
345 345
346//////////////////////////////////////////////////////////////////////////// 346////////////////////////////////////////////////////////////////////////////
347//////////////////////////////////////////////////////////////////////////// 347////////////////////////////////////////////////////////////////////////////
348//////////////////////////////////////////////////////////////////////////// 348////////////////////////////////////////////////////////////////////////////
349 349
350KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : 350KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
351 KOEventView (cal,parent,name) 351 KOEventView (cal,parent,name)
352{ 352{
353 mBlockUpdating = true; 353 mBlockUpdating = true;
354 mStartHour = 8; 354 mStartHour = 8;
355 mSelectedDates.append(QDate::currentDate()); 355 mSelectedDates.append(QDate::currentDate());
356 356
357 mLayoutDayLabels = 0; 357 mLayoutDayLabels = 0;
358 mDayLabelsFrame = 0; 358 mDayLabelsFrame = 0;
359 mDayLabels = 0; 359 mDayLabels = 0;
360 bool isRTL = KOGlobals::self()->reverseLayout(); 360 bool isRTL = KOGlobals::self()->reverseLayout();
361 361
362 if ( KOPrefs::instance()->mVerticalScreen ) { 362 if ( KOPrefs::instance()->mVerticalScreen ) {
363 mExpandedPixmap = SmallIcon( "1downarrow" ); 363 mExpandedPixmap = SmallIcon( "1downarrow" );
364 mNotExpandedPixmap = SmallIcon( "1uparrow" ); 364 mNotExpandedPixmap = SmallIcon( "1uparrow" );
365 } else { 365 } else {
366 mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" ); 366 mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" );
367 mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" ); 367 mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" );
368 } 368 }
369 369
370 QBoxLayout *topLayout = new QVBoxLayout(this); 370 QBoxLayout *topLayout = new QVBoxLayout(this);
371 371
372 // Create day name labels for agenda columns 372 // Create day name labels for agenda columns
373 mDayLabelsFrame = new QHBox(this); 373 mDayLabelsFrame = new QHBox(this);
374 topLayout->addWidget(mDayLabelsFrame); 374 topLayout->addWidget(mDayLabelsFrame);
375 mDayLabels = new QFrame (mDayLabelsFrame); 375 mDayLabels = new QFrame (mDayLabelsFrame);
376 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 376 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
377 // Create agenda splitter 377 // Create agenda splitter
378#ifndef KORG_NOSPLITTER 378#ifndef KORG_NOSPLITTER
379 mSplitterAgenda = new QSplitter(Vertical,this); 379 mSplitterAgenda = new QSplitter(Vertical,this);
380 topLayout->addWidget(mSplitterAgenda); 380 topLayout->addWidget(mSplitterAgenda);
381 mSplitterAgenda->setOpaqueResize(); 381 mSplitterAgenda->setOpaqueResize();
382 382
383 mAllDayFrame = new QHBox(mSplitterAgenda); 383 mAllDayFrame = new QHBox(mSplitterAgenda);
384 384
385 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 385 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
386#else 386#else
387#if 0 387#if 0
388 QWidget *mainBox = new QWidget( this ); 388 QWidget *mainBox = new QWidget( this );
389 topLayout->addWidget( mainBox ); 389 topLayout->addWidget( mainBox );
390 QBoxLayout *mainLayout = new QVBoxLayout(mainBox); 390 QBoxLayout *mainLayout = new QVBoxLayout(mainBox);
391 mAllDayFrame = new QHBox(mainBox); 391 mAllDayFrame = new QHBox(mainBox);
392 mainLayout->addWidget(mAllDayFrame); 392 mainLayout->addWidget(mAllDayFrame);
393 mainLayout->setStretchFactor( mAllDayFrame, 0 ); 393 mainLayout->setStretchFactor( mAllDayFrame, 0 );
394 mAllDayFrame->setFocusPolicy(NoFocus); 394 mAllDayFrame->setFocusPolicy(NoFocus);
395 QWidget *agendaFrame = new QWidget(mainBox); 395 QWidget *agendaFrame = new QWidget(mainBox);
396 mainLayout->addWidget(agendaFrame); 396 mainLayout->addWidget(agendaFrame);
397 mainLayout->setStretchFactor( agendaFrame, 10 ); 397 mainLayout->setStretchFactor( agendaFrame, 10 );
398 398
399 agendaFrame->setFocusPolicy(NoFocus); 399 agendaFrame->setFocusPolicy(NoFocus);
400#endif 400#endif
401 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); 401 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
402 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 402 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
403 topLayout->addWidget( mSplitterAgenda ); 403 topLayout->addWidget( mSplitterAgenda );
404 mAllDayFrame = new QHBox(mSplitterAgenda); 404 mAllDayFrame = new QHBox(mSplitterAgenda);
405 mAllDayFrame->setFocusPolicy(NoFocus); 405 mAllDayFrame->setFocusPolicy(NoFocus);
406 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 406 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
407 agendaFrame->setFocusPolicy(NoFocus); 407 agendaFrame->setFocusPolicy(NoFocus);
408 408
409#endif 409#endif
410 410
411 // Create all-day agenda widget 411 // Create all-day agenda widget
412 mDummyAllDayLeft = new QVBox( mAllDayFrame ); 412 mDummyAllDayLeft = new QVBox( mAllDayFrame );
413 413
414 mExpandButton = new QPushButton(mDummyAllDayLeft); 414 mExpandButton = new QPushButton(mDummyAllDayLeft);
415 mExpandButton->setPixmap( mNotExpandedPixmap ); 415 mExpandButton->setPixmap( mNotExpandedPixmap );
416 int widebut = mExpandButton->sizeHint().width(); 416 int widebut = mExpandButton->sizeHint().width();
417 if ( QApplication::desktop()->width() < 480 ) 417 if ( QApplication::desktop()->width() < 480 )
418 widebut = widebut*2; 418 widebut = widebut*2;
419 else 419 else
420 widebut = (widebut*3) / 2; 420 widebut = (widebut*3) / 2;
421 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 421 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
422 // QSizePolicy::Fixed ) ); 422 // QSizePolicy::Fixed ) );
423 mExpandButton->setFixedSize( widebut, widebut); 423 mExpandButton->setFixedSize( widebut, widebut);
424 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 424 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
425 mExpandButton->setFocusPolicy(NoFocus); 425 mExpandButton->setFocusPolicy(NoFocus);
426 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 426 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
427 mAllDayAgenda->setFocusPolicy(NoFocus); 427 mAllDayAgenda->setFocusPolicy(NoFocus);
428 QVBox *dummyAllDayRight = new QVBox(mAllDayFrame); 428 QVBox *dummyAllDayRight = new QVBox(mAllDayFrame);
429 429
430 QPushButton *dummyAllDayRightB = new QPushButton(dummyAllDayRight);
431 mDummyAllDayRightL = new QLabel ( dummyAllDayRight ); 430 mDummyAllDayRightL = new QLabel ( dummyAllDayRight );
432 431 QPushButton *dummyAllDayRightB = new QPushButton(dummyAllDayRight);
432 new QLabel ( dummyAllDayRight );
433 mDummyAllDayRightL->setSizePolicy( QSizePolicy( QSizePolicy::Minimum,QSizePolicy::Fixed ) );
433 dummyAllDayRightB->setFlat( true ); 434 dummyAllDayRightB->setFlat( true );
434 dummyAllDayRightB->setFocusPolicy(NoFocus); 435 dummyAllDayRightB->setFocusPolicy(NoFocus);
435 dummyAllDayRightB->setFixedHeight( (dummyAllDayRightB->sizeHint().height()/4)*3 ); 436 dummyAllDayRightB->setFixedHeight( (dummyAllDayRightB->sizeHint().height()/4)*3 );
436 437
437 QPopupMenu * wpo = new QPopupMenu (this); 438 QPopupMenu * wpo = new QPopupMenu (this);
438 QPopupMenu * all = new QPopupMenu (this); 439 QPopupMenu * all = new QPopupMenu (this);
439 //wpo->insertItem( i18n("W#"), 0 ); 440 //wpo->insertItem( i18n("W#"), 0 );
440 int first = 1; 441 int first = 1;
441 int i; 442 int i;
442 for ( i = 1; i < 50; ++i ) { 443 for ( i = 1; i < 50; ++i ) {
443 if ( !(i%10) ) { 444 if ( !(i%10) ) {
444 all->insertItem( i18n("Select week %1-%2" ).arg(first).arg( i-1) ,wpo ); 445 all->insertItem( i18n("Select week %1-%2" ).arg(first).arg( i-1) ,wpo );
445 connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeekNum ( int ) ) ); 446 connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeekNum ( int ) ) );
446 first = i; 447 first = i;
447 wpo = new QPopupMenu (this); 448 wpo = new QPopupMenu (this);
448 } 449 }
449 wpo->insertItem( QString::number(i), i ); 450 wpo->insertItem( QString::number(i), i );
450 } 451 }
451 for ( i = 50; i < 53; ++i ) { 452 for ( i = 50; i < 53; ++i ) {
452 wpo->insertItem( QString::number(i), i); 453 wpo->insertItem( QString::number(i), i);
453 } 454 }
454 all->insertItem( i18n("Select week %1-%2" ).arg(first).arg( i-1) ,wpo ); 455 all->insertItem( i18n("Select week %1-%2" ).arg(first).arg( i-1) ,wpo );
455 dummyAllDayRightB->setPopup( all ); 456 dummyAllDayRightB->setPopup( all );
456 connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeekNum ( int ) ) ); 457 connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeekNum ( int ) ) );
457 458
458 // Create event context menu for all day agenda 459 // Create event context menu for all day agenda
459 mAllDayAgendaPopup = eventPopup(); 460 mAllDayAgendaPopup = eventPopup();
460 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 461 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
461 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 462 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
462 463
463 // Create agenda frame 464 // Create agenda frame
464 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3); 465 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3);
465 // QHBox *agendaFrame = new QHBox(splitterAgenda); 466 // QHBox *agendaFrame = new QHBox(splitterAgenda);
466 467
467 // create event indicator bars 468 // create event indicator bars
468 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 469 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
469 agendaLayout->addWidget(mEventIndicatorTop,0,1); 470 agendaLayout->addWidget(mEventIndicatorTop,0,1);
470 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 471 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
471 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 472 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
472 agendaFrame); 473 agendaFrame);
473 agendaLayout->addWidget(mEventIndicatorBottom,2,1); 474 agendaLayout->addWidget(mEventIndicatorBottom,2,1);
474 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 475 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
475 agendaLayout->addWidget(dummyAgendaRight,0,2); 476 agendaLayout->addWidget(dummyAgendaRight,0,2);
476 477
477 // Create time labels 478 // Create time labels
478 mTimeLabels = new TimeLabels(24,agendaFrame); 479 mTimeLabels = new TimeLabels(24,agendaFrame);
479 agendaLayout->addWidget(mTimeLabels,1,0); 480 agendaLayout->addWidget(mTimeLabels,1,0);
480 connect(mTimeLabels,SIGNAL( scaleChanged()), 481 connect(mTimeLabels,SIGNAL( scaleChanged()),
481 this,SLOT(updateConfig())); 482 this,SLOT(updateConfig()));
482 483
483 // Create agenda 484 // Create agenda
484 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 485 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
485 agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2); 486 agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2);
486 agendaLayout->setColStretch(1,1); 487 agendaLayout->setColStretch(1,1);
487 mAgenda->setFocusPolicy(NoFocus); 488 mAgenda->setFocusPolicy(NoFocus);
488 // Create event context menu for agenda 489 // Create event context menu for agenda
489 mAgendaPopup = eventPopup(); 490 mAgendaPopup = eventPopup();
490 491
491 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 492 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
492 i18n("Toggle Alarm"),mAgenda, 493 i18n("Toggle Alarm"),mAgenda,
493 SLOT(popupAlarm()),true); 494 SLOT(popupAlarm()),true);
494 495
495 496
496 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 497 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
497 mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 498 mAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
498 499
499 // make connections between dependent widgets 500 // make connections between dependent widgets
500 mTimeLabels->setAgenda(mAgenda); 501 mTimeLabels->setAgenda(mAgenda);
501 502
502 // Update widgets to reflect user preferences 503 // Update widgets to reflect user preferences
503 // updateConfig(); 504 // updateConfig();
504 505
505 // createDayLabels(); 506 // createDayLabels();
506 507
507 // these blank widgets make the All Day Event box line up with the agenda 508 // these blank widgets make the All Day Event box line up with the agenda
508 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 509 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
509 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 510 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
510 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 511 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
511 512
512 // Scrolling 513 // Scrolling
513 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 514 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
514 mTimeLabels, SLOT(positionChanged())); 515 mTimeLabels, SLOT(positionChanged()));
515 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 516 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
516 SLOT(setContentsPos(int))); 517 SLOT(setContentsPos(int)));
517 518
518 connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); 519 connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate )));
519 connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); 520 connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate )));
520 521
521 // Create/Show/Edit/Delete Event 522 // Create/Show/Edit/Delete Event
522 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 523 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
523 SLOT(newEvent(int,int))); 524 SLOT(newEvent(int,int)));
524 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 525 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
525 SLOT(newTodo(int,int))); 526 SLOT(newTodo(int,int)));
526 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 527 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
527 SLOT(newEvent(int,int,int,int))); 528 SLOT(newEvent(int,int,int,int)));
528 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 529 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
529 SLOT(newEventAllDay(int,int))); 530 SLOT(newEventAllDay(int,int)));
530 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 531 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
531 SLOT(newTodoAllDay(int,int))); 532 SLOT(newTodoAllDay(int,int)));
532 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 533 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
533 SLOT(newEventAllDay(int,int))); 534 SLOT(newEventAllDay(int,int)));
534 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 535 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
535 SLOT(newTimeSpanSelected(int,int,int,int))); 536 SLOT(newTimeSpanSelected(int,int,int,int)));
536 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 537 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
537 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 538 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
538 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 539 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
539 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 540 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
540 541
541 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 542 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
542 SIGNAL(editIncidenceSignal(Incidence *))); 543 SIGNAL(editIncidenceSignal(Incidence *)));
543 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 544 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
544 SIGNAL(editIncidenceSignal(Incidence *))); 545 SIGNAL(editIncidenceSignal(Incidence *)));
545 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 546 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
546 SIGNAL(showIncidenceSignal(Incidence *))); 547 SIGNAL(showIncidenceSignal(Incidence *)));
547 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 548 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
548 SIGNAL(showIncidenceSignal(Incidence *))); 549 SIGNAL(showIncidenceSignal(Incidence *)));
549 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 550 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
550 SIGNAL(deleteIncidenceSignal(Incidence *))); 551 SIGNAL(deleteIncidenceSignal(Incidence *)));
551 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 552 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
552 SIGNAL(deleteIncidenceSignal(Incidence *))); 553 SIGNAL(deleteIncidenceSignal(Incidence *)));
553 554
554 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 555 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
555 SLOT(updateEventDates(KOAgendaItem *, int ))); 556 SLOT(updateEventDates(KOAgendaItem *, int )));
556 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 557 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
557 SLOT(updateEventDates(KOAgendaItem *, int))); 558 SLOT(updateEventDates(KOAgendaItem *, int)));
558 559
559 // event indicator update 560 // event indicator update
560 connect(mAgenda,SIGNAL(lowerYChanged(int)), 561 connect(mAgenda,SIGNAL(lowerYChanged(int)),
561 SLOT(updateEventIndicatorTop(int))); 562 SLOT(updateEventIndicatorTop(int)));
562 connect(mAgenda,SIGNAL(upperYChanged(int)), 563 connect(mAgenda,SIGNAL(upperYChanged(int)),
563 SLOT(updateEventIndicatorBottom(int))); 564 SLOT(updateEventIndicatorBottom(int)));
564 // drag signals 565 // drag signals
565 /* 566 /*
566 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 567 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
567 SLOT(startDrag(Event *))); 568 SLOT(startDrag(Event *)));
568 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 569 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
569 SLOT(startDrag(Event *))); 570 SLOT(startDrag(Event *)));
570 */ 571 */
571 // synchronize selections 572 // synchronize selections
572 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 573 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
573 mAllDayAgenda, SLOT( deselectItem() ) ); 574 mAllDayAgenda, SLOT( deselectItem() ) );
574 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 575 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
575 mAgenda, SLOT( deselectItem() ) ); 576 mAgenda, SLOT( deselectItem() ) );
576 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 577 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
577 SIGNAL( incidenceSelected( Incidence * ) ) ); 578 SIGNAL( incidenceSelected( Incidence * ) ) );
578 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 579 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
579 SIGNAL( incidenceSelected( Incidence * ) ) ); 580 SIGNAL( incidenceSelected( Incidence * ) ) );
580 connect( mAgenda, SIGNAL( resizedSignal() ), 581 connect( mAgenda, SIGNAL( resizedSignal() ),
581 SLOT( updateConfig( ) ) ); 582 SLOT( updateConfig( ) ) );
582 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 583 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
583 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 584 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
584 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 585 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
585 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 586 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
586 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 587 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
587 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 588 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
588 589
589 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 590 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
590 QFontMetrics fm ( dlf ); 591 QFontMetrics fm ( dlf );
591 QString dayTest = "30"; 592 QString dayTest = "30";
592 int wid = fm.width( dayTest ); 593 int wid = fm.width( dayTest );
593 int maxWid = dummyAllDayRight->width()-2; 594 int maxWid = dummyAllDayRight->width()-2;
594 int fontPoint = dlf.pointSize(); 595 int fontPoint = dlf.pointSize();
595 while ( wid > maxWid ) { 596 while ( wid > maxWid ) {
596 --fontPoint; 597 --fontPoint;
597 dlf.setPointSize( fontPoint ); 598 dlf.setPointSize( fontPoint );
598 QFontMetrics f( dlf ); 599 QFontMetrics f( dlf );
599 wid = f.width( dayTest ); 600 wid = f.width( dayTest );
600 } 601 }
601 mDummyAllDayRightL->setFont( dlf ); 602 mDummyAllDayRightL->setFont( dlf );
602 mDummyAllDayRightL->setAlignment( AlignHCenter ); 603 mDummyAllDayRightL->setAlignment( AlignHCenter );
603} 604}
604 605
605void KOAgendaView::toggleAllDay() 606void KOAgendaView::toggleAllDay()
606{ 607{
607 if ( mSplitterAgenda->firstHandle() ) 608 if ( mSplitterAgenda->firstHandle() )
608 mSplitterAgenda->firstHandle()->toggle(); 609 mSplitterAgenda->firstHandle()->toggle();
609} 610}
610void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 611void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
611{ 612{
612 calendar()->addIncidence( inc ); 613 calendar()->addIncidence( inc );
613 614
614 if ( incOld ) { 615 if ( incOld ) {
615 if ( incOld->type() == "Todo" ) 616 if ( incOld->type() == "Todo" )
616 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 617 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
617 else 618 else
618 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 619 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
619 } 620 }
620 621
621} 622}
622 623
623KOAgendaView::~KOAgendaView() 624KOAgendaView::~KOAgendaView()
624{ 625{
625 delete mAgendaPopup; 626 delete mAgendaPopup;
626 delete mAllDayAgendaPopup; 627 delete mAllDayAgendaPopup;
627 delete KOAgendaItem::paintPix(); 628 delete KOAgendaItem::paintPix();
628 delete KOAgendaItem::paintPixSel(); 629 delete KOAgendaItem::paintPixSel();
629} 630}
630void KOAgendaView::resizeEvent( QResizeEvent* e ) 631void KOAgendaView::resizeEvent( QResizeEvent* e )
631{ 632{
632 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 633 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
633 bool uc = false; 634 bool uc = false;
634 int ow = e->oldSize().width(); 635 int ow = e->oldSize().width();
635 int oh = e->oldSize().height(); 636 int oh = e->oldSize().height();
636 int w = e->size().width(); 637 int w = e->size().width();
637 int h = e->size().height(); 638 int h = e->size().height();
638 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 639 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
639 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 640 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
640 uc = true; 641 uc = true;
641 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 642 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
642 } 643 }
643 mUpcomingWidth = e->size().width() ; 644 mUpcomingWidth = e->size().width() ;
644 if ( mBlockUpdating || uc ) { 645 if ( mBlockUpdating || uc ) {
645 mBlockUpdating = false; 646 mBlockUpdating = false;
646 //mAgenda->setMinimumSize(800 , 600 ); 647 //mAgenda->setMinimumSize(800 , 600 );
647 //qDebug("mAgenda->resize+++++++++++++++ "); 648 //qDebug("mAgenda->resize+++++++++++++++ ");
648 updateConfig(); 649 updateConfig();
649 //qDebug("KOAgendaView::Updating now possible "); 650 //qDebug("KOAgendaView::Updating now possible ");
650 } else 651 } else
651 createDayLabels(); 652 createDayLabels();
652 //qDebug("resizeEvent end "); 653 //qDebug("resizeEvent end ");
653 654
654} 655}
655void KOAgendaView::slotDaylabelClicked( int num ) 656void KOAgendaView::slotDaylabelClicked( int num )
656{ 657{
657 658
658 QDate firstDate = mSelectedDates.first(); 659 QDate firstDate = mSelectedDates.first();
659 if ( num == -1 ) 660 if ( num == -1 )
660 emit showDateView( 6, firstDate ); 661 emit showDateView( 6, firstDate );
661 else if (num >= 0 ) { 662 else if (num >= 0 ) {
662 if ( mSelectedDates.count() == 1) 663 if ( mSelectedDates.count() == 1)
663 emit showDateView( 9, firstDate.addDays( num ) ); 664 emit showDateView( 9, firstDate.addDays( num ) );
664 else 665 else
665 emit showDateView( 3, firstDate.addDays( num ) ); 666 emit showDateView( 3, firstDate.addDays( num ) );
666 } 667 }
667 else 668 else
668 showDateView( 10, firstDate.addDays(1) ); 669 showDateView( 10, firstDate.addDays(1) );
669} 670}
670 671
671KOAgendaButton* KOAgendaView::getNewDaylabel() 672KOAgendaButton* KOAgendaView::getNewDaylabel()
672{ 673{
673 674
674 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 675 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
675 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 676 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
676 mDayLabelsList.append( dayLabel ); 677 mDayLabelsList.append( dayLabel );
677 mLayoutDayLabels->addWidget(dayLabel); 678 mLayoutDayLabels->addWidget(dayLabel);
678 return dayLabel ; 679 return dayLabel ;
679} 680}
680 681
681void KOAgendaView::createDayLabels() 682void KOAgendaView::createDayLabels()
682{ 683{
683 684
684 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 685 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
685 // qDebug(" KOAgendaView::createDayLabels() blocked "); 686 // qDebug(" KOAgendaView::createDayLabels() blocked ");
686 return; 687 return;
687 688
688 } 689 }