summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp11
-rw-r--r--korganizer/koagenda.h1
-rw-r--r--korganizer/koagendaitem.cpp34
-rw-r--r--korganizer/koagendaitem.h1
-rw-r--r--korganizer/koagendaview.cpp11
-rw-r--r--korganizer/koagendaview.h1
-rw-r--r--korganizer/koeventpopupmenu.cpp44
-rw-r--r--korganizer/koeventpopupmenu.h4
-rw-r--r--korganizer/koeventview.cpp1
-rw-r--r--korganizer/kolistview.cpp8
10 files changed, 89 insertions, 27 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index ce73168..f860f7d 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -347,129 +347,138 @@ void KOAgenda::marcus_bains()
347void KOAgenda::changeColumns(int columns) 347void KOAgenda::changeColumns(int columns)
348{ 348{
349 if (columns == 0) { 349 if (columns == 0) {
350 qDebug("KOAgenda::changeColumns() called with argument 0 "); 350 qDebug("KOAgenda::changeColumns() called with argument 0 ");
351 return; 351 return;
352 } 352 }
353 clear(); 353 clear();
354 mColumns = columns; 354 mColumns = columns;
355 computeSizes(); 355 computeSizes();
356} 356}
357 357
358/* 358/*
359 This is the eventFilter function, which gets all events from the KOAgendaItems 359 This is the eventFilter function, which gets all events from the KOAgendaItems
360 contained in the agenda. It has to handle moving and resizing for all items. 360 contained in the agenda. It has to handle moving and resizing for all items.
361*/ 361*/
362bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) 362bool KOAgenda::eventFilter ( QObject *object, QEvent *event )
363{ 363{
364 // kdDebug() << "KOAgenda::eventFilter" << endl; 364 // kdDebug() << "KOAgenda::eventFilter" << endl;
365 switch(event->type()) { 365 switch(event->type()) {
366 case QEvent::MouseButtonPress: 366 case QEvent::MouseButtonPress:
367 case QEvent::MouseButtonDblClick: 367 case QEvent::MouseButtonDblClick:
368 case QEvent::MouseButtonRelease: 368 case QEvent::MouseButtonRelease:
369 case QEvent::MouseMove: 369 case QEvent::MouseMove:
370 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); 370 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event));
371 371
372 case (QEvent::Leave): 372 case (QEvent::Leave):
373 if (!mActionItem) 373 if (!mActionItem)
374 setCursor(arrowCursor); 374 setCursor(arrowCursor);
375 return true; 375 return true;
376 376
377 default: 377 default:
378 return QScrollView::eventFilter(object,event); 378 return QScrollView::eventFilter(object,event);
379 } 379 }
380} 380}
381void KOAgenda::popupMenu() 381void KOAgenda::popupMenu()
382{ 382{
383 mPopupTimer->stop(); 383 mPopupTimer->stop();
384 if ( mPopupKind == 1 || mPopupKind == 3 ) { 384 if ( mPopupKind == 1 || mPopupKind == 3 ) {
385 if (mActionItem ) { 385 if (mActionItem ) {
386 endItemAction(); 386 endItemAction();
387 } 387 }
388 mLeftMouseDown = false; // no more leftMouse computation 388 mLeftMouseDown = false; // no more leftMouse computation
389 if (mPopupItem) { 389 if (mPopupItem) {
390 //mClickedItem = mPopupItem; 390 //mClickedItem = mPopupItem;
391 selectItem(mPopupItem); 391 selectItem(mPopupItem);
392 if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) 392 if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 )
393 mAllAgendaPopup->installEventFilter( this ); 393 mAllAgendaPopup->installEventFilter( this );
394 emit showIncidencePopupSignal(mPopupItem->incidence()); 394 emit showIncidencePopupSignal(mPopupItem->incidence());
395 395
396 } 396 }
397 } else if ( mPopupKind == 2 || mPopupKind == 4 ) { 397 } else if ( mPopupKind == 2 || mPopupKind == 4 ) {
398 if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action 398 if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action
399 endSelectAction( false ); // do not emit new event signal 399 endSelectAction( false ); // do not emit new event signal
400 mLeftMouseDown = false; // no more leftMouse computation 400 mLeftMouseDown = false; // no more leftMouse computation
401 } 401 }
402 if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) 402 if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 )
403 mNewItemPopup->installEventFilter( this ); 403 mNewItemPopup->installEventFilter( this );
404 mNewItemPopup->popup( mPopupPos); 404 mNewItemPopup->popup( mPopupPos);
405 405
406 } 406 }
407 mLeftMouseDown = false; 407 mLeftMouseDown = false;
408 mPopupItem = 0; 408 mPopupItem = 0;
409 mPopupKind = 0; 409 mPopupKind = 0;
410} 410}
411 411void KOAgenda::categoryChanged(Incidence * inc)
412{
413 KOAgendaItem *item;
414 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
415 if ( item->incidence() == inc ) {
416 item->initColor ();
417 item->updateItem();
418 }
419 }
420}
412bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) 421bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
413{ 422{
414 static int startX = 0; 423 static int startX = 0;
415 static int startY = 0; 424 static int startY = 0;
416 int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); 425 int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 );
417 static bool blockMoving = true; 426 static bool blockMoving = true;
418 427
419 //qDebug("KOAgenda::eventFilter_mous "); 428 //qDebug("KOAgenda::eventFilter_mous ");
420 if ( object == mNewItemPopup ) { 429 if ( object == mNewItemPopup ) {
421 //qDebug("mNewItemPopup "); 430 //qDebug("mNewItemPopup ");
422 if ( me->type() == QEvent::MouseButtonRelease ) { 431 if ( me->type() == QEvent::MouseButtonRelease ) {
423 mNewItemPopup->removeEventFilter( this ); 432 mNewItemPopup->removeEventFilter( this );
424 int dX = me->globalPos().x() - mPopupPos.x();; 433 int dX = me->globalPos().x() - mPopupPos.x();;
425 if ( dX < 0 ) 434 if ( dX < 0 )
426 dX = -dX; 435 dX = -dX;
427 int dY = me->globalPos().y() - mPopupPos.y(); 436 int dY = me->globalPos().y() - mPopupPos.y();
428 if ( dY < 0 ) 437 if ( dY < 0 )
429 dY = -dY; 438 dY = -dY;
430 if ( dX > blockmoveDist || dY > blockmoveDist ) { 439 if ( dX > blockmoveDist || dY > blockmoveDist ) {
431 mNewItemPopup->hide(); 440 mNewItemPopup->hide();
432 } 441 }
433 } 442 }
434 return true; 443 return true;
435 } 444 }
436 if ( object == mAllAgendaPopup ) { 445 if ( object == mAllAgendaPopup ) {
437 //qDebug(" mAllAgendaPopup "); 446 //qDebug(" mAllAgendaPopup ");
438 if ( me->type() == QEvent::MouseButtonRelease ) { 447 if ( me->type() == QEvent::MouseButtonRelease ) {
439 mAllAgendaPopup->removeEventFilter( this ); 448 mAllAgendaPopup->removeEventFilter( this );
440 int dX = me->globalPos().x() - mPopupPos.x();; 449 int dX = me->globalPos().x() - mPopupPos.x();;
441 if ( dX < 0 ) 450 if ( dX < 0 )
442 dX = -dX; 451 dX = -dX;
443 int dY = me->globalPos().y() - mPopupPos.y(); 452 int dY = me->globalPos().y() - mPopupPos.y();
444 if ( dY < 0 ) 453 if ( dY < 0 )
445 dY = -dY; 454 dY = -dY;
446 if ( dX > blockmoveDist || dY > blockmoveDist ) { 455 if ( dX > blockmoveDist || dY > blockmoveDist ) {
447 mAllAgendaPopup->hide(); 456 mAllAgendaPopup->hide();
448 } 457 }
449 } 458 }
450 return true; 459 return true;
451 } 460 }
452 QPoint viewportPos; 461 QPoint viewportPos;
453 if (object != viewport()) { 462 if (object != viewport()) {
454 blockmoveDist = blockmoveDist*2; 463 blockmoveDist = blockmoveDist*2;
455 viewportPos = ((QWidget *)object)->mapToParent(me->pos()); 464 viewportPos = ((QWidget *)object)->mapToParent(me->pos());
456 } else { 465 } else {
457 viewportPos = me->pos(); 466 viewportPos = me->pos();
458 } 467 }
459 bool objIsNotViewport = (object != viewport()); 468 bool objIsNotViewport = (object != viewport());
460 bool leftButt = false; 469 bool leftButt = false;
461#ifdef DESKTOP_VERSION 470#ifdef DESKTOP_VERSION
462 leftButt = (me->button() == LeftButton); 471 leftButt = (me->button() == LeftButton);
463#endif 472#endif
464 switch (me->type()) { 473 switch (me->type()) {
465 case QEvent::MouseButtonPress: 474 case QEvent::MouseButtonPress:
466 if (me->button() == LeftButton) { 475 if (me->button() == LeftButton) {
467 mPopupTimer->start( 600 ); 476 mPopupTimer->start( 600 );
468 mLeftMouseDown = true; 477 mLeftMouseDown = true;
469 } 478 }
470 blockMoving = true; 479 blockMoving = true;
471 startX = viewportPos.x(); 480 startX = viewportPos.x();
472 startY = viewportPos.y(); 481 startY = viewportPos.y();
473 mPopupPos = me->globalPos(); 482 mPopupPos = me->globalPos();
474 if ( objIsNotViewport && !leftButt ) { 483 if ( objIsNotViewport && !leftButt ) {
475 KOAgendaItem * tempItem = (KOAgendaItem *)object; 484 KOAgendaItem * tempItem = (KOAgendaItem *)object;
diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h
index fb9983e..de6acac 100644
--- a/korganizer/koagenda.h
+++ b/korganizer/koagenda.h
@@ -66,128 +66,129 @@ class MarcusBains : public QFrame {
66class KOAgenda : public QScrollView 66class KOAgenda : public QScrollView
67{ 67{
68 Q_OBJECT 68 Q_OBJECT
69 public: 69 public:
70 enum MouseActionType { NOP, MOVE, SELECT, 70 enum MouseActionType { NOP, MOVE, SELECT,
71 RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT }; 71 RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT };
72 72
73 KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0, 73 KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0,
74 const char * name=0, WFlags f=0 ); 74 const char * name=0, WFlags f=0 );
75 KOAgenda ( int columns, QWidget * parent=0, 75 KOAgenda ( int columns, QWidget * parent=0,
76 const char * name=0, WFlags f=0 ); 76 const char * name=0, WFlags f=0 );
77 virtual ~KOAgenda(); 77 virtual ~KOAgenda();
78 78
79 Incidence *selectedIncidence() const; 79 Incidence *selectedIncidence() const;
80 QDate selectedIncidenceDate() const; 80 QDate selectedIncidenceDate() const;
81 81
82 virtual bool eventFilter ( QObject *, QEvent * ); 82 virtual bool eventFilter ( QObject *, QEvent * );
83 83
84 void contentsToGrid (int x, int y, int& gx, int& gy); 84 void contentsToGrid (int x, int y, int& gx, int& gy);
85 void gridToContents (int gx, int gy, int& x, int& y); 85 void gridToContents (int gx, int gy, int& x, int& y);
86 86
87 int timeToY (const QTime &time); 87 int timeToY (const QTime &time);
88 QTime gyToTime (int y); 88 QTime gyToTime (int y);
89 89
90 void setStartHour(int startHour); 90 void setStartHour(int startHour);
91 91
92 KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom); 92 KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom);
93 KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd); 93 KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd);
94 void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, 94 void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
95 int YTop,int YBottom); 95 int YTop,int YBottom);
96 96
97 void changeColumns(int columns); 97 void changeColumns(int columns);
98 98
99 int columns() { return mColumns; } 99 int columns() { return mColumns; }
100 int rows() { return mRows; } 100 int rows() { return mRows; }
101 101
102 int gridSpacingX() const { return mGridSpacingX; } 102 int gridSpacingX() const { return mGridSpacingX; }
103 int gridSpacingY() const { return mGridSpacingY; } 103 int gridSpacingY() const { return mGridSpacingY; }
104 104
105// virtual QSizePolicy sizePolicy() const; 105// virtual QSizePolicy sizePolicy() const;
106 106
107 void clear(); 107 void clear();
108 108
109 void clearSelection(); 109 void clearSelection();
110 void hideUnused(); 110 void hideUnused();
111 111
112 /** Calculates the minimum width */ 112 /** Calculates the minimum width */
113 virtual int minimumWidth() const; 113 virtual int minimumWidth() const;
114 /** Update configuration from preference settings */ 114 /** Update configuration from preference settings */
115 void updateConfig(); 115 void updateConfig();
116 116
117 void checkScrollBoundaries(); 117 void checkScrollBoundaries();
118 118
119 void setHolidayMask(QMemArray<bool> *); 119 void setHolidayMask(QMemArray<bool> *);
120 void setDateList(const DateList &selectedDates); 120 void setDateList(const DateList &selectedDates);
121 DateList dateList() const; 121 DateList dateList() const;
122 void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false); 122 void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false);
123 void finishUpdate(); 123 void finishUpdate();
124 void printSelection(); 124 void printSelection();
125 void storePosition(); 125 void storePosition();
126 void restorePosition(); 126 void restorePosition();
127 void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; } 127 void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; }
128 128
129 public slots: 129 public slots:
130 void categoryChanged(Incidence * inc);
130 void slotClearSelection(); 131 void slotClearSelection();
131 void popupMenu(); 132 void popupMenu();
132 void newItem( int ); 133 void newItem( int );
133 void moveChild( QWidget *, int, int ); 134 void moveChild( QWidget *, int, int );
134 void scrollUp(); 135 void scrollUp();
135 void scrollDown(); 136 void scrollDown();
136 void updateTodo( Todo * t, int , bool ); 137 void updateTodo( Todo * t, int , bool );
137 void popupAlarm(); 138 void popupAlarm();
138 139
139 void checkScrollBoundaries(int); 140 void checkScrollBoundaries(int);
140 141
141 /** Deselect selected items. This function does not emit any signals. */ 142 /** Deselect selected items. This function does not emit any signals. */
142 void deselectItem(); 143 void deselectItem();
143 /** Select item. If the argument is 0, the currently selected item gets 144 /** Select item. If the argument is 0, the currently selected item gets
144 deselected. This function emits the itemSelected(bool) signal to inform 145 deselected. This function emits the itemSelected(bool) signal to inform
145 about selection/deseelction of events. */ 146 about selection/deseelction of events. */
146 void selectItem(KOAgendaItem *); 147 void selectItem(KOAgendaItem *);
147 void finishResize(); 148 void finishResize();
148 149
149 signals: 150 signals:
150 void signalClearSelection(); 151 void signalClearSelection();
151 void showDateView( int, int); 152 void showDateView( int, int);
152 void newEventSignal(); 153 void newEventSignal();
153 void newEventSignal(int gx,int gy); 154 void newEventSignal(int gx,int gy);
154 void newTodoSignal(int gx,int gy); 155 void newTodoSignal(int gx,int gy);
155 void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); 156 void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
156 void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); 157 void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
157 void newStartSelectSignal(); 158 void newStartSelectSignal();
158 void showIncidenceSignal(Incidence *); 159 void showIncidenceSignal(Incidence *);
159 void editIncidenceSignal(Incidence *); 160 void editIncidenceSignal(Incidence *);
160 void deleteIncidenceSignal(Incidence *); 161 void deleteIncidenceSignal(Incidence *);
161 void showIncidencePopupSignal(Incidence *); 162 void showIncidencePopupSignal(Incidence *);
162 163
163 void itemModified(KOAgendaItem *item, int ); 164 void itemModified(KOAgendaItem *item, int );
164 void incidenceSelected(Incidence *); 165 void incidenceSelected(Incidence *);
165 166
166 void lowerYChanged(int); 167 void lowerYChanged(int);
167 void upperYChanged(int); 168 void upperYChanged(int);
168 169
169 void startDragSignal(Incidence *); 170 void startDragSignal(Incidence *);
170 void addToCalSignal(Incidence *, Incidence *); 171 void addToCalSignal(Incidence *, Incidence *);
171 void resizedSignal(); 172 void resizedSignal();
172 173
173 protected: 174 protected:
174 KOEventPopupMenu * mAllAgendaPopup; 175 KOEventPopupMenu * mAllAgendaPopup;
175 QPainter mPixPainter; 176 QPainter mPixPainter;
176 QPixmap mPaintPixmap; 177 QPixmap mPaintPixmap;
177 QPixmap mHighlightPixmap; 178 QPixmap mHighlightPixmap;
178 void drawContents(QPainter *p,int cx, int cy, int cw, int ch); 179 void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
179 virtual void resizeEvent ( QResizeEvent * ); 180 virtual void resizeEvent ( QResizeEvent * );
180 181
181 /** Handles mouse events. Called from eventFilter */ 182 /** Handles mouse events. Called from eventFilter */
182 virtual bool eventFilter_mouse ( QObject *, QMouseEvent * ); 183 virtual bool eventFilter_mouse ( QObject *, QMouseEvent * );
183 184
184 /** Start selecting time span. */ 185 /** Start selecting time span. */
185 void startSelectAction(QPoint viewportPos); 186 void startSelectAction(QPoint viewportPos);
186 187
187 /** Select time span. */ 188 /** Select time span. */
188 void performSelectAction(QPoint viewportPos); 189 void performSelectAction(QPoint viewportPos);
189 190
190 /** Emd selecting time span. */ 191 /** Emd selecting time span. */
191 void endSelectAction( bool emitNewEvent = false ); 192 void endSelectAction( bool emitNewEvent = false );
192 193
193 /** Start moving/resizing agenda item */ 194 /** Start moving/resizing agenda item */
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index a8e0678..a42d07b 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -36,172 +36,176 @@
36#define AGENDA_ICON_SIZE 5 36#define AGENDA_ICON_SIZE 5
37#else 37#else
38#include <qapplication.h> 38#include <qapplication.h>
39#define AGENDA_ICON_SIZE 7 39#define AGENDA_ICON_SIZE 7
40#endif 40#endif
41#include <libkcal/icaldrag.h> 41#include <libkcal/icaldrag.h>
42#include <libkcal/vcaldrag.h> 42#include <libkcal/vcaldrag.h>
43#include <libkcal/kincidenceformatter.h> 43#include <libkcal/kincidenceformatter.h>
44extern int globalFlagBlockAgenda; 44extern int globalFlagBlockAgenda;
45extern int globalFlagBlockAgendaItemPaint; 45extern int globalFlagBlockAgendaItemPaint;
46extern int globalFlagBlockAgendaItemUpdate; 46extern int globalFlagBlockAgendaItemUpdate;
47 47
48#include "koprefs.h" 48#include "koprefs.h"
49 49
50#include "koagendaitem.h" 50#include "koagendaitem.h"
51//#include "koagendaitem.moc" 51//#include "koagendaitem.moc"
52 52
53 53
54//-------------------------------------------------------------------------- 54//--------------------------------------------------------------------------
55 55
56QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; 56QToolTipGroup *KOAgendaItem::mToolTipGroup = 0;
57 57
58//-------------------------------------------------------------------------- 58//--------------------------------------------------------------------------
59 59
60class KOAgendaItemWhatsThis :public QWhatsThis 60class KOAgendaItemWhatsThis :public QWhatsThis
61{ 61{
62public: 62public:
63 KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; 63 KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { };
64 64
65protected: 65protected:
66 virtual QString text( const QPoint& ) 66 virtual QString text( const QPoint& )
67 { 67 {
68 return _view->getWhatsThisText() ; 68 return _view->getWhatsThisText() ;
69 } 69 }
70private: 70private:
71 KOAgendaItem * _view; 71 KOAgendaItem * _view;
72}; 72};
73 73
74KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, 74KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday,
75 const char *name,WFlags) : 75 const char *name,WFlags) :
76 QWidget(parent, name), mIncidence(incidence), mDate(qd) 76 QWidget(parent, name), mIncidence(incidence), mDate(qd)
77{ 77{
78#ifndef DESKTOP_VERSION 78#ifndef DESKTOP_VERSION
79 //QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); 79 //QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold );
80#endif 80#endif
81 mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this); 81 mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this);
82 int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase 82 int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase
83 setWFlags ( wflags); 83 setWFlags ( wflags);
84 mAllDay = allday; 84 mAllDay = allday;
85 init ( incidence, qd ); 85 init ( incidence, qd );
86 //setMouseTracking(true); 86 //setMouseTracking(true);
87 //setAcceptDrops(true); 87 //setAcceptDrops(true);
88 xPaintCoord = -1; 88 xPaintCoord = -1;
89 yPaintCoord = -1; 89 yPaintCoord = -1;
90} 90}
91QString KOAgendaItem::getWhatsThisText() 91QString KOAgendaItem::getWhatsThisText()
92{ 92{
93 if ( mIncidence ) 93 if ( mIncidence )
94 return KIncidenceFormatter::instance()->getFormattedText( mIncidence, 94 return KIncidenceFormatter::instance()->getFormattedText( mIncidence,
95 KOPrefs::instance()->mWTshowDetails, 95 KOPrefs::instance()->mWTshowDetails,
96 KOPrefs::instance()->mWTshowCreated, 96 KOPrefs::instance()->mWTshowCreated,
97 KOPrefs::instance()->mWTshowChanged); 97 KOPrefs::instance()->mWTshowChanged);
98 return "KOAgendaItem::getWhatsThisText()::internal error"; 98 return "KOAgendaItem::getWhatsThisText()::internal error";
99} 99}
100void KOAgendaItem::init ( Incidence *incidence, QDate qd ) 100
101void KOAgendaItem::initColor ()
101{ 102{
102 mIncidence = incidence; 103 if ( (mIncidence->typeID() == todoID ) &&
103 mDate = qd; 104 ( !((static_cast<Todo*>(mIncidence))->isCompleted()) &&
104 mFirstMultiItem = 0; 105 ((static_cast<Todo*>(mIncidence))->dtDue().date() <= QDate::currentDate()) ) ) {
105 mNextMultiItem = 0; 106 if ( (static_cast<Todo*>(mIncidence))->dtDue() < QDateTime::currentDateTime().date())
106 mLastMultiItem = 0;
107 computeText();
108
109 if ( (incidence->typeID() == todoID ) &&
110 ( !((static_cast<Todo*>(incidence))->isCompleted()) &&
111 ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) {
112 if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date())
113 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; 107 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ;
114 else 108 else
115 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; 109 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor;
116 } 110 }
117 else { 111 else {
118 QStringList categories = mIncidence->categories(); 112 QStringList categories = mIncidence->categories();
119 QString cat = categories.first(); 113 QString cat = categories.first();
120 if (cat.isEmpty()) { 114 if (cat.isEmpty()) {
121 if ( (incidence->typeID() == todoID ) &&((static_cast<Todo*>(incidence))->isCompleted()) ) 115 if ( (mIncidence->typeID() == todoID ) &&((static_cast<Todo*>(mIncidence))->isCompleted()) )
122 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; 116 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor;
123 else 117 else
124 mBackgroundColor =KOPrefs::instance()->defaultColor( incidence->calID() ); 118 mBackgroundColor =KOPrefs::instance()->defaultColor( mIncidence->calID() );
125 } else { 119 } else {
126 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); 120 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat);
127 if ( (incidence->typeID() == todoID ) &&((static_cast<Todo*>(incidence))->isCompleted()) ) { 121 if ( (mIncidence->typeID() == todoID ) &&((static_cast<Todo*>(mIncidence))->isCompleted()) ) {
128 if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) 122 if ( mBackgroundColor == KOPrefs::instance()->mEventColor )
129 mBackgroundColor = KOPrefs::instance()->mTodoDoneColor; 123 mBackgroundColor = KOPrefs::instance()->mTodoDoneColor;
130 } 124 }
131 } 125 }
132 126
133 } 127 }
134 128
135 QColor BackgroundColor ( mBackgroundColor ); 129 QColor BackgroundColor ( mBackgroundColor );
136 if ( mIncidence->calID() > 1 ) { 130 if ( mIncidence->calID() > 1 ) {
137 BackgroundColor = KOPrefs::instance()->defaultColor( mIncidence->calID() ); 131 BackgroundColor = KOPrefs::instance()->defaultColor( mIncidence->calID() );
138 } 132 }
139 mColorGroup = QColorGroup( BackgroundColor.light(), 133 mColorGroup = QColorGroup( BackgroundColor.light(),
140 BackgroundColor.dark(),BackgroundColor.light(), 134 BackgroundColor.dark(),BackgroundColor.light(),
141 BackgroundColor.dark(),BackgroundColor, black, BackgroundColor) ; 135 BackgroundColor.dark(),BackgroundColor, black, BackgroundColor) ;
142 setBackgroundColor( mBackgroundColor ); 136 setBackgroundColor( mBackgroundColor );
143 mWhiteText = (mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue() < 250); 137 mWhiteText = (mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue() < 250);
138}
139void KOAgendaItem::init ( Incidence *incidence, QDate qd )
140{
141 mIncidence = incidence;
142 mDate = qd;
143 mFirstMultiItem = 0;
144 mNextMultiItem = 0;
145 mLastMultiItem = 0;
146 computeText();
147 initColor();
144 mConflictItems.clear(); 148 mConflictItems.clear();
145 setCellXY(0,0,1); 149 setCellXY(0,0,1);
146 setCellXWidth(0); 150 setCellXWidth(0);
147 setSubCell(0); 151 setSubCell(0);
148 setSubCells(1); 152 setSubCells(1);
149 setMultiItem(0,0,0); 153 setMultiItem(0,0,0);
150 startMove(); 154 startMove();
151 mSelected = true; 155 mSelected = true;
152 select(false); 156 select(false);
153 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); 157 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont);
154 mFontPixelSize = fontinf.height();; 158 mFontPixelSize = fontinf.height();;
155 hide(); 159 hide();
156 xPaintCoord = -1; 160 xPaintCoord = -1;
157 yPaintCoord = -1; 161 yPaintCoord = -1;
158} 162}
159 163
160 164
161KOAgendaItem::~KOAgendaItem() 165KOAgendaItem::~KOAgendaItem()
162{ 166{
163#if QT_VERSION >= 0x030000 167#if QT_VERSION >= 0x030000
164 168
165#else 169#else
166 delete mKOAgendaItemWhatsThis; 170 delete mKOAgendaItemWhatsThis;
167#endif 171#endif
168 172
169} 173}
170 174
171void KOAgendaItem::recreateIncidence() 175void KOAgendaItem::recreateIncidence()
172{ 176{
173#if 0 177#if 0
174 Incidence* newInc = mIncidence->clone(); 178 Incidence* newInc = mIncidence->clone();
175 newInc->recreate(); 179 newInc->recreate();
176 if ( mIncidence->doesRecur() ) { 180 if ( mIncidence->doesRecur() ) {
177 mIncidence->addExDate( mDate ); 181 mIncidence->addExDate( mDate );
178 newInc->recurrence()->unsetRecurs(); 182 newInc->recurrence()->unsetRecurs();
179 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); 183 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd());
180 QTime tim = mIncidence->dtStart().time(); 184 QTime tim = mIncidence->dtStart().time();
181 newInc->setDtStart( QDateTime(mDate, tim) ); 185 newInc->setDtStart( QDateTime(mDate, tim) );
182 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); 186 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) );
183 } 187 }
184#endif 188#endif
185 mIncidence = mIncidence->recreateCloneException( mDate ); 189 mIncidence = mIncidence->recreateCloneException( mDate );
186} 190}
187bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) 191bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout)
188{ 192{
189 int size = AGENDA_ICON_SIZE; 193 int size = AGENDA_ICON_SIZE;
190 194
191 int yOff = 0; 195 int yOff = 0;
192 int xOff = 0; 196 int xOff = 0;
193 int x = pos().x() +3; 197 int x = pos().x() +3;
194 int y; 198 int y;
195 if ( mAllDay ) 199 if ( mAllDay )
196 y = pos().y()+3; 200 y = pos().y()+3;
197 else 201 else
198 y = mCellYTop * ( height() / cellHeight() ) +3; 202 y = mCellYTop * ( height() / cellHeight() ) +3;
199 if (mIncidence->cancelled()) { 203 if (mIncidence->cancelled()) {
200 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; 204 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x;
201 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; 205 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y;
202 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); 206 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 );
203 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); 207 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos );
204 if ( horLayout ) 208 if ( horLayout )
205 ++xOff; 209 ++xOff;
206 else 210 else
207 ++yOff; 211 ++yOff;
diff --git a/korganizer/koagendaitem.h b/korganizer/koagendaitem.h
index d1b1940..dc2316a 100644
--- a/korganizer/koagendaitem.h
+++ b/korganizer/koagendaitem.h
@@ -48,118 +48,119 @@ class KOAgendaItem : public QWidget
48 WFlags f=0 ); 48 WFlags f=0 );
49 ~KOAgendaItem(); 49 ~KOAgendaItem();
50 QString getWhatsThisText(); 50 QString getWhatsThisText();
51 void init ( Incidence *incidence, QDate qd ); 51 void init ( Incidence *incidence, QDate qd );
52 int cellX() { return mCellX; } 52 int cellX() { return mCellX; }
53 int cellXWidth() { return mCellXWidth; } 53 int cellXWidth() { return mCellXWidth; }
54 int cellYTop() { return mCellYTop; } 54 int cellYTop() { return mCellYTop; }
55 int cellYBottom() { return mCellYBottom; } 55 int cellYBottom() { return mCellYBottom; }
56 int cellHeight(); 56 int cellHeight();
57 int cellWidth(); 57 int cellWidth();
58 int subCell() { return mSubCell; } 58 int subCell() { return mSubCell; }
59 int subCells() { return mSubCells; } 59 int subCells() { return mSubCells; }
60 60
61 void setCellXY(int X, int YTop, int YBottom); 61 void setCellXY(int X, int YTop, int YBottom);
62 void setCellY(int YTop, int YBottom); 62 void setCellY(int YTop, int YBottom);
63 void setCellX(int XLeft, int XRight); 63 void setCellX(int XLeft, int XRight);
64 void setCellXWidth(int xwidth); 64 void setCellXWidth(int xwidth);
65 void setSubCell(int subCell); 65 void setSubCell(int subCell);
66 void setSubCells(int subCells); 66 void setSubCells(int subCells);
67 67
68 /** Start movement */ 68 /** Start movement */
69 void startMove(); 69 void startMove();
70 /** Reset to original values */ 70 /** Reset to original values */
71 void resetMove(); 71 void resetMove();
72 72
73 void moveRelative(int dx,int dy); 73 void moveRelative(int dx,int dy);
74 void expandTop(int dy); 74 void expandTop(int dy);
75 void expandBottom(int dy); 75 void expandBottom(int dy);
76 void expandLeft(int dx); 76 void expandLeft(int dx);
77 void expandRight(int dx); 77 void expandRight(int dx);
78 int mLastMoveXPos; 78 int mLastMoveXPos;
79 79
80 void setMultiItem(KOAgendaItem *first,KOAgendaItem *next, 80 void setMultiItem(KOAgendaItem *first,KOAgendaItem *next,
81 KOAgendaItem *last); 81 KOAgendaItem *last);
82 KOAgendaItem *firstMultiItem() { return mFirstMultiItem; } 82 KOAgendaItem *firstMultiItem() { return mFirstMultiItem; }
83 KOAgendaItem *nextMultiItem() { return mNextMultiItem; } 83 KOAgendaItem *nextMultiItem() { return mNextMultiItem; }
84 KOAgendaItem *lastMultiItem() { return mLastMultiItem; } 84 KOAgendaItem *lastMultiItem() { return mLastMultiItem; }
85 85
86 Incidence *incidence() const { return mIncidence; } 86 Incidence *incidence() const { return mIncidence; }
87 QDate itemDate() { return mDate; } 87 QDate itemDate() { return mDate; }
88 88
89 /** Update the date of this item's occurence (not in the event) */ 89 /** Update the date of this item's occurence (not in the event) */
90 void setItemDate(QDate qd); 90 void setItemDate(QDate qd);
91 91
92 void setText ( const QString & text ) { mDisplayedText = text; } 92 void setText ( const QString & text ) { mDisplayedText = text; }
93 QString text () { return mDisplayedText; } 93 QString text () { return mDisplayedText; }
94 94
95 virtual bool eventFilter ( QObject *, QEvent * ); 95 virtual bool eventFilter ( QObject *, QEvent * );
96 96
97 static QToolTipGroup *toolTipGroup(); 97 static QToolTipGroup *toolTipGroup();
98 98
99 QPtrList<KOAgendaItem> conflictItems(); 99 QPtrList<KOAgendaItem> conflictItems();
100 void setConflictItems(QPtrList<KOAgendaItem>); 100 void setConflictItems(QPtrList<KOAgendaItem>);
101 void addConflictItem(KOAgendaItem *ci); 101 void addConflictItem(KOAgendaItem *ci);
102 void paintMe( bool, QPainter* painter = 0 ); 102 void paintMe( bool, QPainter* painter = 0 );
103 void repaintMe(); 103 void repaintMe();
104 static void resizePixmap( int, int ); 104 static void resizePixmap( int, int );
105 static QPixmap * paintPix(); 105 static QPixmap * paintPix();
106 static QPixmap * paintPixSel(); 106 static QPixmap * paintPixSel();
107 static QPixmap * paintPixAllday(); 107 static QPixmap * paintPixAllday();
108 void updateItem(); 108 void updateItem();
109 void computeText(); 109 void computeText();
110 void recreateIncidence(); 110 void recreateIncidence();
111 bool checkLayout(); 111 bool checkLayout();
112 void initColor ();
112 public slots: 113 public slots:
113 bool updateIcons( QPainter *, bool ); 114 bool updateIcons( QPainter *, bool );
114 void select(bool=true); 115 void select(bool=true);
115 116
116 protected: 117 protected:
117 void dragEnterEvent(QDragEnterEvent *e); 118 void dragEnterEvent(QDragEnterEvent *e);
118 void dropEvent(QDropEvent *e); 119 void dropEvent(QDropEvent *e);
119 void paintEvent ( QPaintEvent * ); 120 void paintEvent ( QPaintEvent * );
120 void resizeEvent ( QResizeEvent *ev ); 121 void resizeEvent ( QResizeEvent *ev );
121 122
122 private: 123 private:
123 KOAgendaItemWhatsThis* mKOAgendaItemWhatsThis; 124 KOAgendaItemWhatsThis* mKOAgendaItemWhatsThis;
124 bool mAllDay; 125 bool mAllDay;
125 bool mWhiteText; 126 bool mWhiteText;
126 int mCellX; 127 int mCellX;
127 int mCellXWidth; 128 int mCellXWidth;
128 int mCellYTop,mCellYBottom; 129 int mCellYTop,mCellYBottom;
129 int mSubCell; // subcell number of this item 130 int mSubCell; // subcell number of this item
130 int mSubCells; // Total number of subcells in cell of this item 131 int mSubCells; // Total number of subcells in cell of this item
131 int xPaintCoord; 132 int xPaintCoord;
132 int yPaintCoord; 133 int yPaintCoord;
133 int wPaintCoord; 134 int wPaintCoord;
134 int hPaintCoord; 135 int hPaintCoord;
135 // Variables to remember start position 136 // Variables to remember start position
136 int mStartCellX; 137 int mStartCellX;
137 int mStartCellXWidth; 138 int mStartCellXWidth;
138 int mStartCellYTop,mStartCellYBottom; 139 int mStartCellYTop,mStartCellYBottom;
139 int mLastMovePos; 140 int mLastMovePos;
140 141
141 // Multi item pointers 142 // Multi item pointers
142 KOAgendaItem *mFirstMultiItem; 143 KOAgendaItem *mFirstMultiItem;
143 KOAgendaItem *mNextMultiItem; 144 KOAgendaItem *mNextMultiItem;
144 KOAgendaItem *mLastMultiItem; 145 KOAgendaItem *mLastMultiItem;
145 146
146 int mFontPixelSize; 147 int mFontPixelSize;
147 Incidence *mIncidence; // corresponding event or todo 148 Incidence *mIncidence; // corresponding event or todo
148 QDate mDate; //date this events occurs (for recurrence) 149 QDate mDate; //date this events occurs (for recurrence)
149 //void showIcon( QLabel*, int ); 150 //void showIcon( QLabel*, int );
150 //QLabel *mTodoIconLabel; 151 //QLabel *mTodoIconLabel;
151 //QLabel *mItemLabel; 152 //QLabel *mItemLabel;
152 //QWidget *mIconBox; 153 //QWidget *mIconBox;
153 //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly; 154 //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly;
154 //QLabel *mIconReply,*mIconGroup,*mIconOrganizer; 155 //QLabel *mIconReply,*mIconGroup,*mIconOrganizer;
155 //QLabel *mIconMoreInfo; 156 //QLabel *mIconMoreInfo;
156 static QToolTipGroup *mToolTipGroup; 157 static QToolTipGroup *mToolTipGroup;
157 158
158 QColor mBackgroundColor; 159 QColor mBackgroundColor;
159 QColorGroup mColorGroup; 160 QColorGroup mColorGroup;
160 QString mDisplayedText; 161 QString mDisplayedText;
161 bool mSelected; 162 bool mSelected;
162 QPtrList<KOAgendaItem> mConflictItems; 163 QPtrList<KOAgendaItem> mConflictItems;
163}; 164};
164 165
165#endif // KOAGENDAITEM_H 166#endif // KOAGENDAITEM_H
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index c851ab5..a42227c 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -413,243 +413,252 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
413 int widebut = mExpandButton->sizeHint().width()+4; 413 int widebut = mExpandButton->sizeHint().width()+4;
414 int heibut = mExpandButton->sizeHint().height()+4; 414 int heibut = mExpandButton->sizeHint().height()+4;
415 if ( heibut > widebut ) 415 if ( heibut > widebut )
416 widebut = heibut ; 416 widebut = heibut ;
417 417
418 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 418 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
419 // QSizePolicy::Fixed ) ); 419 // QSizePolicy::Fixed ) );
420 mExpandButton->setFixedSize( widebut, widebut); 420 mExpandButton->setFixedSize( widebut, widebut);
421 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 421 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
422 mExpandButton->setFocusPolicy(NoFocus); 422 mExpandButton->setFocusPolicy(NoFocus);
423 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 423 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
424 mAllDayAgenda->setFocusPolicy(NoFocus); 424 mAllDayAgenda->setFocusPolicy(NoFocus);
425 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); 425 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame);
426 426
427 // Create event context menu for all day agenda 427 // Create event context menu for all day agenda
428 //mAllDayAgendaPopup = eventPopup(); 428 //mAllDayAgendaPopup = eventPopup();
429 429
430 // Create agenda frame 430 // Create agenda frame
431 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); 431 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3);
432 // QHBox *agendaFrame = new QHBox(splitterAgenda); 432 // QHBox *agendaFrame = new QHBox(splitterAgenda);
433 433
434 // create event indicator bars 434 // create event indicator bars
435 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 435 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
436#ifndef DESKTOP_VERSION 436#ifndef DESKTOP_VERSION
437 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 437 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
438#endif 438#endif
439 mDayLabelsFrame = new QHBox(agendaFrame); 439 mDayLabelsFrame = new QHBox(agendaFrame);
440 //topLayout->addWidget(mDayLabelsFrame); 440 //topLayout->addWidget(mDayLabelsFrame);
441 mDayLabels = new QFrame (mDayLabelsFrame); 441 mDayLabels = new QFrame (mDayLabelsFrame);
442 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 442 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
443 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); 443 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2);
444 agendaLayout->addWidget(mEventIndicatorTop,1,1); 444 agendaLayout->addWidget(mEventIndicatorTop,1,1);
445 445
446 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 446 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
447 agendaFrame); 447 agendaFrame);
448 agendaLayout->addWidget(mEventIndicatorBottom,3,1); 448 agendaLayout->addWidget(mEventIndicatorBottom,3,1);
449 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 449 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
450 agendaLayout->addWidget(dummyAgendaRight,1,2); 450 agendaLayout->addWidget(dummyAgendaRight,1,2);
451 451
452 // Create time labels 452 // Create time labels
453 mTimeLabels = new TimeLabels(24,agendaFrame); 453 mTimeLabels = new TimeLabels(24,agendaFrame);
454 agendaLayout->addWidget(mTimeLabels,2,0); 454 agendaLayout->addWidget(mTimeLabels,2,0);
455 connect(mTimeLabels,SIGNAL( scaleChanged()), 455 connect(mTimeLabels,SIGNAL( scaleChanged()),
456 this,SLOT(updateConfig())); 456 this,SLOT(updateConfig()));
457 457
458 // Create agenda 458 // Create agenda
459 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 459 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
460 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); 460 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2);
461 agendaLayout->setColStretch(1,1); 461 agendaLayout->setColStretch(1,1);
462 mAgenda->setFocusPolicy(NoFocus); 462 mAgenda->setFocusPolicy(NoFocus);
463 // Create event context menu for agenda 463 // Create event context menu for agenda
464 mAllAgendaPopup = eventPopup(); 464 mAllAgendaPopup = eventPopup();
465 465
466#if 0 466#if 0
467 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 467 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
468 i18n("Toggle Alarm"),mAgenda, 468 i18n("Toggle Alarm"),mAgenda,
469 SLOT(popupAlarm()),true); 469 SLOT(popupAlarm()),true);
470 470
471#endif 471#endif
472 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 472 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
473 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 473 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
474 474
475 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 475 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
476 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 476 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
477
478 connect(mAllAgendaPopup,SIGNAL(categoryChanged(Incidence *)),
479 this,SLOT(categoryChanged(Incidence *)));
480
481
477 mAgenda->setPopup( mAllAgendaPopup ); 482 mAgenda->setPopup( mAllAgendaPopup );
478 mAllDayAgenda->setPopup( mAllAgendaPopup ); 483 mAllDayAgenda->setPopup( mAllAgendaPopup );
479 // make connections between dependent widgets 484 // make connections between dependent widgets
480 mTimeLabels->setAgenda(mAgenda); 485 mTimeLabels->setAgenda(mAgenda);
481 486
482 // Update widgets to reflect user preferences 487 // Update widgets to reflect user preferences
483 // updateConfig(); 488 // updateConfig();
484 489
485 // createDayLabels(); 490 // createDayLabels();
486 491
487 // these blank widgets make the All Day Event box line up with the agenda 492 // these blank widgets make the All Day Event box line up with the agenda
488 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 493 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
489 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 494 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
490 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 495 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
491 496
492 // Scrolling 497 // Scrolling
493 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 498 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
494 mTimeLabels, SLOT(positionChanged())); 499 mTimeLabels, SLOT(positionChanged()));
495 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 500 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
496 SLOT(setContentsPos(int))); 501 SLOT(setContentsPos(int)));
497 502
498 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); 503 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int )));
499 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); 504 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) ));
500 505
501 // Create/Show/Edit/Delete Event 506 // Create/Show/Edit/Delete Event
502 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 507 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
503 SLOT(newEvent(int,int))); 508 SLOT(newEvent(int,int)));
504 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 509 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
505 SLOT(newTodo(int,int))); 510 SLOT(newTodo(int,int)));
506 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 511 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
507 SLOT(newEvent(int,int,int,int))); 512 SLOT(newEvent(int,int,int,int)));
508 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 513 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
509 SLOT(newEventAllDay(int,int))); 514 SLOT(newEventAllDay(int,int)));
510 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 515 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
511 SLOT(newTodoAllDay(int,int))); 516 SLOT(newTodoAllDay(int,int)));
512 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 517 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
513 SLOT(newEventAllDay(int,int))); 518 SLOT(newEventAllDay(int,int)));
514 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 519 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
515 SLOT(newTimeSpanSelected(int,int,int,int))); 520 SLOT(newTimeSpanSelected(int,int,int,int)));
516 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 521 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
517 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 522 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
518 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 523 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
519 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 524 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
520 525
521 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 526 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
522 SIGNAL(editIncidenceSignal(Incidence *))); 527 SIGNAL(editIncidenceSignal(Incidence *)));
523 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 528 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
524 SIGNAL(editIncidenceSignal(Incidence *))); 529 SIGNAL(editIncidenceSignal(Incidence *)));
525 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 530 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
526 SIGNAL(showIncidenceSignal(Incidence *))); 531 SIGNAL(showIncidenceSignal(Incidence *)));
527 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 532 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
528 SIGNAL(showIncidenceSignal(Incidence *))); 533 SIGNAL(showIncidenceSignal(Incidence *)));
529 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 534 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
530 SIGNAL(deleteIncidenceSignal(Incidence *))); 535 SIGNAL(deleteIncidenceSignal(Incidence *)));
531 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 536 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
532 SIGNAL(deleteIncidenceSignal(Incidence *))); 537 SIGNAL(deleteIncidenceSignal(Incidence *)));
533 538
534 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 539 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
535 SLOT(updateEventDates(KOAgendaItem *, int ))); 540 SLOT(updateEventDates(KOAgendaItem *, int )));
536 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 541 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
537 SLOT(updateEventDates(KOAgendaItem *, int))); 542 SLOT(updateEventDates(KOAgendaItem *, int)));
538 543
539 // event indicator update 544 // event indicator update
540 connect(mAgenda,SIGNAL(lowerYChanged(int)), 545 connect(mAgenda,SIGNAL(lowerYChanged(int)),
541 SLOT(updateEventIndicatorTop(int))); 546 SLOT(updateEventIndicatorTop(int)));
542 connect(mAgenda,SIGNAL(upperYChanged(int)), 547 connect(mAgenda,SIGNAL(upperYChanged(int)),
543 SLOT(updateEventIndicatorBottom(int))); 548 SLOT(updateEventIndicatorBottom(int)));
544 // drag signals 549 // drag signals
545 /* 550 /*
546 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 551 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
547 SLOT(startDrag(Event *))); 552 SLOT(startDrag(Event *)));
548 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 553 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
549 SLOT(startDrag(Event *))); 554 SLOT(startDrag(Event *)));
550 */ 555 */
551 // synchronize selections 556 // synchronize selections
552 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 557 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
553 mAllDayAgenda, SLOT( deselectItem() ) ); 558 mAllDayAgenda, SLOT( deselectItem() ) );
554 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 559 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
555 mAgenda, SLOT( deselectItem() ) ); 560 mAgenda, SLOT( deselectItem() ) );
556 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 561 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
557 SIGNAL( incidenceSelected( Incidence * ) ) ); 562 SIGNAL( incidenceSelected( Incidence * ) ) );
558 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 563 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
559 SIGNAL( incidenceSelected( Incidence * ) ) ); 564 SIGNAL( incidenceSelected( Incidence * ) ) );
560 connect( mAgenda, SIGNAL( resizedSignal() ), 565 connect( mAgenda, SIGNAL( resizedSignal() ),
561 SLOT( updateConfig( ) ) ); 566 SLOT( updateConfig( ) ) );
562 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 567 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
563 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 568 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
564 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 569 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
565 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 570 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
566 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 571 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
567 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 572 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
568 573
569 connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) ); 574 connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) );
570 connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) ); 575 connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) );
571 576
572} 577}
573 578
574void KOAgendaView::toggleAllDay() 579void KOAgendaView::toggleAllDay()
575{ 580{
576 if ( mSplitterAgenda->firstHandle() ) 581 if ( mSplitterAgenda->firstHandle() )
577 mSplitterAgenda->firstHandle()->toggle(); 582 mSplitterAgenda->firstHandle()->toggle();
578} 583}
579void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 584void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
580{ 585{
581 calendar()->addIncidence( inc ); 586 calendar()->addIncidence( inc );
582 587
583 if ( incOld ) { 588 if ( incOld ) {
584 if ( incOld->typeID() == todoID ) 589 if ( incOld->typeID() == todoID )
585 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 590 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
586 else 591 else
587 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 592 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
588 } 593 }
589 594
590} 595}
591 596void KOAgendaView::categoryChanged(Incidence * inc)
597{
598 mAgenda->categoryChanged( inc );
599 mAllDayAgenda->categoryChanged( inc );
600}
592KOAgendaView::~KOAgendaView() 601KOAgendaView::~KOAgendaView()
593{ 602{
594 delete mAllAgendaPopup; 603 delete mAllAgendaPopup;
595 //delete mAllDayAgendaPopup; 604 //delete mAllDayAgendaPopup;
596 delete KOAgendaItem::paintPix(); 605 delete KOAgendaItem::paintPix();
597 delete KOAgendaItem::paintPixSel(); 606 delete KOAgendaItem::paintPixSel();
598} 607}
599void KOAgendaView::resizeEvent( QResizeEvent* e ) 608void KOAgendaView::resizeEvent( QResizeEvent* e )
600{ 609{
601 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 610 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
602 bool uc = false; 611 bool uc = false;
603 int ow = e->oldSize().width(); 612 int ow = e->oldSize().width();
604 int oh = e->oldSize().height(); 613 int oh = e->oldSize().height();
605 int w = e->size().width(); 614 int w = e->size().width();
606 int h = e->size().height(); 615 int h = e->size().height();
607 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 616 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
608 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 617 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
609 uc = true; 618 uc = true;
610 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 619 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
611 } 620 }
612 mUpcomingWidth = e->size().width() ; 621 mUpcomingWidth = e->size().width() ;
613 if ( mBlockUpdating || uc ) { 622 if ( mBlockUpdating || uc ) {
614 mBlockUpdating = false; 623 mBlockUpdating = false;
615 //mAgenda->setMinimumSize(800 , 600 ); 624 //mAgenda->setMinimumSize(800 , 600 );
616 //qDebug("mAgenda->resize+++++++++++++++ "); 625 //qDebug("mAgenda->resize+++++++++++++++ ");
617 updateConfig(); 626 updateConfig();
618 //qDebug("KOAgendaView::Updating now possible "); 627 //qDebug("KOAgendaView::Updating now possible ");
619 } else 628 } else
620 createDayLabels(); 629 createDayLabels();
621 //qDebug("resizeEvent end "); 630 //qDebug("resizeEvent end ");
622 631
623} 632}
624void KOAgendaView::slotDaylabelClicked( int num ) 633void KOAgendaView::slotDaylabelClicked( int num )
625{ 634{
626 635
627 QDate firstDate = mSelectedDates.first(); 636 QDate firstDate = mSelectedDates.first();
628 if ( num == -1 ) 637 if ( num == -1 )
629 emit showDateView( 6, firstDate ); 638 emit showDateView( 6, firstDate );
630 else if (num >= 0 ) { 639 else if (num >= 0 ) {
631 if ( mSelectedDates.count() == 1) 640 if ( mSelectedDates.count() == 1)
632 emit showDateView( 9, firstDate.addDays( num ) ); 641 emit showDateView( 9, firstDate.addDays( num ) );
633 else 642 else
634 emit showDateView( 3, firstDate.addDays( num ) ); 643 emit showDateView( 3, firstDate.addDays( num ) );
635 } 644 }
636 else 645 else
637 showDateView( 10, firstDate.addDays(1) ); 646 showDateView( 10, firstDate.addDays(1) );
638} 647}
639 648
640KOAgendaButton* KOAgendaView::getNewDaylabel() 649KOAgendaButton* KOAgendaView::getNewDaylabel()
641{ 650{
642 651
643 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 652 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
644 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 653 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
645 mDayLabelsList.append( dayLabel ); 654 mDayLabelsList.append( dayLabel );
646 mLayoutDayLabels->addWidget(dayLabel); 655 mLayoutDayLabels->addWidget(dayLabel);
647 return dayLabel ; 656 return dayLabel ;
648} 657}
649 658
650void KOAgendaView::createDayLabels() 659void KOAgendaView::createDayLabels()
651{ 660{
652 661
653 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 662 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
654 // qDebug(" KOAgendaView::createDayLabels() blocked "); 663 // qDebug(" KOAgendaView::createDayLabels() blocked ");
655 return; 664 return;
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h
index cc953fc..a1cf308 100644
--- a/korganizer/koagendaview.h
+++ b/korganizer/koagendaview.h
@@ -178,116 +178,117 @@ class KOAgendaView : public KOEventView {
178 /** returns true if selection is for whole day */ 178 /** returns true if selection is for whole day */
179 bool selectedIsAllDay() {return mTimeSpanInAllDay;} 179 bool selectedIsAllDay() {return mTimeSpanInAllDay;}
180 /** make selected start/end invalid */ 180 /** make selected start/end invalid */
181 void deleteSelectedDateTime(); 181 void deleteSelectedDateTime();
182 void repaintAgenda(); 182 void repaintAgenda();
183 public slots: 183 public slots:
184 void setInitStartHour(); 184 void setInitStartHour();
185 virtual void updateView(); 185 virtual void updateView();
186 virtual void updateConfig(); 186 virtual void updateConfig();
187 virtual void showDates(const QDate &start, const QDate &end); 187 virtual void showDates(const QDate &start, const QDate &end);
188 virtual void showEvents(QPtrList<Event> eventList); 188 virtual void showEvents(QPtrList<Event> eventList);
189 189
190 void updateTodo( Todo *, int ); 190 void updateTodo( Todo *, int );
191 void changeEventDisplay(Event *, int); 191 void changeEventDisplay(Event *, int);
192 192
193 void clearSelection(); 193 void clearSelection();
194 194
195 void newTodo(int gx,int gy); 195 void newTodo(int gx,int gy);
196 void newEvent(int gx,int gy); 196 void newEvent(int gx,int gy);
197 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd); 197 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd);
198 void newEventAllDay(int gx, int gy); 198 void newEventAllDay(int gx, int gy);
199 void newTodoAllDay(int gx, int gy); 199 void newTodoAllDay(int gx, int gy);
200 200
201 void startDrag(Event *); 201 void startDrag(Event *);
202 202
203 void readSettings(); 203 void readSettings();
204 void readSettings(KConfig *); 204 void readSettings(KConfig *);
205 void writeSettings(KConfig *); 205 void writeSettings(KConfig *);
206 206
207 void setContentsPos(int y); 207 void setContentsPos(int y);
208 208
209 void scrollOneHourUp(); 209 void scrollOneHourUp();
210 void scrollOneHourDown(); 210 void scrollOneHourDown();
211 void addToCalSlot(Incidence *, Incidence *); 211 void addToCalSlot(Incidence *, Incidence *);
212 void slotShowDateView( int, int ); 212 void slotShowDateView( int, int );
213 213
214 signals: 214 signals:
215 void showDateView( int, QDate ); 215 void showDateView( int, QDate );
216 void newTodoSignal( QDateTime ,bool ); 216 void newTodoSignal( QDateTime ,bool );
217 void toggleExpand(); 217 void toggleExpand();
218 void selectWeekNum( int ); 218 void selectWeekNum( int );
219 void todoMoved( Todo *, int ); 219 void todoMoved( Todo *, int );
220 void incidenceChanged(Incidence * , int ); 220 void incidenceChanged(Incidence * , int );
221 // void cloneIncidenceSignal(Incidence *); 221 // void cloneIncidenceSignal(Incidence *);
222 222
223 protected: 223 protected:
224 KOAgendaButton* getNewDaylabel(); 224 KOAgendaButton* getNewDaylabel();
225 bool mBlockUpdating; 225 bool mBlockUpdating;
226 int mUpcomingWidth; 226 int mUpcomingWidth;
227 /** Fill agenda beginning with date startDate */ 227 /** Fill agenda beginning with date startDate */
228 void fillAgenda(const QDate &startDate); 228 void fillAgenda(const QDate &startDate);
229 void resizeEvent( QResizeEvent* e ); 229 void resizeEvent( QResizeEvent* e );
230 /** Fill agenda using the current set value for the start date */ 230 /** Fill agenda using the current set value for the start date */
231 void fillAgenda(); 231 void fillAgenda();
232 232
233 /** Create labels for the selected dates. */ 233 /** Create labels for the selected dates. */
234 void createDayLabels(); 234 void createDayLabels();
235 235
236 /** 236 /**
237 Set the masks on the agenda widgets indicating, which days are holidays. 237 Set the masks on the agenda widgets indicating, which days are holidays.
238 */ 238 */
239 void setHolidayMasks(); 239 void setHolidayMasks();
240 240
241 protected slots: 241 protected slots:
242 void categoryChanged( Incidence * );
242 void slotDaylabelClicked( int ); 243 void slotDaylabelClicked( int );
243 /** Update event belonging to agenda item */ 244 /** Update event belonging to agenda item */
244 void updateEventDates(KOAgendaItem *item, int mode = -1); 245 void updateEventDates(KOAgendaItem *item, int mode = -1);
245 //void updateMovedTodo(); 246 //void updateMovedTodo();
246 247
247 void updateEventIndicatorTop(int newY); 248 void updateEventIndicatorTop(int newY);
248 void updateEventIndicatorBottom(int newY); 249 void updateEventIndicatorBottom(int newY);
249 250
250 /** Updates data for selected timespan */ 251 /** Updates data for selected timespan */
251 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd); 252 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd);
252 /** Updates data for selected timespan for all day event*/ 253 /** Updates data for selected timespan for all day event*/
253 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd); 254 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd);
254 255
255 private: 256 private:
256 // view widgets 257 // view widgets
257 QFrame *mDayLabels; 258 QFrame *mDayLabels;
258 QHBox *mDayLabelsFrame; 259 QHBox *mDayLabelsFrame;
259 QBoxLayout *mLayoutDayLabels; 260 QBoxLayout *mLayoutDayLabels;
260 QFrame *mAllDayFrame; 261 QFrame *mAllDayFrame;
261 KOAgenda *mAllDayAgenda; 262 KOAgenda *mAllDayAgenda;
262 KOAgenda *mAgenda; 263 KOAgenda *mAgenda;
263 TimeLabels *mTimeLabels; 264 TimeLabels *mTimeLabels;
264 QWidget *mDummyAllDayLeft; 265 QWidget *mDummyAllDayLeft;
265 266
266 KDGanttMinimizeSplitter* mSplitterAgenda; 267 KDGanttMinimizeSplitter* mSplitterAgenda;
267 QPushButton *mExpandButton; 268 QPushButton *mExpandButton;
268 269
269 DateList mSelectedDates; // List of dates to be displayed 270 DateList mSelectedDates; // List of dates to be displayed
270 int mViewType; 271 int mViewType;
271 272
272 bool mWeekStartsMonday; 273 bool mWeekStartsMonday;
273 int mStartHour; 274 int mStartHour;
274 275
275 KOEventPopupMenu *mAllAgendaPopup; 276 KOEventPopupMenu *mAllAgendaPopup;
276 //KOEventPopupMenu *mAllDayAgendaPopup; 277 //KOEventPopupMenu *mAllDayAgendaPopup;
277 278
278 EventIndicator *mEventIndicatorTop; 279 EventIndicator *mEventIndicatorTop;
279 EventIndicator *mEventIndicatorBottom; 280 EventIndicator *mEventIndicatorBottom;
280 281
281 QMemArray<int> mMinY; 282 QMemArray<int> mMinY;
282 QMemArray<int> mMaxY; 283 QMemArray<int> mMaxY;
283 284
284 QMemArray<bool> mHolidayMask; 285 QMemArray<bool> mHolidayMask;
285 286
286 QPtrList<KOAgendaButton> mDayLabelsList; 287 QPtrList<KOAgendaButton> mDayLabelsList;
287 QDateTime mTimeSpanBegin; 288 QDateTime mTimeSpanBegin;
288 QDateTime mTimeSpanEnd; 289 QDateTime mTimeSpanEnd;
289 bool mTimeSpanInAllDay; 290 bool mTimeSpanInAllDay;
290 void keyPressEvent ( QKeyEvent * e ); 291 void keyPressEvent ( QKeyEvent * e );
291}; 292};
292 293
293#endif // KOAGENDAVIEW_H 294#endif // KOAGENDAVIEW_H
diff --git a/korganizer/koeventpopupmenu.cpp b/korganizer/koeventpopupmenu.cpp
index 17ef81e..90caaf4 100644
--- a/korganizer/koeventpopupmenu.cpp
+++ b/korganizer/koeventpopupmenu.cpp
@@ -1,130 +1,168 @@
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 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qcursor.h> 24#include <qcursor.h>
25 25
26#include <klocale.h> 26#include <klocale.h>
27#include <kdebug.h> 27#include <kdebug.h>
28#include <kiconloader.h> 28#include <kiconloader.h>
29 29
30#include <libkcal/event.h> 30#include <libkcal/event.h>
31 31
32#include "koeventpopupmenu.h" 32#include "koeventpopupmenu.h"
33#include "koprefs.h"
33 34
34KOEventPopupMenu::KOEventPopupMenu() 35KOEventPopupMenu::KOEventPopupMenu(): QPopupMenu()
35{ 36{
36 mCurrentIncidence = 0; 37 mCurrentIncidence = 0;
37 mHasAdditionalItems = false; 38 mHasAdditionalItems = false;
38 39
39 40
40 mSingleOnlyItems.append( insertItem (i18n("&Show"),this,SLOT(popupShow()))); 41 mSingleOnlyItems.append( insertItem (i18n("&Show"),this,SLOT(popupShow())));
41 mEditOnlyItems.append(insertItem (i18n("&Edit..."),this,SLOT(popupEdit()))); 42 mEditOnlyItems.append(insertItem (i18n("&Edit..."),this,SLOT(popupEdit())));
42 mEditOnlyItems.append(insertItem (i18n("&Delete"), 43 mEditOnlyItems.append(insertItem (i18n("&Delete"),
43 this,SLOT(popupDelete()))); 44 this,SLOT(popupDelete())));
44 mEditOnlyItems.append(insertItem (i18n("&Clone..."), 45 mEditOnlyItems.append(insertItem (i18n("&Clone..."),
45 this,SLOT(popupClone()))); 46 this,SLOT(popupClone())));
46 mEditOnlyItems.append(insertItem (i18n("&Move..."), 47 mEditOnlyItems.append(insertItem (i18n("&Move..."),
47 this,SLOT(popupMove()))); 48 this,SLOT(popupMove())));
48#ifndef DESKTOP_VERSION 49#ifndef DESKTOP_VERSION
49 mEditOnlyItems.append(insertItem (i18n("&Beam..."), 50 mEditOnlyItems.append(insertItem (i18n("&Beam..."),
50 this,SLOT(popupBeam()))); 51 this,SLOT(popupBeam())));
51#endif 52#endif
52 mEditOnlyItems.append(insertItem (i18n("&Toggle Cancel"), 53 mEditOnlyItems.append(insertItem (i18n("&Toggle Cancel"),
53 this,SLOT(popupCancel()))); 54 this,SLOT(popupCancel())));
54 isDisabled = false; 55 isDisabled = false;
56 mCatPopup = new QPopupMenu ( this );
57 mCatPopup->setCheckable (true);
58 connect(mCatPopup,SIGNAL( aboutToShow ()), this ,SLOT( fillCatPopup()));
59 connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT( computeCatPopup( int )));
60 mEditOnlyItems.append(insertItem (i18n("Categories"),mCatPopup ));
55 QValueList<int>::Iterator it; 61 QValueList<int>::Iterator it;
56 for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) { 62 for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) {
57 mSingleOnlyItems.append(*it); 63 mSingleOnlyItems.append(*it);
58 } 64 }
65
59} 66}
60void KOEventPopupMenu::enableDefault( bool enable ) 67void KOEventPopupMenu::enableDefault( bool enable )
61{ 68{
62 isDisabled = !enable; 69 isDisabled = !enable;
63 QValueList<int>::Iterator it; 70 QValueList<int>::Iterator it;
64 for( it = mSingleOnlyItems.begin(); it != mSingleOnlyItems.end(); ++it ) { 71 for( it = mSingleOnlyItems.begin(); it != mSingleOnlyItems.end(); ++it ) {
65 setItemEnabled(*it,enable); 72 setItemEnabled(*it,enable);
66 } 73 }
67 74
68} 75}
69 76
77void KOEventPopupMenu::fillCatPopup()
78{
79 mCatPopup->clear();
80 QStringList checkedCategories = mCurrentIncidence->categories();
81 int index = 0;
82 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
83 it != KOPrefs::instance()->mCustomCategories.end ();
84 ++it) {
85 mCatPopup->insertItem (*it, index );
86 if (checkedCategories.find (*it) != checkedCategories.end ()) {
87 mCatPopup->setItemChecked (index, true);
88 }
89 ++index;
90 }
91}
92void KOEventPopupMenu::computeCatPopup( int index )
93{
94 QStringList categories = mCurrentIncidence->categories();
95 QString colcat = categories.first();
96 if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ())
97 categories.remove (KOPrefs::instance()->mCustomCategories[index]);
98 else
99 categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]);
100 categories.sort ();
101 if ( !colcat.isEmpty() ) {
102 if ( categories.find ( colcat ) != categories.end () ) {
103 categories.remove( colcat );
104 categories.prepend( colcat );
105 }
106 }
107 mCurrentIncidence->setCategories( categories );
108 emit categoryChanged( mCurrentIncidence );
109}
70void KOEventPopupMenu::showIncidencePopup(Incidence *incidence) 110void KOEventPopupMenu::showIncidencePopup(Incidence *incidence)
71{ 111{
72 mCurrentIncidence = incidence; 112 mCurrentIncidence = incidence;
73 113
74 if (mCurrentIncidence) { 114 if (mCurrentIncidence) {
75 // Enable/Disabled menu items only valid for editable events. 115 // Enable/Disabled menu items only valid for editable events.
76 if ( !isDisabled ) { 116 if ( !isDisabled ) {
77 QValueList<int>::Iterator it; 117 QValueList<int>::Iterator it;
78 for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) { 118 for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) {
79 setItemEnabled(*it,!mCurrentIncidence->isReadOnly()); 119 setItemEnabled(*it,!mCurrentIncidence->isReadOnly());
80 } 120 }
81 } 121 }
82 popup(QCursor::pos()); 122 popup(QCursor::pos());
83 } else {
84 kdDebug() << "KOEventPopupMenu::showEventPopup(): No event selected" << endl;
85 } 123 }
86} 124}
87 125
88void KOEventPopupMenu::addAdditionalItem(const QIconSet &icon,const QString &text, 126void KOEventPopupMenu::addAdditionalItem(const QIconSet &icon,const QString &text,
89 const QObject *receiver, const char *member, 127 const QObject *receiver, const char *member,
90 bool editOnly) 128 bool editOnly)
91{ 129{
92 if (!mHasAdditionalItems) { 130 if (!mHasAdditionalItems) {
93 mHasAdditionalItems = true; 131 mHasAdditionalItems = true;
94 insertSeparator(); 132 insertSeparator();
95 } 133 }
96 int id = insertItem(icon,text,receiver,member); 134 int id = insertItem(icon,text,receiver,member);
97 if (editOnly) mEditOnlyItems.append(id); 135 if (editOnly) mEditOnlyItems.append(id);
98} 136}
99 137
100void KOEventPopupMenu::popupShow() 138void KOEventPopupMenu::popupShow()
101{ 139{
102 if (mCurrentIncidence) emit showIncidenceSignal(mCurrentIncidence); 140 if (mCurrentIncidence) emit showIncidenceSignal(mCurrentIncidence);
103} 141}
104 142
105void KOEventPopupMenu::popupEdit() 143void KOEventPopupMenu::popupEdit()
106{ 144{
107 if (mCurrentIncidence) emit editIncidenceSignal(mCurrentIncidence); 145 if (mCurrentIncidence) emit editIncidenceSignal(mCurrentIncidence);
108} 146}
109 147
110void KOEventPopupMenu::popupDelete() 148void KOEventPopupMenu::popupDelete()
111{ 149{
112 if (mCurrentIncidence) emit deleteIncidenceSignal(mCurrentIncidence); 150 if (mCurrentIncidence) emit deleteIncidenceSignal(mCurrentIncidence);
113} 151}
114void KOEventPopupMenu::popupClone() 152void KOEventPopupMenu::popupClone()
115{ 153{
116 if (mCurrentIncidence) emit cloneIncidenceSignal(mCurrentIncidence); 154 if (mCurrentIncidence) emit cloneIncidenceSignal(mCurrentIncidence);
117} 155}
118void KOEventPopupMenu::popupCancel() 156void KOEventPopupMenu::popupCancel()
119{ 157{
120 if (mCurrentIncidence) emit cancelIncidenceSignal(mCurrentIncidence); 158 if (mCurrentIncidence) emit cancelIncidenceSignal(mCurrentIncidence);
121} 159}
122void KOEventPopupMenu::popupMove() 160void KOEventPopupMenu::popupMove()
123{ 161{
124 if (mCurrentIncidence) emit moveIncidenceSignal(mCurrentIncidence); 162 if (mCurrentIncidence) emit moveIncidenceSignal(mCurrentIncidence);
125} 163}
126 164
127void KOEventPopupMenu::popupBeam() 165void KOEventPopupMenu::popupBeam()
128{ 166{
129 if (mCurrentIncidence) emit beamIncidenceSignal(mCurrentIncidence); 167 if (mCurrentIncidence) emit beamIncidenceSignal(mCurrentIncidence);
130} 168}
diff --git a/korganizer/koeventpopupmenu.h b/korganizer/koeventpopupmenu.h
index 8fb51fa..3d8b595 100644
--- a/korganizer/koeventpopupmenu.h
+++ b/korganizer/koeventpopupmenu.h
@@ -1,76 +1,80 @@
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 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOEVENTPOPUPMENU_H 23#ifndef KOEVENTPOPUPMENU_H
24#define KOEVENTPOPUPMENU_H 24#define KOEVENTPOPUPMENU_H
25// 25//
26// Context menu for event views with standard event actions 26// Context menu for event views with standard event actions
27// 27//
28 28
29#include <qpopupmenu.h> 29#include <qpopupmenu.h>
30 30
31#include <libkcal/incidence.h> 31#include <libkcal/incidence.h>
32 32
33using namespace KCal; 33using namespace KCal;
34 34
35class KOEventPopupMenu : public QPopupMenu { 35class KOEventPopupMenu : public QPopupMenu {
36 Q_OBJECT 36 Q_OBJECT
37 public: 37 public:
38 KOEventPopupMenu(); 38 KOEventPopupMenu();
39 39
40 void addAdditionalItem(const QIconSet &icon,const QString &text, 40 void addAdditionalItem(const QIconSet &icon,const QString &text,
41 const QObject *receiver, const char *member, 41 const QObject *receiver, const char *member,
42 bool editOnly=false); 42 bool editOnly=false);
43 43
44 44
45 public slots: 45 public slots:
46 void showIncidencePopup(Incidence *); 46 void showIncidencePopup(Incidence *);
47 void enableDefault( bool ); 47 void enableDefault( bool );
48 48
49 protected slots: 49 protected slots:
50 void popupShow(); 50 void popupShow();
51 void popupEdit(); 51 void popupEdit();
52 void popupDelete(); 52 void popupDelete();
53 void popupClone(); 53 void popupClone();
54 void popupCancel(); 54 void popupCancel();
55 void popupMove(); 55 void popupMove();
56 void popupBeam(); 56 void popupBeam();
57 void fillCatPopup();
58 void computeCatPopup( int );
57 59
58 signals: 60 signals:
59 void editIncidenceSignal(Incidence *); 61 void editIncidenceSignal(Incidence *);
60 void showIncidenceSignal(Incidence *); 62 void showIncidenceSignal(Incidence *);
61 void deleteIncidenceSignal(Incidence *); 63 void deleteIncidenceSignal(Incidence *);
62 void cloneIncidenceSignal(Incidence *); 64 void cloneIncidenceSignal(Incidence *);
63 void cancelIncidenceSignal(Incidence *); 65 void cancelIncidenceSignal(Incidence *);
64 void moveIncidenceSignal(Incidence *); 66 void moveIncidenceSignal(Incidence *);
65 void beamIncidenceSignal(Incidence *); 67 void beamIncidenceSignal(Incidence *);
68 void categoryChanged( Incidence * );
66 69
67 private: 70 private:
68 Incidence *mCurrentIncidence; 71 Incidence *mCurrentIncidence;
69 72
70 bool mHasAdditionalItems; 73 bool mHasAdditionalItems;
71 QValueList<int> mEditOnlyItems; 74 QValueList<int> mEditOnlyItems;
72 QValueList<int> mSingleOnlyItems; 75 QValueList<int> mSingleOnlyItems;
73 bool isDisabled; 76 bool isDisabled;
77 QPopupMenu *mCatPopup;
74}; 78};
75 79
76#endif 80#endif
diff --git a/korganizer/koeventview.cpp b/korganizer/koeventview.cpp
index bce2626..1d26930 100644
--- a/korganizer/koeventview.cpp
+++ b/korganizer/koeventview.cpp
@@ -16,115 +16,114 @@
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 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qpopupmenu.h> 24#include <qpopupmenu.h>
25#include <qcursor.h> 25#include <qcursor.h>
26 26
27#include <klocale.h> 27#include <klocale.h>
28#include <kdebug.h> 28#include <kdebug.h>
29#include <kiconloader.h> 29#include <kiconloader.h>
30#include <kmessagebox.h> 30#include <kmessagebox.h>
31 31
32#include <libkcal/calendar.h> 32#include <libkcal/calendar.h>
33#include "koprefs.h" 33#include "koprefs.h"
34#include "koeventview.h" 34#include "koeventview.h"
35using namespace KOrg; 35using namespace KOrg;
36 36
37//--------------------------------------------------------------------------- 37//---------------------------------------------------------------------------
38 38
39KOEventView::KOEventView(Calendar *cal,QWidget *parent,const char *name) 39KOEventView::KOEventView(Calendar *cal,QWidget *parent,const char *name)
40 : KOrg::BaseView(cal,parent,name) 40 : KOrg::BaseView(cal,parent,name)
41{ 41{
42} 42}
43 43
44//--------------------------------------------------------------------------- 44//---------------------------------------------------------------------------
45 45
46KOEventView::~KOEventView() 46KOEventView::~KOEventView()
47{ 47{
48} 48}
49 49
50//--------------------------------------------------------------------------- 50//---------------------------------------------------------------------------
51 51
52KOEventPopupMenu *KOEventView::eventPopup() 52KOEventPopupMenu *KOEventView::eventPopup()
53{ 53{
54 KOEventPopupMenu *eventPopup = new KOEventPopupMenu; 54 KOEventPopupMenu *eventPopup = new KOEventPopupMenu;
55 55
56 connect(eventPopup,SIGNAL(editIncidenceSignal(Incidence *)), 56 connect(eventPopup,SIGNAL(editIncidenceSignal(Incidence *)),
57 SIGNAL(editIncidenceSignal(Incidence *))); 57 SIGNAL(editIncidenceSignal(Incidence *)));
58 connect(eventPopup,SIGNAL(showIncidenceSignal(Incidence *)), 58 connect(eventPopup,SIGNAL(showIncidenceSignal(Incidence *)),
59 SIGNAL(showIncidenceSignal(Incidence *))); 59 SIGNAL(showIncidenceSignal(Incidence *)));
60 connect(eventPopup,SIGNAL(deleteIncidenceSignal(Incidence *)), 60 connect(eventPopup,SIGNAL(deleteIncidenceSignal(Incidence *)),
61 SIGNAL(deleteIncidenceSignal(Incidence *))); 61 SIGNAL(deleteIncidenceSignal(Incidence *)));
62 connect(eventPopup,SIGNAL(cancelIncidenceSignal(Incidence *)), 62 connect(eventPopup,SIGNAL(cancelIncidenceSignal(Incidence *)),
63 SIGNAL(cancelIncidenceSignal(Incidence *))); 63 SIGNAL(cancelIncidenceSignal(Incidence *)));
64 connect(eventPopup,SIGNAL(cloneIncidenceSignal(Incidence *)), 64 connect(eventPopup,SIGNAL(cloneIncidenceSignal(Incidence *)),
65 SIGNAL(cloneIncidenceSignal(Incidence *))); 65 SIGNAL(cloneIncidenceSignal(Incidence *)));
66 connect(eventPopup,SIGNAL(beamIncidenceSignal(Incidence *)), 66 connect(eventPopup,SIGNAL(beamIncidenceSignal(Incidence *)),
67 SIGNAL(beamIncidenceSignal(Incidence *))); 67 SIGNAL(beamIncidenceSignal(Incidence *)));
68 connect(eventPopup,SIGNAL(moveIncidenceSignal(Incidence *)), 68 connect(eventPopup,SIGNAL(moveIncidenceSignal(Incidence *)),
69 SIGNAL(moveIncidenceSignal(Incidence *))); 69 SIGNAL(moveIncidenceSignal(Incidence *)));
70 70
71 return eventPopup; 71 return eventPopup;
72} 72}
73 73
74//--------------------------------------------------------------------------- 74//---------------------------------------------------------------------------
75 75
76void KOEventView::showIncidencePopup(QPopupMenu *popup,Incidence *event) 76void KOEventView::showIncidencePopup(QPopupMenu *popup,Incidence *event)
77{ 77{
78 mCurrentIncidence = event; 78 mCurrentIncidence = event;
79 if (event) popup->popup(QCursor::pos()); 79 if (event) popup->popup(QCursor::pos());
80 else kdDebug() << "KOEventView::showEventPopup(): No event selected" << endl;
81} 80}
82 81
83//--------------------------------------------------------------------------- 82//---------------------------------------------------------------------------
84 83
85void KOEventView::popupShow() 84void KOEventView::popupShow()
86{ 85{
87 emit showIncidenceSignal(mCurrentIncidence); 86 emit showIncidenceSignal(mCurrentIncidence);
88} 87}
89 88
90//--------------------------------------------------------------------------- 89//---------------------------------------------------------------------------
91 90
92void KOEventView::popupEdit() 91void KOEventView::popupEdit()
93{ 92{
94 emit editIncidenceSignal(mCurrentIncidence); 93 emit editIncidenceSignal(mCurrentIncidence);
95} 94}
96 95
97//--------------------------------------------------------------------------- 96//---------------------------------------------------------------------------
98 97
99void KOEventView::popupDelete() 98void KOEventView::popupDelete()
100{ 99{
101 emit deleteIncidenceSignal(mCurrentIncidence); 100 emit deleteIncidenceSignal(mCurrentIncidence);
102} 101}
103void KOEventView::popupClone() 102void KOEventView::popupClone()
104{ 103{
105 emit cloneIncidenceSignal(mCurrentIncidence); 104 emit cloneIncidenceSignal(mCurrentIncidence);
106} 105}
107void KOEventView::popupCancel() 106void KOEventView::popupCancel()
108{ 107{
109 emit cancelIncidenceSignal(mCurrentIncidence); 108 emit cancelIncidenceSignal(mCurrentIncidence);
110} 109}
111 110
112//--------------------------------------------------------------------------- 111//---------------------------------------------------------------------------
113 112
114void KOEventView::defaultAction( Incidence *incidence ) 113void KOEventView::defaultAction( Incidence *incidence )
115{ 114{
116 115
117 if ( !incidence ) return; 116 if ( !incidence ) return;
118 117
119 if ( incidence->isReadOnly() ) 118 if ( incidence->isReadOnly() )
120 emit showIncidenceSignal(incidence); 119 emit showIncidenceSignal(incidence);
121 else { 120 else {
122 if ( KOPrefs::instance()->mEditOnDoubleClick ) 121 if ( KOPrefs::instance()->mEditOnDoubleClick )
123 emit editIncidenceSignal(incidence); 122 emit editIncidenceSignal(incidence);
124 else 123 else
125 emit showIncidenceSignal(incidence); 124 emit showIncidenceSignal(incidence);
126 } 125 }
127} 126}
128 127
129//--------------------------------------------------------------------------- 128//---------------------------------------------------------------------------
130 129
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index 8f17e6e..43e1113 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -174,129 +174,129 @@ bool ListItemVisitor::visit(Todo *t)
174 mItem->setText(3,"---"); 174 mItem->setText(3,"---");
175 mItem->setText(4,"---"); 175 mItem->setText(4,"---");
176 if ( t->isAlarmEnabled() ) { 176 if ( t->isAlarmEnabled() ) {
177 mItem->setText(5,t->alarms().first()->offsetText() ); 177 mItem->setText(5,t->alarms().first()->offsetText() );
178 } else { 178 } else {
179 mItem->setText(5, i18n("No")); 179 mItem->setText(5, i18n("No"));
180 } 180 }
181 mItem->setText(6, t->recurrence()->recurrenceText()); 181 mItem->setText(6, t->recurrence()->recurrenceText());
182 if( ! t->doesRecur() ) 182 if( ! t->doesRecur() )
183 mItem->setSortKey( 6, "-" ); 183 mItem->setSortKey( 6, "-" );
184 if (t->hasDueDate()) { 184 if (t->hasDueDate()) {
185 mItem->setText(7,t->dtDueDateStr()); 185 mItem->setText(7,t->dtDueDateStr());
186 if (t->doesFloat()) { 186 if (t->doesFloat()) {
187 mItem->setText(8,"---"); 187 mItem->setText(8,"---");
188 } else { 188 } else {
189 mItem->setText(8,t->dtDueTimeStr()); 189 mItem->setText(8,t->dtDueTimeStr());
190 } 190 }
191 } else { 191 } else {
192 mItem->setText(7,"---"); 192 mItem->setText(7,"---");
193 mItem->setText(8,"---"); 193 mItem->setText(8,"---");
194 } 194 }
195 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); 195 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No"));
196 mItem->setText(10,t->categoriesStr()); 196 mItem->setText(10,t->categoriesStr());
197 mItem->setText(11, KOPrefs::instance()->calName( t->calID() )); 197 mItem->setText(11, KOPrefs::instance()->calName( t->calID() ));
198 198
199 QString key; 199 QString key;
200 QDate d; 200 QDate d;
201 if (t->hasDueDate()) { 201 if (t->hasDueDate()) {
202 d = t->dtDue().date(); 202 d = t->dtDue().date();
203 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); 203 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time();
204 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 204 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
205 mItem->setSortKey(7,key); 205 mItem->setSortKey(7,key);
206 } 206 }
207 if ( t->hasStartDate() ) { 207 if ( t->hasStartDate() ) {
208 d = t->dtStart().date(); 208 d = t->dtStart().date();
209 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); 209 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time();
210 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 210 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
211 mItem->setSortKey(1,key); 211 mItem->setSortKey(1,key);
212 } 212 }
213 return true; 213 return true;
214} 214}
215 215
216bool ListItemVisitor::visit(Journal * j) 216bool ListItemVisitor::visit(Journal * j)
217{ 217{
218 218
219 QString des; 219 QString des;
220 if ( !j->summary().isEmpty() ) { 220 if ( !j->summary().isEmpty() ) {
221 des = j->summary(); 221 des = j->summary();
222 } else { 222 } else {
223 des = j->description().left(30); 223 des = j->description().left(30);
224 des = des.simplifyWhiteSpace (); 224 des = des.simplifyWhiteSpace ();
225 des.replace (QRegExp ("\\n"),"" ); 225 des.replace (QRegExp ("\\n"),"" );
226 des.replace (QRegExp ("\\r"),"" ); 226 des.replace (QRegExp ("\\r"),"" );
227 } 227 }
228 mItem->setText(0,i18n("Journal: ")+des.left(25)); 228 mItem->setText(0,i18n("Journal: ")+des.left(25));
229 mItem->setText(1,j->dtStartDateStr()); 229 mItem->setText(1,j->dtStartDateStr());
230 mItem->setText(2,"---"); 230 mItem->setText(2,"---");
231 mItem->setText(3,"---"); 231 mItem->setText(3,"---");
232 mItem->setText(4,"---"); 232 mItem->setText(4,"---");
233 mItem->setText(5,"---"); 233 mItem->setText(5,"---");
234 mItem->setText(6,"---"); 234 mItem->setText(6,"---");
235 mItem->setText(7,j->dtStartDateStr()); 235 mItem->setText(7,j->dtStartDateStr());
236 mItem->setText(8,"---"); 236 mItem->setText(8,"---");
237 mItem->setText(9,"---"); 237 mItem->setText(9,"---");
238 mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); 238 mItem->setText(10,j->categoriesStr());
239 mItem->setText(11, KOPrefs::instance()->calName( j->calID() )); 239 mItem->setText(11, KOPrefs::instance()->calName( j->calID() ));
240 240
241 QString key; 241 QString key;
242 QDate d = j->dtStart().date(); 242 QDate d = j->dtStart().date();
243 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 243 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
244 mItem->setSortKey(1,key); 244 mItem->setSortKey(1,key);
245 mItem->setSortKey(7,key); 245 mItem->setSortKey(7,key);
246 246
247 return true; 247 return true;
248} 248}
249 249
250KOListView::KOListView(Calendar *calendar, QWidget *parent, 250KOListView::KOListView(Calendar *calendar, QWidget *parent,
251 const char *name) 251 const char *name)
252 : KOEventView(calendar, parent, name) 252 : KOEventView(calendar, parent, name)
253{ 253{
254 254
255 mActiveItem = 0; 255 mActiveItem = 0;
256 mForceShowCompletedTodos = false; 256 mForceShowCompletedTodos = false;
257 mListView = new KOListViewListView(this); 257 mListView = new KOListViewListView(this);
258 mListView->addColumn(i18n("Summary")); 258 mListView->addColumn(i18n("Summary"));
259 mListView->addColumn(i18n("Start Date")); 259 mListView->addColumn(i18n("Start Date"));
260 mListView->addColumn(i18n("Start Time")); 260 mListView->addColumn(i18n("Start Time"));
261 mListView->addColumn(i18n("End Date")); 261 mListView->addColumn(i18n("End Date"));
262 mListView->addColumn(i18n("End Time")); 262 mListView->addColumn(i18n("End Time"));
263 mListView->addColumn(i18n("Alarm")); // alarm set? 263 mListView->addColumn(i18n("Alarm")); // alarm set?
264 mListView->addColumn(i18n("Recurs")); // recurs? 264 mListView->addColumn(i18n("Recurs")); // recurs?
265 mListView->addColumn(i18n("Due Date")); 265 mListView->addColumn(i18n("Due Date"));
266 mListView->addColumn(i18n("Due Time")); 266 mListView->addColumn(i18n("Due Time"));
267 mListView->addColumn(i18n("Cancelled")); 267 mListView->addColumn(i18n("Cancelled"));
268 mListView->addColumn(i18n("Categories")); 268 mListView->addColumn(i18n("Categories"));
269 mListView->addColumn(i18n("Calendar")); 269 mListView->addColumn(i18n("Calendar"));
270 270
271 mListView->setColumnAlignment(0,AlignLeft); 271 mListView->setColumnAlignment(0,AlignLeft);
272 mListView->setColumnAlignment(1,AlignLeft); 272 mListView->setColumnAlignment(1,AlignLeft);
273 mListView->setColumnAlignment(2,AlignHCenter); 273 mListView->setColumnAlignment(2,AlignHCenter);
274 mListView->setColumnAlignment(3,AlignLeft); 274 mListView->setColumnAlignment(3,AlignLeft);
275 mListView->setColumnAlignment(4,AlignHCenter); 275 mListView->setColumnAlignment(4,AlignHCenter);
276 mListView->setColumnAlignment(5,AlignLeft); 276 mListView->setColumnAlignment(5,AlignLeft);
277 mListView->setColumnAlignment(6,AlignLeft); 277 mListView->setColumnAlignment(6,AlignLeft);
278 mListView->setColumnAlignment(7,AlignLeft); 278 mListView->setColumnAlignment(7,AlignLeft);
279 mListView->setColumnAlignment(8,AlignLeft); 279 mListView->setColumnAlignment(8,AlignLeft);
280 mListView->setColumnAlignment(9,AlignLeft); 280 mListView->setColumnAlignment(9,AlignLeft);
281 mListView->setColumnAlignment(10,AlignLeft); 281 mListView->setColumnAlignment(10,AlignLeft);
282 mListView->setColumnAlignment(11,AlignLeft); 282 mListView->setColumnAlignment(11,AlignLeft);
283 mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this); 283 mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this);
284 284
285 int iii = 0; 285 int iii = 0;
286 for ( iii = 0; iii< 12 ; ++iii ) 286 for ( iii = 0; iii< 12 ; ++iii )
287 mListView->setColumnWidthMode( iii, QListView::Manual ); 287 mListView->setColumnWidthMode( iii, QListView::Manual );
288 288
289 QBoxLayout *layoutTop = new QVBoxLayout(this); 289 QBoxLayout *layoutTop = new QVBoxLayout(this);
290 layoutTop->addWidget(mListView); 290 layoutTop->addWidget(mListView);
291 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 291 mListView->setFont ( KOPrefs::instance()->mListViewFont );
292 mPopupMenu = eventPopup(); 292 mPopupMenu = eventPopup();
293 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 293 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
294 i18n("Select all"),this, 294 i18n("Select all"),this,
295 SLOT(allSelection()),true); 295 SLOT(allSelection()),true);
296 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 296 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
297 i18n("Deselect all"),this, 297 i18n("Deselect all"),this,
298 SLOT(clearSelection()),true); 298 SLOT(clearSelection()),true);
299 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 299 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
300 i18n("Delete all selected"),this, 300 i18n("Delete all selected"),this,
301 SLOT(deleteAll()),true); 301 SLOT(deleteAll()),true);
302 302
@@ -950,138 +950,134 @@ void KOListView::showDates(bool show)
950 // Shouldn't we set it to a value greater 0? When showDates is called with 950 // Shouldn't we set it to a value greater 0? When showDates is called with
951 // show == true at first, then the columnwidths are set to zero. 951 // show == true at first, then the columnwidths are set to zero.
952 static int oldColWidth1 = 0; 952 static int oldColWidth1 = 0;
953 static int oldColWidth3 = 0; 953 static int oldColWidth3 = 0;
954 954
955 if (!show) { 955 if (!show) {
956 oldColWidth1 = mListView->columnWidth(1); 956 oldColWidth1 = mListView->columnWidth(1);
957 oldColWidth3 = mListView->columnWidth(3); 957 oldColWidth3 = mListView->columnWidth(3);
958 mListView->setColumnWidth(1, 0); 958 mListView->setColumnWidth(1, 0);
959 mListView->setColumnWidth(3, 0); 959 mListView->setColumnWidth(3, 0);
960 } else { 960 } else {
961 mListView->setColumnWidth(1, oldColWidth1); 961 mListView->setColumnWidth(1, oldColWidth1);
962 mListView->setColumnWidth(3, oldColWidth3); 962 mListView->setColumnWidth(3, oldColWidth3);
963 } 963 }
964 mListView->repaint(); 964 mListView->repaint();
965} 965}
966 966
967void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, 967void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd,
968 const QDate &td) 968 const QDate &td)
969{ 969{
970#ifndef KORG_NOPRINTER 970#ifndef KORG_NOPRINTER
971 calPrinter->preview(CalPrinter::Day, fd, td); 971 calPrinter->preview(CalPrinter::Day, fd, td);
972#endif 972#endif
973} 973}
974 974
975void KOListView::showDates() 975void KOListView::showDates()
976{ 976{
977 showDates(true); 977 showDates(true);
978} 978}
979 979
980void KOListView::hideDates() 980void KOListView::hideDates()
981{ 981{
982 showDates(false); 982 showDates(false);
983} 983}
984 984
985void KOListView::resetFocus() 985void KOListView::resetFocus()
986{ 986{
987 topLevelWidget()->setActiveWindow(); 987 topLevelWidget()->setActiveWindow();
988 topLevelWidget()->raise(); 988 topLevelWidget()->raise();
989 mListView->setFocus(); 989 mListView->setFocus();
990} 990}
991void KOListView::updateView() 991void KOListView::updateView()
992{ 992{
993 mListView->setFocus(); 993 mListView->setFocus();
994 if ( mListView->firstChild () ) 994 if ( mListView->firstChild () )
995 mListView->setCurrentItem( mListView->firstChild () ); 995 mListView->setCurrentItem( mListView->firstChild () );
996} 996}
997void KOListView::updateConfig() 997void KOListView::updateConfig()
998{ 998{
999 999
1000 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 1000 mListView->setFont ( KOPrefs::instance()->mListViewFont );
1001 updateView(); 1001 updateView();
1002 1002
1003} 1003}
1004void KOListView::setStartDate(const QDate &start) 1004void KOListView::setStartDate(const QDate &start)
1005{ 1005{
1006 mStartDate = start; 1006 mStartDate = start;
1007} 1007}
1008 1008
1009void KOListView::showDates(const QDate &start, const QDate &end) 1009void KOListView::showDates(const QDate &start, const QDate &end)
1010{ 1010{
1011 clear(); 1011 clear();
1012 mStartDate = start; 1012 mStartDate = start;
1013 QDate date = start; 1013 QDate date = start;
1014 QPtrList<Journal> j_list;
1015 while( date <= end ) { 1014 while( date <= end ) {
1016 addEvents(calendar()->events(date)); 1015 addEvents(calendar()->events(date));
1017 addTodos(calendar()->todos(date)); 1016 addTodos(calendar()->todos(date));
1018 Journal* jo = calendar()->journal(date); 1017 addJournals( calendar()->journals4Date(date) );
1019 if ( jo )
1020 j_list.append( jo );
1021 date = date.addDays( 1 ); 1018 date = date.addDays( 1 );
1022 } 1019 }
1023 addJournals(j_list);
1024 emit incidenceSelected( 0 ); 1020 emit incidenceSelected( 0 );
1025 updateView(); 1021 updateView();
1026 1022
1027} 1023}
1028 1024
1029void KOListView::addEvents(QPtrList<Event> eventList) 1025void KOListView::addEvents(QPtrList<Event> eventList)
1030{ 1026{
1031 1027
1032 Event *ev; 1028 Event *ev;
1033 for(ev = eventList.first(); ev; ev = eventList.next()) { 1029 for(ev = eventList.first(); ev; ev = eventList.next()) {
1034 addIncidence(ev); 1030 addIncidence(ev);
1035 } 1031 }
1036 if ( !mListView->currentItem() ){ 1032 if ( !mListView->currentItem() ){
1037 updateView(); 1033 updateView();
1038 } 1034 }
1039} 1035}
1040 1036
1041void KOListView::addTodos(QPtrList<Todo> eventList) 1037void KOListView::addTodos(QPtrList<Todo> eventList)
1042{ 1038{
1043 Todo *ev; 1039 Todo *ev;
1044 for(ev = eventList.first(); ev; ev = eventList.next()) { 1040 for(ev = eventList.first(); ev; ev = eventList.next()) {
1045 addIncidence(ev); 1041 addIncidence(ev);
1046 } 1042 }
1047 if ( !mListView->currentItem() ){ 1043 if ( !mListView->currentItem() ){
1048 updateView(); 1044 updateView();
1049 } 1045 }
1050} 1046}
1051void KOListView::addJournals(QPtrList<Journal> eventList) 1047void KOListView::addJournals(QPtrList<Journal> eventList)
1052{ 1048{
1053 Journal *ev; 1049 Journal *ev;
1054 for(ev = eventList.first(); ev; ev = eventList.next()) { 1050 for(ev = eventList.first(); ev; ev = eventList.next()) {
1055 addIncidence(ev); 1051 addIncidence(ev);
1056 } 1052 }
1057 if ( !mListView->currentItem() ){ 1053 if ( !mListView->currentItem() ){
1058 updateView(); 1054 updateView();
1059 } 1055 }
1060} 1056}
1061 1057
1062void KOListView::showCompletedTodos() 1058void KOListView::showCompletedTodos()
1063{ 1059{
1064 mForceShowCompletedTodos = true; 1060 mForceShowCompletedTodos = true;
1065} 1061}
1066void KOListView::addIncidence(Incidence *incidence) 1062void KOListView::addIncidence(Incidence *incidence)
1067{ 1063{
1068 if ( mUidDict.find( incidence->uid() ) ) return; 1064 if ( mUidDict.find( incidence->uid() ) ) return;
1069 1065
1070 // mListView->setFont ( KOPrefs::instance()->mListViewFont ); 1066 // mListView->setFont ( KOPrefs::instance()->mListViewFont );
1071 if ( incidence->typeID() == todoID ) { 1067 if ( incidence->typeID() == todoID ) {
1072 if ( ! mForceShowCompletedTodos ) { 1068 if ( ! mForceShowCompletedTodos ) {
1073 if ( !KOPrefs::instance()->mShowCompletedTodo && ((Todo*)incidence)->isCompleted() ) 1069 if ( !KOPrefs::instance()->mShowCompletedTodo && ((Todo*)incidence)->isCompleted() )
1074 return; 1070 return;
1075 } 1071 }
1076 } 1072 }
1077 mUidDict.insert( incidence->uid(), incidence ); 1073 mUidDict.insert( incidence->uid(), incidence );
1078 KOListViewItem *item = new KOListViewItem( incidence, mListView ); 1074 KOListViewItem *item = new KOListViewItem( incidence, mListView );
1079 ListItemVisitor v(item, mStartDate ); 1075 ListItemVisitor v(item, mStartDate );
1080 if (incidence->accept(v)) { 1076 if (incidence->accept(v)) {
1081 return; 1077 return;
1082 } 1078 }
1083 else delete item; 1079 else delete item;
1084} 1080}
1085 1081
1086void KOListView::showEvents(QPtrList<Event> eventList) 1082void KOListView::showEvents(QPtrList<Event> eventList)
1087{ 1083{