summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-01-31 08:46:08 (UTC)
committer zautrix <zautrix>2005-01-31 08:46:08 (UTC)
commit9b13105b4cc0ede4ca2d01a3d998fdb90bf67b58 (patch) (unidiff)
treedb736dd6d3615d46db1bf1d32965a5872d3cc0d4
parentf7663a4c854d217bcb4f828a3ebb69cc40d0dd7c (diff)
downloadkdepimpi-9b13105b4cc0ede4ca2d01a3d998fdb90bf67b58.zip
kdepimpi-9b13105b4cc0ede4ca2d01a3d998fdb90bf67b58.tar.gz
kdepimpi-9b13105b4cc0ede4ca2d01a3d998fdb90bf67b58.tar.bz2
fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kodaymatrix.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index be5a775..9812321 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -199,196 +199,197 @@ void KODayMatrix::recalculateToday()
199 // if today is in the currently displayed month, hilight today 199 // if today is in the currently displayed month, hilight today
200 if (days[i].year() == QDate::currentDate().year() && 200 if (days[i].year() == QDate::currentDate().year() &&
201 days[i].month() == QDate::currentDate().month() && 201 days[i].month() == QDate::currentDate().month() &&
202 days[i].day() == QDate::currentDate().day()) { 202 days[i].day() == QDate::currentDate().day()) {
203 today = i; 203 today = i;
204 } 204 }
205 } 205 }
206 // qDebug(QString("Today is visible at %1.").arg(today)); 206 // qDebug(QString("Today is visible at %1.").arg(today));
207} 207}
208 208
209void KODayMatrix::updateView() 209void KODayMatrix::updateView()
210{ 210{
211 updateView(startdate); 211 updateView(startdate);
212} 212}
213void KODayMatrix::repaintViewTimed() 213void KODayMatrix::repaintViewTimed()
214{ 214{
215 //qDebug("KODayMatrix::repaintViewTimed "); 215 //qDebug("KODayMatrix::repaintViewTimed ");
216 mRepaintTimer->stop(); 216 mRepaintTimer->stop();
217 repaint(false); 217 repaint(false);
218} 218}
219void KODayMatrix::updateViewTimed() 219void KODayMatrix::updateViewTimed()
220{ 220{
221 221
222 mUpdateTimer->stop(); 222 mUpdateTimer->stop();
223 //qDebug("KODayMatrix::updateView(QDate actdate) %d", ++iii ); 223 //qDebug("KODayMatrix::updateView(QDate actdate) %d", ++iii );
224 for(int i = 0; i < NUMDAYS; i++) { 224 for(int i = 0; i < NUMDAYS; i++) {
225 225
226 // if events are set for the day then remember to draw it bold 226 // if events are set for the day then remember to draw it bold
227 QPtrList<Event> eventlist = mCalendar->events(days[i]); 227 QPtrList<Event> eventlist = mCalendar->events(days[i]);
228 Event *event; 228 Event *event;
229 int numEvents = eventlist.count(); 229 int numEvents = eventlist.count();
230 230
231 for(event=eventlist.first();event != 0;event=eventlist.next()) { 231 for(event=eventlist.first();event != 0;event=eventlist.next()) {
232 ushort recurType = event->recurrence()->doesRecur(); 232 ushort recurType = event->recurrence()->doesRecur();
233 233
234 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || 234 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) ||
235 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { 235 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
236 numEvents--; 236 numEvents--;
237 } 237 }
238 } 238 }
239 events[i] = numEvents; 239 events[i] = numEvents;
240 240
241 //if it is a holy day then draw it red. Sundays are consider holidays, too 241 //if it is a holy day then draw it red. Sundays are consider holidays, too
242#ifndef KORG_NOPLUGINS 242#ifndef KORG_NOPLUGINS
243 QString holiStr = KOCore::self()->holiday(days[i]); 243 QString holiStr = KOCore::self()->holiday(days[i]);
244#else 244#else
245 QString holiStr = QString::null; 245 QString holiStr = QString::null;
246#endif 246#endif
247 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || 247 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) ||
248 !holiStr.isEmpty()) { 248 !holiStr.isEmpty()) {
249 if (holiStr.isNull()) holiStr = ""; 249 if (holiStr.isNull()) holiStr = "";
250 mHolidays[i] = holiStr; 250 mHolidays[i] = holiStr;
251 251
252 } else { 252 } else {
253 mHolidays[i] = QString::null; 253 mHolidays[i] = QString::null;
254 } 254 }
255 } 255 }
256 if ( ! mPendingUpdateBeforeRepaint ) 256 if ( ! mPendingUpdateBeforeRepaint )
257 repaint(false); 257 repaint(false);
258 } 258 }
259void KODayMatrix::updateView(QDate actdate) 259void KODayMatrix::updateView(QDate actdate)
260{ 260{
261 261
262 if ( ! actdate.isValid() ) { 262 if ( ! actdate.isValid() ) {
263 //qDebug("date not valid "); 263 //qDebug("date not valid ");
264 return; 264 return;
265 } 265 }
266 mDayChanged = false; 266 mDayChanged = false;
267 //flag to indicate if the starting day of the matrix has changed by this call 267 //flag to indicate if the starting day of the matrix has changed by this call
268 //mDayChanged = false; 268 //mDayChanged = false;
269 // if a new startdate is to be set then apply Cornelius's calculation 269 // if a new startdate is to be set then apply Cornelius's calculation
270 // of the first day to be shown 270 // of the first day to be shown
271 if (actdate != startdate) { 271 if (actdate != startdate) {
272 // reset index of selection according to shift of starting date from startdate to actdate 272 // reset index of selection according to shift of starting date from startdate to actdate
273 if (mSelStart != NOSELECTION) { 273 if (mSelStart != NOSELECTION) {
274 int tmp = actdate.daysTo(startdate); 274 int tmp = actdate.daysTo(startdate);
275 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; 275 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl;
276 // shift selection if new one would be visible at least partly ! 276 // shift selection if new one would be visible at least partly !
277 277
278 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { 278 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) {
279 // nested if is required for next X display pushed from a different month - correction required 279 // nested if is required for next X display pushed from a different month - correction required
280 // otherwise, for month forward and backward, it must be avoided 280 // otherwise, for month forward and backward, it must be avoided
281 if( mSelStart > NUMDAYS || mSelStart < 0 ) 281 if( mSelStart > NUMDAYS || mSelStart < 0 )
282 mSelStart = mSelStart + tmp; 282 mSelStart = mSelStart + tmp;
283 if( mSelEnd > NUMDAYS || mSelEnd < 0 ) 283 if( mSelEnd > NUMDAYS || mSelEnd < 0 )
284 mSelEnd = mSelEnd + tmp; 284 mSelEnd = mSelEnd + tmp;
285 } 285 }
286 } 286 }
287 startdate = actdate; 287 startdate = actdate;
288 mDayChanged = true; 288 mDayChanged = true;
289 recalculateToday(); 289 recalculateToday();
290 } 290 }
291 //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); 291 //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() );
292 if ( !isVisible() ) { 292 if ( !isVisible() ) {
293 mPendingUpdateBeforeRepaint = true; 293 mPendingUpdateBeforeRepaint = true;
294 } else { 294 } else {
295 mRepaintTimer->start( 250 );
296#ifdef DESKTOP_VERSION 295#ifdef DESKTOP_VERSION
296 mRepaintTimer->start( 250 );
297 mUpdateTimer->start( 2000 ); 297 mUpdateTimer->start( 2000 );
298#else 298#else
299 mRepaintTimer->start( 350 );
299 mUpdateTimer->start( 4000 ); 300 mUpdateTimer->start( 4000 );
300#endif 301#endif
301 } 302 }
302} 303}
303 304
304const QDate& KODayMatrix::getDate(int offset) 305const QDate& KODayMatrix::getDate(int offset)
305{ 306{
306 if (offset < 0 || offset > NUMDAYS-1) { 307 if (offset < 0 || offset > NUMDAYS-1) {
307 qDebug("Wrong offset2 "); 308 qDebug("Wrong offset2 ");
308 return days[0]; 309 return days[0];
309 } 310 }
310 return days[offset]; 311 return days[offset];
311} 312}
312 313
313QString KODayMatrix::getHolidayLabel(int offset) 314QString KODayMatrix::getHolidayLabel(int offset)
314{ 315{
315 if (offset < 0 || offset > NUMDAYS-1) { 316 if (offset < 0 || offset > NUMDAYS-1) {
316 qDebug("Wrong offset1 "); 317 qDebug("Wrong offset1 ");
317 return 0; 318 return 0;
318 } 319 }
319 return mHolidays[offset]; 320 return mHolidays[offset];
320} 321}
321 322
322int KODayMatrix::getDayIndexFrom(int x, int y) 323int KODayMatrix::getDayIndexFrom(int x, int y)
323{ 324{
324 return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? 325 return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ?
325 6 - x/daysize.width() : x/daysize.width()); 326 6 - x/daysize.width() : x/daysize.width());
326} 327}
327 328
328// ---------------------------------------------------------------------------- 329// ----------------------------------------------------------------------------
329// M O U S E E V E N T H A N D L I N G 330// M O U S E E V E N T H A N D L I N G
330// ---------------------------------------------------------------------------- 331// ----------------------------------------------------------------------------
331 332
332void KODayMatrix::mousePressEvent (QMouseEvent* e) 333void KODayMatrix::mousePressEvent (QMouseEvent* e)
333{ 334{
334 mSelStart = getDayIndexFrom(e->x(), e->y()); 335 mSelStart = getDayIndexFrom(e->x(), e->y());
335 if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; 336 if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1;
336 mSelInit = mSelStart; 337 mSelInit = mSelStart;
337} 338}
338 339
339void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) 340void KODayMatrix::mouseReleaseEvent (QMouseEvent* e)
340{ 341{
341 342
342 int tmp = getDayIndexFrom(e->x(), e->y()); 343 int tmp = getDayIndexFrom(e->x(), e->y());
343 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; 344 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1;
344 345
345 if (mSelInit > tmp) { 346 if (mSelInit > tmp) {
346 mSelEnd = mSelInit; 347 mSelEnd = mSelInit;
347 if (tmp != mSelStart) { 348 if (tmp != mSelStart) {
348 mSelStart = tmp; 349 mSelStart = tmp;
349 repaint(); 350 repaint();
350 } 351 }
351 } else { 352 } else {
352 mSelStart = mSelInit; 353 mSelStart = mSelInit;
353 354
354 //repaint only if selection has changed 355 //repaint only if selection has changed
355 if (tmp != mSelEnd) { 356 if (tmp != mSelEnd) {
356 mSelEnd = tmp; 357 mSelEnd = tmp;
357 repaint(); 358 repaint();
358 } 359 }
359 } 360 }
360 361
361 DateList daylist; 362 DateList daylist;
362 if ( mSelStart < 0 ) 363 if ( mSelStart < 0 )
363 mSelStart = 0; 364 mSelStart = 0;
364 for (int i = mSelStart; i <= mSelEnd; i++) { 365 for (int i = mSelStart; i <= mSelEnd; i++) {
365 daylist.append(days[i]); 366 daylist.append(days[i]);
366 } 367 }
367 emit selected((const DateList)daylist); 368 emit selected((const DateList)daylist);
368 369
369} 370}
370 371
371void KODayMatrix::mouseMoveEvent (QMouseEvent* e) 372void KODayMatrix::mouseMoveEvent (QMouseEvent* e)
372{ 373{
373 int tmp = getDayIndexFrom(e->x(), e->y()); 374 int tmp = getDayIndexFrom(e->x(), e->y());
374 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; 375 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1;
375 376
376 if (mSelInit > tmp) { 377 if (mSelInit > tmp) {
377 mSelEnd = mSelInit; 378 mSelEnd = mSelInit;
378 if (tmp != mSelStart) { 379 if (tmp != mSelStart) {
379 mSelStart = tmp; 380 mSelStart = tmp;
380 repaint(); 381 repaint();
381 } 382 }
382 } else { 383 } else {
383 mSelStart = mSelInit; 384 mSelStart = mSelInit;
384 385
385 //repaint only if selection has changed 386 //repaint only if selection has changed
386 if (tmp != mSelEnd) { 387 if (tmp != mSelEnd) {
387 mSelEnd = tmp; 388 mSelEnd = tmp;
388 repaint(); 389 repaint();
389 } 390 }
390 } 391 }
391} 392}
392 393
393// ---------------------------------------------------------------------------- 394// ----------------------------------------------------------------------------
394// D R A G ' N D R O P H A N D L I N G 395// D R A G ' N D R O P H A N D L I N G