summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaitem.cpp28
-rw-r--r--korganizer/komonthview.cpp21
2 files changed, 35 insertions, 14 deletions
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index 23afe7a..e545ca8 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -62,747 +62,755 @@ public:
62 KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; 62 KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { };
63 63
64protected: 64protected:
65 virtual QString text( const QPoint& ) 65 virtual QString text( const QPoint& )
66 { 66 {
67 return _view->getWhatsThisText() ; 67 return _view->getWhatsThisText() ;
68 } 68 }
69private: 69private:
70 KOAgendaItem * _view; 70 KOAgendaItem * _view;
71}; 71};
72 72
73KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, 73KOAgendaItem::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 mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this); 80 mKOAgendaItemWhatsThis = 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}
90QString KOAgendaItem::getWhatsThisText() 90QString 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}
99void KOAgendaItem::init ( Incidence *incidence, QDate qd ) 99void 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 mConflictItems.clear(); 138 mConflictItems.clear();
139 setCellXY(0,0,1); 139 setCellXY(0,0,1);
140 setCellXWidth(0); 140 setCellXWidth(0);
141 setSubCell(0); 141 setSubCell(0);
142 setSubCells(1); 142 setSubCells(1);
143 setMultiItem(0,0,0); 143 setMultiItem(0,0,0);
144 startMove(); 144 startMove();
145 mSelected = true; 145 mSelected = true;
146 select(false); 146 select(false);
147 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); 147 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont);
148 mFontPixelSize = fontinf.height();; 148 mFontPixelSize = fontinf.height();;
149 hide(); 149 hide();
150 xPaintCoord = -1; 150 xPaintCoord = -1;
151 yPaintCoord = -1; 151 yPaintCoord = -1;
152} 152}
153 153
154 154
155KOAgendaItem::~KOAgendaItem() 155KOAgendaItem::~KOAgendaItem()
156{ 156{
157 // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); 157 // qDebug("deleteKOAgendaItem::~KOAgendaItem( ");
158 // delete mKOAgendaItemWhatsThis; 158 // delete mKOAgendaItemWhatsThis;
159} 159}
160 160
161void KOAgendaItem::recreateIncidence() 161void KOAgendaItem::recreateIncidence()
162{ 162{
163#if 0 163#if 0
164 Incidence* newInc = mIncidence->clone(); 164 Incidence* newInc = mIncidence->clone();
165 newInc->recreate(); 165 newInc->recreate();
166 if ( mIncidence->doesRecur() ) { 166 if ( mIncidence->doesRecur() ) {
167 mIncidence->addExDate( mDate ); 167 mIncidence->addExDate( mDate );
168 newInc->recurrence()->unsetRecurs(); 168 newInc->recurrence()->unsetRecurs();
169 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); 169 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd());
170 QTime tim = mIncidence->dtStart().time(); 170 QTime tim = mIncidence->dtStart().time();
171 newInc->setDtStart( QDateTime(mDate, tim) ); 171 newInc->setDtStart( QDateTime(mDate, tim) );
172 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); 172 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) );
173 } 173 }
174#endif 174#endif
175 mIncidence = mIncidence->recreateCloneException( mDate ); 175 mIncidence = mIncidence->recreateCloneException( mDate );
176} 176}
177bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) 177bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout)
178{ 178{
179 int size = AGENDA_ICON_SIZE; 179 int size = AGENDA_ICON_SIZE;
180 180
181 int yOff = 0; 181 int yOff = 0;
182 int xOff = 0; 182 int xOff = 0;
183 int x = pos().x() +3; 183 int x = pos().x() +3;
184 int y; 184 int y;
185 if ( mAllDay ) 185 if ( mAllDay )
186 y = pos().y()+3; 186 y = pos().y()+3;
187 else 187 else
188 y = mCellYTop * ( height() / cellHeight() ) +3; 188 y = mCellYTop * ( height() / cellHeight() ) +3;
189 if (mIncidence->cancelled()) { 189 if (mIncidence->cancelled()) {
190 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; 190 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x;
191 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; 191 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y;
192 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); 192 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 );
193 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); 193 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos );
194 if ( horLayout ) 194 if ( horLayout )
195 ++xOff; 195 ++xOff;
196 else 196 else
197 ++yOff; 197 ++yOff;
198 } 198 }
199 if (mIncidence->isAlarmEnabled()) { 199 if (mIncidence->isAlarmEnabled()) {
200 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); 200 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red );
201 if ( horLayout ) 201 if ( horLayout )
202 ++xOff; 202 ++xOff;
203 else 203 else
204 ++yOff; 204 ++yOff;
205 } 205 }
206 if (mIncidence->recurrence()->doesRecur()) { 206 if (mIncidence->recurrence()->doesRecur()) {
207 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); 207 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue );
208 if ( horLayout ) 208 if ( horLayout )
209 ++xOff; 209 ++xOff;
210 else 210 else
211 ++yOff; 211 ++yOff;
212 } 212 }
213 if (mIncidence->description().length() > 0) { 213 if (mIncidence->description().length() > 0) {
214 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); 214 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen );
215 if ( horLayout ) 215 if ( horLayout )
216 ++xOff; 216 ++xOff;
217 else 217 else
218 ++yOff; 218 ++yOff;
219 } 219 }
220 if (mIncidence->isReadOnly()) { 220 if (mIncidence->isReadOnly()) {
221 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); 221 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white );
222 if ( horLayout ) 222 if ( horLayout )
223 ++xOff; 223 ++xOff;
224 else 224 else
225 ++yOff; 225 ++yOff;
226 } 226 }
227 227
228 if (mIncidence->attendeeCount()>0) { 228 if (mIncidence->attendeeCount()>0) {
229 229
230 if (mIncidence->organizer() == KOPrefs::instance()->email()) { 230 if (mIncidence->organizer() == KOPrefs::instance()->email()) {
231 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); 231 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black );
232 if ( horLayout ) 232 if ( horLayout )
233 ++xOff; 233 ++xOff;
234 else 234 else
235 ++yOff; 235 ++yOff;
236 } else { 236 } else {
237 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 237 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
238 if (me!=0) { 238 if (me!=0) {
239 239
240 240
241 } else { 241 } else {
242 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); 242 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow );
243 if ( horLayout ) 243 if ( horLayout )
244 ++xOff; 244 ++xOff;
245 else 245 else
246 ++yOff; 246 ++yOff;
247 247
248 } 248 }
249 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); 249 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow );
250 if ( horLayout ) 250 if ( horLayout )
251 ++xOff; 251 ++xOff;
252 else 252 else
253 ++yOff; 253 ++yOff;
254 254
255 } 255 }
256 256
257 } 257 }
258 return ( yOff || xOff ); 258 return ( yOff || xOff );
259} 259}
260 260
261 261
262void KOAgendaItem::select(bool selected) 262void KOAgendaItem::select(bool selected)
263{ 263{
264 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); 264 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() );
265 if (mSelected == selected) return; 265 if (mSelected == selected) return;
266 mSelected = selected; 266 mSelected = selected;
267 if ( ! isVisible() ) 267 if ( ! isVisible() )
268 return; 268 return;
269 if ( firstMultiItem() ) 269 if ( firstMultiItem() )
270 firstMultiItem()->select( selected ); 270 firstMultiItem()->select( selected );
271 if ( !firstMultiItem() && nextMultiItem() ) { 271 if ( !firstMultiItem() && nextMultiItem() ) {
272 KOAgendaItem * placeItem = nextMultiItem(); 272 KOAgendaItem * placeItem = nextMultiItem();
273 while ( placeItem ) { 273 while ( placeItem ) {
274 placeItem->select( selected ); 274 placeItem->select( selected );
275 placeItem = placeItem->nextMultiItem(); 275 placeItem = placeItem->nextMultiItem();
276 } 276 }
277 } 277 }
278 globalFlagBlockAgendaItemUpdate = 0; 278 globalFlagBlockAgendaItemUpdate = 0;
279 paintMe( selected ); 279 paintMe( selected );
280 globalFlagBlockAgendaItemUpdate = 1; 280 globalFlagBlockAgendaItemUpdate = 1;
281 repaint( false ); 281 repaint( false );
282} 282}
283 283
284 284
285/* 285/*
286 The eventFilter has to filter the mouse events of the agenda item childs. The 286 The eventFilter has to filter the mouse events of the agenda item childs. The
287 events are fed into the event handling method of KOAgendaItem. This allows the 287 events are fed into the event handling method of KOAgendaItem. This allows the
288 KOAgenda to handle the KOAgendaItems by using an eventFilter. 288 KOAgenda to handle the KOAgendaItems by using an eventFilter.
289*/ 289*/
290bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) 290bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e )
291{ 291{
292 if (e->type() == QEvent::MouseButtonPress || 292 if (e->type() == QEvent::MouseButtonPress ||
293 e->type() == QEvent::MouseButtonDblClick || 293 e->type() == QEvent::MouseButtonDblClick ||
294 e->type() == QEvent::MouseButtonRelease || 294 e->type() == QEvent::MouseButtonRelease ||
295 e->type() == QEvent::MouseMove) { 295 e->type() == QEvent::MouseMove) {
296 QMouseEvent *me = (QMouseEvent *)e; 296 QMouseEvent *me = (QMouseEvent *)e;
297 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> 297 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)->
298 mapToGlobal(me->pos())); 298 mapToGlobal(me->pos()));
299 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); 299 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state());
300 return event(&returnEvent); 300 return event(&returnEvent);
301 } else { 301 } else {
302 return false; 302 return false;
303 } 303 }
304} 304}
305void KOAgendaItem::repaintMe( ) 305void KOAgendaItem::repaintMe( )
306{ 306{
307 paintMe ( mSelected ); 307 paintMe ( mSelected );
308} 308}
309void KOAgendaItem::paintMe( bool selected, QPainter* paint ) 309void KOAgendaItem::paintMe( bool selected, QPainter* paint )
310{ 310{
311 if ( globalFlagBlockAgendaItemUpdate && ! selected) 311 if ( globalFlagBlockAgendaItemUpdate && ! selected)
312 return; 312 return;
313 QPainter pa; 313 QPainter pa;
314 314
315 if ( mSelected ) { 315 if ( mSelected ) {
316 pa.begin( paintPixSel() ); 316 pa.begin( paintPixSel() );
317 } else { 317 } else {
318 if ( mAllDay ) 318 if ( mAllDay )
319 pa.begin( paintPixAllday() ); 319 pa.begin( paintPixAllday() );
320 else 320 else
321 pa.begin( paintPix() ); 321 pa.begin( paintPix() );
322 } 322 }
323 int x, yy, w, h; 323 int x, yy, w, h;
324 float nfh = 7.0; 324 float nfh = 7.0;
325 x = pos().x(); w = width(); h = height (); 325 x = pos().x(); w = width(); h = height ();
326 if ( mAllDay ) 326 if ( mAllDay )
327 yy = y(); 327 yy = y();
328 else 328 else
329 yy = mCellYTop * ( height() / cellHeight() ); 329 yy = mCellYTop * ( height() / cellHeight() );
330 xPaintCoord= x; 330 xPaintCoord= x;
331 yPaintCoord = yy; 331 yPaintCoord = yy;
332 wPaintCoord = width(); 332 wPaintCoord = width();
333 hPaintCoord = height(); 333 hPaintCoord = height();
334 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); 334 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height());
335 if ( paint == 0 ) 335 if ( paint == 0 )
336 paint = &pa; 336 paint = &pa;
337 bool horLayout = ( w < h ); 337 bool horLayout = ( w < h );
338 int maxhei = mFontPixelSize+4; 338 int maxhei = mFontPixelSize+4;
339 if ( horLayout ) 339 if ( horLayout )
340 maxhei += AGENDA_ICON_SIZE -4; 340 maxhei += AGENDA_ICON_SIZE -4;
341 bool small = ( h < maxhei ); 341 bool small = ( h < maxhei );
342 if ( ! small ) 342 if ( ! small )
343 paint->setFont(KOPrefs::instance()->mAgendaViewFont); 343 paint->setFont(KOPrefs::instance()->mAgendaViewFont);
344 else { 344 else {
345 QFont f = KOPrefs::instance()->mAgendaViewFont; 345 QFont f = KOPrefs::instance()->mAgendaViewFont;
346 f.setBold( false ); 346 f.setBold( false );
347 int fh = f.pointSize(); 347 int fh = f.pointSize();
348 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; 348 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh;
349 if ( nfh < 6 ) 349 if ( nfh < 6 )
350 nfh = 6; 350 nfh = 6;
351 f.setPointSize( nfh ); 351 f.setPointSize( nfh );
352 paint->setFont(f); 352 paint->setFont(f);
353 } 353 }
354 paint->fillRect ( x, yy, w, h, mBackgroundColor ); 354 paint->fillRect ( x, yy, w, h, mBackgroundColor );
355 static const QPixmap completedPxmp = SmallIcon("greenhook16"); 355 static const QPixmap completedPxmp = SmallIcon("greenhook16");
356 static const QPixmap overduePxmp = SmallIcon("redcross16"); 356 static const QPixmap overduePxmp = SmallIcon("redcross16");
357 if ( mIncidence->type() == "Todo" ) { 357 if ( mIncidence->type() == "Todo" ) {
358 Todo* tempTodo = static_cast<Todo*>(mIncidence); 358 Todo* tempTodo = static_cast<Todo*>(mIncidence);
359 int xx = pos().x()+(width()-completedPxmp.width()-3 ); 359 int xx = pos().x()+(width()-completedPxmp.width()-3 );
360 int yyy = yy+3; 360 int yyy = yy+3;
361 if ( tempTodo->isCompleted() ) 361 if ( tempTodo->isCompleted() )
362 paint->drawPixmap ( xx, yyy, completedPxmp ); 362 paint->drawPixmap ( xx, yyy, completedPxmp );
363 else { 363 else {
364 paint->drawPixmap ( xx, yyy, overduePxmp ); 364 paint->drawPixmap ( xx, yyy, overduePxmp );
365 365
366 } 366 }
367 } 367 }
368 bool addIcon = false; 368 bool addIcon = false;
369 if ( ! small || w > 3 * h || h > 3* w ) 369 if ( ! small || w > 3 * h || h > 3* w )
370 addIcon = updateIcons( paint, horLayout ); 370 addIcon = updateIcons( paint, horLayout );
371 371
372 qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); 372 qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0);
373 //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); 373 //qDebug("draw rect %d %d %d %d ",x, yy, w, h );
374 if ( ! small ) { 374 if ( ! small ) {
375 x += 3; yy += 3;w -= 6; h-= 5; 375 x += 3; yy += 3;w -= 6; h-= 5;
376 } else { 376 } else {
377 x += 2; yy += 1;w -= 4; h-= 4; 377 x += 2; yy += 1;w -= 4; h-= 4;
378 if ( nfh < 6.01 ) { 378 if ( nfh < 6.01 ) {
379 yy -= 2; 379 yy -= 2;
380 h += 4; 380 h += 4;
381 } 381 }
382 else 382 else
383 if ( nfh < h -2 ) 383 if ( nfh < h -2 )
384 ++yy; 384 ++yy;
385 } 385 }
386 int align; 386 int align;
387#ifndef DESKTOP_VERSION 387#ifndef DESKTOP_VERSION
388 align = ( AlignLeft|WordBreak|AlignTop); 388 align = ( AlignLeft|WordBreak|AlignTop);
389#else 389#else
390 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); 390 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop);
391#endif 391#endif
392 if ( addIcon ) { 392 if ( addIcon ) {
393 if ( ! horLayout ) { 393 if ( ! horLayout ) {
394 x += AGENDA_ICON_SIZE+3; 394 x += AGENDA_ICON_SIZE+3;
395 w -= (AGENDA_ICON_SIZE+3); 395 w -= (AGENDA_ICON_SIZE+3);
396 } 396 }
397 else { 397 else {
398 yy+= AGENDA_ICON_SIZE+2; 398 yy+= AGENDA_ICON_SIZE+2;
399 h -=(AGENDA_ICON_SIZE+3); 399 h -=(AGENDA_ICON_SIZE+3);
400 } 400 }
401 } 401 }
402 int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); 402 int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue();
403 if ( colsum < 250 ) 403 if ( colsum < 250 )
404 paint->setPen ( white); 404 paint->setPen ( white);
405 if ( x < 0 ) { 405 if ( x < 0 ) {
406 w = w+x-3; 406 w = w+x-3;
407 x = 3; 407 x = 3;
408 if ( w > parentWidget()->width() ){ 408 if ( w > parentWidget()->width() ){
409 w = parentWidget()->width() - 6; 409 w = parentWidget()->width() - 6;
410#ifndef DESKTOP_VERSION 410#ifndef DESKTOP_VERSION
411 align = ( AlignHCenter|WordBreak|AlignTop); 411 align = ( AlignHCenter|WordBreak|AlignTop);
412#else 412#else
413 align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); 413 align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop);
414#endif 414#endif
415 415
416 } 416 }
417 } 417 }
418 QRect dr; 418 QRect dr;
419 if ( w + x > parentWidget()->width() ) 419 if ( w + x > parentWidget()->width() )
420 w = parentWidget()->width()-x; 420 w = parentWidget()->width()-x;
421 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); 421 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr );
422 //qDebug("%d %d %d %d ", x, yy, w, h ); 422 //qDebug("%d %d %d %d ", x, yy, w, h );
423 if ( mIncidence->cancelled() ){ 423 if ( mIncidence->cancelled() ){
424 424
425 425
426 small = ( height() < 20 ); 426 small = ( height() < 20 );
427 427
428 if ( ! small ) { 428 if ( ! small ) {
429 QFontMetrics fm ( paint->font() ); 429 QFontMetrics fm ( paint->font() );
430 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); 430 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2);
431 } 431 }
432 432
433 } 433 }
434 pa.end(); 434 pa.end();
435 435
436} 436}
437void KOAgendaItem::resizePixmap( int w , int h ) 437void KOAgendaItem::resizePixmap( int w , int h )
438{ 438{
439 paintPix()->resize( w, h ); 439 paintPix()->resize( w, h );
440 paintPixSel()->resize( w, h ); 440 paintPixSel()->resize( w, h );
441 441
442} 442}
443QPixmap * KOAgendaItem::paintPix() 443QPixmap * KOAgendaItem::paintPix()
444{ 444{
445 static QPixmap* mPaintPix = 0; 445 static QPixmap* mPaintPix = 0;
446 if ( ! mPaintPix ) 446 if ( ! mPaintPix ) {
447 mPaintPix = new QPixmap(1,1); 447 int w = QApplication::desktop()->width();
448 int h = QApplication::desktop()->height();
449 mPaintPix = new QPixmap(w,h);
450 }
448 return mPaintPix ; 451 return mPaintPix ;
449} 452}
450QPixmap * KOAgendaItem::paintPixAllday() 453QPixmap * KOAgendaItem::paintPixAllday()
451{ 454{
452 static QPixmap* mPaintPixA = 0; 455 static QPixmap* mPaintPixA = 0;
453 if ( ! mPaintPixA ) 456 if ( ! mPaintPixA ) {
454 mPaintPixA = new QPixmap(1,1); 457 int w = QApplication::desktop()->width();
458 int h = QApplication::desktop()->height()/3;
459 mPaintPixA = new QPixmap(w,h);
460 }
455 return mPaintPixA ; 461 return mPaintPixA ;
456} 462}
457QPixmap * KOAgendaItem::paintPixSel() 463QPixmap * KOAgendaItem::paintPixSel()
458{ 464{
459 static QPixmap* mPaintPixSel = 0; 465 static QPixmap* mPaintPixSel = 0;
460 if ( ! mPaintPixSel ) 466 if ( ! mPaintPixSel ) {
461 mPaintPixSel = new QPixmap(1,1); 467 int w = QApplication::desktop()->width();
468 int h = QApplication::desktop()->height();
469 mPaintPixSel = new QPixmap(w,h);
470 }
462 return mPaintPixSel ; 471 return mPaintPixSel ;
463} 472}
464void KOAgendaItem::paintEvent ( QPaintEvent *e ) 473void KOAgendaItem::paintEvent ( QPaintEvent *e )
465{ 474{
466 475
467 if ( globalFlagBlockAgendaItemPaint ) 476 if ( globalFlagBlockAgendaItemPaint )
468 return; 477 return;
469 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) 478 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 )
470 return; 479 return;
471 int yy; 480 int yy;
472 if ( mAllDay ) 481 if ( mAllDay )
473 yy = y(); 482 yy = y();
474 else 483 else
475 yy = mCellYTop * ( height() / cellHeight() ); 484 yy = mCellYTop * ( height() / cellHeight() );
476 int xx = x(); 485 int xx = x();
477 486
478 if ( xPaintCoord != xx || yPaintCoord != yy || 487 if ( xPaintCoord != xx || yPaintCoord != yy ||
479 wPaintCoord != width() || hPaintCoord != height()) { 488 wPaintCoord != width() || hPaintCoord != height()) {
480 xPaintCoord= xx; 489 xPaintCoord= xx;
481 yPaintCoord = yy; 490 yPaintCoord = yy;
482 wPaintCoord = width(); 491 wPaintCoord = width();
483 hPaintCoord = height(); 492 hPaintCoord = height();
484 globalFlagBlockAgendaItemUpdate = 0; 493 globalFlagBlockAgendaItemUpdate = 0;
485 paintMe( mSelected ); 494 paintMe( mSelected );
486 //qDebug("calling paintMe "); 495 //qDebug("calling paintMe ");
487 globalFlagBlockAgendaItemUpdate = 1; 496 globalFlagBlockAgendaItemUpdate = 1;
488 } 497 }
489 int rx, ry, rw, rh; 498 int rx, ry, rw, rh;
490 rx = e->rect().x(); 499 rx = e->rect().x();
491 ry = e->rect().y(); 500 ry = e->rect().y();
492 rw = e->rect().width(); 501 rw = e->rect().width();
493 rh = e->rect().height(); 502 rh = e->rect().height();
494 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); 503 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height());
495 504
496 QPixmap* paintFrom ; 505 QPixmap* paintFrom ;
497 if ( mSelected ) { 506 if ( mSelected ) {
498 paintFrom = paintPixSel(); 507 paintFrom = paintPixSel();
499 } else { 508 } else {
500 if ( mAllDay ) 509 if ( mAllDay )
501 paintFrom = paintPixAllday(); 510 paintFrom = paintPixAllday();
502 else 511 else
503 paintFrom = paintPix(); 512 paintFrom = paintPix();
504 } 513 }
505 xx += rx; 514 xx += rx;
506 515
507 if ( xx < 0 ) { 516 if ( xx < 0 ) {
508 rw = rw + xx; 517 rw = rw + xx;
509 rx -= xx; 518 rx -= xx;
510 xx = 0; 519 xx = 0;
511 if ( rw <= 1 ) { 520 if ( rw <= 1 ) {
512 //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); 521 //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1());
513 return; 522 return;
514 } 523 }
515 } 524 }
516 if ( paintFrom->width() < xx+rw ) { 525 if ( paintFrom->width() < xx+rw ) {
517 rw = paintFrom->width() - xx; 526 rw = paintFrom->width() - xx;
518 if ( rw <= 1 ) { 527 if ( rw <= 1 ) {
519 //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); 528 //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() );
520 return; 529 return;
521 } 530 }
522 } 531 }
523 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); 532 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh);
524 bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); 533 bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP);
525} 534}
526void KOAgendaItem::computeText() 535void KOAgendaItem::computeText()
527{ 536{
528
529 mDisplayedText = mIncidence->summary(); 537 mDisplayedText = mIncidence->summary();
530 if ( (mIncidence->type() == "Todo") ) { 538 if ( (mIncidence->type() == "Todo") ) {
531 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { 539 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) {
532 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) 540 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() )
533 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; 541 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")";
534 else if ( !(mIncidence->doesFloat())) 542 else if ( !(mIncidence->doesFloat()))
535 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; 543 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")";
536 } 544 }
537 } else { 545 } else {
538 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) 546 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda)
539 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; 547 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ;
540 548
541 if ( mAllDay ) { 549 if ( mAllDay ) {
542 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { 550 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) {
543 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; 551 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ;
544 } 552 }
545 } 553 }
546 554
547 } 555 }
548 556
549 if ( !mIncidence->location().isEmpty() ) { 557 if ( !mIncidence->location().isEmpty() ) {
550 if ( mAllDay ) 558 if ( mAllDay )
551 mDisplayedText += " ("; 559 mDisplayedText += " (";
552 else 560 else
553 mDisplayedText += "\n("; 561 mDisplayedText += "\n(";
554 mDisplayedText += mIncidence->location() +")"; 562 mDisplayedText += mIncidence->location() +")";
555 } 563 }
556 564#ifdef DESKTOP_VERSION
557 QString tipText = mIncidence->summary(); 565 QString tipText = mIncidence->summary();
558 if ( !mIncidence->doesFloat() ) { 566 if ( !mIncidence->doesFloat() ) {
559 if ( mIncidence->type() == "Event" ) { 567 if ( mIncidence->type() == "Event" ) {
560 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { 568 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) {
561 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); 569 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr();
562 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); 570 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr();
563 } 571 }
564 else { 572 else {
565 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); 573 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr();
566 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); 574 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr();
567 } 575 }
568 } 576 }
569 else if ( mIncidence->type() == "Todo" ) { 577 else if ( mIncidence->type() == "Todo" ) {
570 if (mIncidence->hasStartDate()) 578 if (mIncidence->hasStartDate())
571 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); 579 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr();
572 if (((Todo*)mIncidence)->hasDueDate()) 580 if (((Todo*)mIncidence)->hasDueDate())
573 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); 581 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr();
574 } 582 }
575 } else if ( mIncidence->type() == "Todo" ) { 583 } else if ( mIncidence->type() == "Todo" ) {
576 if (mIncidence->hasStartDate()) 584 if (mIncidence->hasStartDate())
577 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); 585 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr();
578 if (((Todo*)mIncidence)->hasDueDate()) 586 if (((Todo*)mIncidence)->hasDueDate())
579 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); 587 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr();
580 } 588 }
581 589
582 if (!mIncidence->location().isEmpty()) { 590 if (!mIncidence->location().isEmpty()) {
583 tipText += "\n"+i18n("Location: ")+mIncidence->location(); 591 tipText += "\n"+i18n("Location: ")+mIncidence->location();
584 } 592 }
585 QToolTip::add(this,tipText,toolTipGroup(),""); 593 QToolTip::add(this,tipText,toolTipGroup(),"");
586 594#endif
587} 595}
588void KOAgendaItem::updateItem() 596void KOAgendaItem::updateItem()
589{ 597{
590 computeText(); 598 computeText();
591 599
592 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); 600 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y());
593 paintMe( mSelected ); 601 paintMe( mSelected );
594 repaint( false); 602 repaint( false);
595} 603}
596 604
597void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) 605void KOAgendaItem::resizeEvent ( QResizeEvent *ev )
598{ 606{
599 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); 607 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1());
600 paintMe( mSelected ); 608 paintMe( mSelected );
601 repaint( false ); 609 repaint( false );
602} 610}
603 611
604/* 612/*
605 Return height of item in units of agenda cells 613 Return height of item in units of agenda cells
606*/ 614*/
607int KOAgendaItem::cellHeight() 615int KOAgendaItem::cellHeight()
608{ 616{
609 int ret = mCellYBottom - mCellYTop + 1; 617 int ret = mCellYBottom - mCellYTop + 1;
610 if ( ret <= 0 ) { 618 if ( ret <= 0 ) {
611 ret = 1; 619 ret = 1;
612 mCellYBottom = 0; 620 mCellYBottom = 0;
613 mCellYTop = 0; 621 mCellYTop = 0;
614 } 622 }
615 return ret; 623 return ret;
616} 624}
617 625
618/* 626/*
619 Return height of item in units of agenda cells 627 Return height of item in units of agenda cells
620*/ 628*/
621int KOAgendaItem::cellWidth() 629int KOAgendaItem::cellWidth()
622{ 630{
623 return mCellXWidth - mCellX + 1; 631 return mCellXWidth - mCellX + 1;
624} 632}
625 633
626void KOAgendaItem::setItemDate(QDate qd) 634void KOAgendaItem::setItemDate(QDate qd)
627{ 635{
628 mDate = qd; 636 mDate = qd;
629} 637}
630 638
631void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) 639void KOAgendaItem::setCellXY(int X, int YTop, int YBottom)
632{ 640{
633 mCellX = X; 641 mCellX = X;
634 mCellYTop = YTop; 642 mCellYTop = YTop;
635 mCellYBottom = YBottom; 643 mCellYBottom = YBottom;
636} 644}
637 645
638void KOAgendaItem::setCellXWidth(int xwidth) 646void KOAgendaItem::setCellXWidth(int xwidth)
639{ 647{
640 mCellXWidth = xwidth; 648 mCellXWidth = xwidth;
641} 649}
642 650
643void KOAgendaItem::setCellX(int XLeft, int XRight) 651void KOAgendaItem::setCellX(int XLeft, int XRight)
644{ 652{
645 mCellX = XLeft; 653 mCellX = XLeft;
646 mCellXWidth = XRight; 654 mCellXWidth = XRight;
647} 655}
648 656
649void KOAgendaItem::setCellY(int YTop, int YBottom) 657void KOAgendaItem::setCellY(int YTop, int YBottom)
650{ 658{
651 mCellYTop = YTop; 659 mCellYTop = YTop;
652 mCellYBottom = YBottom; 660 mCellYBottom = YBottom;
653} 661}
654 662
655void KOAgendaItem::setSubCell(int subCell) 663void KOAgendaItem::setSubCell(int subCell)
656{ 664{
657 mSubCell = subCell; 665 mSubCell = subCell;
658} 666}
659 667
660void KOAgendaItem::setSubCells(int subCells) 668void KOAgendaItem::setSubCells(int subCells)
661{ 669{
662 mSubCells = subCells; 670 mSubCells = subCells;
663} 671}
664 672
665void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, 673void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next,
666 KOAgendaItem *last) 674 KOAgendaItem *last)
667{ 675{
668 mFirstMultiItem = first; 676 mFirstMultiItem = first;
669 mNextMultiItem = next; 677 mNextMultiItem = next;
670 mLastMultiItem = last; 678 mLastMultiItem = last;
671} 679}
672 680
673void KOAgendaItem::startMove() 681void KOAgendaItem::startMove()
674{ 682{
675 mStartCellX = mCellX; 683 mStartCellX = mCellX;
676 mStartCellXWidth = mCellXWidth; 684 mStartCellXWidth = mCellXWidth;
677 mStartCellYTop = mCellYTop; 685 mStartCellYTop = mCellYTop;
678 mStartCellYBottom = mCellYBottom; 686 mStartCellYBottom = mCellYBottom;
679} 687}
680 688
681void KOAgendaItem::resetMove() 689void KOAgendaItem::resetMove()
682{ 690{
683 mCellX = mStartCellX; 691 mCellX = mStartCellX;
684 mCellXWidth = mStartCellXWidth; 692 mCellXWidth = mStartCellXWidth;
685 mCellYTop = mStartCellYTop; 693 mCellYTop = mStartCellYTop;
686 mCellYBottom = mStartCellYBottom; 694 mCellYBottom = mStartCellYBottom;
687} 695}
688 696
689void KOAgendaItem::moveRelative(int dx, int dy) 697void KOAgendaItem::moveRelative(int dx, int dy)
690{ 698{
691 int newX = cellX() + dx; 699 int newX = cellX() + dx;
692 int newXWidth = cellXWidth() + dx; 700 int newXWidth = cellXWidth() + dx;
693 int newYTop = cellYTop() + dy; 701 int newYTop = cellYTop() + dy;
694 int newYBottom = cellYBottom() + dy; 702 int newYBottom = cellYBottom() + dy;
695 setCellXY(newX,newYTop,newYBottom); 703 setCellXY(newX,newYTop,newYBottom);
696 setCellXWidth(newXWidth); 704 setCellXWidth(newXWidth);
697} 705}
698 706
699void KOAgendaItem::expandTop(int dy) 707void KOAgendaItem::expandTop(int dy)
700{ 708{
701 int newYTop = cellYTop() + dy; 709 int newYTop = cellYTop() + dy;
702 int newYBottom = cellYBottom(); 710 int newYBottom = cellYBottom();
703 if (newYTop > newYBottom) newYTop = newYBottom; 711 if (newYTop > newYBottom) newYTop = newYBottom;
704 setCellY(newYTop, newYBottom); 712 setCellY(newYTop, newYBottom);
705} 713}
706 714
707void KOAgendaItem::expandBottom(int dy) 715void KOAgendaItem::expandBottom(int dy)
708{ 716{
709 int newYTop = cellYTop(); 717 int newYTop = cellYTop();
710 int newYBottom = cellYBottom() + dy; 718 int newYBottom = cellYBottom() + dy;
711 if (newYBottom < newYTop) newYBottom = newYTop; 719 if (newYBottom < newYTop) newYBottom = newYTop;
712 setCellY(newYTop, newYBottom); 720 setCellY(newYTop, newYBottom);
713} 721}
714 722
715void KOAgendaItem::expandLeft(int dx) 723void KOAgendaItem::expandLeft(int dx)
716{ 724{
717 int newX = cellX() + dx; 725 int newX = cellX() + dx;
718 int newXWidth = cellXWidth(); 726 int newXWidth = cellXWidth();
719 if (newX > newXWidth) newX = newXWidth; 727 if (newX > newXWidth) newX = newXWidth;
720 setCellX(newX,newXWidth); 728 setCellX(newX,newXWidth);
721} 729}
722 730
723void KOAgendaItem::expandRight(int dx) 731void KOAgendaItem::expandRight(int dx)
724{ 732{
725 int newX = cellX(); 733 int newX = cellX();
726 int newXWidth = cellXWidth() + dx; 734 int newXWidth = cellXWidth() + dx;
727 if (newXWidth < newX) newXWidth = newX; 735 if (newXWidth < newX) newXWidth = newX;
728 setCellX(newX,newXWidth); 736 setCellX(newX,newXWidth);
729} 737}
730 738
731QToolTipGroup *KOAgendaItem::toolTipGroup() 739QToolTipGroup *KOAgendaItem::toolTipGroup()
732{ 740{
733 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 741 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
734 return mToolTipGroup; 742 return mToolTipGroup;
735} 743}
736 744
737void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) 745void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e )
738{ 746{
739#ifndef KORG_NODND 747#ifndef KORG_NODND
740 if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || 748 if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) ||
741 !QTextDrag::canDecode( e ) ) { 749 !QTextDrag::canDecode( e ) ) {
742 e->ignore(); 750 e->ignore();
743 return; 751 return;
744 } 752 }
745 e->accept(); 753 e->accept();
746#endif 754#endif
747} 755}
748 756
749void KOAgendaItem::dropEvent( QDropEvent *e ) 757void KOAgendaItem::dropEvent( QDropEvent *e )
750{ 758{
751#ifndef KORG_NODND 759#ifndef KORG_NODND
752 QString text; 760 QString text;
753 if(QTextDrag::decode(e,text)) 761 if(QTextDrag::decode(e,text))
754 { 762 {
755 kdDebug() << "Dropped : " << text << endl; 763 kdDebug() << "Dropped : " << text << endl;
756 QStringList emails = QStringList::split(",",text); 764 QStringList emails = QStringList::split(",",text);
757 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 765 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
758 kdDebug() << " Email: " << (*it) << endl; 766 kdDebug() << " Email: " << (*it) << endl;
759 int pos = (*it).find("<"); 767 int pos = (*it).find("<");
760 QString name = (*it).left(pos); 768 QString name = (*it).left(pos);
761 QString email = (*it).mid(pos); 769 QString email = (*it).mid(pos);
762 if (!email.isEmpty()) { 770 if (!email.isEmpty()) {
763 mIncidence->addAttendee(new Attendee(name,email)); 771 mIncidence->addAttendee(new Attendee(name,email));
764 } 772 }
765 } 773 }
766 } 774 }
767#endif 775#endif
768} 776}
769 777
770 778
771QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() 779QPtrList<KOAgendaItem> KOAgendaItem::conflictItems()
772{ 780{
773 return mConflictItems; 781 return mConflictItems;
774} 782}
775 783
776void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) 784void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci)
777{ 785{
778 mConflictItems = ci; 786 mConflictItems = ci;
779 KOAgendaItem *item; 787 KOAgendaItem *item;
780 for ( item=mConflictItems.first(); item != 0; 788 for ( item=mConflictItems.first(); item != 0;
781 item=mConflictItems.next() ) { 789 item=mConflictItems.next() ) {
782 item->addConflictItem(this); 790 item->addConflictItem(this);
783 } 791 }
784} 792}
785 793
786void KOAgendaItem::addConflictItem(KOAgendaItem *ci) 794void KOAgendaItem::addConflictItem(KOAgendaItem *ci)
787{ 795{
788 if (mConflictItems.find(ci)<0) 796 if (mConflictItems.find(ci)<0)
789 mConflictItems.append(ci); 797 mConflictItems.append(ci);
790} 798}
791 799
792bool KOAgendaItem::checkLayout() 800bool KOAgendaItem::checkLayout()
793{ 801{
794 if ( !mConflictItems.count() ) 802 if ( !mConflictItems.count() )
795 return true; 803 return true;
796 int max = 0; 804 int max = 0;
797 KOAgendaItem *item; 805 KOAgendaItem *item;
798 for ( item=mConflictItems.first(); item != 0; 806 for ( item=mConflictItems.first(); item != 0;
799 item=mConflictItems.next() ) { 807 item=mConflictItems.next() ) {
800 if ( item->subCells() > max ) 808 if ( item->subCells() > max )
801 max = item->subCells(); 809 max = item->subCells();
802 } 810 }
803 if ( max > subCells() ) { 811 if ( max > subCells() ) {
804 setSubCells( max ); 812 setSubCells( max );
805 return false; 813 return false;
806 } 814 }
807 return true; 815 return true;
808} 816}
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 4dfb9df..65d6acf 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -260,944 +260,957 @@ void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
260 emit shiftUp(); 260 emit shiftUp();
261 break; 261 break;
262 default: 262 default:
263 break; 263 break;
264 } 264 }
265} 265}
266 266
267void KNoScrollListBox::mousePressEvent(QMouseEvent *e) 267void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
268{ 268{
269 QListBox::mousePressEvent(e); 269 QListBox::mousePressEvent(e);
270 270
271 if(e->button() == RightButton) { 271 if(e->button() == RightButton) {
272 emit rightClick(); 272 emit rightClick();
273 } 273 }
274} 274}
275 275
276MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) 276MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
277 : QListBoxItem() 277 : QListBoxItem()
278{ 278{
279 mblockRepaint = true; 279 mblockRepaint = true;
280 setText( s ); 280 setText( s );
281 mMultiday = 0; 281 mMultiday = 0;
282 mIncidence = incidence; 282 mIncidence = incidence;
283 mDate = qd; 283 mDate = qd;
284 mRecur = false; 284 mRecur = false;
285 mAlarm = false; 285 mAlarm = false;
286 mReply = false; 286 mReply = false;
287 mInfo = false; 287 mInfo = false;
288 mdayPos = 0; 288 mdayPos = 0;
289 isWeekItem = KOPrefs::instance()->mMonthViewWeek; 289 isWeekItem = KOPrefs::instance()->mMonthViewWeek;
290 //qDebug("NEWWWWWWWWWWWWW "); 290 //qDebug("NEWWWWWWWWWWWWW ");
291} 291}
292void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) 292void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s)
293{ 293{
294 setText( s ); 294 setText( s );
295 mMultiday = 0; 295 mMultiday = 0;
296 mIncidence = incidence; 296 mIncidence = incidence;
297 mDate = qd; 297 mDate = qd;
298 mRecur = false; 298 mRecur = false;
299 mAlarm = false; 299 mAlarm = false;
300 mReply = false; 300 mReply = false;
301 mInfo = false; 301 mInfo = false;
302 mdayPos = 0; 302 mdayPos = 0;
303 //qDebug("recucleeeeeeeeeeeeeeeee "); 303 //qDebug("recucleeeeeeeeeeeeeeeee ");
304} 304}
305 305
306void MonthViewItem::paint(QPainter *p) 306void MonthViewItem::paint(QPainter *p)
307{ 307{
308 if ( mblockRepaint ) { 308 if ( mblockRepaint ) {
309 //qDebug("block "); 309 //qDebug("block ");
310 return; 310 return;
311 } 311 }
312 //qDebug("NON block "); 312 //qDebug("NON block ");
313#if QT_VERSION >= 0x030000 313#if QT_VERSION >= 0x030000
314 bool sel = isSelected(); 314 bool sel = isSelected();
315#else 315#else
316 bool sel = selected(); 316 bool sel = selected();
317#endif 317#endif
318 318
319 319
320 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) 320 if (KOPrefs::instance()->mMonthViewUsesCategoryColor)
321 { 321 {
322 p->setBackgroundColor( palette().color( QPalette::Normal, \ 322 p->setBackgroundColor( palette().color( QPalette::Normal, \
323 sel ? QColorGroup::Highlight : QColorGroup::Background ) ); 323 sel ? QColorGroup::Highlight : QColorGroup::Background ) );
324 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); 324 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) );
325 } 325 }
326 int x = 1; 326 int x = 1;
327 //int y = 3;//(height() - mRecurPixmap.height()) /2; 327 //int y = 3;//(height() - mRecurPixmap.height()) /2;
328 int size = PIXMAP_SIZE; 328 int size = PIXMAP_SIZE;
329 if ( QApplication::desktop()->width() < 300 ) 329 if ( QApplication::desktop()->width() < 300 )
330 size = 3; 330 size = 3;
331 int heihei = height( listBox () ); 331 int heihei = height( listBox () );
332 int y = (heihei - size -1 ) /2; 332 int y = (heihei - size -1 ) /2;
333 333
334 if ( KOPrefs::instance()->mMonthShowIcons ) { 334 if ( KOPrefs::instance()->mMonthShowIcons ) {
335 if ( mInfo ) { 335 if ( mInfo ) {
336 p->fillRect ( x, y,size,size, Qt::darkGreen ); 336 p->fillRect ( x, y,size,size, Qt::darkGreen );
337 x += size + 1; 337 x += size + 1;
338 } 338 }
339 if ( mRecur ) { 339 if ( mRecur ) {
340 p->fillRect ( x, y,size,size, Qt::blue ); 340 p->fillRect ( x, y,size,size, Qt::blue );
341 x += size + 1; 341 x += size + 1;
342 } 342 }
343 if ( mAlarm ) { 343 if ( mAlarm ) {
344 p->fillRect ( x, y,size,size, Qt::red ); 344 p->fillRect ( x, y,size,size, Qt::red );
345 x += size + 1; 345 x += size + 1;
346 } 346 }
347 if ( mReply ) { 347 if ( mReply ) {
348 p->fillRect ( x, y,size,size, Qt::yellow ); 348 p->fillRect ( x, y,size,size, Qt::yellow );
349 x += size + 1; 349 x += size + 1;
350 } 350 }
351 } 351 }
352 if ( mMultiday ) { 352 if ( mMultiday ) {
353 int yyy = y+(size/2); 353 int yyy = y+(size/2);
354 int sizeM = size+2; 354 int sizeM = size+2;
355 p->setBrush( QBrush::SolidPattern ); 355 p->setBrush( QBrush::SolidPattern );
356 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; 356 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ;
357 if ( mMultiday == 2 || mMultiday == 3 ) { 357 if ( mMultiday == 2 || mMultiday == 3 ) {
358 QPointArray pa ( 3 ); 358 QPointArray pa ( 3 );
359 pa.setPoint (0, x, yyy ); 359 pa.setPoint (0, x, yyy );
360 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); 360 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 );
361 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); 361 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 );
362 p->drawPolygon( pa ); 362 p->drawPolygon( pa );
363 } 363 }
364 if ( mMultiday == 2 || mMultiday == 1 ) { 364 if ( mMultiday == 2 || mMultiday == 1 ) {
365 QPointArray pa ( 3 ); 365 QPointArray pa ( 3 );
366 pa.setPoint (0, x+sizeM +sizeM/2, yyy ); 366 pa.setPoint (0, x+sizeM +sizeM/2, yyy );
367 pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); 367 pa.setPoint (1, x+sizeM, yyy+sizeM/2 );
368 pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); 368 pa.setPoint (2, x+sizeM, yyy-sizeM/2 );
369 p->drawPolygon( pa ); 369 p->drawPolygon( pa );
370 } 370 }
371 if ( mMultiday == 1 ) { 371 if ( mMultiday == 1 ) {
372 // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); 372 // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
373 373
374 p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); 374 p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 );
375 } 375 }
376 if ( mMultiday == 3 ) { 376 if ( mMultiday == 3 ) {
377 // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); 377 // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
378 p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); 378 p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 );
379 379
380 } 380 }
381 x += sizeM/2 + 1; 381 x += sizeM/2 + 1;
382 x += sizeM + 1; 382 x += sizeM + 1;
383 } 383 }
384 384
385 if ( mIncidence->type() == "Todo" ){ 385 if ( mIncidence->type() == "Todo" ){
386 Todo* td = ( Todo* ) mIncidence; 386 Todo* td = ( Todo* ) mIncidence;
387 if ( td->isCompleted() ) { 387 if ( td->isCompleted() ) {
388 int half = size/2; 388 int half = size/2;
389 p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; 389 p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ;
390 p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; 390 p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ;
391 x += half+half + 4; 391 x += half+half + 4;
392 392
393 } else { 393 } else {
394 int val = td->percentComplete()/20; 394 int val = td->percentComplete()/20;
395 p->fillRect ( x+1, y-2, val ,size+4,Qt::black ); 395 p->fillRect ( x+1, y-2, val ,size+4,Qt::black );
396 p->drawRect ( x, y-2,7,size+4); 396 p->drawRect ( x, y-2,7,size+4);
397 x += size + 3; 397 x += size + 3;
398 } 398 }
399 } 399 }
400 QFontMetrics fm = p->fontMetrics(); 400 QFontMetrics fm = p->fontMetrics();
401 int yPos; 401 int yPos;
402 int pmheight = size; 402 int pmheight = size;
403 if( pmheight < fm.height() ) 403 if( pmheight < fm.height() )
404 yPos = fm.ascent() + fm.leading()/2; 404 yPos = fm.ascent() + fm.leading()/2;
405 else 405 else
406 yPos = pmheight/2 - fm.height()/2 + fm.ascent(); 406 yPos = pmheight/2 - fm.height()/2 + fm.ascent();
407 p->setPen( palette().color( QPalette::Normal, sel ? \ 407 p->setPen( palette().color( QPalette::Normal, sel ? \
408 QColorGroup::HighlightedText : QColorGroup::Foreground ) ); 408 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
409 p->drawText( x, yPos, text() ); 409 p->drawText( x, yPos, text() );
410 if ( mIncidence->cancelled() ) { 410 if ( mIncidence->cancelled() ) {
411 int wid = fm.width( text() ); 411 int wid = fm.width( text() );
412 p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); 412 p->drawLine( x, heihei/2 ,x+wid, heihei/2 );
413 } 413 }
414 414
415} 415}
416 416
417int MonthViewItem::height(const QListBox *lb) const 417int MonthViewItem::height(const QListBox *lb) const
418{ 418{
419 int ret = 10; 419 int ret = 10;
420 if ( lb ) 420 if ( lb )
421 ret = lb->fontMetrics().lineSpacing()+1; 421 ret = lb->fontMetrics().lineSpacing()+1;
422 return ret; 422 return ret;
423} 423}
424 424
425int MonthViewItem::width(const QListBox *lb) const 425int MonthViewItem::width(const QListBox *lb) const
426{ 426{
427 if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { 427 if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) {
428 int size = PIXMAP_SIZE; 428 int size = PIXMAP_SIZE;
429 if ( QApplication::desktop()->width() < 300 ) 429 if ( QApplication::desktop()->width() < 300 )
430 size = 3; 430 size = 3;
431 int x = 1; 431 int x = 1;
432 if ( KOPrefs::instance()->mMonthShowIcons ) { 432 if ( KOPrefs::instance()->mMonthShowIcons ) {
433 if ( mInfo ) { 433 if ( mInfo ) {
434 x += size + 1; 434 x += size + 1;
435 } 435 }
436 if( mRecur ) { 436 if( mRecur ) {
437 x += size+1; 437 x += size+1;
438 } 438 }
439 if( mAlarm ) { 439 if( mAlarm ) {
440 x += size+1; 440 x += size+1;
441 } 441 }
442 if( mReply ) { 442 if( mReply ) {
443 x += size+1; 443 x += size+1;
444 } 444 }
445 } 445 }
446 if( mMultiday ) { 446 if( mMultiday ) {
447 x += size+1+2+size/2; 447 x += size+1+2+size/2;
448 } 448 }
449 return( x + lb->fontMetrics().width( text() ) + 1 ); 449 return( x + lb->fontMetrics().width( text() ) + 1 );
450 } 450 }
451 if ( ! lb ) 451 if ( ! lb )
452 return 10; 452 return 10;
453 //qDebug("ret wid %d ", lb->width()); 453 //qDebug("ret wid %d ", lb->width());
454 return lb->width(); 454 return lb->width();
455} 455}
456 456
457 457
458MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) 458MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par )
459 : KNoScrollListBox( par ), 459 : KNoScrollListBox( par ),
460 mMonthView( parent ) 460 mMonthView( parent )
461{ 461{
462 //QVBoxLayout *topLayout = new QVBoxLayout( this ); 462 //QVBoxLayout *topLayout = new QVBoxLayout( this );
463 currentPalette = 0; 463 currentPalette = 0;
464 // mLabel = new QLabel( this );QPushButton 464 // mLabel = new QLabel( this );QPushButton
465 mLabel = new QPushButton( this ); 465 mLabel = new QPushButton( this );
466 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); 466 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
467 //mLabel->setLineWidth( 1 ); 467 //mLabel->setLineWidth( 1 );
468 //mLabel->setAlignment( AlignCenter ); 468 //mLabel->setAlignment( AlignCenter );
469 mLabel->setFlat( true ); 469 mLabel->setFlat( true );
470 mLabel->setFocusPolicy(NoFocus); 470 mLabel->setFocusPolicy(NoFocus);
471 //mItemList = new KNoScrollListBox( this ); 471 //mItemList = new KNoScrollListBox( this );
472 setMinimumSize( 10, 10 ); 472 setMinimumSize( 10, 10 );
473 setFrameStyle( QFrame::Panel | QFrame::Plain ); 473 setFrameStyle( QFrame::Panel | QFrame::Plain );
474 setLineWidth( 1 ); 474 setLineWidth( 1 );
475 //topLayout->addWidget( mItemList ); 475 //topLayout->addWidget( mItemList );
476 mLabel->raise(); 476 mLabel->raise();
477 // QColor( 0,0,255 ) QColor( 160,1600,255 ) 477 // QColor( 0,0,255 ) QColor( 160,1600,255 )
478 mStandardPalette = palette(); 478 mStandardPalette = palette();
479 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); 479 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) );
480 480
481 enableScrollBars( false ); 481 enableScrollBars( false );
482 updateConfig(); 482 updateConfig();
483 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); 483 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() ));
484 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); 484 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() ));
485 connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), 485 connect( this , SIGNAL( doubleClicked( QListBoxItem *) ),
486 SLOT( defaultAction( QListBoxItem * ) ) ); 486 SLOT( defaultAction( QListBoxItem * ) ) );
487 connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, 487 connect( this, SIGNAL( rightButtonPressed( QListBoxItem *,
488 const QPoint &) ), 488 const QPoint &) ),
489 SLOT( contextMenu( QListBoxItem * ) ) ); 489 SLOT( contextMenu( QListBoxItem * ) ) );
490 connect( this, SIGNAL( highlighted( QListBoxItem *) ), 490 connect( this, SIGNAL( highlighted( QListBoxItem *) ),
491 SLOT( selection( QListBoxItem * ) ) ); 491 SLOT( selection( QListBoxItem * ) ) );
492 492
493 /* 493 /*
494 connect( this, SIGNAL( clicked( QListBoxItem * ) ), 494 connect( this, SIGNAL( clicked( QListBoxItem * ) ),
495 SLOT( selection( QListBoxItem * ) ) ); 495 SLOT( selection( QListBoxItem * ) ) );
496 */ 496 */
497} 497}
498#ifdef DESKTOP_VERSION 498#ifdef DESKTOP_VERSION
499QToolTipGroup *MonthViewCell::toolTipGroup() 499QToolTipGroup *MonthViewCell::toolTipGroup()
500{ 500{
501 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 501 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
502 return mToolTipGroup; 502 return mToolTipGroup;
503} 503}
504#endif 504#endif
505 505
506void MonthViewCell::setDate( const QDate &date ) 506void MonthViewCell::setDate( const QDate &date )
507{ 507{
508 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; 508 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
509 mDate = date; 509 mDate = date;
510 510
511 511
512 512
513 //resizeEvent( 0 ); 513 //resizeEvent( 0 );
514} 514}
515 515
516QDate MonthViewCell::date() const 516QDate MonthViewCell::date() const
517{ 517{
518 return mDate; 518 return mDate;
519} 519}
520 520
521void MonthViewCell::setPrimary( bool primary ) 521void MonthViewCell::setPrimary( bool primary )
522{ 522{
523 mPrimary = primary; 523 mPrimary = primary;
524 //setMyPalette(); 524 //setMyPalette();
525} 525}
526void MonthViewCell::setMyPalette() 526void MonthViewCell::setMyPalette()
527{ 527{
528 528
529 if ( mHoliday) { 529 if ( mHoliday) {
530 if ( currentPalette == 1 ) return; 530 if ( currentPalette == 1 ) return;
531 mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); 531 mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) ));
532 setPalette( mHolidayPalette ); 532 setPalette( mHolidayPalette );
533 //mLabel->setPalette( mHolidayPalette ); 533 //mLabel->setPalette( mHolidayPalette );
534 currentPalette = 1; 534 currentPalette = 1;
535 535
536 } else { 536 } else {
537 if ( mPrimary ) { 537 if ( mPrimary ) {
538 if ( currentPalette == 2 ) return; 538 if ( currentPalette == 2 ) return;
539 mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); 539 mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) ));
540 //mLabel->setPalette( mPrimaryPalette ); 540 //mLabel->setPalette( mPrimaryPalette );
541 setPalette( mPrimaryPalette ); 541 setPalette( mPrimaryPalette );
542 currentPalette = 2; 542 currentPalette = 2;
543 543
544 } else { 544 } else {
545 if ( currentPalette == 3 ) return; 545 if ( currentPalette == 3 ) return;
546 setPalette( mNonPrimaryPalette ); 546 setPalette( mNonPrimaryPalette );
547 mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); 547 mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) ));
548 //mLabel->setPalette( mNonPrimaryPalette );; 548 //mLabel->setPalette( mNonPrimaryPalette );;
549 currentPalette = 3; 549 currentPalette = 3;
550 } 550 }
551 } 551 }
552 //QPalette pal = palette(); 552 //QPalette pal = palette();
553 553
554 //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); 554 //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) ));
555} 555}
556QPalette MonthViewCell::getPalette () 556QPalette MonthViewCell::getPalette ()
557{ 557{
558 if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) 558 if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
559 return mStandardPalette; 559 return mStandardPalette;
560 if ( mHoliday) { 560 if ( mHoliday) {
561 return mHolidayPalette ; 561 return mHolidayPalette ;
562 } else { 562 } else {
563 if ( mPrimary ) { 563 if ( mPrimary ) {
564 return mPrimaryPalette ; 564 return mPrimaryPalette ;
565 } 565 }
566 } 566 }
567 return mNonPrimaryPalette; 567 return mNonPrimaryPalette;
568} 568}
569bool MonthViewCell::isPrimary() const 569bool MonthViewCell::isPrimary() const
570{ 570{
571 return mPrimary; 571 return mPrimary;
572} 572}
573 573
574void MonthViewCell::setHoliday( bool holiday ) 574void MonthViewCell::setHoliday( bool holiday )
575{ 575{
576 mHoliday = holiday; 576 mHoliday = holiday;
577 //setMyPalette(); 577 //setMyPalette();
578} 578}
579 579
580void MonthViewCell::setHoliday( const QString &holiday ) 580void MonthViewCell::setHoliday( const QString &holiday )
581{ 581{
582 mHolidayString = holiday; 582 mHolidayString = holiday;
583 583
584 if ( !holiday.isEmpty() ) { 584 if ( !holiday.isEmpty() ) {
585 setHoliday( true ); 585 setHoliday( true );
586 } 586 }
587} 587}
588 588
589void MonthViewCell::startUpdateCell() 589void MonthViewCell::startUpdateCell()
590{ 590{
591 mdayCount = 0; 591 mdayCount = 0;
592 setFocusPolicy(NoFocus); 592 setFocusPolicy(NoFocus);
593 if ( !mMonthView->isUpdatePossible() ) 593 if ( !mMonthView->isUpdatePossible() )
594 return; 594 return;
595 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 595 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
596 while ( mitem ) { 596 while ( mitem ) {
597 mitem->setBlockRepaint( true ); 597 mitem->setBlockRepaint( true );
598 mitem = (MonthViewItem *)mitem->next(); 598 mitem = (MonthViewItem *)mitem->next();
599 } 599 }
600 if ( mAvailItemList.count() > 20 ) { 600 if ( mAvailItemList.count() > 20 ) {
601 mAvailItemList.setAutoDelete( true ); 601 mAvailItemList.setAutoDelete( true );
602 mAvailItemList.clear(); 602 mAvailItemList.clear();
603 mAvailItemList.setAutoDelete( false ); 603 mAvailItemList.setAutoDelete( false );
604 } 604 }
605 /* 605 /*
606 if ( !isVisible() ){ 606 if ( !isVisible() ){
607 return; 607 return;
608 } 608 }
609 */ 609 */
610 // qDebug("MonthViewCell::updateCell() "); 610 // qDebug("MonthViewCell::updateCell() ");
611 setPrimary( mDate.month()%2 ); 611 setPrimary( mDate.month()%2 );
612 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); 612 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
613 if ( mDate == QDate::currentDate() ) { 613 if ( mDate == QDate::currentDate() ) {
614 setLineWidth( 3 ); 614 setLineWidth( 3 );
615 } else { 615 } else {
616 setLineWidth( 1 ); 616 setLineWidth( 1 );
617 } 617 }
618 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); 618 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem ();
619 //clear(); 619 //clear();
620 while ( CurrentAvailItem ) { 620 while ( CurrentAvailItem ) {
621 MonthViewItem *item = CurrentAvailItem; 621 MonthViewItem *item = CurrentAvailItem;
622 CurrentAvailItem = (MonthViewItem *)item->next(); 622 CurrentAvailItem = (MonthViewItem *)item->next();
623 mAvailItemList.append( item ); 623 mAvailItemList.append( item );
624 takeItem ( item ); 624 takeItem ( item );
625 } 625 }
626 626
627#ifdef DESKTOP_VERSION 627#ifdef DESKTOP_VERSION
628 QToolTip::remove(this); 628 QToolTip::remove(this);
629#endif 629#endif
630 mToolTip.clear(); 630 mToolTip.clear();
631 //qApp->processEvents(); 631 //qApp->processEvents();
632#if 0 632#if 0
633 if ( !mHolidayString.isEmpty() ) { 633 if ( !mHolidayString.isEmpty() ) {
634 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 634 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
635 item->setPalette( mHolidayPalette ); 635 item->setPalette( mHolidayPalette );
636 insertItem( item ); 636 insertItem( item );
637 mToolTip.append ( mHolidayString ); 637 mToolTip.append ( mHolidayString );
638 } 638 }
639#endif 639#endif
640} 640}
641 641
642int MonthViewCell::insertEvent(Event *event) 642int MonthViewCell::insertEvent(Event *event)
643{ 643{
644 bool useToolTips = true;
645#ifndef DEKSTOP_VERSION
646 useToolTips = false;
647#endif
644 QString mToolTipText; 648 QString mToolTipText;
645 setFocusPolicy(WheelFocus); 649 setFocusPolicy(WheelFocus);
646 if ( !(event->doesRecur() == Recurrence::rNone) ) { 650 if ( !(event->doesRecur() == Recurrence::rNone) ) {
647 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 651 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
648 return mdayCount; 652 return mdayCount;
649 else 653 else
650 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 654 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
651 return mdayCount; 655 return mdayCount;
652 } 656 }
653 657
654 if ( event->isHoliday()) { 658 if ( event->isHoliday()) {
655 setHoliday( true ); 659 setHoliday( true );
656 if ( mDate.dayOfWeek() == 7 ) 660 if ( mDate.dayOfWeek() == 7 )
657 setLineWidth( 3 ); 661 setLineWidth( 3 );
658 } 662 }
659 QString text; 663 QString text;
660 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day 664 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day
661 if (event->isMultiDay()) { 665 if (event->isMultiDay()) {
662 QString prefix = "<->";multiday = 2; 666 QString prefix = "<->";multiday = 2;
663 QString time; 667 QString time;
664 if ( event->doesRecur() ) { 668 if ( event->doesRecur() ) {
665 if ( event->recursOn( mDate) ) { 669 if ( event->recursOn( mDate) ) {
666 prefix ="->" ;multiday = 1; 670 prefix ="->" ;multiday = 1;
667 } 671 }
668 else { 672 else {
669 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 673 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
670 if ( event->recursOn( mDate.addDays( -days)) ) { 674 if ( event->recursOn( mDate.addDays( -days)) ) {
671 prefix ="<-" ;multiday = 3; 675 prefix ="<-" ;multiday = 3;
672 } 676 }
673 } 677 }
674 678
675 } else { 679 } else {
676 if (mDate == event->dtStart().date()) { 680 if (mDate == event->dtStart().date()) {
677 prefix ="->" ;multiday = 1; 681 prefix ="->" ;multiday = 1;
678 } else if (mDate == event->dtEnd().date()) { 682 } else if (mDate == event->dtEnd().date()) {
679 prefix ="<-" ;multiday = 3; 683 prefix ="<-" ;multiday = 3;
680 } 684 }
681 } 685 }
682 if ( !event->doesFloat() ) { 686 if ( !event->doesFloat() ) {
683 if ( mDate == event->dtStart().date () ) 687 if ( mDate == event->dtStart().date () )
684 time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; 688 time = KGlobal::locale()->formatTime(event->dtStart().time())+" ";
685 else if ( mDate == event->dtEnd().date () ) 689 else if ( mDate == event->dtEnd().date () )
686 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; 690 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
687 691
688 } 692 }
689 text = time + event->summary(); 693 text = time + event->summary();
690 mToolTipText += prefix + text; 694 if ( useToolTips )
695 mToolTipText += prefix + text;
691 } else { 696 } else {
692 if (event->doesFloat()) { 697 if (event->doesFloat()) {
693 text = event->summary(); 698 text = event->summary();
694 mToolTipText += text; 699 if ( useToolTips )
700 mToolTipText += text;
695 } 701 }
696 else { 702 else {
697 text = KGlobal::locale()->formatTime(event->dtStart().time()); 703 text = KGlobal::locale()->formatTime(event->dtStart().time());
698 text += " " + event->summary(); 704 text += " " + event->summary();
699 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 705 if ( useToolTips )
706 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
700 } 707 }
701 } 708 }
709 if ( useToolTips && ! event->location().isEmpty() ) {
710 mToolTipText += " (" + event->location() +")";
711 }
702 MonthViewItem *item ; 712 MonthViewItem *item ;
703 713
704 if ( mAvailItemList.count() ) { 714 if ( mAvailItemList.count() ) {
705 item = mAvailItemList.first(); 715 item = mAvailItemList.first();
706 mAvailItemList.remove( item ); 716 mAvailItemList.remove( item );
707 item->recycle( event, mDate, text ); 717 item->recycle( event, mDate, text );
708 } else { 718 } else {
709 item = new MonthViewItem( event, mDate, text ); 719 item = new MonthViewItem( event, mDate, text );
710 } 720 }
711 721
712 QPalette pal; 722 QPalette pal;
713 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 723 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
714 QStringList categories = event->categories(); 724 QStringList categories = event->categories();
715 QString cat = categories.first(); 725 QString cat = categories.first();
716 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 726 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
717 pal = getPalette(); 727 pal = getPalette();
718 if (cat.isEmpty()) { 728 if (cat.isEmpty()) {
719 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 729 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
720 } else { 730 } else {
721 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 731 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
722 } 732 }
723 733
724 } else { 734 } else {
725 if (cat.isEmpty()) { 735 if (cat.isEmpty()) {
726 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 736 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
727 } else { 737 } else {
728 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 738 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
729 } 739 }
730 } 740 }
731 741
732 } else { 742 } else {
733 pal = mStandardPalette ; 743 pal = mStandardPalette ;
734 } 744 }
735 item->setPalette( pal ); 745 item->setPalette( pal );
736 item->setRecur( event->recurrence()->doesRecur() ); 746 item->setRecur( event->recurrence()->doesRecur() );
737 item->setAlarm( event->isAlarmEnabled() && multiday < 2 ); 747 item->setAlarm( event->isAlarmEnabled() && multiday < 2 );
738 item->setMoreInfo( event->description().length() > 0 ); 748 item->setMoreInfo( event->description().length() > 0 );
739#ifdef DESKTOP_VERSION 749#ifdef DESKTOP_VERSION
740 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, 750 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
741 KOPrefs::instance()->email()); 751 KOPrefs::instance()->email());
742 if ( me != 0 ) { 752 if ( me != 0 ) {
743 if ( me->status() == Attendee::NeedsAction && me->RSVP()) 753 if ( me->status() == Attendee::NeedsAction && me->RSVP())
744 item->setReply(true && multiday < 2); 754 item->setReply(true && multiday < 2);
745 else 755 else
746 item->setReply(false); 756 item->setReply(false);
747 } else 757 } else
748 item->setReply(false); 758 item->setReply(false);
749#endif 759#endif
750 item->setMultiDay( multiday ); 760 item->setMultiDay( multiday );
751 if ( multiday ) { 761 if ( multiday ) {
752 insertItem( item ,mdayCount); 762 insertItem( item ,mdayCount);
753 ++mdayCount; 763 ++mdayCount;
754 } else { 764 } else {
755 uint i; 765 uint i;
756 int pos = mdayCount; 766 int pos = mdayCount;
757 for ( i = mdayCount; i < count();++i ) { 767 for ( i = mdayCount; i < count();++i ) {
758 QListBoxItem* it = this->item ( i ); 768 QListBoxItem* it = this->item ( i );
759 if ( text < it->text() ) { 769 if ( text < it->text() ) {
760 pos = i; 770 pos = i;
761 break; 771 break;
762 } 772 }
763 ++pos; 773 ++pos;
764 } 774 }
765 insertItem( item ,pos); 775 insertItem( item ,pos);
766 } 776 }
767 mToolTip.append( mToolTipText ); 777 if ( useToolTips )
778 mToolTip.append( mToolTipText );
768 return mdayCount; 779 return mdayCount;
769} 780}
770void MonthViewCell::insertTodo(Todo *todo) 781void MonthViewCell::insertTodo(Todo *todo)
771{ 782{
772 setFocusPolicy(WheelFocus); 783 setFocusPolicy(WheelFocus);
773 QString text; 784 QString text;
774 if (todo->hasDueDate()) { 785 if (todo->hasDueDate()) {
775 if (!todo->doesFloat()) { 786 if (!todo->doesFloat()) {
776 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 787 text += KGlobal::locale()->formatTime(todo->dtDue().time());
777 text += " "; 788 text += " ";
778 } 789 }
779 } 790 }
780 text += todo->summary(); 791 text += todo->summary();
781 MonthViewItem *item ; 792 MonthViewItem *item ;
782 if ( mAvailItemList.count() ) { 793 if ( mAvailItemList.count() ) {
783 item = mAvailItemList.first(); 794 item = mAvailItemList.first();
784 mAvailItemList.remove( item ); 795 mAvailItemList.remove( item );
785 item->recycle( todo, mDate, text ); 796 item->recycle( todo, mDate, text );
786 } else { 797 } else {
787 item = new MonthViewItem( todo, mDate, text ); 798 item = new MonthViewItem( todo, mDate, text );
788 } 799 }
789 //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); 800 //MonthViewItem *item = new MonthViewItem( todo, mDate, text );
790 //item->setPalette( mStandardPalette ); 801 //item->setPalette( mStandardPalette );
791 QPalette pal; 802 QPalette pal;
792 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 803 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
793 QStringList categories = todo->categories(); 804 QStringList categories = todo->categories();
794 QString cat = categories.first(); 805 QString cat = categories.first();
795 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 806 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
796 pal = getPalette(); 807 pal = getPalette();
797 if (cat.isEmpty()) { 808 if (cat.isEmpty()) {
798 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 809 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
799 } else { 810 } else {
800 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 811 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
801 } 812 }
802 813
803 } else { 814 } else {
804 if (cat.isEmpty()) { 815 if (cat.isEmpty()) {
805 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 816 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
806 } else { 817 } else {
807 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 818 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
808 } 819 }
809 } 820 }
810 821
811 } else { 822 } else {
812 pal = mStandardPalette ; 823 pal = mStandardPalette ;
813 } 824 }
814 item->setPalette( pal ); 825 item->setPalette( pal );
815 item->setRecur( todo->recurrence()->doesRecur() ); 826 item->setRecur( todo->recurrence()->doesRecur() );
816 item->setAlarm( todo->isAlarmEnabled() ); 827 item->setAlarm( todo->isAlarmEnabled() );
817 item->setMoreInfo( todo->description().length() > 0 ); 828 item->setMoreInfo( todo->description().length() > 0 );
818 insertItem( item , count()); 829 insertItem( item , count());
830#ifdef DESKTOP_VERSION
819 mToolTip.append( text ); 831 mToolTip.append( text );
832#endif
820} 833}
821void MonthViewCell::repaintfinishUpdateCell() 834void MonthViewCell::repaintfinishUpdateCell()
822{ 835{
823 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 836 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
824 while ( mitem ) { 837 while ( mitem ) {
825 mitem->setBlockRepaint( false ); 838 mitem->setBlockRepaint( false );
826 updateItem ( mitem ); 839 updateItem ( mitem );
827 mitem = (MonthViewItem *)mitem->next(); 840 mitem = (MonthViewItem *)mitem->next();
828 } 841 }
829} 842}
830void MonthViewCell::finishUpdateCell() 843void MonthViewCell::finishUpdateCell()
831{ 844{
832 845
833 846
834 847
835#ifdef DESKTOP_VERSION 848#ifdef DESKTOP_VERSION
836 if (mToolTip.count() > 0 ) { 849 if (mToolTip.count() > 0 ) {
837 mToolTip.sort(); 850 mToolTip.sort();
838 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); 851 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),"");
839 } 852 }
840#endif 853#endif
841 //sort(); 854 //sort();
842 //setMyPalette(); 855 //setMyPalette();
843 setMyPalette(); 856 setMyPalette();
844 857
845 resizeEvent( 0 ); 858 resizeEvent( 0 );
846 859
847} 860}
848void MonthViewCell::updateCell() 861void MonthViewCell::updateCell()
849{ 862{
850 //qDebug("MonthViewCell::updateCell() "); 863 //qDebug("MonthViewCell::updateCell() ");
851 if ( !mMonthView->isUpdatePossible() ) 864 if ( !mMonthView->isUpdatePossible() )
852 return; 865 return;
853 startUpdateCell(); 866 startUpdateCell();
854 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 867 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
855 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 868 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
856 Event *event; 869 Event *event;
857 for( event = events.first(); event; event = events.next() ) { // for event 870 for( event = events.first(); event; event = events.next() ) { // for event
858 insertEvent(event); 871 insertEvent(event);
859 } 872 }
860 // insert due todos 873 // insert due todos
861 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 874 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
862 Todo *todo; 875 Todo *todo;
863 for(todo = todos.first(); todo; todo = todos.next()) { 876 for(todo = todos.first(); todo; todo = todos.next()) {
864 insertTodo( todo ); 877 insertTodo( todo );
865 } 878 }
866 finishUpdateCell(); 879 finishUpdateCell();
867 // if ( isVisible()) 880 // if ( isVisible())
868 //qApp->processEvents(); 881 //qApp->processEvents();
869} 882}
870 883
871void MonthViewCell::updateConfig( bool bigFont ) // = false 884void MonthViewCell::updateConfig( bool bigFont ) // = false
872{ 885{
873 886
874 if ( bigFont ) { 887 if ( bigFont ) {
875 QFont fo = KOPrefs::instance()->mMonthViewFont; 888 QFont fo = KOPrefs::instance()->mMonthViewFont;
876 int ps = fo.pointSize() + 2; 889 int ps = fo.pointSize() + 2;
877 if ( ps < 18 ) 890 if ( ps < 18 )
878 ps += 2; 891 ps += 2;
879 fo.setPointSize( ps ); 892 fo.setPointSize( ps );
880 setFont( fo ); 893 setFont( fo );
881 } else 894 } else
882 setFont( KOPrefs::instance()->mMonthViewFont ); 895 setFont( KOPrefs::instance()->mMonthViewFont );
883 896
884 QFontMetrics fm( font() ); 897 QFontMetrics fm( font() );
885 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 898 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
886 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 899 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
887 mHolidayPalette = mStandardPalette; 900 mHolidayPalette = mStandardPalette;
888 mPrimaryPalette = mStandardPalette; 901 mPrimaryPalette = mStandardPalette;
889 mNonPrimaryPalette = mStandardPalette; 902 mNonPrimaryPalette = mStandardPalette;
890 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 903 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
891 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 904 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
892 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 905 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
893 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 906 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
894 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 907 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
895 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 908 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
896 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 909 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
897 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 910 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
898 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 911 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
899 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 912 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
900 } 913 }
901 //updateCell(); 914 //updateCell();
902} 915}
903 916
904void MonthViewCell::enableScrollBars( bool enabled ) 917void MonthViewCell::enableScrollBars( bool enabled )
905{ 918{
906 919
907 return; 920 return;
908 if ( enabled ) { 921 if ( enabled ) {
909 QListBoxItem *fi = firstItem (); 922 QListBoxItem *fi = firstItem ();
910 if (fi ) { 923 if (fi ) {
911 int ihei = fi->height( this ); 924 int ihei = fi->height( this );
912 int hei = numRows () * ihei; 925 int hei = numRows () * ihei;
913 if ( hei < height() - horizontalScrollBar()->height () ) { 926 if ( hei < height() - horizontalScrollBar()->height () ) {
914 setVScrollBarMode(QScrollView::AlwaysOff); 927 setVScrollBarMode(QScrollView::AlwaysOff);
915 } 928 }
916 else 929 else
917 setVScrollBarMode(QScrollView::Auto); 930 setVScrollBarMode(QScrollView::Auto);
918 if ( ihei *3 > height() ) { 931 if ( ihei *3 > height() ) {
919 setHScrollBarMode(QScrollView::AlwaysOff); 932 setHScrollBarMode(QScrollView::AlwaysOff);
920 } 933 }
921 else { 934 else {
922 setHScrollBarMode(QScrollView::Auto); 935 setHScrollBarMode(QScrollView::Auto);
923 } 936 }
924 } else { 937 } else {
925 setVScrollBarMode(QScrollView::Auto); 938 setVScrollBarMode(QScrollView::Auto);
926 setHScrollBarMode(QScrollView::Auto); 939 setHScrollBarMode(QScrollView::Auto);
927 } 940 }
928 } else { 941 } else {
929 setVScrollBarMode(QScrollView::AlwaysOff); 942 setVScrollBarMode(QScrollView::AlwaysOff);
930 setHScrollBarMode(QScrollView::AlwaysOff); 943 setHScrollBarMode(QScrollView::AlwaysOff);
931 } 944 }
932} 945}
933 946
934Incidence *MonthViewCell::selectedIncidence() 947Incidence *MonthViewCell::selectedIncidence()
935{ 948{
936 int index = currentItem(); 949 int index = currentItem();
937 if ( index < 0 ) return 0; 950 if ( index < 0 ) return 0;
938 951
939 MonthViewItem *mitem = 952 MonthViewItem *mitem =
940 static_cast<MonthViewItem *>( item( index ) ); 953 static_cast<MonthViewItem *>( item( index ) );
941 954
942 if ( !mitem ) return 0; 955 if ( !mitem ) return 0;
943 956
944 return mitem->incidence(); 957 return mitem->incidence();
945} 958}
946 959
947QDate MonthViewCell::selectedIncidenceDate() 960QDate MonthViewCell::selectedIncidenceDate()
948{ 961{
949 QDate qd; 962 QDate qd;
950 int index = currentItem(); 963 int index = currentItem();
951 if ( index < 0 ) return qd; 964 if ( index < 0 ) return qd;
952 965
953 MonthViewItem *mitem = 966 MonthViewItem *mitem =
954 static_cast<MonthViewItem *>( item( index ) ); 967 static_cast<MonthViewItem *>( item( index ) );
955 968
956 if ( !mitem ) return qd; 969 if ( !mitem ) return qd;
957 970
958 return mitem->incidenceDate(); 971 return mitem->incidenceDate();
959} 972}
960 973
961void MonthViewCell::deselect() 974void MonthViewCell::deselect()
962{ 975{
963 clearSelection(); 976 clearSelection();
964 enableScrollBars( false ); 977 enableScrollBars( false );
965 // updateCell(); 978 // updateCell();
966} 979}
967void MonthViewCell::select() 980void MonthViewCell::select()
968{ 981{
969 ;// updateCell(); 982 ;// updateCell();
970} 983}
971 984
972void MonthViewCell::resizeEvent ( QResizeEvent * e ) 985void MonthViewCell::resizeEvent ( QResizeEvent * e )
973{ 986{
974 if ( !mMonthView->isUpdatePossible() ) 987 if ( !mMonthView->isUpdatePossible() )
975 return; 988 return;
976 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); 989 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height());
977 deselect(); 990 deselect();
978 mLabel->setMaximumHeight( height() - lineWidth()*2 ); 991 mLabel->setMaximumHeight( height() - lineWidth()*2 );
979 992
980 QString text; 993 QString text;
981 mLabel->setText( text ); 994 mLabel->setText( text );
982 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 995 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
983 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 996 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
984 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; 997 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
985 mLabel->resize( mLabelBigSize ); 998 mLabel->resize( mLabelBigSize );
986 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 999 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
987 } else { 1000 } else {
988 mLabel->resize( mLabelSize ); 1001 mLabel->resize( mLabelSize );
989 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 1002 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
990 } 1003 }
991 mLabel->setText( text ); 1004 mLabel->setText( text );
992 1005
993 int size = height() - mLabel->height() - lineWidth()-1; 1006 int size = height() - mLabel->height() - lineWidth()-1;
994 //qDebug("LW %d ", lineWidth()); 1007 //qDebug("LW %d ", lineWidth());
995 if ( size > 0 ) 1008 if ( size > 0 )
996 verticalScrollBar()->setMaximumHeight( size ); 1009 verticalScrollBar()->setMaximumHeight( size );
997 size = width() - mLabel->width() -lineWidth()-1; 1010 size = width() - mLabel->width() -lineWidth()-1;
998 if ( size > 0 ) 1011 if ( size > 0 )
999 horizontalScrollBar()->setMaximumWidth( size ); 1012 horizontalScrollBar()->setMaximumWidth( size );
1000 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); 1013 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() );
1001 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 1014 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
1002 // mItemList->resize ( width(), height () ); 1015 // mItemList->resize ( width(), height () );
1003 if ( e ) 1016 if ( e )
1004 KNoScrollListBox::resizeEvent ( e ); 1017 KNoScrollListBox::resizeEvent ( e );
1005} 1018}
1006 1019
1007void MonthViewCell::defaultAction( QListBoxItem *item ) 1020void MonthViewCell::defaultAction( QListBoxItem *item )
1008{ 1021{
1009 1022
1010 if ( !item ) { 1023 if ( !item ) {
1011 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1024 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1012 emit newEventSignal( dt ); 1025 emit newEventSignal( dt );
1013 return; 1026 return;
1014 } 1027 }
1015 1028
1016 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 1029 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
1017 Incidence *incidence = eventItem->incidence(); 1030 Incidence *incidence = eventItem->incidence();
1018 if ( incidence ) mMonthView->defaultAction( incidence ); 1031 if ( incidence ) mMonthView->defaultAction( incidence );
1019} 1032}
1020void MonthViewCell::showDay() 1033void MonthViewCell::showDay()
1021{ 1034{
1022 emit showDaySignal( date() ); 1035 emit showDaySignal( date() );
1023} 1036}
1024void MonthViewCell::newEvent() 1037void MonthViewCell::newEvent()
1025{ 1038{
1026 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1039 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1027 emit newEventSignal( dt ); 1040 emit newEventSignal( dt );
1028} 1041}
1029void MonthViewCell::cellClicked( QListBoxItem *item ) 1042void MonthViewCell::cellClicked( QListBoxItem *item )
1030{ 1043{
1031 qDebug("CELL "); 1044 qDebug("CELL ");
1032 if ( item == 0 ) { 1045 if ( item == 0 ) {
1033 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1046 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1034 emit newEventSignal( dt ); 1047 emit newEventSignal( dt );
1035 return; 1048 return;
1036 } 1049 }
1037 1050
1038} 1051}
1039 1052
1040void MonthViewCell::contextMenu( QListBoxItem *item ) 1053void MonthViewCell::contextMenu( QListBoxItem *item )
1041{ 1054{
1042 if ( !item ) return; 1055 if ( !item ) return;
1043 1056
1044 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 1057 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
1045 Incidence *incidence = eventItem->incidence(); 1058 Incidence *incidence = eventItem->incidence();
1046 if ( incidence ) mMonthView->showContextMenu( incidence ); 1059 if ( incidence ) mMonthView->showContextMenu( incidence );
1047} 1060}
1048 1061
1049void MonthViewCell::selection( QListBoxItem *item ) 1062void MonthViewCell::selection( QListBoxItem *item )
1050{ 1063{
1051 if ( !item ) return; 1064 if ( !item ) return;
1052 1065
1053 mMonthView->setSelectedCell( this ); 1066 mMonthView->setSelectedCell( this );
1054} 1067}
1055 1068
1056 1069
1057// ******************************************************************************* 1070// *******************************************************************************
1058// ******************************************************************************* 1071// *******************************************************************************
1059// ******************************************************************************* 1072// *******************************************************************************
1060 1073
1061 1074
1062KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) 1075KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
1063 : KOEventView( calendar, parent, name ), 1076 : KOEventView( calendar, parent, name ),
1064 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), 1077 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
1065 mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) 1078 mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
1066{ 1079{
1067 mFlagKeyPressed = false; 1080 mFlagKeyPressed = false;
1068 mShortDayLabelsM = false; 1081 mShortDayLabelsM = false;
1069 mShortDayLabelsW = false; 1082 mShortDayLabelsW = false;
1070 skipResize = false; 1083 skipResize = false;
1071 clPending = true; 1084 clPending = true;
1072 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); 1085 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" );
1073 mWidStack = new QWidgetStack( this ); 1086 mWidStack = new QWidgetStack( this );
1074 QVBoxLayout* hb = new QVBoxLayout( this ); 1087 QVBoxLayout* hb = new QVBoxLayout( this );
1075 mMonthView = new QWidget( mWidStack ); 1088 mMonthView = new QWidget( mWidStack );
1076 mWeekView = new QWidget( mWidStack ); 1089 mWeekView = new QWidget( mWidStack );
1077#if QT_VERSION >= 0x030000 1090#if QT_VERSION >= 0x030000
1078 mWidStack->addWidget(mMonthView ); 1091 mWidStack->addWidget(mMonthView );
1079 mWidStack->addWidget(mWeekView ); 1092 mWidStack->addWidget(mWeekView );
1080#else 1093#else
1081 mWidStack->addWidget( mMonthView, 1 ); 1094 mWidStack->addWidget( mMonthView, 1 );
1082 mWidStack->addWidget( mWeekView , 1 ); 1095 mWidStack->addWidget( mWeekView , 1 );
1083#endif 1096#endif
1084 hb->addWidget( mNavigatorBar ); 1097 hb->addWidget( mNavigatorBar );
1085 hb->addWidget( mWidStack ); 1098 hb->addWidget( mWidStack );
1086 mShowWeekView = KOPrefs::instance()->mMonthViewWeek; 1099 mShowWeekView = KOPrefs::instance()->mMonthViewWeek;
1087 updatePossible = false; 1100 updatePossible = false;
1088 //updatePossible = true; 1101 //updatePossible = true;
1089 mCells.setAutoDelete( true ); 1102 mCells.setAutoDelete( true );
1090 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 1103 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
1091 mDayLabels.resize( mDaysPerWeek ); 1104 mDayLabels.resize( mDaysPerWeek );
1092 mDayLabelsW.resize( mDaysPerWeek ); 1105 mDayLabelsW.resize( mDaysPerWeek );
1093 QFont bfont = font(); 1106 QFont bfont = font();
1094 if ( QApplication::desktop()->width() < 650 ) { 1107 if ( QApplication::desktop()->width() < 650 ) {
1095 bfont.setPointSize( bfont.pointSize() - 2 ); 1108 bfont.setPointSize( bfont.pointSize() - 2 );
1096 } 1109 }
1097 bfont.setBold( true ); 1110 bfont.setBold( true );
1098 int i; 1111 int i;
1099 1112
1100 for( i = 0; i < mDaysPerWeek; i++ ) { 1113 for( i = 0; i < mDaysPerWeek; i++ ) {
1101 QLabel *label = new QLabel( mMonthView ); 1114 QLabel *label = new QLabel( mMonthView );
1102 label->setFont(bfont); 1115 label->setFont(bfont);
1103 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1116 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1104 label->setLineWidth(1); 1117 label->setLineWidth(1);
1105 label->setAlignment(AlignCenter); 1118 label->setAlignment(AlignCenter);
1106 mDayLabels.insert( i, label ); 1119 mDayLabels.insert( i, label );
1107 label = new QLabel( mWeekView ); 1120 label = new QLabel( mWeekView );
1108 label->setFont(bfont); 1121 label->setFont(bfont);
1109 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1122 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1110 label->setLineWidth(1); 1123 label->setLineWidth(1);
1111 label->setAlignment(AlignCenter); 1124 label->setAlignment(AlignCenter);
1112 mDayLabelsW.insert( i, label ); 1125 mDayLabelsW.insert( i, label );
1113 } 1126 }
1114 1127
1115 bfont.setBold( false ); 1128 bfont.setBold( false );
1116 mWeekLabels.resize( mNumWeeks+1 ); 1129 mWeekLabels.resize( mNumWeeks+1 );
1117 mWeekLabelsW.resize( 2 ); 1130 mWeekLabelsW.resize( 2 );
1118 for( i = 0; i < mNumWeeks+1; i++ ) { 1131 for( i = 0; i < mNumWeeks+1; i++ ) {
1119 KOWeekButton *label = new KOWeekButton( mMonthView ); 1132 KOWeekButton *label = new KOWeekButton( mMonthView );
1120 label->setFocusPolicy(NoFocus); 1133 label->setFocusPolicy(NoFocus);
1121 label->setFont(bfont); 1134 label->setFont(bfont);
1122 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 1135 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
1123 label->setFlat(true); 1136 label->setFlat(true);
1124 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 1137 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
1125 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1138 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1126 //label->setLineWidth(1); 1139 //label->setLineWidth(1);
1127 //label->setAlignment(AlignCenter); 1140 //label->setAlignment(AlignCenter);
1128 mWeekLabels.insert( i, label ); 1141 mWeekLabels.insert( i, label );
1129 } 1142 }
1130 mWeekLabels[mNumWeeks]->setText( i18n("W")); 1143 mWeekLabels[mNumWeeks]->setText( i18n("W"));
1131 mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); 1144 mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus);
1132 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); 1145 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number"));
1133 1146
1134 for( i = 0; i < 1+1; i++ ) { 1147 for( i = 0; i < 1+1; i++ ) {
1135 KOWeekButton *label = new KOWeekButton( mWeekView ); 1148 KOWeekButton *label = new KOWeekButton( mWeekView );
1136 label->setFocusPolicy(NoFocus); 1149 label->setFocusPolicy(NoFocus);
1137 label->setFont(bfont); 1150 label->setFont(bfont);
1138 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 1151 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
1139 label->setFlat(true); 1152 label->setFlat(true);
1140 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 1153 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
1141 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1154 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1142 //label->setLineWidth(1); 1155 //label->setLineWidth(1);
1143 //label->setAlignment(AlignCenter); 1156 //label->setAlignment(AlignCenter);
1144 mWeekLabelsW.insert( i, label ); 1157 mWeekLabelsW.insert( i, label );
1145 } 1158 }
1146 mWeekLabelsW[1]->setText( i18n("W")); 1159 mWeekLabelsW[1]->setText( i18n("W"));
1147 mWeekLabelsW[1]->setFocusPolicy(WheelFocus); 1160 mWeekLabelsW[1]->setFocusPolicy(WheelFocus);
1148 1161
1149 1162
1150 int row, col; 1163 int row, col;
1151 mCells.resize( mNumCells ); 1164 mCells.resize( mNumCells );
1152 for( row = 0; row < mNumWeeks; ++row ) { 1165 for( row = 0; row < mNumWeeks; ++row ) {
1153 for( col = 0; col < mDaysPerWeek; ++col ) { 1166 for( col = 0; col < mDaysPerWeek; ++col ) {
1154 MonthViewCell *cell = new MonthViewCell( this, mMonthView ); 1167 MonthViewCell *cell = new MonthViewCell( this, mMonthView );
1155 mCells.insert( row * mDaysPerWeek + col, cell ); 1168 mCells.insert( row * mDaysPerWeek + col, cell );
1156 1169
1157 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 1170 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
1158 SLOT( defaultAction( Incidence * ) ) ); 1171 SLOT( defaultAction( Incidence * ) ) );
1159 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 1172 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
1160 SIGNAL( newEventSignal( QDateTime ) ) ); 1173 SIGNAL( newEventSignal( QDateTime ) ) );
1161 connect( cell, SIGNAL( showDaySignal( QDate ) ), 1174 connect( cell, SIGNAL( showDaySignal( QDate ) ),
1162 SIGNAL( showDaySignal( QDate ) ) ); 1175 SIGNAL( showDaySignal( QDate ) ) );
1163 connect( cell, SIGNAL( nextCell() ), 1176 connect( cell, SIGNAL( nextCell() ),
1164 SLOT( nextCell() ) ); 1177 SLOT( nextCell() ) );
1165 connect( cell, SIGNAL( prevCell() ), 1178 connect( cell, SIGNAL( prevCell() ),
1166 SLOT( prevCell() ) ); 1179 SLOT( prevCell() ) );
1167 } 1180 }
1168 } 1181 }
1169 mCellsW.resize( mDaysPerWeek ); 1182 mCellsW.resize( mDaysPerWeek );
1170 for( col = 0; col < mDaysPerWeek; ++col ) { 1183 for( col = 0; col < mDaysPerWeek; ++col ) {
1171 MonthViewCell *cell = new MonthViewCell( this, mWeekView ); 1184 MonthViewCell *cell = new MonthViewCell( this, mWeekView );
1172 mCellsW.insert( col, cell ); 1185 mCellsW.insert( col, cell );
1173 1186
1174 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 1187 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
1175 SLOT( defaultAction( Incidence * ) ) ); 1188 SLOT( defaultAction( Incidence * ) ) );
1176 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 1189 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
1177 SIGNAL( newEventSignal( QDateTime ) ) ); 1190 SIGNAL( newEventSignal( QDateTime ) ) );
1178 connect( cell, SIGNAL( showDaySignal( QDate ) ), 1191 connect( cell, SIGNAL( showDaySignal( QDate ) ),
1179 SIGNAL( showDaySignal( QDate ) ) ); 1192 SIGNAL( showDaySignal( QDate ) ) );
1180 connect( cell, SIGNAL( nextCell() ), 1193 connect( cell, SIGNAL( nextCell() ),
1181 SLOT( nextCell() ) ); 1194 SLOT( nextCell() ) );
1182 connect( cell, SIGNAL( prevCell() ), 1195 connect( cell, SIGNAL( prevCell() ),
1183 SLOT( prevCell() ) ); 1196 SLOT( prevCell() ) );
1184 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); 1197 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont );
1185 } 1198 }
1186 1199
1187 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); 1200 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) );
1188 mContextMenu = eventPopup(); 1201 mContextMenu = eventPopup();
1189 // updateConfig(); //useless here... 1202 // updateConfig(); //useless here...
1190 // ... but we need mWidthLongDayLabel computed 1203 // ... but we need mWidthLongDayLabel computed
1191 QFontMetrics fontmetric(mDayLabels[0]->font()); 1204 QFontMetrics fontmetric(mDayLabels[0]->font());
1192 mWidthLongDayLabel = 0; 1205 mWidthLongDayLabel = 0;
1193 for (int i = 0; i < 7; i++) { 1206 for (int i = 0; i < 7; i++) {
1194 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 1207 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
1195 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 1208 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
1196 } 1209 }
1197 1210
1198 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 1211 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
1199 1212
1200#if 0 1213#if 0
1201 if ( mShowWeekView ) 1214 if ( mShowWeekView )
1202 mWidStack->raiseWidget( mWeekView ); 1215 mWidStack->raiseWidget( mWeekView );
1203 else 1216 else