-rw-r--r-- | korganizer/koagenda.cpp | 11 | ||||
-rw-r--r-- | korganizer/koagenda.h | 1 | ||||
-rw-r--r-- | korganizer/koagendaitem.cpp | 34 | ||||
-rw-r--r-- | korganizer/koagendaitem.h | 1 | ||||
-rw-r--r-- | korganizer/koagendaview.cpp | 11 | ||||
-rw-r--r-- | korganizer/koagendaview.h | 1 | ||||
-rw-r--r-- | korganizer/koeventpopupmenu.cpp | 44 | ||||
-rw-r--r-- | korganizer/koeventpopupmenu.h | 4 | ||||
-rw-r--r-- | korganizer/koeventview.cpp | 1 | ||||
-rw-r--r-- | korganizer/kolistview.cpp | 8 |
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 | |||
@@ -399,25 +399,34 @@ void KOAgenda::popupMenu() | |||
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 | 411 | void 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 | } | ||
412 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | 421 | bool 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 ); |
diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h index fb9983e..de6acac 100644 --- a/korganizer/koagenda.h +++ b/korganizer/koagenda.h | |||
@@ -118,24 +118,25 @@ class KOAgenda : public QScrollView | |||
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. */ |
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index a8e0678..a42d07b 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp | |||
@@ -88,68 +88,72 @@ KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool | |||
88 | xPaintCoord = -1; | 88 | xPaintCoord = -1; |
89 | yPaintCoord = -1; | 89 | yPaintCoord = -1; |
90 | } | 90 | } |
91 | QString KOAgendaItem::getWhatsThisText() | 91 | QString 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 | } |
100 | void KOAgendaItem::init ( Incidence *incidence, QDate qd ) | 100 | |
101 | void 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 | } | ||
139 | void 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(); |
diff --git a/korganizer/koagendaitem.h b/korganizer/koagendaitem.h index d1b1940..dc2316a 100644 --- a/korganizer/koagendaitem.h +++ b/korganizer/koagendaitem.h | |||
@@ -100,24 +100,25 @@ class KOAgendaItem : public QWidget | |||
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; |
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index c851ab5..a42227c 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -465,24 +465,29 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : | |||
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()); |
@@ -579,25 +584,29 @@ void KOAgendaView::toggleAllDay() | |||
579 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) | 584 | void 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 | 596 | void KOAgendaView::categoryChanged(Incidence * inc) | |
597 | { | ||
598 | mAgenda->categoryChanged( inc ); | ||
599 | mAllDayAgenda->categoryChanged( inc ); | ||
600 | } | ||
592 | KOAgendaView::~KOAgendaView() | 601 | KOAgendaView::~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 | } |
599 | void KOAgendaView::resizeEvent( QResizeEvent* e ) | 608 | void 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(); |
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h index cc953fc..a1cf308 100644 --- a/korganizer/koagendaview.h +++ b/korganizer/koagendaview.h | |||
@@ -230,24 +230,25 @@ class KOAgendaView : public KOEventView { | |||
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); |
diff --git a/korganizer/koeventpopupmenu.cpp b/korganizer/koeventpopupmenu.cpp index 17ef81e..90caaf4 100644 --- a/korganizer/koeventpopupmenu.cpp +++ b/korganizer/koeventpopupmenu.cpp | |||
@@ -21,76 +21,114 @@ | |||
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 | ||
34 | KOEventPopupMenu::KOEventPopupMenu() | 35 | KOEventPopupMenu::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 | } |
60 | void KOEventPopupMenu::enableDefault( bool enable ) | 67 | void 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 | ||
77 | void 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 | } | ||
92 | void 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 | } | ||
70 | void KOEventPopupMenu::showIncidencePopup(Incidence *incidence) | 110 | void 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 | ||
88 | void KOEventPopupMenu::addAdditionalItem(const QIconSet &icon,const QString &text, | 126 | void 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); |
diff --git a/korganizer/koeventpopupmenu.h b/korganizer/koeventpopupmenu.h index 8fb51fa..3d8b595 100644 --- a/korganizer/koeventpopupmenu.h +++ b/korganizer/koeventpopupmenu.h | |||
@@ -45,32 +45,36 @@ class KOEventPopupMenu : public QPopupMenu { | |||
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 | |||
@@ -68,25 +68,24 @@ KOEventPopupMenu *KOEventView::eventPopup() | |||
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 | ||
76 | void KOEventView::showIncidencePopup(QPopupMenu *popup,Incidence *event) | 76 | void 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 | ||
85 | void KOEventView::popupShow() | 84 | void KOEventView::popupShow() |
86 | { | 85 | { |
87 | emit showIncidenceSignal(mCurrentIncidence); | 86 | emit showIncidenceSignal(mCurrentIncidence); |
88 | } | 87 | } |
89 | 88 | ||
90 | //--------------------------------------------------------------------------- | 89 | //--------------------------------------------------------------------------- |
91 | 90 | ||
92 | void KOEventView::popupEdit() | 91 | void KOEventView::popupEdit() |
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index 8f17e6e..43e1113 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp | |||
@@ -226,25 +226,25 @@ bool ListItemVisitor::visit(Journal * j) | |||
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 | ||
250 | KOListView::KOListView(Calendar *calendar, QWidget *parent, | 250 | KOListView::KOListView(Calendar *calendar, QWidget *parent, |
@@ -1002,34 +1002,30 @@ void KOListView::updateConfig() | |||
1002 | 1002 | ||
1003 | } | 1003 | } |
1004 | void KOListView::setStartDate(const QDate &start) | 1004 | void KOListView::setStartDate(const QDate &start) |
1005 | { | 1005 | { |
1006 | mStartDate = start; | 1006 | mStartDate = start; |
1007 | } | 1007 | } |
1008 | 1008 | ||
1009 | void KOListView::showDates(const QDate &start, const QDate &end) | 1009 | void 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 | ||
1029 | void KOListView::addEvents(QPtrList<Event> eventList) | 1025 | void 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 | } |