summaryrefslogtreecommitdiffabout
path: root/microkde
authorzautrix <zautrix>2005-02-08 16:58:16 (UTC)
committer zautrix <zautrix>2005-02-08 16:58:16 (UTC)
commit126b79abd88bb13ab41c4d987ee759eb9ba7d483 (patch) (unidiff)
tree45d26727b41c6f344152ed3f4ee1dd4bc97d58b0 /microkde
parent720510bf933a86211f8e9e2465788d141f0f1149 (diff)
downloadkdepimpi-126b79abd88bb13ab41c4d987ee759eb9ba7d483.zip
kdepimpi-126b79abd88bb13ab41c4d987ee759eb9ba7d483.tar.gz
kdepimpi-126b79abd88bb13ab41c4d987ee759eb9ba7d483.tar.bz2
ffff
Diffstat (limited to 'microkde') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdatetbl.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/microkde/kdatetbl.cpp b/microkde/kdatetbl.cpp
index 990cfb9..a9924ba 100644
--- a/microkde/kdatetbl.cpp
+++ b/microkde/kdatetbl.cpp
@@ -363,193 +363,193 @@ KDateTable::contentsMousePressEvent(QMouseEvent *e)
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
378bool 378bool
379KDateTable::setDate(const QDate& date_) 379KDateTable::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
415const QDate& 415const QDate&
416KDateTable::getDate() const 416KDateTable::getDate() const
417{ 417{
418 return date; 418 return date;
419} 419}
420 420
421void KDateTable::focusInEvent( QFocusEvent *e ) 421void KDateTable::focusInEvent( QFocusEvent *e )
422{ 422{
423 repaintContents(false); 423 repaintContents(false);
424 QGridView::focusInEvent( e ); 424 QGridView::focusInEvent( e );
425} 425}
426 426
427void KDateTable::focusOutEvent( QFocusEvent *e ) 427void KDateTable::focusOutEvent( QFocusEvent *e )
428{ 428{
429 repaintContents(false); 429 repaintContents(false);
430 QGridView::focusOutEvent( e ); 430 QGridView::focusOutEvent( e );
431} 431}
432 432
433QSize 433QSize
434KDateTable::sizeHint() const 434KDateTable::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
445KDateInternalMonthPicker::KDateInternalMonthPicker 445KDateInternalMonthPicker::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 += 6; 459 add += 8;
460 font.setPointSize(fontsize+add); 460 font.setPointSize(fontsize+add);
461 setFont(font); 461 setFont(font);
462 setHScrollBarMode(AlwaysOff); 462 setHScrollBarMode(AlwaysOff);
463 setVScrollBarMode(AlwaysOff); 463 setVScrollBarMode(AlwaysOff);
464 setFrameStyle(QFrame::NoFrame); 464 setFrameStyle(QFrame::NoFrame);
465 setNumRows(4); 465 setNumRows(4);
466 setNumCols(3); 466 setNumCols(3);
467 // enable to find drawing failures: 467 // enable to find drawing failures:
468 // setTableFlags(Tbl_clipCellPainting); 468 // setTableFlags(Tbl_clipCellPainting);
469#if 0 469#if 0
470 viewport()->setEraseColor(lightGray); // for consistency with the datepicker 470 viewport()->setEraseColor(lightGray); // for consistency with the datepicker
471#endif 471#endif
472 // ----- find the preferred size 472 // ----- find the preferred size
473 // (this is slow, possibly, but unfortunatly it is needed here): 473 // (this is slow, possibly, but unfortunatly it is needed here):
474 QFontMetrics metrics(font); 474 QFontMetrics metrics(font);
475 for(int i=1; i <= 12; ++i) 475 for(int i=1; i <= 12; ++i)
476 { 476 {
477 rect=metrics.boundingRect(KGlobal::locale()->monthName(i, false)); 477 rect=metrics.boundingRect(KGlobal::locale()->monthName(i, false));
478 if(max.width()<rect.width()) max.setWidth(rect.width()); 478 if(max.width()<rect.width()) max.setWidth(rect.width());
479 if(max.height()<rect.height()) max.setHeight(rect.height()); 479 if(max.height()<rect.height()) max.setHeight(rect.height());
480 } 480 }
481 481
482} 482}
483 483
484QSize 484QSize
485KDateInternalMonthPicker::sizeHint() const 485KDateInternalMonthPicker::sizeHint() const
486{ 486{
487 return QSize((max.width()+6)*numCols()+2*frameWidth(), 487 return QSize((max.width()+6)*numCols()+2*frameWidth(),
488 (max.height()+6)*numRows()+2*frameWidth()); 488 (max.height()+6)*numRows()+2*frameWidth());
489} 489}
490 490
491int 491int
492KDateInternalMonthPicker::getResult() const 492KDateInternalMonthPicker::getResult() const
493{ 493{
494 return result; 494 return result;
495} 495}
496 496
497void 497void
498KDateInternalMonthPicker::setupPainter(QPainter *p) 498KDateInternalMonthPicker::setupPainter(QPainter *p)
499{ 499{
500 p->setPen(black); 500 p->setPen(black);
501} 501}
502 502
503void 503void
504KDateInternalMonthPicker::viewportResizeEvent(QResizeEvent*) 504KDateInternalMonthPicker::viewportResizeEvent(QResizeEvent*)
505{ 505{
506 setCellWidth(width()/3); 506 setCellWidth(width()/3);
507 setCellHeight(height()/4); 507 setCellHeight(height()/4);
508} 508}
509 509
510void 510void
511KDateInternalMonthPicker::paintCell(QPainter* painter, int row, int col) 511KDateInternalMonthPicker::paintCell(QPainter* painter, int row, int col)
512{ 512{
513 int index; 513 int index;
514 QString text; 514 QString text;
515 // ----- find the number of the cell: 515 // ----- find the number of the cell:
516 index=3*row+col+1; 516 index=3*row+col+1;
517 text=KGlobal::locale()->monthName(index, false); 517 text=KGlobal::locale()->monthName(index, false);
518 painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text); 518 painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text);
519 if ( activeCol == col && activeRow == row ) 519 if ( activeCol == col && activeRow == row )
520 painter->drawRect( 0, 0, cellWidth(), cellHeight() ); 520 painter->drawRect( 0, 0, cellWidth(), cellHeight() );
521} 521}
522 522
523void 523void
524KDateInternalMonthPicker::contentsMousePressEvent(QMouseEvent *e) 524KDateInternalMonthPicker::contentsMousePressEvent(QMouseEvent *e)
525{ 525{
526 if(!isEnabled() || e->button() != LeftButton) 526 if(!isEnabled() || e->button() != LeftButton)
527 { 527 {
528 KNotifyClient::beep(); 528 KNotifyClient::beep();
529 return; 529 return;
530 } 530 }
531 // ----- 531 // -----
532 int row, col; 532 int row, col;
533 QPoint mouseCoord; 533 QPoint mouseCoord;
534 // ----- 534 // -----
535 mouseCoord = e->pos(); 535 mouseCoord = e->pos();
536 row=rowAt(mouseCoord.y()); 536 row=rowAt(mouseCoord.y());
537 col=columnAt(mouseCoord.x()); 537 col=columnAt(mouseCoord.x());
538 538
539 if(row<0 || col<0) 539 if(row<0 || col<0)
540 { // the user clicked on the frame of the table 540 { // the user clicked on the frame of the table
541 activeCol = -1; 541 activeCol = -1;
542 activeRow = -1; 542 activeRow = -1;
543 } else { 543 } else {
544 activeCol = col; 544 activeCol = col;
545 activeRow = row; 545 activeRow = row;
546 updateCell( row, col /*, false */ ); 546 updateCell( row, col /*, false */ );
547 } 547 }
548} 548}
549 549
550void 550void
551KDateInternalMonthPicker::contentsMouseMoveEvent(QMouseEvent *e) 551KDateInternalMonthPicker::contentsMouseMoveEvent(QMouseEvent *e)
552{ 552{
553 if (e->state() & LeftButton) 553 if (e->state() & LeftButton)
554 { 554 {
555 int row, col; 555 int row, col;
@@ -685,193 +685,193 @@ KPopupFrame::keyPressEvent(QKeyEvent* e)
685 if(e->key()==Key_Escape) 685 if(e->key()==Key_Escape)
686 { 686 {
687 result=0; // rejected 687 result=0; // rejected
688 qApp->exit_loop(); 688 qApp->exit_loop();
689 } 689 }
690} 690}
691 691
692void 692void
693KPopupFrame::close(int r) 693KPopupFrame::close(int r)
694{ 694{
695 result=r; 695 result=r;
696 qApp->exit_loop(); 696 qApp->exit_loop();
697} 697}
698 698
699void 699void
700KPopupFrame::setMainWidget(QWidget* m) 700KPopupFrame::setMainWidget(QWidget* m)
701{ 701{
702 main=m; 702 main=m;
703 if(main!=0) 703 if(main!=0)
704 { 704 {
705 resize(main->width()+2*frameWidth(), main->height()+2*frameWidth()); 705 resize(main->width()+2*frameWidth(), main->height()+2*frameWidth());
706 } 706 }
707} 707}
708 708
709void 709void
710KPopupFrame::resizeEvent(QResizeEvent*) 710KPopupFrame::resizeEvent(QResizeEvent*)
711{ 711{
712 if(main!=0) 712 if(main!=0)
713 { 713 {
714 main->setGeometry(frameWidth(), frameWidth(), 714 main->setGeometry(frameWidth(), frameWidth(),
715 width()-2*frameWidth(), height()-2*frameWidth()); 715 width()-2*frameWidth(), height()-2*frameWidth());
716 } 716 }
717} 717}
718 718
719void 719void
720KPopupFrame::popup(const QPoint &pos) 720KPopupFrame::popup(const QPoint &pos)
721{ 721{
722 // Make sure the whole popup is visible. 722 // Make sure the whole popup is visible.
723 QRect d = QApplication::desktop()->frameGeometry(); 723 QRect d = QApplication::desktop()->frameGeometry();
724 int x = pos.x(); 724 int x = pos.x();
725 int y = pos.y(); 725 int y = pos.y();
726 int w = width(); 726 int w = width();
727 int h = height(); 727 int h = height();
728 if (x+w > d.x()+d.width()) 728 if (x+w > d.x()+d.width())
729 x = d.width() - w; 729 x = d.width() - w;
730 if (y+h > d.y()+d.height()) 730 if (y+h > d.y()+d.height())
731 y = d.height() - h; 731 y = d.height() - h;
732 if (x < d.x()) 732 if (x < d.x())
733 x = 0; 733 x = 0;
734 if (y < d.y()) 734 if (y < d.y())
735 y = 0; 735 y = 0;
736 736
737 // Pop the thingy up. 737 // Pop the thingy up.
738 move(x, y); 738 move(x, y);
739 show(); 739 show();
740} 740}
741 741
742int 742int
743KPopupFrame::exec(QPoint pos) 743KPopupFrame::exec(QPoint pos)
744{ 744{
745 popup(pos); 745 popup(pos);
746 repaint(); 746 repaint();
747 qApp->enter_loop(); 747 qApp->enter_loop();
748 hide(); 748 hide();
749 return result; 749 return result;
750} 750}
751 751
752int 752int
753KPopupFrame::exec(int x, int y) 753KPopupFrame::exec(int x, int y)
754{ 754{
755 return exec(QPoint(x, y)); 755 return exec(QPoint(x, y));
756} 756}
757 757
758void KPopupFrame::virtual_hook( int, void* ) 758void KPopupFrame::virtual_hook( int, void* )
759{ /*BASE::virtual_hook( id, data );*/ } 759{ /*BASE::virtual_hook( id, data );*/ }
760 760
761void KDateTable::virtual_hook( int, void* ) 761void KDateTable::virtual_hook( int, void* )
762{ /*BASE::virtual_hook( id, data );*/ } 762{ /*BASE::virtual_hook( id, data );*/ }
763 763
764//#include "kdatetbl.moc" 764//#include "kdatetbl.moc"
765 765
766 766
767KDateInternalWeekPicker::KDateInternalWeekPicker 767KDateInternalWeekPicker::KDateInternalWeekPicker
768(QWidget* parent, const char* name) 768(QWidget* parent, const char* name)
769 : QGridView(parent, name), 769 : QGridView(parent, name),
770 result(0) // invalid 770 result(0) // invalid
771{ 771{
772 QRect rect; 772 QRect rect;
773 QFont font; 773 QFont font;
774 // ----- 774 // -----
775 activeCol = -1; 775 activeCol = -1;
776 activeRow = -1; 776 activeRow = -1;
777 font=KGlobalSettings::generalFont(); 777 font=KGlobalSettings::generalFont();
778 int fontsize = 10; 778 int fontsize = 10;
779 int add = 2; 779 int add = 2;
780 if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 ) 780 if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 )
781 add += 4; 781 add += 6;
782 font.setPointSize(fontsize+add); 782 font.setPointSize(fontsize+add);
783 setFont(font); 783 setFont(font);
784 setHScrollBarMode(AlwaysOff); 784 setHScrollBarMode(AlwaysOff);
785 setVScrollBarMode(AlwaysOff); 785 setVScrollBarMode(AlwaysOff);
786 setFrameStyle(QFrame::NoFrame); 786 setFrameStyle(QFrame::NoFrame);
787 setNumRows(13); 787 setNumRows(13);
788 setNumCols(4); 788 setNumCols(4);
789 // enable to find drawing failures: 789 // enable to find drawing failures:
790 // setTableFlags(Tbl_clipCellPainting); 790 // setTableFlags(Tbl_clipCellPainting);
791#if 0 791#if 0
792 viewport()->setEraseColor(lightGray); // for consistency with the datepicker 792 viewport()->setEraseColor(lightGray); // for consistency with the datepicker
793#endif 793#endif
794 // ----- find the preferred size 794 // ----- find the preferred size
795 // (this is slow, possibly, but unfortunatly it is needed here): 795 // (this is slow, possibly, but unfortunatly it is needed here):
796 QFontMetrics metrics(font); 796 QFontMetrics metrics(font);
797 for(int i=1; i <= 52; ++i) 797 for(int i=1; i <= 52; ++i)
798 { 798 {
799 rect=metrics.boundingRect(QString::number( i )); 799 rect=metrics.boundingRect(QString::number( i ));
800 if(max.width()<rect.width()) max.setWidth(rect.width()); 800 if(max.width()<rect.width()) max.setWidth(rect.width());
801 if(max.height()<rect.height()) max.setHeight(rect.height()); 801 if(max.height()<rect.height()) max.setHeight(rect.height());
802 } 802 }
803 if ( QApplication::desktop()->width() > 640 ) { 803 if ( QApplication::desktop()->width() > 640 ) {
804 804
805 max.setWidth(max.width()+6); 805 max.setWidth(max.width()+6);
806 max.setHeight(max.height()+8); 806 max.setHeight(max.height()+8);
807 } 807 }
808} 808}
809 809
810QSize 810QSize
811KDateInternalWeekPicker::sizeHint() const 811KDateInternalWeekPicker::sizeHint() const
812{ 812{
813 return QSize((max.width()+6)*numCols()+2*frameWidth(), 813 return QSize((max.width()+6)*numCols()+2*frameWidth(),
814 (max.height()+6)*numRows()+2*frameWidth()); 814 (max.height()+6)*numRows()+2*frameWidth());
815} 815}
816 816
817int 817int
818KDateInternalWeekPicker::getResult() const 818KDateInternalWeekPicker::getResult() const
819{ 819{
820 return result; 820 return result;
821} 821}
822 822
823void 823void
824KDateInternalWeekPicker::setupPainter(QPainter *p) 824KDateInternalWeekPicker::setupPainter(QPainter *p)
825{ 825{
826 p->setPen(black); 826 p->setPen(black);
827} 827}
828 828
829void 829void
830KDateInternalWeekPicker::viewportResizeEvent(QResizeEvent*) 830KDateInternalWeekPicker::viewportResizeEvent(QResizeEvent*)
831{ 831{
832 setCellWidth(width()/4); 832 setCellWidth(width()/4);
833 setCellHeight(height()/13); 833 setCellHeight(height()/13);
834} 834}
835 835
836void 836void
837KDateInternalWeekPicker::paintCell(QPainter* painter, int row, int col) 837KDateInternalWeekPicker::paintCell(QPainter* painter, int row, int col)
838{ 838{
839 int index; 839 int index;
840 QString text; 840 QString text;
841 // ----- find the number of the cell: 841 // ----- find the number of the cell:
842 index=4*row+col+1; 842 index=4*row+col+1;
843 text=QString::number( index ); 843 text=QString::number( index );
844 painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text); 844 painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text);
845 if ( activeCol == col && activeRow == row ) 845 if ( activeCol == col && activeRow == row )
846 painter->drawRect( 0, 0, cellWidth(), cellHeight() ); 846 painter->drawRect( 0, 0, cellWidth(), cellHeight() );
847} 847}
848 848
849void 849void
850KDateInternalWeekPicker::contentsMousePressEvent(QMouseEvent *e) 850KDateInternalWeekPicker::contentsMousePressEvent(QMouseEvent *e)
851{ 851{
852 if(!isEnabled() || e->button() != LeftButton) 852 if(!isEnabled() || e->button() != LeftButton)
853 { 853 {
854 KNotifyClient::beep(); 854 KNotifyClient::beep();
855 return; 855 return;
856 } 856 }
857 // ----- 857 // -----
858 int row, col; 858 int row, col;
859 QPoint mouseCoord; 859 QPoint mouseCoord;
860 // ----- 860 // -----
861 mouseCoord = e->pos(); 861 mouseCoord = e->pos();
862 row=rowAt(mouseCoord.y()); 862 row=rowAt(mouseCoord.y());
863 col=columnAt(mouseCoord.x()); 863 col=columnAt(mouseCoord.x());
864 864
865 if(row<0 || col<0) 865 if(row<0 || col<0)
866 { // the user clicked on the frame of the table 866 { // the user clicked on the frame of the table
867 activeCol = -1; 867 activeCol = -1;
868 activeRow = -1; 868 activeRow = -1;
869 } else { 869 } else {
870 activeCol = col; 870 activeCol = col;
871 activeRow = row; 871 activeRow = row;
872 updateCell( row, col /*, false */ ); 872 updateCell( row, col /*, false */ );
873 } 873 }
874} 874}
875 875
876void 876void
877KDateInternalWeekPicker::contentsMouseMoveEvent(QMouseEvent *e) 877KDateInternalWeekPicker::contentsMouseMoveEvent(QMouseEvent *e)