author | zautrix <zautrix> | 2005-02-08 23:15:22 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-08 23:15:22 (UTC) |
commit | d0ab37d35ca9a9d919c9fc4856f3314bfef6dd5a (patch) (unidiff) | |
tree | 751d52e216392132e8ad36ba9e8a23ae64083951 /microkde/kdatetbl.cpp | |
parent | 2124ce7f8c6edbd0e3ec32b1d1e6a625ef9450d6 (diff) | |
download | kdepimpi-d0ab37d35ca9a9d919c9fc4856f3314bfef6dd5a.zip kdepimpi-d0ab37d35ca9a9d919c9fc4856f3314bfef6dd5a.tar.gz kdepimpi-d0ab37d35ca9a9d919c9fc4856f3314bfef6dd5a.tar.bz2 |
fff
-rw-r--r-- | microkde/kdatetbl.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/microkde/kdatetbl.cpp b/microkde/kdatetbl.cpp index 1024796..d182279 100644 --- a/microkde/kdatetbl.cpp +++ b/microkde/kdatetbl.cpp | |||
@@ -269,385 +269,385 @@ KDateTable::keyPressEvent( QKeyEvent *e ) | |||
269 | if(firstday+numdays<pos+dayoff) | 269 | if(firstday+numdays<pos+dayoff) |
270 | { // this date is in the next month | 270 | { // this date is in the next month |
271 | KNotifyClient::beep(i18n( "Month not long enough" )); | 271 | KNotifyClient::beep(i18n( "Month not long enough" )); |
272 | return; | 272 | return; |
273 | } | 273 | } |
274 | 274 | ||
275 | if ( pos == temp ) | 275 | if ( pos == temp ) |
276 | return; | 276 | return; |
277 | 277 | ||
278 | setDate(QDate(date.year(), date.month(), pos-firstday+dayoff)); | 278 | setDate(QDate(date.year(), date.month(), pos-firstday+dayoff)); |
279 | updateCell(temp/7+1, temp%7); // Update the previously selected cell | 279 | updateCell(temp/7+1, temp%7); // Update the previously selected cell |
280 | updateCell(pos/7+1, pos%7); // Update the selected cell | 280 | updateCell(pos/7+1, pos%7); // Update the selected cell |
281 | assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); | 281 | assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); |
282 | 282 | ||
283 | 283 | ||
284 | } | 284 | } |
285 | 285 | ||
286 | void | 286 | void |
287 | KDateTable::viewportResizeEvent(QResizeEvent * e) | 287 | KDateTable::viewportResizeEvent(QResizeEvent * e) |
288 | { | 288 | { |
289 | QGridView::viewportResizeEvent(e); | 289 | QGridView::viewportResizeEvent(e); |
290 | 290 | ||
291 | setCellWidth(viewport()->width()/7); | 291 | setCellWidth(viewport()->width()/7); |
292 | setCellHeight(viewport()->height()/7); | 292 | setCellHeight(viewport()->height()/7); |
293 | } | 293 | } |
294 | 294 | ||
295 | void | 295 | void |
296 | KDateTable::setFontSize(int size) | 296 | KDateTable::setFontSize(int size) |
297 | { | 297 | { |
298 | int count; | 298 | int count; |
299 | QRect rect; | 299 | QRect rect; |
300 | // ----- store rectangles: | 300 | // ----- store rectangles: |
301 | fontsize=size; | 301 | fontsize=size; |
302 | QFont _font = font(); | 302 | QFont _font = font(); |
303 | _font.setPointSize(fontsize); | 303 | _font.setPointSize(fontsize); |
304 | setFont( _font ); | 304 | setFont( _font ); |
305 | _font.setBold( true ); | 305 | _font.setBold( true ); |
306 | QFontMetrics metrics(_font); | 306 | QFontMetrics metrics(_font); |
307 | 307 | ||
308 | // ----- find largest day name: | 308 | // ----- find largest day name: |
309 | maxCell.setWidth(0); | 309 | maxCell.setWidth(0); |
310 | maxCell.setHeight(0); | 310 | maxCell.setHeight(0); |
311 | for(count=0; count<7; ++count) | 311 | for(count=0; count<7; ++count) |
312 | { | 312 | { |
313 | rect=metrics.boundingRect(KGlobal::locale()->weekDayName(count+1, true)); | 313 | rect=metrics.boundingRect(KGlobal::locale()->weekDayName(count+1, true)); |
314 | maxCell.setWidth(QMAX(maxCell.width(), rect.width())); | 314 | maxCell.setWidth(QMAX(maxCell.width(), rect.width())); |
315 | maxCell.setHeight(QMAX(maxCell.height(), rect.height())); | 315 | maxCell.setHeight(QMAX(maxCell.height(), rect.height())); |
316 | } | 316 | } |
317 | // ----- compare with a real wide number and add some space: | 317 | // ----- compare with a real wide number and add some space: |
318 | rect=metrics.boundingRect(QString::fromLatin1("88")); | 318 | rect=metrics.boundingRect(QString::fromLatin1("88")); |
319 | maxCell.setWidth(QMAX(maxCell.width()+2, rect.width())); | 319 | maxCell.setWidth(QMAX(maxCell.width()+2, rect.width())); |
320 | #ifdef DESKTOP_VERSION | 320 | #ifdef DESKTOP_VERSION |
321 | maxCell.setHeight(QMAX(maxCell.height()+8, rect.height())); | 321 | maxCell.setHeight(QMAX(maxCell.height()+8, rect.height())); |
322 | #else | 322 | #else |
323 | maxCell.setHeight(QMAX(maxCell.height()+4, rect.height())); | 323 | maxCell.setHeight(QMAX(maxCell.height()+4, rect.height())); |
324 | #endif | 324 | #endif |
325 | if ( maxCell.width() * 1000 / maxCell.height() > 1900 ) { | 325 | if ( maxCell.width() * 1000 / maxCell.height() > 1900 ) { |
326 | maxCell.setHeight(maxCell.width() * 1000 / 1900 ); | 326 | maxCell.setHeight(maxCell.width() * 1000 / 1900 ); |
327 | qDebug("setmax "); | 327 | qDebug("setmax "); |
328 | } | 328 | } |
329 | } | 329 | } |
330 | 330 | ||
331 | void | 331 | void |
332 | KDateTable::contentsMousePressEvent(QMouseEvent *e) | 332 | KDateTable::contentsMousePressEvent(QMouseEvent *e) |
333 | { | 333 | { |
334 | if(e->type()!=QEvent::MouseButtonPress) | 334 | if(e->type()!=QEvent::MouseButtonPress) |
335 | { // the KDatePicker only reacts on mouse press events: | 335 | { // the KDatePicker only reacts on mouse press events: |
336 | return; | 336 | return; |
337 | } | 337 | } |
338 | if(!isEnabled()) | 338 | if(!isEnabled()) |
339 | { | 339 | { |
340 | KNotifyClient::beep(); | 340 | KNotifyClient::beep(); |
341 | return; | 341 | return; |
342 | } | 342 | } |
343 | 343 | ||
344 | int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; | 344 | int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; |
345 | // ----- | 345 | // ----- |
346 | int row, col, pos, temp; | 346 | int row, col, pos, temp; |
347 | QPoint mouseCoord; | 347 | QPoint mouseCoord; |
348 | // ----- | 348 | // ----- |
349 | mouseCoord = e->pos(); | 349 | mouseCoord = e->pos(); |
350 | row=rowAt(mouseCoord.y()); | 350 | row=rowAt(mouseCoord.y()); |
351 | col=columnAt(mouseCoord.x()); | 351 | col=columnAt(mouseCoord.x()); |
352 | if(row<0 || col<0) | 352 | if(row<0 || col<0) |
353 | { // the user clicked on the frame of the table | 353 | { // the user clicked on the frame of the table |
354 | return; | 354 | return; |
355 | } | 355 | } |
356 | pos=7*(row-1)+col+1; | 356 | pos=7*(row-1)+col+1; |
357 | #if 0 | 357 | #if 0 |
358 | if(pos+dayoff<=firstday) | 358 | if(pos+dayoff<=firstday) |
359 | { // this day is in the previous month | 359 | { // this day is in the previous month |
360 | KNotifyClient::beep(); | 360 | KNotifyClient::beep(); |
361 | return; | 361 | return; |
362 | } | 362 | } |
363 | if(firstday+numdays<pos+dayoff) | 363 | if(firstday+numdays<pos+dayoff) |
364 | { // this date is in the next month | 364 | { // this date is in the next month |
365 | KNotifyClient::beep(); | 365 | KNotifyClient::beep(); |
366 | return; | 366 | return; |
367 | } | 367 | } |
368 | #endif | 368 | #endif |
369 | temp=firstday+date.day()-dayoff-1; | 369 | temp=firstday+date.day()-dayoff-1; |
370 | QDate da = QDate(date.year(), date.month(),1); | 370 | QDate da = QDate(date.year(), date.month(),1); |
371 | setDate(da.addDays( pos-firstday+dayoff-1)); | 371 | setDate(da.addDays( pos-firstday+dayoff-1)); |
372 | updateCell(temp/7+1, temp%7); // Update the previously selected cell | 372 | updateCell(temp/7+1, temp%7); // Update the previously selected cell |
373 | updateCell(row, col); // Update the selected cell | 373 | updateCell(row, col); // Update the selected cell |
374 | // assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); | 374 | // assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); |
375 | emit(tableClicked()); | 375 | emit(tableClicked()); |
376 | } | 376 | } |
377 | 377 | ||
378 | bool | 378 | bool |
379 | KDateTable::setDate(const QDate& date_) | 379 | KDateTable::setDate(const QDate& date_) |
380 | { | 380 | { |
381 | bool changed=false; | 381 | bool changed=false; |
382 | QDate temp; | 382 | QDate temp; |
383 | mMarkCurrent = false; | 383 | mMarkCurrent = false; |
384 | // ----- | 384 | // ----- |
385 | if(!date_.isValid()) | 385 | if(!date_.isValid()) |
386 | { | 386 | { |
387 | kdDebug() << "KDateTable::setDate: refusing to set invalid date." << endl; | 387 | kdDebug() << "KDateTable::setDate: refusing to set invalid date." << endl; |
388 | return false; | 388 | return false; |
389 | } | 389 | } |
390 | if(date!=date_) | 390 | if(date!=date_) |
391 | { | 391 | { |
392 | date=date_; | 392 | date=date_; |
393 | changed=true; | 393 | changed=true; |
394 | } | 394 | } |
395 | mMarkCurrent = ( date.month() == QDate::currentDate().month() && date.year() == QDate::currentDate().year() ); | 395 | mMarkCurrent = ( date.month() == QDate::currentDate().month() && date.year() == QDate::currentDate().year() ); |
396 | temp.setYMD(date.year(), date.month(), 1); | 396 | temp.setYMD(date.year(), date.month(), 1); |
397 | firstday=temp.dayOfWeek(); | 397 | firstday=temp.dayOfWeek(); |
398 | if(firstday==1) firstday=8; | 398 | if(firstday==1) firstday=8; |
399 | numdays=date.daysInMonth(); | 399 | numdays=date.daysInMonth(); |
400 | if(date.month()==1) | 400 | if(date.month()==1) |
401 | { // set to december of previous year | 401 | { // set to december of previous year |
402 | temp.setYMD(date.year()-1, 12, 1); | 402 | temp.setYMD(date.year()-1, 12, 1); |
403 | } else { // set to previous month | 403 | } else { // set to previous month |
404 | temp.setYMD(date.year(), date.month()-1, 1); | 404 | temp.setYMD(date.year(), date.month()-1, 1); |
405 | } | 405 | } |
406 | numDaysPrevMonth=temp.daysInMonth(); | 406 | numDaysPrevMonth=temp.daysInMonth(); |
407 | if(changed) | 407 | if(changed) |
408 | { | 408 | { |
409 | repaintContents(false); | 409 | repaintContents(false); |
410 | } | 410 | } |
411 | emit(dateChanged(date)); | 411 | emit(dateChanged(date)); |
412 | return true; | 412 | return true; |
413 | } | 413 | } |
414 | 414 | ||
415 | const QDate& | 415 | const QDate& |
416 | KDateTable::getDate() const | 416 | KDateTable::getDate() const |
417 | { | 417 | { |
418 | return date; | 418 | return date; |
419 | } | 419 | } |
420 | 420 | ||
421 | void KDateTable::focusInEvent( QFocusEvent *e ) | 421 | void KDateTable::focusInEvent( QFocusEvent *e ) |
422 | { | 422 | { |
423 | repaintContents(false); | 423 | repaintContents(false); |
424 | QGridView::focusInEvent( e ); | 424 | QGridView::focusInEvent( e ); |
425 | } | 425 | } |
426 | 426 | ||
427 | void KDateTable::focusOutEvent( QFocusEvent *e ) | 427 | void KDateTable::focusOutEvent( QFocusEvent *e ) |
428 | { | 428 | { |
429 | repaintContents(false); | 429 | repaintContents(false); |
430 | QGridView::focusOutEvent( e ); | 430 | QGridView::focusOutEvent( e ); |
431 | } | 431 | } |
432 | 432 | ||
433 | QSize | 433 | QSize |
434 | KDateTable::sizeHint() const | 434 | KDateTable::sizeHint() const |
435 | { | 435 | { |
436 | if(maxCell.height()>0 && maxCell.width()>0) | 436 | if(maxCell.height()>0 && maxCell.width()>0) |
437 | { | 437 | { |
438 | return QSize((maxCell.width()+2)*numCols()+2*frameWidth(), | 438 | return QSize((maxCell.width()+2)*numCols()+2*frameWidth(), |
439 | (maxCell.height()+4)*numRows()+2*frameWidth()); | 439 | (maxCell.height()+4)*numRows()+2*frameWidth()); |
440 | } else { | 440 | } else { |
441 | return QSize(-1, -1); | 441 | return QSize(-1, -1); |
442 | } | 442 | } |
443 | } | 443 | } |
444 | 444 | ||
445 | KDateInternalMonthPicker::KDateInternalMonthPicker | 445 | KDateInternalMonthPicker::KDateInternalMonthPicker |
446 | (QWidget* parent, const char* name) | 446 | (QWidget* parent, const char* name) |
447 | : QGridView(parent, name), | 447 | : QGridView(parent, name), |
448 | result(0) // invalid | 448 | result(0) // invalid |
449 | { | 449 | { |
450 | QRect rect; | 450 | QRect rect; |
451 | QFont font; | 451 | QFont font; |
452 | // ----- | 452 | // ----- |
453 | activeCol = -1; | 453 | activeCol = -1; |
454 | activeRow = -1; | 454 | activeRow = -1; |
455 | font=KGlobalSettings::generalFont(); | 455 | font=KGlobalSettings::generalFont(); |
456 | int fontsize = 10; | 456 | int fontsize = 10; |
457 | int add = 2; | 457 | int add = 2; |
458 | if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 ) | 458 | if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 ) |
459 | add += 8; | 459 | add += 8; |
460 | if ( QApplication::desktop()->width() > 640 ) | 460 | if ( QApplication::desktop()->width() > 640 ) |
461 | add += 4; | 461 | add += 6; |
462 | font.setPointSize(fontsize+add); | 462 | font.setPointSize(fontsize+add); |
463 | setFont(font); | 463 | setFont(font); |
464 | setHScrollBarMode(AlwaysOff); | 464 | setHScrollBarMode(AlwaysOff); |
465 | setVScrollBarMode(AlwaysOff); | 465 | setVScrollBarMode(AlwaysOff); |
466 | setFrameStyle(QFrame::NoFrame); | 466 | setFrameStyle(QFrame::NoFrame); |
467 | setNumRows(4); | 467 | setNumRows(4); |
468 | setNumCols(3); | 468 | setNumCols(3); |
469 | // enable to find drawing failures: | 469 | // enable to find drawing failures: |
470 | // setTableFlags(Tbl_clipCellPainting); | 470 | // setTableFlags(Tbl_clipCellPainting); |
471 | #if 0 | 471 | #if 0 |
472 | viewport()->setEraseColor(lightGray); // for consistency with the datepicker | 472 | viewport()->setEraseColor(lightGray); // for consistency with the datepicker |
473 | #endif | 473 | #endif |
474 | // ----- find the preferred size | 474 | // ----- find the preferred size |
475 | // (this is slow, possibly, but unfortunatly it is needed here): | 475 | // (this is slow, possibly, but unfortunatly it is needed here): |
476 | QFontMetrics metrics(font); | 476 | QFontMetrics metrics(font); |
477 | for(int i=1; i <= 12; ++i) | 477 | for(int i=1; i <= 12; ++i) |
478 | { | 478 | { |
479 | rect=metrics.boundingRect(KGlobal::locale()->monthName(i, false)); | 479 | rect=metrics.boundingRect(KGlobal::locale()->monthName(i, false)); |
480 | if(max.width()<rect.width()) max.setWidth(rect.width()); | 480 | if(max.width()<rect.width()) max.setWidth(rect.width()); |
481 | if(max.height()<rect.height()) max.setHeight(rect.height()); | 481 | if(max.height()<rect.height()) max.setHeight(rect.height()); |
482 | } | 482 | } |
483 | 483 | ||
484 | } | 484 | } |
485 | 485 | ||
486 | QSize | 486 | QSize |
487 | KDateInternalMonthPicker::sizeHint() const | 487 | KDateInternalMonthPicker::sizeHint() const |
488 | { | 488 | { |
489 | return QSize((max.width()+6)*numCols()+2*frameWidth(), | 489 | return QSize((max.width()+6)*numCols()+2*frameWidth(), |
490 | (max.height()+6)*numRows()+2*frameWidth()); | 490 | (max.height()+6)*numRows()+2*frameWidth()); |
491 | } | 491 | } |
492 | 492 | ||
493 | int | 493 | int |
494 | KDateInternalMonthPicker::getResult() const | 494 | KDateInternalMonthPicker::getResult() const |
495 | { | 495 | { |
496 | return result; | 496 | return result; |
497 | } | 497 | } |
498 | 498 | ||
499 | void | 499 | void |
500 | KDateInternalMonthPicker::setupPainter(QPainter *p) | 500 | KDateInternalMonthPicker::setupPainter(QPainter *p) |
501 | { | 501 | { |
502 | p->setPen(black); | 502 | p->setPen(black); |
503 | } | 503 | } |
504 | 504 | ||
505 | void | 505 | void |
506 | KDateInternalMonthPicker::viewportResizeEvent(QResizeEvent*) | 506 | KDateInternalMonthPicker::viewportResizeEvent(QResizeEvent*) |
507 | { | 507 | { |
508 | setCellWidth(width()/3); | 508 | setCellWidth(width()/3); |
509 | setCellHeight(height()/4); | 509 | setCellHeight(height()/4); |
510 | } | 510 | } |
511 | 511 | ||
512 | void | 512 | void |
513 | KDateInternalMonthPicker::paintCell(QPainter* painter, int row, int col) | 513 | KDateInternalMonthPicker::paintCell(QPainter* painter, int row, int col) |
514 | { | 514 | { |
515 | int index; | 515 | int index; |
516 | QString text; | 516 | QString text; |
517 | // ----- find the number of the cell: | 517 | // ----- find the number of the cell: |
518 | index=3*row+col+1; | 518 | index=3*row+col+1; |
519 | text=KGlobal::locale()->monthName(index, false); | 519 | text=KGlobal::locale()->monthName(index, false); |
520 | painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text); | 520 | painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text); |
521 | if ( activeCol == col && activeRow == row ) | 521 | if ( activeCol == col && activeRow == row ) |
522 | painter->drawRect( 0, 0, cellWidth(), cellHeight() ); | 522 | painter->drawRect( 0, 0, cellWidth(), cellHeight() ); |
523 | } | 523 | } |
524 | 524 | ||
525 | void | 525 | void |
526 | KDateInternalMonthPicker::contentsMousePressEvent(QMouseEvent *e) | 526 | KDateInternalMonthPicker::contentsMousePressEvent(QMouseEvent *e) |
527 | { | 527 | { |
528 | if(!isEnabled() || e->button() != LeftButton) | 528 | if(!isEnabled() || e->button() != LeftButton) |
529 | { | 529 | { |
530 | KNotifyClient::beep(); | 530 | KNotifyClient::beep(); |
531 | return; | 531 | return; |
532 | } | 532 | } |
533 | // ----- | 533 | // ----- |
534 | int row, col; | 534 | int row, col; |
535 | QPoint mouseCoord; | 535 | QPoint mouseCoord; |
536 | // ----- | 536 | // ----- |
537 | mouseCoord = e->pos(); | 537 | mouseCoord = e->pos(); |
538 | row=rowAt(mouseCoord.y()); | 538 | row=rowAt(mouseCoord.y()); |
539 | col=columnAt(mouseCoord.x()); | 539 | col=columnAt(mouseCoord.x()); |
540 | 540 | ||
541 | if(row<0 || col<0) | 541 | if(row<0 || col<0) |
542 | { // the user clicked on the frame of the table | 542 | { // the user clicked on the frame of the table |
543 | activeCol = -1; | 543 | activeCol = -1; |
544 | activeRow = -1; | 544 | activeRow = -1; |
545 | } else { | 545 | } else { |
546 | activeCol = col; | 546 | activeCol = col; |
547 | activeRow = row; | 547 | activeRow = row; |
548 | updateCell( row, col /*, false */ ); | 548 | updateCell( row, col /*, false */ ); |
549 | } | 549 | } |
550 | } | 550 | } |
551 | 551 | ||
552 | void | 552 | void |
553 | KDateInternalMonthPicker::contentsMouseMoveEvent(QMouseEvent *e) | 553 | KDateInternalMonthPicker::contentsMouseMoveEvent(QMouseEvent *e) |
554 | { | 554 | { |
555 | if (e->state() & LeftButton) | 555 | if (e->state() & LeftButton) |
556 | { | 556 | { |
557 | int row, col; | 557 | int row, col; |
558 | QPoint mouseCoord; | 558 | QPoint mouseCoord; |
559 | // ----- | 559 | // ----- |
560 | mouseCoord = e->pos(); | 560 | mouseCoord = e->pos(); |
561 | row=rowAt(mouseCoord.y()); | 561 | row=rowAt(mouseCoord.y()); |
562 | col=columnAt(mouseCoord.x()); | 562 | col=columnAt(mouseCoord.x()); |
563 | int tmpRow = -1, tmpCol = -1; | 563 | int tmpRow = -1, tmpCol = -1; |
564 | if(row<0 || col<0) | 564 | if(row<0 || col<0) |
565 | { // the user clicked on the frame of the table | 565 | { // the user clicked on the frame of the table |
566 | if ( activeCol > -1 ) | 566 | if ( activeCol > -1 ) |
567 | { | 567 | { |
568 | tmpRow = activeRow; | 568 | tmpRow = activeRow; |
569 | tmpCol = activeCol; | 569 | tmpCol = activeCol; |
570 | } | 570 | } |
571 | activeCol = -1; | 571 | activeCol = -1; |
572 | activeRow = -1; | 572 | activeRow = -1; |
573 | } else { | 573 | } else { |
574 | bool differentCell = (activeRow != row || activeCol != col); | 574 | bool differentCell = (activeRow != row || activeCol != col); |
575 | if ( activeCol > -1 && differentCell) | 575 | if ( activeCol > -1 && differentCell) |
576 | { | 576 | { |
577 | tmpRow = activeRow; | 577 | tmpRow = activeRow; |
578 | tmpCol = activeCol; | 578 | tmpCol = activeCol; |
579 | } | 579 | } |
580 | if ( differentCell) | 580 | if ( differentCell) |
581 | { | 581 | { |
582 | activeRow = row; | 582 | activeRow = row; |
583 | activeCol = col; | 583 | activeCol = col; |
584 | updateCell( row, col /*, false */ ); // mark the new active cell | 584 | updateCell( row, col /*, false */ ); // mark the new active cell |
585 | } | 585 | } |
586 | } | 586 | } |
587 | if ( tmpRow > -1 ) // repaint the former active cell | 587 | if ( tmpRow > -1 ) // repaint the former active cell |
588 | updateCell( tmpRow, tmpCol /*, true */ ); | 588 | updateCell( tmpRow, tmpCol /*, true */ ); |
589 | } | 589 | } |
590 | } | 590 | } |
591 | 591 | ||
592 | void | 592 | void |
593 | KDateInternalMonthPicker::contentsMouseReleaseEvent(QMouseEvent *e) | 593 | KDateInternalMonthPicker::contentsMouseReleaseEvent(QMouseEvent *e) |
594 | { | 594 | { |
595 | if(!isEnabled()) | 595 | if(!isEnabled()) |
596 | { | 596 | { |
597 | return; | 597 | return; |
598 | } | 598 | } |
599 | // ----- | 599 | // ----- |
600 | int row, col, pos; | 600 | int row, col, pos; |
601 | QPoint mouseCoord; | 601 | QPoint mouseCoord; |
602 | // ----- | 602 | // ----- |
603 | mouseCoord = e->pos(); | 603 | mouseCoord = e->pos(); |
604 | row=rowAt(mouseCoord.y()); | 604 | row=rowAt(mouseCoord.y()); |
605 | col=columnAt(mouseCoord.x()); | 605 | col=columnAt(mouseCoord.x()); |
606 | if(row<0 || col<0) | 606 | if(row<0 || col<0) |
607 | { // the user clicked on the frame of the table | 607 | { // the user clicked on the frame of the table |
608 | emit(closeMe(0)); | 608 | emit(closeMe(0)); |
609 | } | 609 | } |
610 | pos=3*row+col+1; | 610 | pos=3*row+col+1; |
611 | result=pos; | 611 | result=pos; |
612 | emit(closeMe(1)); | 612 | emit(closeMe(1)); |
613 | } | 613 | } |
614 | 614 | ||
615 | 615 | ||
616 | 616 | ||
617 | KDateInternalYearSelector::KDateInternalYearSelector | 617 | KDateInternalYearSelector::KDateInternalYearSelector |
618 | (int fontsize, QWidget* parent, const char* name) | 618 | (int fontsize, QWidget* parent, const char* name) |
619 | : QLineEdit(parent, name), | 619 | : QLineEdit(parent, name), |
620 | val(new QIntValidator(this)), | 620 | val(new QIntValidator(this)), |
621 | result(0) | 621 | result(0) |
622 | { | 622 | { |
623 | QFont font; | 623 | QFont font; |
624 | // ----- | 624 | // ----- |
625 | font=KGlobalSettings::generalFont(); | 625 | font=KGlobalSettings::generalFont(); |
626 | font.setPointSize(fontsize); | 626 | font.setPointSize(fontsize); |
627 | setFont(font); | 627 | setFont(font); |
628 | #if 0 | 628 | #if 0 |
629 | setFrameStyle(QFrame::NoFrame); | 629 | setFrameStyle(QFrame::NoFrame); |
630 | #endif | 630 | #endif |
631 | // we have to respect the limits of QDate here, I fear: | 631 | // we have to respect the limits of QDate here, I fear: |
632 | val->setRange(0, 8000); | 632 | val->setRange(0, 8000); |
633 | setValidator(val); | 633 | setValidator(val); |
634 | connect(this, SIGNAL(returnPressed()), SLOT(yearEnteredSlot())); | 634 | connect(this, SIGNAL(returnPressed()), SLOT(yearEnteredSlot())); |
635 | } | 635 | } |
636 | 636 | ||
637 | void | 637 | void |
638 | KDateInternalYearSelector::yearEnteredSlot() | 638 | KDateInternalYearSelector::yearEnteredSlot() |
639 | { | 639 | { |
640 | bool ok; | 640 | bool ok; |
641 | int year; | 641 | int year; |
642 | QDate date; | 642 | QDate date; |
643 | // ----- check if this is a valid year: | 643 | // ----- check if this is a valid year: |
644 | year=text().toInt(&ok); | 644 | year=text().toInt(&ok); |
645 | if(!ok) | 645 | if(!ok) |
646 | { | 646 | { |
647 | KNotifyClient::beep(); | 647 | KNotifyClient::beep(); |
648 | return; | 648 | return; |
649 | } | 649 | } |
650 | date.setYMD(year, 1, 1); | 650 | date.setYMD(year, 1, 1); |
651 | if(!date.isValid()) | 651 | if(!date.isValid()) |
652 | { | 652 | { |
653 | KNotifyClient::beep(); | 653 | KNotifyClient::beep(); |