-rw-r--r-- | korganizer/koagendaitem.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index cead612..7b29ce7 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp | |||
@@ -34,729 +34,732 @@ | |||
34 | #ifndef DESKTOP_VERSION | 34 | #ifndef DESKTOP_VERSION |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | #define AGENDA_ICON_SIZE 5 | 36 | #define AGENDA_ICON_SIZE 5 |
37 | #else | 37 | #else |
38 | #define AGENDA_ICON_SIZE 7 | 38 | #define AGENDA_ICON_SIZE 7 |
39 | #endif | 39 | #endif |
40 | #include <libkcal/icaldrag.h> | 40 | #include <libkcal/icaldrag.h> |
41 | #include <libkcal/vcaldrag.h> | 41 | #include <libkcal/vcaldrag.h> |
42 | #include <libkcal/kincidenceformatter.h> | 42 | #include <libkcal/kincidenceformatter.h> |
43 | extern int globalFlagBlockAgenda; | 43 | extern int globalFlagBlockAgenda; |
44 | extern int globalFlagBlockAgendaItemPaint; | 44 | extern int globalFlagBlockAgendaItemPaint; |
45 | extern int globalFlagBlockAgendaItemUpdate; | 45 | extern int globalFlagBlockAgendaItemUpdate; |
46 | 46 | ||
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | 48 | ||
49 | #include "koagendaitem.h" | 49 | #include "koagendaitem.h" |
50 | //#include "koagendaitem.moc" | 50 | //#include "koagendaitem.moc" |
51 | 51 | ||
52 | 52 | ||
53 | //-------------------------------------------------------------------------- | 53 | //-------------------------------------------------------------------------- |
54 | 54 | ||
55 | QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; | 55 | QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; |
56 | 56 | ||
57 | //-------------------------------------------------------------------------- | 57 | //-------------------------------------------------------------------------- |
58 | 58 | ||
59 | class KOAgendaItemWhatsThis :public QWhatsThis | 59 | class KOAgendaItemWhatsThis :public QWhatsThis |
60 | { | 60 | { |
61 | public: | 61 | public: |
62 | KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; | 62 | KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; |
63 | 63 | ||
64 | protected: | 64 | protected: |
65 | virtual QString text( const QPoint& ) | 65 | virtual QString text( const QPoint& ) |
66 | { | 66 | { |
67 | return _view->getWhatsThisText() ; | 67 | return _view->getWhatsThisText() ; |
68 | } | 68 | } |
69 | private: | 69 | private: |
70 | KOAgendaItem * _view; | 70 | KOAgendaItem * _view; |
71 | }; | 71 | }; |
72 | 72 | ||
73 | KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, | 73 | KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, |
74 | const char *name,WFlags) : | 74 | const char *name,WFlags) : |
75 | QWidget(parent, name), mIncidence(incidence), mDate(qd) | 75 | QWidget(parent, name), mIncidence(incidence), mDate(qd) |
76 | { | 76 | { |
77 | #ifndef DESKTOP_VERSION | 77 | #ifndef DESKTOP_VERSION |
78 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); | 78 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); |
79 | #endif | 79 | #endif |
80 | new KOAgendaItemWhatsThis(this); | 80 | new KOAgendaItemWhatsThis(this); |
81 | int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase | 81 | int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase |
82 | setWFlags ( wflags); | 82 | setWFlags ( wflags); |
83 | mAllDay = allday; | 83 | mAllDay = allday; |
84 | init ( incidence, qd ); | 84 | init ( incidence, qd ); |
85 | setMouseTracking(true); | 85 | setMouseTracking(true); |
86 | //setAcceptDrops(true); | 86 | //setAcceptDrops(true); |
87 | xPaintCoord = -1; | 87 | xPaintCoord = -1; |
88 | yPaintCoord = -1; | 88 | yPaintCoord = -1; |
89 | } | 89 | } |
90 | QString KOAgendaItem::getWhatsThisText() | 90 | QString KOAgendaItem::getWhatsThisText() |
91 | { | 91 | { |
92 | if ( mIncidence ) | 92 | if ( mIncidence ) |
93 | return KIncidenceFormatter::instance()->getFormattedText( mIncidence, | 93 | return KIncidenceFormatter::instance()->getFormattedText( mIncidence, |
94 | KOPrefs::instance()->mWTshowDetails, | 94 | KOPrefs::instance()->mWTshowDetails, |
95 | KOPrefs::instance()->mWTshowCreated, | 95 | KOPrefs::instance()->mWTshowCreated, |
96 | KOPrefs::instance()->mWTshowChanged); | 96 | KOPrefs::instance()->mWTshowChanged); |
97 | return "KOAgendaItem::getWhatsThisText()::internal error"; | 97 | return "KOAgendaItem::getWhatsThisText()::internal error"; |
98 | } | 98 | } |
99 | void KOAgendaItem::init ( Incidence *incidence, QDate qd ) | 99 | void KOAgendaItem::init ( Incidence *incidence, QDate qd ) |
100 | { | 100 | { |
101 | mIncidence = incidence; | 101 | mIncidence = incidence; |
102 | mDate = qd; | 102 | mDate = qd; |
103 | mFirstMultiItem = 0; | 103 | mFirstMultiItem = 0; |
104 | mNextMultiItem = 0; | 104 | mNextMultiItem = 0; |
105 | mLastMultiItem = 0; | 105 | mLastMultiItem = 0; |
106 | computeText(); | 106 | computeText(); |
107 | 107 | ||
108 | if ( (incidence->type() == "Todo") && | 108 | if ( (incidence->type() == "Todo") && |
109 | ( !((static_cast<Todo*>(incidence))->isCompleted()) && | 109 | ( !((static_cast<Todo*>(incidence))->isCompleted()) && |
110 | ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { | 110 | ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { |
111 | if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) | 111 | if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) |
112 | mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; | 112 | mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; |
113 | else | 113 | else |
114 | mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; | 114 | mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; |
115 | } | 115 | } |
116 | else { | 116 | else { |
117 | QStringList categories = mIncidence->categories(); | 117 | QStringList categories = mIncidence->categories(); |
118 | QString cat = categories.first(); | 118 | QString cat = categories.first(); |
119 | if (cat.isEmpty()) { | 119 | if (cat.isEmpty()) { |
120 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) | 120 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) |
121 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; | 121 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; |
122 | else | 122 | else |
123 | mBackgroundColor =KOPrefs::instance()->mEventColor; | 123 | mBackgroundColor =KOPrefs::instance()->mEventColor; |
124 | } else { | 124 | } else { |
125 | mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); | 125 | mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); |
126 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) { | 126 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) { |
127 | if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) | 127 | if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) |
128 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; | 128 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; |
129 | } | 129 | } |
130 | } | 130 | } |
131 | 131 | ||
132 | } | 132 | } |
133 | mColorGroup = QColorGroup( mBackgroundColor.light(), | 133 | mColorGroup = QColorGroup( mBackgroundColor.light(), |
134 | mBackgroundColor.dark(),mBackgroundColor.light(), | 134 | mBackgroundColor.dark(),mBackgroundColor.light(), |
135 | mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; | 135 | mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; |
136 | setBackgroundColor( mBackgroundColor ); | 136 | setBackgroundColor( mBackgroundColor ); |
137 | 137 | ||
138 | setCellXY(0,0,1); | 138 | setCellXY(0,0,1); |
139 | setCellXWidth(0); | 139 | setCellXWidth(0); |
140 | setSubCell(0); | 140 | setSubCell(0); |
141 | setSubCells(1); | 141 | setSubCells(1); |
142 | setMultiItem(0,0,0); | 142 | setMultiItem(0,0,0); |
143 | startMove(); | 143 | startMove(); |
144 | mSelected = true; | 144 | mSelected = true; |
145 | select(false); | 145 | select(false); |
146 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); | 146 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); |
147 | mFontPixelSize = fontinf.height();; | 147 | mFontPixelSize = fontinf.height();; |
148 | hide(); | 148 | hide(); |
149 | xPaintCoord = -1; | 149 | xPaintCoord = -1; |
150 | yPaintCoord = -1; | 150 | yPaintCoord = -1; |
151 | } | 151 | } |
152 | 152 | ||
153 | 153 | ||
154 | KOAgendaItem::~KOAgendaItem() | 154 | KOAgendaItem::~KOAgendaItem() |
155 | { | 155 | { |
156 | // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); | 156 | // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); |
157 | 157 | ||
158 | } | 158 | } |
159 | 159 | ||
160 | void KOAgendaItem::recreateIncidence() | 160 | void KOAgendaItem::recreateIncidence() |
161 | { | 161 | { |
162 | #if 0 | 162 | #if 0 |
163 | Incidence* newInc = mIncidence->clone(); | 163 | Incidence* newInc = mIncidence->clone(); |
164 | newInc->recreate(); | 164 | newInc->recreate(); |
165 | if ( mIncidence->doesRecur() ) { | 165 | if ( mIncidence->doesRecur() ) { |
166 | mIncidence->addExDate( mDate ); | 166 | mIncidence->addExDate( mDate ); |
167 | newInc->recurrence()->unsetRecurs(); | 167 | newInc->recurrence()->unsetRecurs(); |
168 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); | 168 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); |
169 | QTime tim = mIncidence->dtStart().time(); | 169 | QTime tim = mIncidence->dtStart().time(); |
170 | newInc->setDtStart( QDateTime(mDate, tim) ); | 170 | newInc->setDtStart( QDateTime(mDate, tim) ); |
171 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); | 171 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); |
172 | } | 172 | } |
173 | #endif | 173 | #endif |
174 | mIncidence = mIncidence->recreateCloneException( mDate ); | 174 | mIncidence = mIncidence->recreateCloneException( mDate ); |
175 | } | 175 | } |
176 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) | 176 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) |
177 | { | 177 | { |
178 | int size = AGENDA_ICON_SIZE; | 178 | int size = AGENDA_ICON_SIZE; |
179 | 179 | ||
180 | int yOff = 0; | 180 | int yOff = 0; |
181 | int xOff = 0; | 181 | int xOff = 0; |
182 | int x = pos().x() +3; | 182 | int x = pos().x() +3; |
183 | int y; | 183 | int y; |
184 | if ( mAllDay ) | 184 | if ( mAllDay ) |
185 | y = pos().y()+3; | 185 | y = pos().y()+3; |
186 | else | 186 | else |
187 | y = mCellYTop * ( height() / cellHeight() ) +3; | 187 | y = mCellYTop * ( height() / cellHeight() ) +3; |
188 | if (mIncidence->cancelled()) { | 188 | if (mIncidence->cancelled()) { |
189 | int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; | 189 | int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; |
190 | int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; | 190 | int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; |
191 | p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); | 191 | p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); |
192 | p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); | 192 | p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); |
193 | if ( horLayout ) | 193 | if ( horLayout ) |
194 | ++xOff; | 194 | ++xOff; |
195 | else | 195 | else |
196 | ++yOff; | 196 | ++yOff; |
197 | } | 197 | } |
198 | if (mIncidence->isAlarmEnabled()) { | 198 | if (mIncidence->isAlarmEnabled()) { |
199 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); | 199 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); |
200 | if ( horLayout ) | 200 | if ( horLayout ) |
201 | ++xOff; | 201 | ++xOff; |
202 | else | 202 | else |
203 | ++yOff; | 203 | ++yOff; |
204 | } | 204 | } |
205 | if (mIncidence->recurrence()->doesRecur()) { | 205 | if (mIncidence->recurrence()->doesRecur()) { |
206 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); | 206 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); |
207 | if ( horLayout ) | 207 | if ( horLayout ) |
208 | ++xOff; | 208 | ++xOff; |
209 | else | 209 | else |
210 | ++yOff; | 210 | ++yOff; |
211 | } | 211 | } |
212 | if (mIncidence->description().length() > 0) { | 212 | if (mIncidence->description().length() > 0) { |
213 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); | 213 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); |
214 | if ( horLayout ) | 214 | if ( horLayout ) |
215 | ++xOff; | 215 | ++xOff; |
216 | else | 216 | else |
217 | ++yOff; | 217 | ++yOff; |
218 | } | 218 | } |
219 | if (mIncidence->isReadOnly()) { | 219 | if (mIncidence->isReadOnly()) { |
220 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); | 220 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); |
221 | if ( horLayout ) | 221 | if ( horLayout ) |
222 | ++xOff; | 222 | ++xOff; |
223 | else | 223 | else |
224 | ++yOff; | 224 | ++yOff; |
225 | } | 225 | } |
226 | 226 | ||
227 | if (mIncidence->attendeeCount()>0) { | 227 | if (mIncidence->attendeeCount()>0) { |
228 | 228 | ||
229 | if (mIncidence->organizer() == KOPrefs::instance()->email()) { | 229 | if (mIncidence->organizer() == KOPrefs::instance()->email()) { |
230 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); | 230 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); |
231 | if ( horLayout ) | 231 | if ( horLayout ) |
232 | ++xOff; | 232 | ++xOff; |
233 | else | 233 | else |
234 | ++yOff; | 234 | ++yOff; |
235 | } else { | 235 | } else { |
236 | Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 236 | Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
237 | if (me!=0) { | 237 | if (me!=0) { |
238 | 238 | ||
239 | 239 | ||
240 | } else { | 240 | } else { |
241 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); | 241 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); |
242 | if ( horLayout ) | 242 | if ( horLayout ) |
243 | ++xOff; | 243 | ++xOff; |
244 | else | 244 | else |
245 | ++yOff; | 245 | ++yOff; |
246 | 246 | ||
247 | } | 247 | } |
248 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); | 248 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); |
249 | if ( horLayout ) | 249 | if ( horLayout ) |
250 | ++xOff; | 250 | ++xOff; |
251 | else | 251 | else |
252 | ++yOff; | 252 | ++yOff; |
253 | 253 | ||
254 | } | 254 | } |
255 | 255 | ||
256 | } | 256 | } |
257 | return ( yOff || xOff ); | 257 | return ( yOff || xOff ); |
258 | } | 258 | } |
259 | 259 | ||
260 | 260 | ||
261 | void KOAgendaItem::select(bool selected) | 261 | void KOAgendaItem::select(bool selected) |
262 | { | 262 | { |
263 | //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); | 263 | //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); |
264 | if (mSelected == selected) return; | 264 | if (mSelected == selected) return; |
265 | mSelected = selected; | 265 | mSelected = selected; |
266 | if ( ! isVisible() ) | 266 | if ( ! isVisible() ) |
267 | return; | 267 | return; |
268 | if ( firstMultiItem() ) | 268 | if ( firstMultiItem() ) |
269 | firstMultiItem()->select( selected ); | 269 | firstMultiItem()->select( selected ); |
270 | if ( !firstMultiItem() && nextMultiItem() ) { | 270 | if ( !firstMultiItem() && nextMultiItem() ) { |
271 | KOAgendaItem * placeItem = nextMultiItem(); | 271 | KOAgendaItem * placeItem = nextMultiItem(); |
272 | while ( placeItem ) { | 272 | while ( placeItem ) { |
273 | placeItem->select( selected ); | 273 | placeItem->select( selected ); |
274 | placeItem = placeItem->nextMultiItem(); | 274 | placeItem = placeItem->nextMultiItem(); |
275 | } | 275 | } |
276 | } | 276 | } |
277 | globalFlagBlockAgendaItemUpdate = 0; | 277 | globalFlagBlockAgendaItemUpdate = 0; |
278 | paintMe( selected ); | 278 | paintMe( selected ); |
279 | globalFlagBlockAgendaItemUpdate = 1; | 279 | globalFlagBlockAgendaItemUpdate = 1; |
280 | repaint( false ); | 280 | repaint( false ); |
281 | } | 281 | } |
282 | 282 | ||
283 | 283 | ||
284 | /* | 284 | /* |
285 | The eventFilter has to filter the mouse events of the agenda item childs. The | 285 | The eventFilter has to filter the mouse events of the agenda item childs. The |
286 | events are fed into the event handling method of KOAgendaItem. This allows the | 286 | events are fed into the event handling method of KOAgendaItem. This allows the |
287 | KOAgenda to handle the KOAgendaItems by using an eventFilter. | 287 | KOAgenda to handle the KOAgendaItems by using an eventFilter. |
288 | */ | 288 | */ |
289 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) | 289 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) |
290 | { | 290 | { |
291 | if (e->type() == QEvent::MouseButtonPress || | 291 | if (e->type() == QEvent::MouseButtonPress || |
292 | e->type() == QEvent::MouseButtonDblClick || | 292 | e->type() == QEvent::MouseButtonDblClick || |
293 | e->type() == QEvent::MouseButtonRelease || | 293 | e->type() == QEvent::MouseButtonRelease || |
294 | e->type() == QEvent::MouseMove) { | 294 | e->type() == QEvent::MouseMove) { |
295 | QMouseEvent *me = (QMouseEvent *)e; | 295 | QMouseEvent *me = (QMouseEvent *)e; |
296 | QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> | 296 | QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> |
297 | mapToGlobal(me->pos())); | 297 | mapToGlobal(me->pos())); |
298 | QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); | 298 | QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); |
299 | return event(&returnEvent); | 299 | return event(&returnEvent); |
300 | } else { | 300 | } else { |
301 | return false; | 301 | return false; |
302 | } | 302 | } |
303 | } | 303 | } |
304 | void KOAgendaItem::repaintMe( ) | 304 | void KOAgendaItem::repaintMe( ) |
305 | { | 305 | { |
306 | paintMe ( mSelected ); | 306 | paintMe ( mSelected ); |
307 | } | 307 | } |
308 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) | 308 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) |
309 | { | 309 | { |
310 | if ( globalFlagBlockAgendaItemUpdate && ! selected) | 310 | if ( globalFlagBlockAgendaItemUpdate && ! selected) |
311 | return; | 311 | return; |
312 | QPainter pa; | 312 | QPainter pa; |
313 | 313 | ||
314 | if ( mSelected ) { | 314 | if ( mSelected ) { |
315 | pa.begin( paintPixSel() ); | 315 | pa.begin( paintPixSel() ); |
316 | } else { | 316 | } else { |
317 | if ( mAllDay ) | 317 | if ( mAllDay ) |
318 | pa.begin( paintPixAllday() ); | 318 | pa.begin( paintPixAllday() ); |
319 | else | 319 | else |
320 | pa.begin( paintPix() ); | 320 | pa.begin( paintPix() ); |
321 | } | 321 | } |
322 | int x, yy, w, h; | 322 | int x, yy, w, h; |
323 | float nfh = 7.0; | 323 | float nfh = 7.0; |
324 | x = pos().x(); w = width(); h = height (); | 324 | x = pos().x(); w = width(); h = height (); |
325 | if ( mAllDay ) | 325 | if ( mAllDay ) |
326 | yy = y(); | 326 | yy = y(); |
327 | else | 327 | else |
328 | yy = mCellYTop * ( height() / cellHeight() ); | 328 | yy = mCellYTop * ( height() / cellHeight() ); |
329 | xPaintCoord= x; | 329 | xPaintCoord= x; |
330 | yPaintCoord = yy; | 330 | yPaintCoord = yy; |
331 | wPaintCoord = width(); | 331 | wPaintCoord = width(); |
332 | hPaintCoord = height(); | 332 | hPaintCoord = height(); |
333 | //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); | 333 | //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); |
334 | if ( paint == 0 ) | 334 | if ( paint == 0 ) |
335 | paint = &pa; | 335 | paint = &pa; |
336 | bool horLayout = ( w < h ); | 336 | bool horLayout = ( w < h ); |
337 | int maxhei = mFontPixelSize+4; | 337 | int maxhei = mFontPixelSize+4; |
338 | if ( horLayout ) | 338 | if ( horLayout ) |
339 | maxhei += AGENDA_ICON_SIZE -4; | 339 | maxhei += AGENDA_ICON_SIZE -4; |
340 | bool small = ( h < maxhei ); | 340 | bool small = ( h < maxhei ); |
341 | if ( ! small ) | 341 | if ( ! small ) |
342 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); | 342 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); |
343 | else { | 343 | else { |
344 | QFont f = KOPrefs::instance()->mAgendaViewFont; | 344 | QFont f = KOPrefs::instance()->mAgendaViewFont; |
345 | f.setBold( false ); | 345 | f.setBold( false ); |
346 | int fh = f.pointSize(); | 346 | int fh = f.pointSize(); |
347 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; | 347 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; |
348 | if ( nfh < 6 ) | 348 | if ( nfh < 6 ) |
349 | nfh = 6; | 349 | nfh = 6; |
350 | f.setPointSize( nfh ); | 350 | f.setPointSize( nfh ); |
351 | paint->setFont(f); | 351 | paint->setFont(f); |
352 | } | 352 | } |
353 | paint->fillRect ( x, yy, w, h, mBackgroundColor ); | 353 | paint->fillRect ( x, yy, w, h, mBackgroundColor ); |
354 | static const QPixmap completedPxmp = SmallIcon("greenhook16"); | 354 | static const QPixmap completedPxmp = SmallIcon("greenhook16"); |
355 | static const QPixmap overduePxmp = SmallIcon("redcross16"); | 355 | static const QPixmap overduePxmp = SmallIcon("redcross16"); |
356 | if ( mIncidence->type() == "Todo" ) { | 356 | if ( mIncidence->type() == "Todo" ) { |
357 | Todo* tempTodo = static_cast<Todo*>(mIncidence); | 357 | Todo* tempTodo = static_cast<Todo*>(mIncidence); |
358 | int xx = pos().x()+(width()-completedPxmp.width()-3 ); | 358 | int xx = pos().x()+(width()-completedPxmp.width()-3 ); |
359 | int yyy = yy+3; | 359 | int yyy = yy+3; |
360 | if ( tempTodo->isCompleted() ) | 360 | if ( tempTodo->isCompleted() ) |
361 | paint->drawPixmap ( xx, yyy, completedPxmp ); | 361 | paint->drawPixmap ( xx, yyy, completedPxmp ); |
362 | else { | 362 | else { |
363 | paint->drawPixmap ( xx, yyy, overduePxmp ); | 363 | paint->drawPixmap ( xx, yyy, overduePxmp ); |
364 | 364 | ||
365 | } | 365 | } |
366 | } | 366 | } |
367 | bool addIcon = false; | 367 | bool addIcon = false; |
368 | if ( ! small || w > 3 * h || h > 3* w ) | 368 | if ( ! small || w > 3 * h || h > 3* w ) |
369 | addIcon = updateIcons( paint, horLayout ); | 369 | addIcon = updateIcons( paint, horLayout ); |
370 | 370 | ||
371 | qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); | 371 | qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); |
372 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); | 372 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); |
373 | if ( ! small ) { | 373 | if ( ! small ) { |
374 | x += 3; yy += 3;w -= 6; h-= 5; | 374 | x += 3; yy += 3;w -= 6; h-= 5; |
375 | } else { | 375 | } else { |
376 | x += 2; yy += 1;w -= 4; h-= 4; | 376 | x += 2; yy += 1;w -= 4; h-= 4; |
377 | if ( nfh < 6.01 ) { | 377 | if ( nfh < 6.01 ) { |
378 | yy -= 2; | 378 | yy -= 2; |
379 | h += 4; | 379 | h += 4; |
380 | } | 380 | } |
381 | else | 381 | else |
382 | if ( nfh < h -2 ) | 382 | if ( nfh < h -2 ) |
383 | ++yy; | 383 | ++yy; |
384 | } | 384 | } |
385 | int align; | 385 | int align; |
386 | #ifndef DESKTOP_VERSION | 386 | #ifndef DESKTOP_VERSION |
387 | align = ( AlignLeft|WordBreak|AlignTop); | 387 | align = ( AlignLeft|WordBreak|AlignTop); |
388 | #else | 388 | #else |
389 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); | 389 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); |
390 | #endif | 390 | #endif |
391 | if ( addIcon ) { | 391 | if ( addIcon ) { |
392 | if ( ! horLayout ) { | 392 | if ( ! horLayout ) { |
393 | x += AGENDA_ICON_SIZE+3; | 393 | x += AGENDA_ICON_SIZE+3; |
394 | w -= (AGENDA_ICON_SIZE+3); | 394 | w -= (AGENDA_ICON_SIZE+3); |
395 | } | 395 | } |
396 | else { | 396 | else { |
397 | yy+= AGENDA_ICON_SIZE+2; | 397 | yy+= AGENDA_ICON_SIZE+2; |
398 | h -=(AGENDA_ICON_SIZE+3); | 398 | h -=(AGENDA_ICON_SIZE+3); |
399 | } | 399 | } |
400 | } | 400 | } |
401 | int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); | 401 | int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); |
402 | if ( colsum < 250 ) | 402 | if ( colsum < 250 ) |
403 | paint->setPen ( white); | 403 | paint->setPen ( white); |
404 | if ( x < 0 ) { | 404 | if ( x < 0 ) { |
405 | w = w+x-3; | 405 | w = w+x-3; |
406 | x = 3; | 406 | x = 3; |
407 | if ( w > parentWidget()->width() ){ | 407 | if ( w > parentWidget()->width() ){ |
408 | w = parentWidget()->width() - 6; | 408 | w = parentWidget()->width() - 6; |
409 | #ifndef DESKTOP_VERSION | 409 | #ifndef DESKTOP_VERSION |
410 | align = ( AlignCenter|WordBreak); | 410 | align = ( AlignCenter|WordBreak); |
411 | #else | 411 | #else |
412 | align = ( AlignCenter|BreakAnywhere|WordBreak); | 412 | align = ( AlignCenter|BreakAnywhere|WordBreak); |
413 | #endif | 413 | #endif |
414 | 414 | ||
415 | } | 415 | } |
416 | } | 416 | } |
417 | QRect dr; | 417 | QRect dr; |
418 | if ( w + x > parentWidget()->width() ) | ||
419 | w = parentWidget()->width()-x; | ||
418 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); | 420 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); |
421 | //qDebug("%d %d %d %d ", x, yy, w, h ); | ||
419 | if ( mIncidence->cancelled() ){ | 422 | if ( mIncidence->cancelled() ){ |
420 | if ( ! small ) { | 423 | if ( ! small ) { |
421 | QFontMetrics fm ( paint->font() ); | 424 | QFontMetrics fm ( paint->font() ); |
422 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); | 425 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); |
423 | } | 426 | } |
424 | 427 | ||
425 | } | 428 | } |
426 | pa.end(); | 429 | pa.end(); |
427 | 430 | ||
428 | } | 431 | } |
429 | void KOAgendaItem::resizePixmap( int w , int h ) | 432 | void KOAgendaItem::resizePixmap( int w , int h ) |
430 | { | 433 | { |
431 | paintPix()->resize( w, h ); | 434 | paintPix()->resize( w, h ); |
432 | paintPixSel()->resize( w, h ); | 435 | paintPixSel()->resize( w, h ); |
433 | 436 | ||
434 | } | 437 | } |
435 | QPixmap * KOAgendaItem::paintPix() | 438 | QPixmap * KOAgendaItem::paintPix() |
436 | { | 439 | { |
437 | static QPixmap* mPaintPix = 0; | 440 | static QPixmap* mPaintPix = 0; |
438 | if ( ! mPaintPix ) | 441 | if ( ! mPaintPix ) |
439 | mPaintPix = new QPixmap(1,1); | 442 | mPaintPix = new QPixmap(1,1); |
440 | return mPaintPix ; | 443 | return mPaintPix ; |
441 | } | 444 | } |
442 | QPixmap * KOAgendaItem::paintPixAllday() | 445 | QPixmap * KOAgendaItem::paintPixAllday() |
443 | { | 446 | { |
444 | static QPixmap* mPaintPixA = 0; | 447 | static QPixmap* mPaintPixA = 0; |
445 | if ( ! mPaintPixA ) | 448 | if ( ! mPaintPixA ) |
446 | mPaintPixA = new QPixmap(1,1); | 449 | mPaintPixA = new QPixmap(1,1); |
447 | return mPaintPixA ; | 450 | return mPaintPixA ; |
448 | } | 451 | } |
449 | QPixmap * KOAgendaItem::paintPixSel() | 452 | QPixmap * KOAgendaItem::paintPixSel() |
450 | { | 453 | { |
451 | static QPixmap* mPaintPixSel = 0; | 454 | static QPixmap* mPaintPixSel = 0; |
452 | if ( ! mPaintPixSel ) | 455 | if ( ! mPaintPixSel ) |
453 | mPaintPixSel = new QPixmap(1,1); | 456 | mPaintPixSel = new QPixmap(1,1); |
454 | return mPaintPixSel ; | 457 | return mPaintPixSel ; |
455 | } | 458 | } |
456 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) | 459 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) |
457 | { | 460 | { |
458 | 461 | ||
459 | if ( globalFlagBlockAgendaItemPaint ) | 462 | if ( globalFlagBlockAgendaItemPaint ) |
460 | return; | 463 | return; |
461 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) | 464 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) |
462 | return; | 465 | return; |
463 | int yy; | 466 | int yy; |
464 | if ( mAllDay ) | 467 | if ( mAllDay ) |
465 | yy = y(); | 468 | yy = y(); |
466 | else | 469 | else |
467 | yy = mCellYTop * ( height() / cellHeight() ); | 470 | yy = mCellYTop * ( height() / cellHeight() ); |
468 | int xx = x(); | 471 | int xx = x(); |
469 | if ( xPaintCoord != xx || yPaintCoord != yy || | 472 | if ( xPaintCoord != xx || yPaintCoord != yy || |
470 | wPaintCoord != width() || hPaintCoord != height()) { | 473 | wPaintCoord != width() || hPaintCoord != height()) { |
471 | xPaintCoord= xx; | 474 | xPaintCoord= xx; |
472 | yPaintCoord = yy; | 475 | yPaintCoord = yy; |
473 | wPaintCoord = width(); | 476 | wPaintCoord = width(); |
474 | hPaintCoord = height(); | 477 | hPaintCoord = height(); |
475 | globalFlagBlockAgendaItemUpdate = 0; | 478 | globalFlagBlockAgendaItemUpdate = 0; |
476 | paintMe( mSelected ); | 479 | paintMe( mSelected ); |
477 | //qDebug("calling paintMe "); | 480 | //qDebug("calling paintMe "); |
478 | globalFlagBlockAgendaItemUpdate = 1; | 481 | globalFlagBlockAgendaItemUpdate = 1; |
479 | } | 482 | } |
480 | int rx, ry, rw, rh; | 483 | int rx, ry, rw, rh; |
481 | rx = e->rect().x(); | 484 | rx = e->rect().x(); |
482 | ry = e->rect().y(); | 485 | ry = e->rect().y(); |
483 | rw = e->rect().width(); | 486 | rw = e->rect().width(); |
484 | rh = e->rect().height(); | 487 | rh = e->rect().height(); |
485 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); | 488 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); |
486 | 489 | ||
487 | QPixmap* paintFrom ; | 490 | QPixmap* paintFrom ; |
488 | if ( mSelected ) { | 491 | if ( mSelected ) { |
489 | paintFrom = paintPixSel(); | 492 | paintFrom = paintPixSel(); |
490 | } else { | 493 | } else { |
491 | if ( mAllDay ) | 494 | if ( mAllDay ) |
492 | paintFrom = paintPixAllday(); | 495 | paintFrom = paintPixAllday(); |
493 | else | 496 | else |
494 | paintFrom = paintPix(); | 497 | paintFrom = paintPix(); |
495 | } | 498 | } |
496 | bitBlt (this, rx, ry, paintFrom, x()+rx ,yPaintCoord+ry, rw, rh ,CopyROP); | 499 | bitBlt (this, rx, ry, paintFrom, x()+rx ,yPaintCoord+ry, rw, rh ,CopyROP); |
497 | } | 500 | } |
498 | void KOAgendaItem::computeText() | 501 | void KOAgendaItem::computeText() |
499 | { | 502 | { |
500 | 503 | ||
501 | mDisplayedText = mIncidence->summary(); | 504 | mDisplayedText = mIncidence->summary(); |
502 | if ( (mIncidence->type() == "Todo") ) { | 505 | if ( (mIncidence->type() == "Todo") ) { |
503 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { | 506 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { |
504 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) | 507 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) |
505 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; | 508 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; |
506 | else if ( !(mIncidence->doesFloat())) | 509 | else if ( !(mIncidence->doesFloat())) |
507 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; | 510 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; |
508 | } | 511 | } |
509 | } else { | 512 | } else { |
510 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) | 513 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) |
511 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; | 514 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; |
512 | 515 | ||
513 | if ( mAllDay ) { | 516 | if ( mAllDay ) { |
514 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { | 517 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { |
515 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; | 518 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; |
516 | } | 519 | } |
517 | } | 520 | } |
518 | 521 | ||
519 | } | 522 | } |
520 | 523 | ||
521 | if ( !mIncidence->location().isEmpty() ) { | 524 | if ( !mIncidence->location().isEmpty() ) { |
522 | if ( mAllDay ) | 525 | if ( mAllDay ) |
523 | mDisplayedText += " ("; | 526 | mDisplayedText += " ("; |
524 | else | 527 | else |
525 | mDisplayedText += "\n("; | 528 | mDisplayedText += "\n("; |
526 | mDisplayedText += mIncidence->location() +")"; | 529 | mDisplayedText += mIncidence->location() +")"; |
527 | } | 530 | } |
528 | 531 | ||
529 | QString tipText = mIncidence->summary(); | 532 | QString tipText = mIncidence->summary(); |
530 | if ( !mIncidence->doesFloat() ) { | 533 | if ( !mIncidence->doesFloat() ) { |
531 | if ( mIncidence->type() == "Event" ) { | 534 | if ( mIncidence->type() == "Event" ) { |
532 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { | 535 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { |
533 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); | 536 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); |
534 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); | 537 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); |
535 | } | 538 | } |
536 | else { | 539 | else { |
537 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); | 540 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); |
538 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); | 541 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); |
539 | } | 542 | } |
540 | } | 543 | } |
541 | else if ( mIncidence->type() == "Todo" ) { | 544 | else if ( mIncidence->type() == "Todo" ) { |
542 | if (mIncidence->hasStartDate()) | 545 | if (mIncidence->hasStartDate()) |
543 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); | 546 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); |
544 | if (((Todo*)mIncidence)->hasDueDate()) | 547 | if (((Todo*)mIncidence)->hasDueDate()) |
545 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); | 548 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); |
546 | } | 549 | } |
547 | } else if ( mIncidence->type() == "Todo" ) { | 550 | } else if ( mIncidence->type() == "Todo" ) { |
548 | if (mIncidence->hasStartDate()) | 551 | if (mIncidence->hasStartDate()) |
549 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); | 552 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); |
550 | if (((Todo*)mIncidence)->hasDueDate()) | 553 | if (((Todo*)mIncidence)->hasDueDate()) |
551 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); | 554 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); |
552 | } | 555 | } |
553 | 556 | ||
554 | if (!mIncidence->location().isEmpty()) { | 557 | if (!mIncidence->location().isEmpty()) { |
555 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); | 558 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); |
556 | } | 559 | } |
557 | QToolTip::add(this,tipText,toolTipGroup(),""); | 560 | QToolTip::add(this,tipText,toolTipGroup(),""); |
558 | 561 | ||
559 | } | 562 | } |
560 | void KOAgendaItem::updateItem() | 563 | void KOAgendaItem::updateItem() |
561 | { | 564 | { |
562 | computeText(); | 565 | computeText(); |
563 | 566 | ||
564 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); | 567 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); |
565 | paintMe( mSelected ); | 568 | paintMe( mSelected ); |
566 | repaint( false); | 569 | repaint( false); |
567 | } | 570 | } |
568 | 571 | ||
569 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) | 572 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) |
570 | { | 573 | { |
571 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); | 574 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); |
572 | paintMe( mSelected ); | 575 | paintMe( mSelected ); |
573 | repaint( false ); | 576 | repaint( false ); |
574 | } | 577 | } |
575 | 578 | ||
576 | /* | 579 | /* |
577 | Return height of item in units of agenda cells | 580 | Return height of item in units of agenda cells |
578 | */ | 581 | */ |
579 | int KOAgendaItem::cellHeight() | 582 | int KOAgendaItem::cellHeight() |
580 | { | 583 | { |
581 | int ret = mCellYBottom - mCellYTop + 1; | 584 | int ret = mCellYBottom - mCellYTop + 1; |
582 | if ( ret <= 0 ) { | 585 | if ( ret <= 0 ) { |
583 | ret = 1; | 586 | ret = 1; |
584 | mCellYBottom = 0; | 587 | mCellYBottom = 0; |
585 | mCellYTop = 0; | 588 | mCellYTop = 0; |
586 | } | 589 | } |
587 | return ret; | 590 | return ret; |
588 | } | 591 | } |
589 | 592 | ||
590 | /* | 593 | /* |
591 | Return height of item in units of agenda cells | 594 | Return height of item in units of agenda cells |
592 | */ | 595 | */ |
593 | int KOAgendaItem::cellWidth() | 596 | int KOAgendaItem::cellWidth() |
594 | { | 597 | { |
595 | return mCellXWidth - mCellX + 1; | 598 | return mCellXWidth - mCellX + 1; |
596 | } | 599 | } |
597 | 600 | ||
598 | void KOAgendaItem::setItemDate(QDate qd) | 601 | void KOAgendaItem::setItemDate(QDate qd) |
599 | { | 602 | { |
600 | mDate = qd; | 603 | mDate = qd; |
601 | } | 604 | } |
602 | 605 | ||
603 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) | 606 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) |
604 | { | 607 | { |
605 | mCellX = X; | 608 | mCellX = X; |
606 | mCellYTop = YTop; | 609 | mCellYTop = YTop; |
607 | mCellYBottom = YBottom; | 610 | mCellYBottom = YBottom; |
608 | } | 611 | } |
609 | 612 | ||
610 | void KOAgendaItem::setCellXWidth(int xwidth) | 613 | void KOAgendaItem::setCellXWidth(int xwidth) |
611 | { | 614 | { |
612 | mCellXWidth = xwidth; | 615 | mCellXWidth = xwidth; |
613 | } | 616 | } |
614 | 617 | ||
615 | void KOAgendaItem::setCellX(int XLeft, int XRight) | 618 | void KOAgendaItem::setCellX(int XLeft, int XRight) |
616 | { | 619 | { |
617 | mCellX = XLeft; | 620 | mCellX = XLeft; |
618 | mCellXWidth = XRight; | 621 | mCellXWidth = XRight; |
619 | } | 622 | } |
620 | 623 | ||
621 | void KOAgendaItem::setCellY(int YTop, int YBottom) | 624 | void KOAgendaItem::setCellY(int YTop, int YBottom) |
622 | { | 625 | { |
623 | mCellYTop = YTop; | 626 | mCellYTop = YTop; |
624 | mCellYBottom = YBottom; | 627 | mCellYBottom = YBottom; |
625 | } | 628 | } |
626 | 629 | ||
627 | void KOAgendaItem::setSubCell(int subCell) | 630 | void KOAgendaItem::setSubCell(int subCell) |
628 | { | 631 | { |
629 | mSubCell = subCell; | 632 | mSubCell = subCell; |
630 | } | 633 | } |
631 | 634 | ||
632 | void KOAgendaItem::setSubCells(int subCells) | 635 | void KOAgendaItem::setSubCells(int subCells) |
633 | { | 636 | { |
634 | mSubCells = subCells; | 637 | mSubCells = subCells; |
635 | } | 638 | } |
636 | 639 | ||
637 | void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, | 640 | void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, |
638 | KOAgendaItem *last) | 641 | KOAgendaItem *last) |
639 | { | 642 | { |
640 | mFirstMultiItem = first; | 643 | mFirstMultiItem = first; |
641 | mNextMultiItem = next; | 644 | mNextMultiItem = next; |
642 | mLastMultiItem = last; | 645 | mLastMultiItem = last; |
643 | } | 646 | } |
644 | 647 | ||
645 | void KOAgendaItem::startMove() | 648 | void KOAgendaItem::startMove() |
646 | { | 649 | { |
647 | mStartCellX = mCellX; | 650 | mStartCellX = mCellX; |
648 | mStartCellXWidth = mCellXWidth; | 651 | mStartCellXWidth = mCellXWidth; |
649 | mStartCellYTop = mCellYTop; | 652 | mStartCellYTop = mCellYTop; |
650 | mStartCellYBottom = mCellYBottom; | 653 | mStartCellYBottom = mCellYBottom; |
651 | } | 654 | } |
652 | 655 | ||
653 | void KOAgendaItem::resetMove() | 656 | void KOAgendaItem::resetMove() |
654 | { | 657 | { |
655 | mCellX = mStartCellX; | 658 | mCellX = mStartCellX; |
656 | mCellXWidth = mStartCellXWidth; | 659 | mCellXWidth = mStartCellXWidth; |
657 | mCellYTop = mStartCellYTop; | 660 | mCellYTop = mStartCellYTop; |
658 | mCellYBottom = mStartCellYBottom; | 661 | mCellYBottom = mStartCellYBottom; |
659 | } | 662 | } |
660 | 663 | ||
661 | void KOAgendaItem::moveRelative(int dx, int dy) | 664 | void KOAgendaItem::moveRelative(int dx, int dy) |
662 | { | 665 | { |
663 | int newX = cellX() + dx; | 666 | int newX = cellX() + dx; |
664 | int newXWidth = cellXWidth() + dx; | 667 | int newXWidth = cellXWidth() + dx; |
665 | int newYTop = cellYTop() + dy; | 668 | int newYTop = cellYTop() + dy; |
666 | int newYBottom = cellYBottom() + dy; | 669 | int newYBottom = cellYBottom() + dy; |
667 | setCellXY(newX,newYTop,newYBottom); | 670 | setCellXY(newX,newYTop,newYBottom); |
668 | setCellXWidth(newXWidth); | 671 | setCellXWidth(newXWidth); |
669 | } | 672 | } |
670 | 673 | ||
671 | void KOAgendaItem::expandTop(int dy) | 674 | void KOAgendaItem::expandTop(int dy) |
672 | { | 675 | { |
673 | int newYTop = cellYTop() + dy; | 676 | int newYTop = cellYTop() + dy; |
674 | int newYBottom = cellYBottom(); | 677 | int newYBottom = cellYBottom(); |
675 | if (newYTop > newYBottom) newYTop = newYBottom; | 678 | if (newYTop > newYBottom) newYTop = newYBottom; |
676 | setCellY(newYTop, newYBottom); | 679 | setCellY(newYTop, newYBottom); |
677 | } | 680 | } |
678 | 681 | ||
679 | void KOAgendaItem::expandBottom(int dy) | 682 | void KOAgendaItem::expandBottom(int dy) |
680 | { | 683 | { |
681 | int newYTop = cellYTop(); | 684 | int newYTop = cellYTop(); |
682 | int newYBottom = cellYBottom() + dy; | 685 | int newYBottom = cellYBottom() + dy; |
683 | if (newYBottom < newYTop) newYBottom = newYTop; | 686 | if (newYBottom < newYTop) newYBottom = newYTop; |
684 | setCellY(newYTop, newYBottom); | 687 | setCellY(newYTop, newYBottom); |
685 | } | 688 | } |
686 | 689 | ||
687 | void KOAgendaItem::expandLeft(int dx) | 690 | void KOAgendaItem::expandLeft(int dx) |
688 | { | 691 | { |
689 | int newX = cellX() + dx; | 692 | int newX = cellX() + dx; |
690 | int newXWidth = cellXWidth(); | 693 | int newXWidth = cellXWidth(); |
691 | if (newX > newXWidth) newX = newXWidth; | 694 | if (newX > newXWidth) newX = newXWidth; |
692 | setCellX(newX,newXWidth); | 695 | setCellX(newX,newXWidth); |
693 | } | 696 | } |
694 | 697 | ||
695 | void KOAgendaItem::expandRight(int dx) | 698 | void KOAgendaItem::expandRight(int dx) |
696 | { | 699 | { |
697 | int newX = cellX(); | 700 | int newX = cellX(); |
698 | int newXWidth = cellXWidth() + dx; | 701 | int newXWidth = cellXWidth() + dx; |
699 | if (newXWidth < newX) newXWidth = newX; | 702 | if (newXWidth < newX) newXWidth = newX; |
700 | setCellX(newX,newXWidth); | 703 | setCellX(newX,newXWidth); |
701 | } | 704 | } |
702 | 705 | ||
703 | QToolTipGroup *KOAgendaItem::toolTipGroup() | 706 | QToolTipGroup *KOAgendaItem::toolTipGroup() |
704 | { | 707 | { |
705 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 708 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
706 | return mToolTipGroup; | 709 | return mToolTipGroup; |
707 | } | 710 | } |
708 | 711 | ||
709 | void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) | 712 | void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) |
710 | { | 713 | { |
711 | #ifndef KORG_NODND | 714 | #ifndef KORG_NODND |
712 | if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || | 715 | if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || |
713 | !QTextDrag::canDecode( e ) ) { | 716 | !QTextDrag::canDecode( e ) ) { |
714 | e->ignore(); | 717 | e->ignore(); |
715 | return; | 718 | return; |
716 | } | 719 | } |
717 | e->accept(); | 720 | e->accept(); |
718 | #endif | 721 | #endif |
719 | } | 722 | } |
720 | 723 | ||
721 | void KOAgendaItem::dropEvent( QDropEvent *e ) | 724 | void KOAgendaItem::dropEvent( QDropEvent *e ) |
722 | { | 725 | { |
723 | #ifndef KORG_NODND | 726 | #ifndef KORG_NODND |
724 | QString text; | 727 | QString text; |
725 | if(QTextDrag::decode(e,text)) | 728 | if(QTextDrag::decode(e,text)) |
726 | { | 729 | { |
727 | kdDebug() << "Dropped : " << text << endl; | 730 | kdDebug() << "Dropped : " << text << endl; |
728 | QStringList emails = QStringList::split(",",text); | 731 | QStringList emails = QStringList::split(",",text); |
729 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 732 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
730 | kdDebug() << " Email: " << (*it) << endl; | 733 | kdDebug() << " Email: " << (*it) << endl; |
731 | int pos = (*it).find("<"); | 734 | int pos = (*it).find("<"); |
732 | QString name = (*it).left(pos); | 735 | QString name = (*it).left(pos); |
733 | QString email = (*it).mid(pos); | 736 | QString email = (*it).mid(pos); |
734 | if (!email.isEmpty()) { | 737 | if (!email.isEmpty()) { |
735 | mIncidence->addAttendee(new Attendee(name,email)); | 738 | mIncidence->addAttendee(new Attendee(name,email)); |
736 | } | 739 | } |
737 | } | 740 | } |
738 | } | 741 | } |
739 | #endif | 742 | #endif |
740 | } | 743 | } |
741 | 744 | ||
742 | 745 | ||
743 | QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() | 746 | QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() |
744 | { | 747 | { |
745 | return mConflictItems; | 748 | return mConflictItems; |
746 | } | 749 | } |
747 | 750 | ||
748 | void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) | 751 | void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) |
749 | { | 752 | { |
750 | mConflictItems = ci; | 753 | mConflictItems = ci; |
751 | KOAgendaItem *item; | 754 | KOAgendaItem *item; |
752 | for ( item=mConflictItems.first(); item != 0; | 755 | for ( item=mConflictItems.first(); item != 0; |
753 | item=mConflictItems.next() ) { | 756 | item=mConflictItems.next() ) { |
754 | item->addConflictItem(this); | 757 | item->addConflictItem(this); |
755 | } | 758 | } |
756 | } | 759 | } |
757 | 760 | ||
758 | void KOAgendaItem::addConflictItem(KOAgendaItem *ci) | 761 | void KOAgendaItem::addConflictItem(KOAgendaItem *ci) |
759 | { | 762 | { |
760 | if (mConflictItems.find(ci)<0) | 763 | if (mConflictItems.find(ci)<0) |
761 | mConflictItems.append(ci); | 764 | mConflictItems.append(ci); |
762 | } | 765 | } |