summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-03-21 12:34:49 (UTC)
committer zautrix <zautrix>2005-03-21 12:34:49 (UTC)
commit3b7ba9f46c78816bae8c4b30a455e261d7da9f4a (patch) (unidiff)
treedb85cf3f0520828c358aadc3867705a95fcb9d88
parentb40a7cc0a8cf0bd06b0f404f58e89980d1291beb (diff)
downloadkdepimpi-3b7ba9f46c78816bae8c4b30a455e261d7da9f4a.zip
kdepimpi-3b7ba9f46c78816bae8c4b30a455e261d7da9f4a.tar.gz
kdepimpi-3b7ba9f46c78816bae8c4b30a455e261d7da9f4a.tar.bz2
fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kodaymatrix.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index 5133519..9c1f5f3 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -151,108 +151,123 @@ QString KODayMatrix::getWhatsThisText( QPoint p )
151 QStringList mToolTip; 151 QStringList mToolTip;
152 for(event=eventlist.first();event != 0;event=eventlist.next()) { 152 for(event=eventlist.first();event != 0;event=eventlist.next()) {
153 QString mToolTipText; 153 QString mToolTipText;
154 QString text; 154 QString text;
155 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day 155 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day
156 if (event->isMultiDay()) { 156 if (event->isMultiDay()) {
157 QString prefix = "<->";multiday = 2; 157 QString prefix = "<->";multiday = 2;
158 QString time; 158 QString time;
159 if ( event->doesRecur() ) { 159 if ( event->doesRecur() ) {
160 if ( event->recursOn( mDate) ) { 160 if ( event->recursOn( mDate) ) {
161 prefix ="->" ;multiday = 1; 161 prefix ="->" ;multiday = 1;
162 } 162 }
163 else { 163 else {
164 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 164 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
165 if ( event->recursOn( mDate.addDays( -days)) ) { 165 if ( event->recursOn( mDate.addDays( -days)) ) {
166 prefix ="<-" ;multiday = 3; 166 prefix ="<-" ;multiday = 3;
167 } 167 }
168 } 168 }
169 } else { 169 } else {
170 if (mDate == event->dtStart().date()) { 170 if (mDate == event->dtStart().date()) {
171 prefix ="->" ;multiday = 1; 171 prefix ="->" ;multiday = 1;
172 } else if (mDate == event->dtEnd().date()) { 172 } else if (mDate == event->dtEnd().date()) {
173 prefix ="<-" ;multiday = 3; 173 prefix ="<-" ;multiday = 3;
174 } 174 }
175 } 175 }
176 if ( !event->doesFloat() ) { 176 if ( !event->doesFloat() ) {
177 if ( mDate == event->dtStart().date () ) 177 if ( mDate == event->dtStart().date () )
178 time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; 178 time = KGlobal::locale()->formatTime(event->dtStart().time())+" ";
179 else if ( mDate == event->dtEnd().date () ) 179 else if ( mDate == event->dtEnd().date () )
180 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; 180 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
181 181
182 } 182 }
183 qDebug("event->isMultiDay() %s", event->summary().latin1() );
183 text = time + event->summary(); 184 text = time + event->summary();
184 mToolTipText += prefix + text; 185 mToolTipText += prefix + text;
185 } else { 186 } else {
186 if (event->doesFloat()) { 187 if (event->doesFloat()) {
187 text = event->summary(); 188 text = event->summary();
188 mToolTipText += text; 189 mToolTipText += text;
189 } 190 }
190 else { 191 else {
191 text = KGlobal::locale()->formatTime(event->dtStart().time()); 192 text = KGlobal::locale()->formatTime(event->dtStart().time());
192 text += " " + event->summary(); 193 text += " " + event->summary();
193 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 194 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
194 } 195 }
195 } 196 }
197 if ( !event->location().isEmpty() )
198 mToolTipText += " (" + event->location() + ")";
199#if QT_VERSION >= 0x030000
200 mToolTipText.replace( '<' , "&lt;" );
201 mToolTipText.replace( '>' , "&gt;" );
202#else
203 if ( mToolTipText.find ('<') > 0 ) {
204 mToolTipText.replace( QRegExp("<") , "&lt;" );
205 }
206 if ( mToolTipText.find ('>') > 0 ) {
207 mToolTipText.replace( QRegExp(">") , "&gt;" );
208 }
209#endif
196 mToolTip.append( mToolTipText ); 210 mToolTip.append( mToolTipText );
197 } 211 }
198 mToolTip.sort(); 212 mToolTip.sort();
213 qDebug("%s ", mToolTip.join("<br>").latin1());
199 return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); 214 return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>");
200} 215}
201void KODayMatrix::setCalendar( Calendar *cal ) 216void KODayMatrix::setCalendar( Calendar *cal )
202{ 217{
203 mCalendar = cal; 218 mCalendar = cal;
204 219
205 setAcceptDrops( mCalendar ); 220 setAcceptDrops( mCalendar );
206 221
207 updateEvents(); 222 updateEvents();
208} 223}
209 224
210QColor KODayMatrix::getShadedColor(QColor color) 225QColor KODayMatrix::getShadedColor(QColor color)
211{ 226{
212 QColor shaded; 227 QColor shaded;
213 int h=0; 228 int h=0;
214 int s=0; 229 int s=0;
215 int v=0; 230 int v=0;
216 color.hsv(&h,&s,&v); 231 color.hsv(&h,&s,&v);
217 s = s/4; 232 s = s/4;
218 v = 192+v/4; 233 v = 192+v/4;
219 shaded.setHsv(h,s,v); 234 shaded.setHsv(h,s,v);
220 235
221 return shaded; 236 return shaded;
222} 237}
223 238
224KODayMatrix::~KODayMatrix() 239KODayMatrix::~KODayMatrix()
225{ 240{
226 delete mKODaymatrixWhatsThis; 241 // delete mKODaymatrixWhatsThis;
227 delete [] days; 242 delete [] days;
228 delete [] daylbls; 243 delete [] daylbls;
229 delete [] events; 244 delete [] events;
230 delete mToolTip; 245 delete mToolTip;
231} 246}
232 247
233/* 248/*
234void KODayMatrix::setStartDate(QDate start) 249void KODayMatrix::setStartDate(QDate start)
235{ 250{
236 updateView(start); 251 updateView(start);
237} 252}
238*/ 253*/
239 254
240void KODayMatrix::addSelectedDaysTo(DateList& selDays) 255void KODayMatrix::addSelectedDaysTo(DateList& selDays)
241{ 256{
242 257
243 if (mSelStart == NOSELECTION) { 258 if (mSelStart == NOSELECTION) {
244 return; 259 return;
245 } 260 }
246 261
247 //cope with selection being out of matrix limits at top (< 0) 262 //cope with selection being out of matrix limits at top (< 0)
248 int i0 = mSelStart; 263 int i0 = mSelStart;
249 if (i0 < 0) { 264 if (i0 < 0) {
250 for (int i = i0; i < 0; i++) { 265 for (int i = i0; i < 0; i++) {
251 selDays.append(days[0].addDays(i)); 266 selDays.append(days[0].addDays(i));
252 } 267 }
253 i0 = 0; 268 i0 = 0;
254 } 269 }
255 270
256 //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) 271 //cope with selection being out of matrix limits at bottom (> NUMDAYS-1)
257 if (mSelEnd > NUMDAYS-1) { 272 if (mSelEnd > NUMDAYS-1) {
258 for (int i = i0; i <= NUMDAYS-1; i++) { 273 for (int i = i0; i <= NUMDAYS-1; i++) {
@@ -308,69 +323,73 @@ void KODayMatrix::updateView()
308 updateView(startdate); 323 updateView(startdate);
309} 324}
310void KODayMatrix::repaintViewTimed() 325void KODayMatrix::repaintViewTimed()
311{ 326{
312 mRepaintTimer->stop(); 327 mRepaintTimer->stop();
313 repaint(false); 328 repaint(false);
314} 329}
315void KODayMatrix::updateViewTimed() 330void KODayMatrix::updateViewTimed()
316{ 331{
317 mUpdateTimer->stop(); 332 mUpdateTimer->stop();
318 if ( !mCalendar ) { 333 if ( !mCalendar ) {
319 qDebug("NOT CAL "); 334 qDebug("NOT CAL ");
320 return; 335 return;
321 } 336 }
322 //qDebug("KODayMatrix::updateViewTimed "); 337 //qDebug("KODayMatrix::updateViewTimed ");
323 for(int i = 0; i < NUMDAYS; i++) { 338 for(int i = 0; i < NUMDAYS; i++) {
324 // if events are set for the day then remember to draw it bold 339 // if events are set for the day then remember to draw it bold
325 QPtrList<Event> eventlist = mCalendar->events(days[i]); 340 QPtrList<Event> eventlist = mCalendar->events(days[i]);
326 Event *event; 341 Event *event;
327 int numEvents = eventlist.count(); 342 int numEvents = eventlist.count();
328 QString holiStr = ""; 343 QString holiStr = "";
329 bDays.clearBit(i); 344 bDays.clearBit(i);
330 for(event=eventlist.first();event != 0;event=eventlist.next()) { 345 for(event=eventlist.first();event != 0;event=eventlist.next()) {
331 ushort recurType = event->recurrence()->doesRecur(); 346 ushort recurType = event->recurrence()->doesRecur();
332 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || 347 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) ||
333 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { 348 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
334 numEvents--; 349 numEvents--;
335 } 350 }
336 if ( event->categories().contains( i18n("Holiday") ) || event->categories().contains( "Holiday" )) { 351 if ( event->categories().contains( i18n("Holiday") ) || event->categories().contains( "Holiday" )) {
337 if ( !holiStr.isEmpty() ) 352 if ( !holiStr.isEmpty() )
338 holiStr += "\n"; 353 holiStr += "\n";
339 holiStr += event->summary(); 354 holiStr += event->summary();
355 if ( !event->location().isEmpty() )
356 holiStr += " (" + event->location() + ")";
340 } 357 }
341 if ( event->categories().contains( i18n("Birthday") ) || event->categories().contains( "Birthday" )) { 358 if ( event->categories().contains( i18n("Birthday") ) || event->categories().contains( "Birthday" )) {
342 if ( !holiStr.isEmpty() ) 359 if ( !holiStr.isEmpty() )
343 holiStr += "\n"; 360 holiStr += "\n";
344 holiStr += event->summary(); 361 holiStr += i18n("Birthday") + ": "+event->summary();
362 if ( !event->location().isEmpty() )
363 holiStr += " (" + event->location() + ")";
345 bDays.setBit(i); 364 bDays.setBit(i);
346 } 365 }
347 } 366 }
348 events[i] = numEvents; 367 events[i] = numEvents;
349 //if it is a holy day then draw it red. Sundays are consider holidays, too 368 //if it is a holy day then draw it red. Sundays are consider holidays, too
350 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || 369 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) ||
351 !holiStr.isEmpty()) { 370 !holiStr.isEmpty()) {
352 mHolidays[i] = holiStr; 371 mHolidays[i] = holiStr;
353 } else { 372 } else {
354 mHolidays[i] = QString::null; 373 mHolidays[i] = QString::null;
355 } 374 }
356 } 375 }
357 if ( ! mPendingUpdateBeforeRepaint ) 376 if ( ! mPendingUpdateBeforeRepaint )
358 repaint(false); 377 repaint(false);
359} 378}
360void KODayMatrix::updateView(QDate actdate) 379void KODayMatrix::updateView(QDate actdate)
361{ 380{
362 381
363 if ( ! actdate.isValid() ) { 382 if ( ! actdate.isValid() ) {
364 //qDebug("date not valid "); 383 //qDebug("date not valid ");
365 return; 384 return;
366 } 385 }
367 mDayChanged = false; 386 mDayChanged = false;
368 //flag to indicate if the starting day of the matrix has changed by this call 387 //flag to indicate if the starting day of the matrix has changed by this call
369 //mDayChanged = false; 388 //mDayChanged = false;
370 // if a new startdate is to be set then apply Cornelius's calculation 389 // if a new startdate is to be set then apply Cornelius's calculation
371 // of the first day to be shown 390 // of the first day to be shown
372 if (actdate != startdate) { 391 if (actdate != startdate) {
373 // reset index of selection according to shift of starting date from startdate to actdate 392 // reset index of selection according to shift of starting date from startdate to actdate
374 if (mSelStart != NOSELECTION) { 393 if (mSelStart != NOSELECTION) {
375 int tmp = actdate.daysTo(startdate); 394 int tmp = actdate.daysTo(startdate);
376 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; 395 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl;