author | zautrix <zautrix> | 2005-04-21 12:32:52 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-21 12:32:52 (UTC) |
commit | 0a13a3490ec3bf4735e3435f80f58fa7d50b4448 (patch) (unidiff) | |
tree | c7f28c49b52e479f47da0dce9f0bfe9189ecdca4 | |
parent | 4d96d7b681ce99d76746a843c289b75f5e7dba64 (diff) | |
download | kdepimpi-0a13a3490ec3bf4735e3435f80f58fa7d50b4448.zip kdepimpi-0a13a3490ec3bf4735e3435f80f58fa7d50b4448.tar.gz kdepimpi-0a13a3490ec3bf4735e3435f80f58fa7d50b4448.tar.bz2 |
rubberband fix
-rw-r--r-- | korganizer/komonthview.cpp | 2 | ||||
-rw-r--r-- | microkde/KDGanttMinimizeSplitter.cpp | 21 | ||||
-rw-r--r-- | microkde/KDGanttMinimizeSplitter.h | 5 |
3 files changed, 22 insertions, 6 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 7927307..8ee1363 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -517,513 +517,513 @@ void MonthViewCell::setDate( const QDate &date ) | |||
517 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 517 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
518 | mDate = date; | 518 | mDate = date; |
519 | 519 | ||
520 | 520 | ||
521 | 521 | ||
522 | //resizeEvent( 0 ); | 522 | //resizeEvent( 0 ); |
523 | } | 523 | } |
524 | 524 | ||
525 | QDate MonthViewCell::date() const | 525 | QDate MonthViewCell::date() const |
526 | { | 526 | { |
527 | return mDate; | 527 | return mDate; |
528 | } | 528 | } |
529 | 529 | ||
530 | void MonthViewCell::setPrimary( bool primary ) | 530 | void MonthViewCell::setPrimary( bool primary ) |
531 | { | 531 | { |
532 | mPrimary = primary; | 532 | mPrimary = primary; |
533 | //setMyPalette(); | 533 | //setMyPalette(); |
534 | } | 534 | } |
535 | void MonthViewCell::setMyPalette() | 535 | void MonthViewCell::setMyPalette() |
536 | { | 536 | { |
537 | 537 | ||
538 | if ( mHoliday) { | 538 | if ( mHoliday) { |
539 | if ( currentPalette == 1 ) return; | 539 | if ( currentPalette == 1 ) return; |
540 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 540 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
541 | setPalette( mHolidayPalette ); | 541 | setPalette( mHolidayPalette ); |
542 | //mLabel->setPalette( mHolidayPalette ); | 542 | //mLabel->setPalette( mHolidayPalette ); |
543 | currentPalette = 1; | 543 | currentPalette = 1; |
544 | 544 | ||
545 | } else { | 545 | } else { |
546 | if ( mPrimary ) { | 546 | if ( mPrimary ) { |
547 | if ( currentPalette == 2 ) return; | 547 | if ( currentPalette == 2 ) return; |
548 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 548 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
549 | //mLabel->setPalette( mPrimaryPalette ); | 549 | //mLabel->setPalette( mPrimaryPalette ); |
550 | setPalette( mPrimaryPalette ); | 550 | setPalette( mPrimaryPalette ); |
551 | currentPalette = 2; | 551 | currentPalette = 2; |
552 | 552 | ||
553 | } else { | 553 | } else { |
554 | if ( currentPalette == 3 ) return; | 554 | if ( currentPalette == 3 ) return; |
555 | setPalette( mNonPrimaryPalette ); | 555 | setPalette( mNonPrimaryPalette ); |
556 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 556 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
557 | //mLabel->setPalette( mNonPrimaryPalette );; | 557 | //mLabel->setPalette( mNonPrimaryPalette );; |
558 | currentPalette = 3; | 558 | currentPalette = 3; |
559 | } | 559 | } |
560 | } | 560 | } |
561 | //QPalette pal = palette(); | 561 | //QPalette pal = palette(); |
562 | 562 | ||
563 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); | 563 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); |
564 | } | 564 | } |
565 | QPalette MonthViewCell::getPalette () | 565 | QPalette MonthViewCell::getPalette () |
566 | { | 566 | { |
567 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 567 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
568 | return mStandardPalette; | 568 | return mStandardPalette; |
569 | if ( mHoliday) { | 569 | if ( mHoliday) { |
570 | return mHolidayPalette ; | 570 | return mHolidayPalette ; |
571 | } else { | 571 | } else { |
572 | if ( mPrimary ) { | 572 | if ( mPrimary ) { |
573 | return mPrimaryPalette ; | 573 | return mPrimaryPalette ; |
574 | } | 574 | } |
575 | } | 575 | } |
576 | return mNonPrimaryPalette; | 576 | return mNonPrimaryPalette; |
577 | } | 577 | } |
578 | bool MonthViewCell::isPrimary() const | 578 | bool MonthViewCell::isPrimary() const |
579 | { | 579 | { |
580 | return mPrimary; | 580 | return mPrimary; |
581 | } | 581 | } |
582 | 582 | ||
583 | void MonthViewCell::setHoliday( bool holiday ) | 583 | void MonthViewCell::setHoliday( bool holiday ) |
584 | { | 584 | { |
585 | mHoliday = holiday; | 585 | mHoliday = holiday; |
586 | //setMyPalette(); | 586 | //setMyPalette(); |
587 | } | 587 | } |
588 | 588 | ||
589 | void MonthViewCell::setHoliday( const QString &holiday ) | 589 | void MonthViewCell::setHoliday( const QString &holiday ) |
590 | { | 590 | { |
591 | mHolidayString = holiday; | 591 | mHolidayString = holiday; |
592 | 592 | ||
593 | if ( !holiday.isEmpty() ) { | 593 | if ( !holiday.isEmpty() ) { |
594 | setHoliday( true ); | 594 | setHoliday( true ); |
595 | } | 595 | } |
596 | } | 596 | } |
597 | 597 | ||
598 | void MonthViewCell::startUpdateCell() | 598 | void MonthViewCell::startUpdateCell() |
599 | { | 599 | { |
600 | mdayCount = 0; | 600 | mdayCount = 0; |
601 | setFocusPolicy(NoFocus); | 601 | setFocusPolicy(NoFocus); |
602 | if ( !mMonthView->isUpdatePossible() ) | 602 | if ( !mMonthView->isUpdatePossible() ) |
603 | return; | 603 | return; |
604 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 604 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
605 | while ( mitem ) { | 605 | while ( mitem ) { |
606 | mitem->setBlockRepaint( true ); | 606 | mitem->setBlockRepaint( true ); |
607 | mitem = (MonthViewItem *)mitem->next(); | 607 | mitem = (MonthViewItem *)mitem->next(); |
608 | } | 608 | } |
609 | if ( mAvailItemList.count() > 20 ) { | 609 | if ( mAvailItemList.count() > 20 ) { |
610 | mAvailItemList.setAutoDelete( true ); | 610 | mAvailItemList.setAutoDelete( true ); |
611 | mAvailItemList.clear(); | 611 | mAvailItemList.clear(); |
612 | mAvailItemList.setAutoDelete( false ); | 612 | mAvailItemList.setAutoDelete( false ); |
613 | } | 613 | } |
614 | 614 | ||
615 | setPrimary( mDate.month()%2 ); | 615 | setPrimary( mDate.month()%2 ); |
616 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); | 616 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); |
617 | if ( mDate == QDate::currentDate() ) { | 617 | if ( mDate == QDate::currentDate() ) { |
618 | setLineWidth( 3 ); | 618 | setLineWidth( 3 ); |
619 | } else { | 619 | } else { |
620 | setLineWidth( 1 ); | 620 | setLineWidth( 1 ); |
621 | } | 621 | } |
622 | MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); | 622 | MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); |
623 | //clear(); | 623 | //clear(); |
624 | while ( CurrentAvailItem ) { | 624 | while ( CurrentAvailItem ) { |
625 | MonthViewItem *item = CurrentAvailItem; | 625 | MonthViewItem *item = CurrentAvailItem; |
626 | CurrentAvailItem = (MonthViewItem *)item->next(); | 626 | CurrentAvailItem = (MonthViewItem *)item->next(); |
627 | mAvailItemList.append( item ); | 627 | mAvailItemList.append( item ); |
628 | takeItem ( item ); | 628 | takeItem ( item ); |
629 | } | 629 | } |
630 | 630 | ||
631 | #ifdef DESKTOP_VERSION | 631 | #ifdef DESKTOP_VERSION |
632 | QToolTip::remove(this); | 632 | QToolTip::remove(this); |
633 | #endif | 633 | #endif |
634 | mToolTip.clear(); | 634 | mToolTip.clear(); |
635 | //qApp->processEvents(); | 635 | //qApp->processEvents(); |
636 | #if 0 | 636 | #if 0 |
637 | if ( !mHolidayString.isEmpty() ) { | 637 | if ( !mHolidayString.isEmpty() ) { |
638 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 638 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
639 | item->setPalette( mHolidayPalette ); | 639 | item->setPalette( mHolidayPalette ); |
640 | insertItem( item ); | 640 | insertItem( item ); |
641 | mToolTip.append ( mHolidayString ); | 641 | mToolTip.append ( mHolidayString ); |
642 | } | 642 | } |
643 | #endif | 643 | #endif |
644 | } | 644 | } |
645 | 645 | ||
646 | int MonthViewCell::insertEvent(Event *event) | 646 | int MonthViewCell::insertEvent(Event *event) |
647 | { | 647 | { |
648 | bool useToolTips = true; | 648 | bool useToolTips = true; |
649 | #ifndef DESKTOP_VERSION | 649 | #ifndef DESKTOP_VERSION |
650 | useToolTips = false; | 650 | useToolTips = false; |
651 | #endif | 651 | #endif |
652 | QString mToolTipText; | 652 | QString mToolTipText; |
653 | setFocusPolicy(WheelFocus); | 653 | setFocusPolicy(WheelFocus); |
654 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 654 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
655 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 655 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
656 | return mdayCount; | 656 | return mdayCount; |
657 | else | 657 | else |
658 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 658 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
659 | return mdayCount; | 659 | return mdayCount; |
660 | } | 660 | } |
661 | 661 | ||
662 | if ( event->isHoliday()) { | 662 | if ( event->isHoliday()) { |
663 | setHoliday( true ); | 663 | setHoliday( true ); |
664 | if ( mDate.dayOfWeek() == 7 ) | 664 | if ( mDate.dayOfWeek() == 7 ) |
665 | setLineWidth( 3 ); | 665 | setLineWidth( 3 ); |
666 | } | 666 | } |
667 | QString text; | 667 | QString text; |
668 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day | 668 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day |
669 | if (event->isMultiDay()) { | 669 | if (event->isMultiDay()) { |
670 | QString prefix = "<->";multiday = 2; | 670 | QString prefix = "<->";multiday = 2; |
671 | QString time; | 671 | QString time; |
672 | if ( event->doesRecur() ) { | 672 | if ( event->doesRecur() ) { |
673 | if ( event->recursOn( mDate) ) { | 673 | if ( event->recursOn( mDate) ) { |
674 | prefix ="->" ;multiday = 1; | 674 | prefix ="->" ;multiday = 1; |
675 | } | 675 | } |
676 | else { | 676 | else { |
677 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 677 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
678 | if ( event->recursOn( mDate.addDays( -days)) ) { | 678 | if ( event->recursOn( mDate.addDays( -days)) ) { |
679 | prefix ="<-" ;multiday = 3; | 679 | prefix ="<-" ;multiday = 3; |
680 | } | 680 | } |
681 | } | 681 | } |
682 | 682 | ||
683 | } else { | 683 | } else { |
684 | if (mDate == event->dtStart().date()) { | 684 | if (mDate == event->dtStart().date()) { |
685 | prefix ="->" ;multiday = 1; | 685 | prefix ="->" ;multiday = 1; |
686 | } else if (mDate == event->dtEnd().date()) { | 686 | } else if (mDate == event->dtEnd().date()) { |
687 | prefix ="<-" ;multiday = 3; | 687 | prefix ="<-" ;multiday = 3; |
688 | } | 688 | } |
689 | } | 689 | } |
690 | if ( !event->doesFloat() ) { | 690 | if ( !event->doesFloat() ) { |
691 | if ( mDate == event->dtStart().date () ) | 691 | if ( mDate == event->dtStart().date () ) |
692 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 692 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
693 | else if ( mDate == event->dtEnd().date () ) | 693 | else if ( mDate == event->dtEnd().date () ) |
694 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 694 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
695 | 695 | ||
696 | } | 696 | } |
697 | text = time + event->summary(); | 697 | text = time + event->summary(); |
698 | if ( useToolTips ) | 698 | if ( useToolTips ) |
699 | mToolTipText += prefix + text; | 699 | mToolTipText += prefix + text; |
700 | } else { | 700 | } else { |
701 | if (event->doesFloat()) { | 701 | if (event->doesFloat()) { |
702 | text = event->summary(); | 702 | text = event->summary(); |
703 | if ( useToolTips ) | 703 | if ( useToolTips ) |
704 | mToolTipText += text; | 704 | mToolTipText += text; |
705 | } | 705 | } |
706 | else { | 706 | else { |
707 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 707 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
708 | text += " " + event->summary(); | 708 | text += " " + event->summary(); |
709 | if ( useToolTips ) | 709 | if ( useToolTips ) |
710 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 710 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
711 | } | 711 | } |
712 | } | 712 | } |
713 | if ( useToolTips && ! event->location().isEmpty() ) { | 713 | if ( useToolTips && ! event->location().isEmpty() ) { |
714 | mToolTipText += " (" + event->location() +")"; | 714 | mToolTipText += " (" + event->location() +")"; |
715 | } | 715 | } |
716 | MonthViewItem *item ; | 716 | MonthViewItem *item ; |
717 | 717 | ||
718 | if ( mAvailItemList.count() ) { | 718 | if ( mAvailItemList.count() ) { |
719 | item = mAvailItemList.first(); | 719 | item = mAvailItemList.first(); |
720 | mAvailItemList.remove( item ); | 720 | mAvailItemList.remove( item ); |
721 | item->recycle( event, mDate, text ); | 721 | item->recycle( event, mDate, text ); |
722 | } else { | 722 | } else { |
723 | item = new MonthViewItem( event, mDate, text ); | 723 | item = new MonthViewItem( event, mDate, text ); |
724 | } | 724 | } |
725 | 725 | ||
726 | QPalette pal; | 726 | QPalette pal; |
727 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 727 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
728 | QStringList categories = event->categories(); | 728 | QStringList categories = event->categories(); |
729 | QString cat = categories.first(); | 729 | QString cat = categories.first(); |
730 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 730 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
731 | pal = getPalette(); | 731 | pal = getPalette(); |
732 | if (cat.isEmpty()) { | 732 | if (cat.isEmpty()) { |
733 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 733 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
734 | } else { | 734 | } else { |
735 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 735 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
736 | } | 736 | } |
737 | 737 | ||
738 | } else { | 738 | } else { |
739 | if (cat.isEmpty()) { | 739 | if (cat.isEmpty()) { |
740 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 740 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
741 | } else { | 741 | } else { |
742 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 742 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
743 | } | 743 | } |
744 | } | 744 | } |
745 | 745 | ||
746 | } else { | 746 | } else { |
747 | pal = mStandardPalette ; | 747 | pal = mStandardPalette ; |
748 | } | 748 | } |
749 | item->setPalette( pal ); | 749 | item->setPalette( pal ); |
750 | item->setRecur( event->recurrence()->doesRecur() ); | 750 | item->setRecur( event->recurrence()->doesRecur() ); |
751 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 ); | 751 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 ); |
752 | item->setMoreInfo( event->description().length() > 0 ); | 752 | item->setMoreInfo( event->description().length() > 0 ); |
753 | #ifdef DESKTOP_VERSION | 753 | #ifdef DESKTOP_VERSION |
754 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, | 754 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, |
755 | KOPrefs::instance()->email()); | 755 | KOPrefs::instance()->email()); |
756 | if ( me != 0 ) { | 756 | if ( me != 0 ) { |
757 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) | 757 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) |
758 | item->setReply(true && multiday < 2); | 758 | item->setReply(true && multiday < 2); |
759 | else | 759 | else |
760 | item->setReply(false); | 760 | item->setReply(false); |
761 | } else | 761 | } else |
762 | item->setReply(false); | 762 | item->setReply(false); |
763 | #endif | 763 | #endif |
764 | item->setMultiDay( multiday ); | 764 | item->setMultiDay( multiday ); |
765 | if ( multiday ) { | 765 | if ( multiday ) { |
766 | insertItem( item ,mdayCount); | 766 | insertItem( item ,mdayCount); |
767 | ++mdayCount; | 767 | ++mdayCount; |
768 | } else { | 768 | } else { |
769 | uint i; | 769 | uint i; |
770 | int pos = mdayCount; | 770 | int pos = mdayCount; |
771 | for ( i = mdayCount; i < count();++i ) { | 771 | for ( i = mdayCount; i < count();++i ) { |
772 | QListBoxItem* it = this->item ( i ); | 772 | QListBoxItem* it = this->item ( i ); |
773 | if ( text < it->text() ) { | 773 | if ( it && text < it->text() ) { |
774 | pos = i; | 774 | pos = i; |
775 | break; | 775 | break; |
776 | } | 776 | } |
777 | ++pos; | 777 | ++pos; |
778 | } | 778 | } |
779 | insertItem( item ,pos); | 779 | insertItem( item ,pos); |
780 | } | 780 | } |
781 | if ( useToolTips ) { | 781 | if ( useToolTips ) { |
782 | mToolTip.append( mToolTipText ); | 782 | mToolTip.append( mToolTipText ); |
783 | } | 783 | } |
784 | return mdayCount; | 784 | return mdayCount; |
785 | } | 785 | } |
786 | void MonthViewCell::insertTodo(Todo *todo) | 786 | void MonthViewCell::insertTodo(Todo *todo) |
787 | { | 787 | { |
788 | setFocusPolicy(WheelFocus); | 788 | setFocusPolicy(WheelFocus); |
789 | QString text; | 789 | QString text; |
790 | if (todo->hasDueDate()) { | 790 | if (todo->hasDueDate()) { |
791 | if (!todo->doesFloat()) { | 791 | if (!todo->doesFloat()) { |
792 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 792 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
793 | text += " "; | 793 | text += " "; |
794 | } | 794 | } |
795 | } | 795 | } |
796 | text += todo->summary(); | 796 | text += todo->summary(); |
797 | MonthViewItem *item ; | 797 | MonthViewItem *item ; |
798 | if ( mAvailItemList.count() ) { | 798 | if ( mAvailItemList.count() ) { |
799 | item = mAvailItemList.first(); | 799 | item = mAvailItemList.first(); |
800 | mAvailItemList.remove( item ); | 800 | mAvailItemList.remove( item ); |
801 | item->recycle( todo, mDate, text ); | 801 | item->recycle( todo, mDate, text ); |
802 | } else { | 802 | } else { |
803 | item = new MonthViewItem( todo, mDate, text ); | 803 | item = new MonthViewItem( todo, mDate, text ); |
804 | } | 804 | } |
805 | //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | 805 | //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); |
806 | //item->setPalette( mStandardPalette ); | 806 | //item->setPalette( mStandardPalette ); |
807 | QPalette pal; | 807 | QPalette pal; |
808 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 808 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
809 | QStringList categories = todo->categories(); | 809 | QStringList categories = todo->categories(); |
810 | QString cat = categories.first(); | 810 | QString cat = categories.first(); |
811 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 811 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
812 | pal = getPalette(); | 812 | pal = getPalette(); |
813 | if (cat.isEmpty()) { | 813 | if (cat.isEmpty()) { |
814 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 814 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
815 | } else { | 815 | } else { |
816 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 816 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
817 | } | 817 | } |
818 | 818 | ||
819 | } else { | 819 | } else { |
820 | if (cat.isEmpty()) { | 820 | if (cat.isEmpty()) { |
821 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 821 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
822 | } else { | 822 | } else { |
823 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 823 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
824 | } | 824 | } |
825 | } | 825 | } |
826 | 826 | ||
827 | } else { | 827 | } else { |
828 | pal = mStandardPalette ; | 828 | pal = mStandardPalette ; |
829 | } | 829 | } |
830 | item->setPalette( pal ); | 830 | item->setPalette( pal ); |
831 | item->setRecur( todo->recurrence()->doesRecur() ); | 831 | item->setRecur( todo->recurrence()->doesRecur() ); |
832 | item->setAlarm( todo->isAlarmEnabled() ); | 832 | item->setAlarm( todo->isAlarmEnabled() ); |
833 | item->setMoreInfo( todo->description().length() > 0 ); | 833 | item->setMoreInfo( todo->description().length() > 0 ); |
834 | insertItem( item , count()); | 834 | insertItem( item , count()); |
835 | #ifdef DESKTOP_VERSION | 835 | #ifdef DESKTOP_VERSION |
836 | mToolTip.append( text ); | 836 | mToolTip.append( text ); |
837 | #endif | 837 | #endif |
838 | } | 838 | } |
839 | void MonthViewCell::repaintfinishUpdateCell() | 839 | void MonthViewCell::repaintfinishUpdateCell() |
840 | { | 840 | { |
841 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 841 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
842 | while ( mitem ) { | 842 | while ( mitem ) { |
843 | mitem->setBlockRepaint( false ); | 843 | mitem->setBlockRepaint( false ); |
844 | updateItem ( mitem ); | 844 | updateItem ( mitem ); |
845 | mitem = (MonthViewItem *)mitem->next(); | 845 | mitem = (MonthViewItem *)mitem->next(); |
846 | } | 846 | } |
847 | } | 847 | } |
848 | void MonthViewCell::finishUpdateCell() | 848 | void MonthViewCell::finishUpdateCell() |
849 | { | 849 | { |
850 | 850 | ||
851 | 851 | ||
852 | 852 | ||
853 | #ifdef DESKTOP_VERSION | 853 | #ifdef DESKTOP_VERSION |
854 | if (mToolTip.count() > 0 ) { | 854 | if (mToolTip.count() > 0 ) { |
855 | mToolTip.sort(); | 855 | mToolTip.sort(); |
856 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); | 856 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); |
857 | } | 857 | } |
858 | #endif | 858 | #endif |
859 | //sort(); | 859 | //sort(); |
860 | //setMyPalette(); | 860 | //setMyPalette(); |
861 | setMyPalette(); | 861 | setMyPalette(); |
862 | 862 | ||
863 | resizeEvent( 0 ); | 863 | resizeEvent( 0 ); |
864 | 864 | ||
865 | } | 865 | } |
866 | void MonthViewCell::updateCell() | 866 | void MonthViewCell::updateCell() |
867 | { | 867 | { |
868 | if ( !mMonthView->isUpdatePossible() ) | 868 | if ( !mMonthView->isUpdatePossible() ) |
869 | return; | 869 | return; |
870 | startUpdateCell(); | 870 | startUpdateCell(); |
871 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 871 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
872 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | 872 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); |
873 | Event *event; | 873 | Event *event; |
874 | for( event = events.first(); event; event = events.next() ) { // for event | 874 | for( event = events.first(); event; event = events.next() ) { // for event |
875 | insertEvent(event); | 875 | insertEvent(event); |
876 | } | 876 | } |
877 | // insert due todos | 877 | // insert due todos |
878 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | 878 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); |
879 | Todo *todo; | 879 | Todo *todo; |
880 | for(todo = todos.first(); todo; todo = todos.next()) { | 880 | for(todo = todos.first(); todo; todo = todos.next()) { |
881 | insertTodo( todo ); | 881 | insertTodo( todo ); |
882 | } | 882 | } |
883 | finishUpdateCell(); | 883 | finishUpdateCell(); |
884 | // if ( isVisible()) | 884 | // if ( isVisible()) |
885 | //qApp->processEvents(); | 885 | //qApp->processEvents(); |
886 | } | 886 | } |
887 | 887 | ||
888 | void MonthViewCell::updateConfig( bool bigFont ) // = false | 888 | void MonthViewCell::updateConfig( bool bigFont ) // = false |
889 | { | 889 | { |
890 | 890 | ||
891 | if ( bigFont ) { | 891 | if ( bigFont ) { |
892 | QFont fo = KOPrefs::instance()->mMonthViewFont; | 892 | QFont fo = KOPrefs::instance()->mMonthViewFont; |
893 | int ps = fo.pointSize() + 2; | 893 | int ps = fo.pointSize() + 2; |
894 | if ( ps < 18 ) | 894 | if ( ps < 18 ) |
895 | ps += 2; | 895 | ps += 2; |
896 | fo.setPointSize( ps ); | 896 | fo.setPointSize( ps ); |
897 | setFont( fo ); | 897 | setFont( fo ); |
898 | } else | 898 | } else |
899 | setFont( KOPrefs::instance()->mMonthViewFont ); | 899 | setFont( KOPrefs::instance()->mMonthViewFont ); |
900 | 900 | ||
901 | QFontMetrics fm( font() ); | 901 | QFontMetrics fm( font() ); |
902 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); | 902 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); |
903 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); | 903 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); |
904 | mHolidayPalette = mStandardPalette; | 904 | mHolidayPalette = mStandardPalette; |
905 | mPrimaryPalette = mStandardPalette; | 905 | mPrimaryPalette = mStandardPalette; |
906 | mNonPrimaryPalette = mStandardPalette; | 906 | mNonPrimaryPalette = mStandardPalette; |
907 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { | 907 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { |
908 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); | 908 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); |
909 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); | 909 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); |
910 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); | 910 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); |
911 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); | 911 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); |
912 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); | 912 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); |
913 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); | 913 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); |
914 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 914 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
915 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 915 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
916 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 916 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
917 | } | 917 | } |
918 | //updateCell(); | 918 | //updateCell(); |
919 | } | 919 | } |
920 | 920 | ||
921 | void MonthViewCell::enableScrollBars( bool enabled ) | 921 | void MonthViewCell::enableScrollBars( bool enabled ) |
922 | { | 922 | { |
923 | 923 | ||
924 | return; | 924 | return; |
925 | if ( enabled ) { | 925 | if ( enabled ) { |
926 | QListBoxItem *fi = firstItem (); | 926 | QListBoxItem *fi = firstItem (); |
927 | if (fi ) { | 927 | if (fi ) { |
928 | int ihei = fi->height( this ); | 928 | int ihei = fi->height( this ); |
929 | int hei = numRows () * ihei; | 929 | int hei = numRows () * ihei; |
930 | if ( hei < height() - horizontalScrollBar()->height () ) { | 930 | if ( hei < height() - horizontalScrollBar()->height () ) { |
931 | setVScrollBarMode(QScrollView::AlwaysOff); | 931 | setVScrollBarMode(QScrollView::AlwaysOff); |
932 | } | 932 | } |
933 | else | 933 | else |
934 | setVScrollBarMode(QScrollView::Auto); | 934 | setVScrollBarMode(QScrollView::Auto); |
935 | if ( ihei *3 > height() ) { | 935 | if ( ihei *3 > height() ) { |
936 | setHScrollBarMode(QScrollView::AlwaysOff); | 936 | setHScrollBarMode(QScrollView::AlwaysOff); |
937 | } | 937 | } |
938 | else { | 938 | else { |
939 | setHScrollBarMode(QScrollView::Auto); | 939 | setHScrollBarMode(QScrollView::Auto); |
940 | } | 940 | } |
941 | } else { | 941 | } else { |
942 | setVScrollBarMode(QScrollView::Auto); | 942 | setVScrollBarMode(QScrollView::Auto); |
943 | setHScrollBarMode(QScrollView::Auto); | 943 | setHScrollBarMode(QScrollView::Auto); |
944 | } | 944 | } |
945 | } else { | 945 | } else { |
946 | setVScrollBarMode(QScrollView::AlwaysOff); | 946 | setVScrollBarMode(QScrollView::AlwaysOff); |
947 | setHScrollBarMode(QScrollView::AlwaysOff); | 947 | setHScrollBarMode(QScrollView::AlwaysOff); |
948 | } | 948 | } |
949 | } | 949 | } |
950 | 950 | ||
951 | Incidence *MonthViewCell::selectedIncidence() | 951 | Incidence *MonthViewCell::selectedIncidence() |
952 | { | 952 | { |
953 | int index = currentItem(); | 953 | int index = currentItem(); |
954 | if ( index < 0 ) return 0; | 954 | if ( index < 0 ) return 0; |
955 | 955 | ||
956 | MonthViewItem *mitem = | 956 | MonthViewItem *mitem = |
957 | static_cast<MonthViewItem *>( item( index ) ); | 957 | static_cast<MonthViewItem *>( item( index ) ); |
958 | 958 | ||
959 | if ( !mitem ) return 0; | 959 | if ( !mitem ) return 0; |
960 | 960 | ||
961 | return mitem->incidence(); | 961 | return mitem->incidence(); |
962 | } | 962 | } |
963 | 963 | ||
964 | QDate MonthViewCell::selectedIncidenceDate() | 964 | QDate MonthViewCell::selectedIncidenceDate() |
965 | { | 965 | { |
966 | QDate qd; | 966 | QDate qd; |
967 | int index = currentItem(); | 967 | int index = currentItem(); |
968 | if ( index < 0 ) return qd; | 968 | if ( index < 0 ) return qd; |
969 | 969 | ||
970 | MonthViewItem *mitem = | 970 | MonthViewItem *mitem = |
971 | static_cast<MonthViewItem *>( item( index ) ); | 971 | static_cast<MonthViewItem *>( item( index ) ); |
972 | 972 | ||
973 | if ( !mitem ) return qd; | 973 | if ( !mitem ) return qd; |
974 | 974 | ||
975 | return mitem->incidenceDate(); | 975 | return mitem->incidenceDate(); |
976 | } | 976 | } |
977 | 977 | ||
978 | void MonthViewCell::deselect() | 978 | void MonthViewCell::deselect() |
979 | { | 979 | { |
980 | clearSelection(); | 980 | clearSelection(); |
981 | enableScrollBars( false ); | 981 | enableScrollBars( false ); |
982 | // updateCell(); | 982 | // updateCell(); |
983 | } | 983 | } |
984 | void MonthViewCell::select() | 984 | void MonthViewCell::select() |
985 | { | 985 | { |
986 | ;// updateCell(); | 986 | ;// updateCell(); |
987 | } | 987 | } |
988 | 988 | ||
989 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) | 989 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) |
990 | { | 990 | { |
991 | if ( !mMonthView->isUpdatePossible() ) | 991 | if ( !mMonthView->isUpdatePossible() ) |
992 | return; | 992 | return; |
993 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); | 993 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); |
994 | deselect(); | 994 | deselect(); |
995 | mLabel->setMaximumHeight( height() - lineWidth()*2 ); | 995 | mLabel->setMaximumHeight( height() - lineWidth()*2 ); |
996 | 996 | ||
997 | QString text; | 997 | QString text; |
998 | mLabel->setText( text ); | 998 | mLabel->setText( text ); |
999 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 999 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
1000 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 1000 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
1001 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; | 1001 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; |
1002 | mLabel->resize( mLabelBigSize ); | 1002 | mLabel->resize( mLabelBigSize ); |
1003 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 1003 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
1004 | } else { | 1004 | } else { |
1005 | mLabel->resize( mLabelSize ); | 1005 | mLabel->resize( mLabelSize ); |
1006 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 1006 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
1007 | } | 1007 | } |
1008 | mLabel->setText( text ); | 1008 | mLabel->setText( text ); |
1009 | 1009 | ||
1010 | int size = height() - mLabel->height() - lineWidth()-1; | 1010 | int size = height() - mLabel->height() - lineWidth()-1; |
1011 | //qDebug("LW %d ", lineWidth()); | 1011 | //qDebug("LW %d ", lineWidth()); |
1012 | if ( size > 0 ) | 1012 | if ( size > 0 ) |
1013 | verticalScrollBar()->setMaximumHeight( size ); | 1013 | verticalScrollBar()->setMaximumHeight( size ); |
1014 | size = width() - mLabel->width() -lineWidth()-1; | 1014 | size = width() - mLabel->width() -lineWidth()-1; |
1015 | if ( size > 0 ) | 1015 | if ( size > 0 ) |
1016 | horizontalScrollBar()->setMaximumWidth( size ); | 1016 | horizontalScrollBar()->setMaximumWidth( size ); |
1017 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); | 1017 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); |
1018 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 1018 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
1019 | // mItemList->resize ( width(), height () ); | 1019 | // mItemList->resize ( width(), height () ); |
1020 | if ( e ) | 1020 | if ( e ) |
1021 | KNoScrollListBox::resizeEvent ( e ); | 1021 | KNoScrollListBox::resizeEvent ( e ); |
1022 | } | 1022 | } |
1023 | 1023 | ||
1024 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 1024 | void MonthViewCell::defaultAction( QListBoxItem *item ) |
1025 | { | 1025 | { |
1026 | 1026 | ||
1027 | if ( !item ) { | 1027 | if ( !item ) { |
1028 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1028 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1029 | emit newEventSignal( dt ); | 1029 | emit newEventSignal( dt ); |
diff --git a/microkde/KDGanttMinimizeSplitter.cpp b/microkde/KDGanttMinimizeSplitter.cpp index fb5d4e3..72c4e60 100644 --- a/microkde/KDGanttMinimizeSplitter.cpp +++ b/microkde/KDGanttMinimizeSplitter.cpp | |||
@@ -1,940 +1,955 @@ | |||
1 | /* -*- Mode: C++ -*- | 1 | /* -*- Mode: C++ -*- |
2 | $Id$ | 2 | $Id$ |
3 | */ | 3 | */ |
4 | 4 | ||
5 | /**************************************************************************** | 5 | /**************************************************************************** |
6 | ** Copyright (C) 2002-2004 Klarälvdalens Datakonsult AB. All rights reserved. | 6 | ** Copyright (C) 2002-2004 Klarälvdalens Datakonsult AB. All rights reserved. |
7 | ** | 7 | ** |
8 | ** This file is part of the KDGantt library. | 8 | ** This file is part of the KDGantt library. |
9 | ** | 9 | ** |
10 | ** This file may be distributed and/or modified under the terms of the | 10 | ** This file may be distributed and/or modified under the terms of the |
11 | ** GNU General Public License version 2 as published by the Free Software | 11 | ** GNU General Public License version 2 as published by the Free Software |
12 | ** Foundation and appearing in the file LICENSE.GPL included in the | 12 | ** Foundation and appearing in the file LICENSE.GPL included in the |
13 | ** packaging of this file. | 13 | ** packaging of this file. |
14 | ** | 14 | ** |
15 | ** Licensees holding valid commercial KDGantt licenses may use this file in | 15 | ** Licensees holding valid commercial KDGantt licenses may use this file in |
16 | ** accordance with the KDGantt Commercial License Agreement provided with | 16 | ** accordance with the KDGantt Commercial License Agreement provided with |
17 | ** the Software. | 17 | ** the Software. |
18 | ** | 18 | ** |
19 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 19 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
20 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 20 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
21 | ** | 21 | ** |
22 | ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for | 22 | ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for |
23 | ** information about KDGantt Commercial License Agreements. | 23 | ** information about KDGantt Commercial License Agreements. |
24 | ** | 24 | ** |
25 | ** Contact info@klaralvdalens-datakonsult.se if any conditions of this | 25 | ** Contact info@klaralvdalens-datakonsult.se if any conditions of this |
26 | ** licensing are not clear to you. | 26 | ** licensing are not clear to you. |
27 | ** | 27 | ** |
28 | ** As a special exception, permission is given to link this program | 28 | ** As a special exception, permission is given to link this program |
29 | ** with any edition of Qt, and distribute the resulting executable, | 29 | ** with any edition of Qt, and distribute the resulting executable, |
30 | ** without including the source code for Qt in the source distribution. | 30 | ** without including the source code for Qt in the source distribution. |
31 | ** | 31 | ** |
32 | **********************************************************************/ | 32 | **********************************************************************/ |
33 | 33 | ||
34 | #include "KDGanttMinimizeSplitter.h" | 34 | #include "KDGanttMinimizeSplitter.h" |
35 | #ifndef QT_NO_SPLITTER___ | 35 | #ifndef QT_NO_SPLITTER___ |
36 | 36 | ||
37 | #include "qpainter.h" | 37 | #include "qpainter.h" |
38 | #include "qdrawutil.h" | 38 | #include "qdrawutil.h" |
39 | #include "qbitmap.h" | 39 | #include "qbitmap.h" |
40 | #if QT_VERSION >= 0x030000 | 40 | #if QT_VERSION >= 0x030000 |
41 | #include "qptrlist.h" | 41 | #include "qptrlist.h" |
42 | #include "qmemarray.h" | 42 | #include "qmemarray.h" |
43 | #else | 43 | #else |
44 | #include <qlist.h> | 44 | #include <qlist.h> |
45 | #include <qarray.h> | 45 | #include <qarray.h> |
46 | #define QPtrList QList | 46 | #define QPtrList QList |
47 | #define QMemArray QArray | 47 | #define QMemArray QArray |
48 | #endif | 48 | #endif |
49 | #include "qlayoutengine_p.h" | 49 | #include "qlayoutengine_p.h" |
50 | #include "qobjectlist.h" | 50 | #include "qobjectlist.h" |
51 | #include "qstyle.h" | 51 | #include "qstyle.h" |
52 | #include "qapplication.h" //sendPostedEvents | 52 | #include "qapplication.h" //sendPostedEvents |
53 | #include <qvaluelist.h> | 53 | #include <qvaluelist.h> |
54 | #include <qcursor.h> | 54 | #include <qcursor.h> |
55 | #include <qframe.h> | ||
55 | #ifndef KDGANTT_MASTER_CVS | 56 | #ifndef KDGANTT_MASTER_CVS |
56 | //#include "KDGanttMinimizeSplitter.moc" | 57 | //#include "KDGanttMinimizeSplitter.moc" |
57 | #endif | 58 | #endif |
58 | 59 | ||
59 | 60 | ||
60 | 61 | ||
61 | #ifndef DOXYGEN_SKIP_INTERNAL | 62 | #ifndef DOXYGEN_SKIP_INTERNAL |
62 | 63 | ||
63 | #if QT_VERSION >= 232 | 64 | #if QT_VERSION >= 232 |
64 | static int mouseOffset; | 65 | static int mouseOffset; |
65 | static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky | 66 | static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky |
66 | 67 | ||
68 | class KDRubberBand: public QFrame | ||
69 | { | ||
70 | public: | ||
71 | KDRubberBand( QWidget *parent, const char * name, WFlags f ) :QFrame ( parent, name, f ) {;} | ||
72 | |||
73 | protected: | ||
74 | virtual void mousePressEvent ( QMouseEvent * ) | ||
75 | { | ||
76 | close(); | ||
77 | }; | ||
78 | |||
79 | }; | ||
67 | 80 | ||
68 | KDGanttSplitterHandle::KDGanttSplitterHandle( Qt::Orientation o, | 81 | KDGanttSplitterHandle::KDGanttSplitterHandle( Qt::Orientation o, |
69 | KDGanttMinimizeSplitter *parent, const char * name ) | 82 | KDGanttMinimizeSplitter *parent, const char * name ) |
70 | : QWidget( parent, name ), _activeButton( 0 ), _collapsed( false ) | 83 | : QWidget( parent, name ), _activeButton( 0 ), _collapsed( false ) |
71 | { | 84 | { |
72 | 85 | ||
73 | if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->width() < 650 ) { | 86 | if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->width() < 650 ) { |
74 | mSizeHint = QSize(7,7); | 87 | mSizeHint = QSize(7,7); |
75 | mUseOffset = true; | 88 | mUseOffset = true; |
76 | } else { | 89 | } else { |
77 | mSizeHint = QSize(6,6); | 90 | mSizeHint = QSize(6,6); |
78 | mUseOffset = false; | 91 | mUseOffset = false; |
79 | } | 92 | } |
80 | s = parent; | 93 | s = parent; |
81 | setOrientation(o); | 94 | setOrientation(o); |
82 | setMouseTracking( true ); | 95 | setMouseTracking( true ); |
83 | mMouseDown = false; | 96 | mMouseDown = false; |
84 | //setMaximumHeight( 5 ); // test only | 97 | //setMaximumHeight( 5 ); // test only |
85 | } | 98 | } |
86 | 99 | ||
87 | QSize KDGanttSplitterHandle::sizeHint() const | 100 | QSize KDGanttSplitterHandle::sizeHint() const |
88 | { | 101 | { |
89 | return mSizeHint; | 102 | return mSizeHint; |
90 | } | 103 | } |
91 | 104 | ||
92 | void KDGanttSplitterHandle::setOrientation( Qt::Orientation o ) | 105 | void KDGanttSplitterHandle::setOrientation( Qt::Orientation o ) |
93 | { | 106 | { |
94 | orient = o; | 107 | orient = o; |
95 | #ifndef QT_NO_CURSOR | 108 | #ifndef QT_NO_CURSOR |
96 | if ( o == KDGanttMinimizeSplitter::Horizontal ) | 109 | if ( o == KDGanttMinimizeSplitter::Horizontal ) |
97 | setCursor( splitHCursor ); | 110 | setCursor( splitHCursor ); |
98 | else | 111 | else |
99 | setCursor( splitVCursor ); | 112 | setCursor( splitVCursor ); |
100 | #endif | 113 | #endif |
101 | } | 114 | } |
102 | 115 | ||
103 | 116 | ||
104 | void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e ) | 117 | void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e ) |
105 | { | 118 | { |
106 | updateCursor( e->pos() ); | 119 | updateCursor( e->pos() ); |
107 | if ( !(e->state()&LeftButton) ) | 120 | if ( !(e->state()&LeftButton) ) |
108 | return; | 121 | return; |
109 | 122 | ||
110 | if ( _activeButton != 0) | 123 | if ( _activeButton != 0) |
111 | return; | 124 | return; |
112 | 125 | ||
113 | QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) | 126 | QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) |
114 | - mouseOffset; | 127 | - mouseOffset; |
115 | if ( opaque() ) { | 128 | if ( opaque() ) { |
116 | s->moveSplitter( pos, id() ); | 129 | s->moveSplitter( pos, id() ); |
117 | } else { | 130 | } else { |
118 | int min = pos; int max = pos; | 131 | int min = pos; int max = pos; |
119 | s->getRange( id(), &min, &max ); | 132 | s->getRange( id(), &min, &max ); |
120 | s->setRubberband( QMAX( min, QMIN(max, pos ))); | 133 | s->setRubberband( QMAX( min, QMIN(max, pos ))); |
121 | } | 134 | } |
122 | _collapsed = false; | 135 | _collapsed = false; |
123 | } | 136 | } |
124 | 137 | ||
125 | void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e ) | 138 | void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e ) |
126 | { | 139 | { |
127 | if ( e->button() == LeftButton ) { | 140 | if ( e->button() == LeftButton ) { |
128 | _activeButton = onButton( e->pos() ); | 141 | _activeButton = onButton( e->pos() ); |
129 | mouseOffset = s->pick(e->pos()); | 142 | mouseOffset = s->pick(e->pos()); |
130 | mMouseDown = true; | 143 | mMouseDown = true; |
131 | repaint(); | 144 | repaint(); |
132 | updateCursor( e->pos() ); | 145 | updateCursor( e->pos() ); |
133 | } | 146 | } |
134 | } | 147 | } |
135 | 148 | ||
136 | void KDGanttSplitterHandle::updateCursor( const QPoint& p) | 149 | void KDGanttSplitterHandle::updateCursor( const QPoint& p) |
137 | { | 150 | { |
138 | if ( onButton( p ) != 0 ) { | 151 | if ( onButton( p ) != 0 ) { |
139 | setCursor( arrowCursor ); | 152 | setCursor( arrowCursor ); |
140 | } | 153 | } |
141 | else { | 154 | else { |
142 | if ( orient == KDGanttMinimizeSplitter::Horizontal ) | 155 | if ( orient == KDGanttMinimizeSplitter::Horizontal ) |
143 | setCursor( splitHCursor ); | 156 | setCursor( splitHCursor ); |
144 | else | 157 | else |
145 | setCursor( splitVCursor ); | 158 | setCursor( splitVCursor ); |
146 | } | 159 | } |
147 | } | 160 | } |
148 | void KDGanttSplitterHandle::toggle() | 161 | void KDGanttSplitterHandle::toggle() |
149 | { | 162 | { |
150 | int pos; | 163 | int pos; |
151 | int min, max; | 164 | int min, max; |
152 | if ( !_collapsed ) { | 165 | if ( !_collapsed ) { |
153 | s->expandPos( id(), &min, &max ); | 166 | s->expandPos( id(), &min, &max ); |
154 | if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left | 167 | if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left |
155 | || s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { | 168 | || s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { |
156 | pos = min; | 169 | pos = min; |
157 | } | 170 | } |
158 | else { | 171 | else { |
159 | pos = max; | 172 | pos = max; |
160 | } | 173 | } |
161 | 174 | ||
162 | _origPos = s->pick(mapToParent( QPoint( 0,0 ) )); | 175 | _origPos = s->pick(mapToParent( QPoint( 0,0 ) )); |
163 | s->moveSplitter( pos, id() ); | 176 | s->moveSplitter( pos, id() ); |
164 | _collapsed = true; | 177 | _collapsed = true; |
165 | } | 178 | } |
166 | else { | 179 | else { |
167 | s->moveSplitter( _origPos, id() ); | 180 | s->moveSplitter( _origPos, id() ); |
168 | _collapsed = false; | 181 | _collapsed = false; |
169 | } | 182 | } |
170 | repaint(); | 183 | repaint(); |
171 | } | 184 | } |
172 | 185 | ||
173 | void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) | 186 | void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) |
174 | { | 187 | { |
175 | mMouseDown = false; | 188 | mMouseDown = false; |
176 | if ( _activeButton != 0 ) { | 189 | if ( _activeButton != 0 ) { |
177 | if ( onButton( e->pos() ) == _activeButton ) | 190 | if ( onButton( e->pos() ) == _activeButton ) |
178 | { | 191 | { |
179 | toggle(); | 192 | toggle(); |
180 | } | 193 | } |
181 | _activeButton = 0; | 194 | _activeButton = 0; |
182 | updateCursor( e->pos() ); | 195 | updateCursor( e->pos() ); |
183 | } | 196 | } |
184 | else { | 197 | else { |
185 | if ( !opaque() && e->button() == LeftButton ) { | 198 | if ( !opaque() && e->button() == LeftButton ) { |
186 | QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) | 199 | QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) |
187 | - mouseOffset; | 200 | - mouseOffset; |
188 | s->setRubberband( -1 ); | 201 | s->setRubberband( -1 ); |
189 | s->moveSplitter( pos, id() ); | 202 | s->moveSplitter( pos, id() ); |
190 | } | 203 | } |
191 | } | 204 | } |
192 | if ( s->rubberBand() ) | 205 | if ( s->rubberBand() ) { |
193 | s->rubberBand()->hide(); | 206 | //qDebug("hide rubberband "); |
207 | s->rubberBand()->close(); | ||
208 | } | ||
194 | repaint(); | 209 | repaint(); |
195 | } | 210 | } |
196 | 211 | ||
197 | int KDGanttSplitterHandle::onButton( const QPoint& p ) | 212 | int KDGanttSplitterHandle::onButton( const QPoint& p ) |
198 | { | 213 | { |
199 | QValueList<QPointArray> list = buttonRegions(); | 214 | QValueList<QPointArray> list = buttonRegions(); |
200 | int index = 1; | 215 | int index = 1; |
201 | int add = 12; | 216 | int add = 12; |
202 | for( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { | 217 | for( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { |
203 | QRect rect = (*it).boundingRect(); | 218 | QRect rect = (*it).boundingRect(); |
204 | rect.setLeft( rect.left()- add ); | 219 | rect.setLeft( rect.left()- add ); |
205 | rect.setRight( rect.right() + add); | 220 | rect.setRight( rect.right() + add); |
206 | rect.setTop( rect.top()- add ); | 221 | rect.setTop( rect.top()- add ); |
207 | rect.setBottom( rect.bottom() + add); | 222 | rect.setBottom( rect.bottom() + add); |
208 | if ( rect.contains( p ) ) { | 223 | if ( rect.contains( p ) ) { |
209 | return index; | 224 | return index; |
210 | } | 225 | } |
211 | index++; | 226 | index++; |
212 | } | 227 | } |
213 | return 0; | 228 | return 0; |
214 | } | 229 | } |
215 | 230 | ||
216 | 231 | ||
217 | QValueList<QPointArray> KDGanttSplitterHandle::buttonRegions() | 232 | QValueList<QPointArray> KDGanttSplitterHandle::buttonRegions() |
218 | { | 233 | { |
219 | QValueList<QPointArray> list; | 234 | QValueList<QPointArray> list; |
220 | 235 | ||
221 | int sw = 8; | 236 | int sw = 8; |
222 | int yyy = 1; | 237 | int yyy = 1; |
223 | int xxx = 1; | 238 | int xxx = 1; |
224 | int voffset[] = { (int) -sw*3, (int) sw*3 }; | 239 | int voffset[] = { (int) -sw*3, (int) sw*3 }; |
225 | for ( int i = 0; i < 2; i++ ) { | 240 | for ( int i = 0; i < 2; i++ ) { |
226 | QPointArray arr; | 241 | QPointArray arr; |
227 | if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right || | 242 | if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right || |
228 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left) { | 243 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left) { |
229 | int mid = height()/2 + voffset[i]; | 244 | int mid = height()/2 + voffset[i]; |
230 | arr.setPoints( 3, | 245 | arr.setPoints( 3, |
231 | 1-xxx, mid - sw + 4, | 246 | 1-xxx, mid - sw + 4, |
232 | sw-3-xxx, mid, | 247 | sw-3-xxx, mid, |
233 | 1-xxx, mid + sw -4); | 248 | 1-xxx, mid + sw -4); |
234 | } | 249 | } |
235 | else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left || | 250 | else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left || |
236 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { | 251 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { |
237 | int mid = height()/2 + voffset[i]; | 252 | int mid = height()/2 + voffset[i]; |
238 | arr.setPoints( 3, | 253 | arr.setPoints( 3, |
239 | sw-4, mid - sw + 4, | 254 | sw-4, mid - sw + 4, |
240 | 0, mid, | 255 | 0, mid, |
241 | sw-4, mid + sw - 4); | 256 | sw-4, mid + sw - 4); |
242 | } | 257 | } |
243 | else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up || | 258 | else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up || |
244 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down) { | 259 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down) { |
245 | int mid = width()/2 + voffset[i]; | 260 | int mid = width()/2 + voffset[i]; |
246 | arr.setPoints( 3, | 261 | arr.setPoints( 3, |
247 | mid - sw + 4, sw-4, | 262 | mid - sw + 4, sw-4, |
248 | mid, 0, | 263 | mid, 0, |
249 | mid + sw - 4, sw-4 ); | 264 | mid + sw - 4, sw-4 ); |
250 | } | 265 | } |
251 | else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down || | 266 | else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down || |
252 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { | 267 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { |
253 | int mid = width()/2 + voffset[i]; | 268 | int mid = width()/2 + voffset[i]; |
254 | arr.setPoints( 3, | 269 | arr.setPoints( 3, |
255 | mid - sw + 4, 1-yyy, | 270 | mid - sw + 4, 1-yyy, |
256 | mid, sw-3-yyy, | 271 | mid, sw-3-yyy, |
257 | mid + sw -4, 1-yyy); | 272 | mid + sw -4, 1-yyy); |
258 | } | 273 | } |
259 | list.append( arr ); | 274 | list.append( arr ); |
260 | } | 275 | } |
261 | return list; | 276 | return list; |
262 | } | 277 | } |
263 | 278 | ||
264 | void KDGanttSplitterHandle::paintEvent( QPaintEvent * ) | 279 | void KDGanttSplitterHandle::paintEvent( QPaintEvent * ) |
265 | { | 280 | { |
266 | QPixmap buffer( size() ); | 281 | QPixmap buffer( size() ); |
267 | QPainter p( &buffer ); | 282 | QPainter p( &buffer ); |
268 | 283 | ||
269 | //LR | 284 | //LR |
270 | // Draw the splitter rectangle | 285 | // Draw the splitter rectangle |
271 | p.setBrush( colorGroup().background() ); | 286 | p.setBrush( colorGroup().background() ); |
272 | p.setPen( colorGroup().foreground() ); | 287 | p.setPen( colorGroup().foreground() ); |
273 | //p.drawRect( rect() ); | 288 | //p.drawRect( rect() ); |
274 | #ifndef DESKTOP_VERSION | 289 | #ifndef DESKTOP_VERSION |
275 | if ( mMouseDown && ! _activeButton) | 290 | if ( mMouseDown && ! _activeButton) |
276 | buffer.fill( colorGroup().background().dark() ); | 291 | buffer.fill( colorGroup().background().dark() ); |
277 | else | 292 | else |
278 | #endif | 293 | #endif |
279 | buffer.fill( colorGroup().background() ); | 294 | buffer.fill( colorGroup().background() ); |
280 | //buffer.fill( backgroundColor() ); | 295 | //buffer.fill( backgroundColor() ); |
281 | // parentWidget()->style().drawPrimitive( QStyle::PE_Panel, &p, rect(), parentWidget()->colorGroup()); | 296 | // parentWidget()->style().drawPrimitive( QStyle::PE_Panel, &p, rect(), parentWidget()->colorGroup()); |
282 | 297 | ||
283 | int sw = 8; // Hardcoded, given I didn't use styles anymore, I didn't like to use their size | 298 | int sw = 8; // Hardcoded, given I didn't use styles anymore, I didn't like to use their size |
284 | 299 | ||
285 | // arrow color | 300 | // arrow color |
286 | QColor col; | 301 | QColor col; |
287 | if ( _activeButton ) | 302 | if ( _activeButton ) |
288 | col = colorGroup().background().dark( 250 ); | 303 | col = colorGroup().background().dark( 250 ); |
289 | else { | 304 | else { |
290 | if ( mMouseDown ) | 305 | if ( mMouseDown ) |
291 | col = Qt::white; | 306 | col = Qt::white; |
292 | else | 307 | else |
293 | col = colorGroup().background().dark( 150 ); | 308 | col = colorGroup().background().dark( 150 ); |
294 | } | 309 | } |
295 | //QColor col = backgroundColor().dark( 130 ); | 310 | //QColor col = backgroundColor().dark( 130 ); |
296 | p.setBrush( col ); | 311 | p.setBrush( col ); |
297 | p.setPen( col ); | 312 | p.setPen( col ); |
298 | 313 | ||
299 | QValueList<QPointArray> list = buttonRegions(); | 314 | QValueList<QPointArray> list = buttonRegions(); |
300 | int index = 1; | 315 | int index = 1; |
301 | if ( mUseOffset ) | 316 | if ( mUseOffset ) |
302 | p.translate( 0, 1 ); | 317 | p.translate( 0, 1 ); |
303 | for ( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { | 318 | for ( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { |
304 | if ( index == _activeButton ) { | 319 | if ( index == _activeButton ) { |
305 | 320 | ||
306 | /* | 321 | /* |
307 | if ( ! _collapsed ) { | 322 | if ( ! _collapsed ) { |
308 | p.save(); | 323 | p.save(); |
309 | // p.translate( parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftHorizontal ), | 324 | // p.translate( parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftHorizontal ), |
310 | // parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftVertical ) ); | 325 | // parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftVertical ) ); |
311 | p.translate( -1, 0 ); | 326 | p.translate( -1, 0 ); |
312 | p.drawPolygon( *it, true ); | 327 | p.drawPolygon( *it, true ); |
313 | p.restore(); } else | 328 | p.restore(); } else |
314 | */ | 329 | */ |
315 | p.drawPolygon( *it, true ); | 330 | p.drawPolygon( *it, true ); |
316 | 331 | ||
317 | } | 332 | } |
318 | else { | 333 | else { |
319 | /* | 334 | /* |
320 | if ( ! _collapsed ) { | 335 | if ( ! _collapsed ) { |
321 | p.save(); | 336 | p.save(); |
322 | p.translate( -1, 0 ); | 337 | p.translate( -1, 0 ); |
323 | p.drawPolygon( *it, true ); | 338 | p.drawPolygon( *it, true ); |
324 | p.restore(); | 339 | p.restore(); |
325 | } else | 340 | } else |
326 | */ | 341 | */ |
327 | p.drawPolygon( *it, true ); | 342 | p.drawPolygon( *it, true ); |
328 | 343 | ||
329 | } | 344 | } |
330 | index++; | 345 | index++; |
331 | } | 346 | } |
332 | 347 | ||
333 | // Draw the lines between the arrows | 348 | // Draw the lines between the arrows |
334 | if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left || | 349 | if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left || |
335 | s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { | 350 | s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { |
336 | int mid = height()/2; | 351 | int mid = height()/2; |
337 | p.drawLine ( 1, mid - sw, 1, mid + sw ); | 352 | p.drawLine ( 1, mid - sw, 1, mid + sw ); |
338 | p.drawLine ( 3, mid - sw, 3, mid + sw ); | 353 | p.drawLine ( 3, mid - sw, 3, mid + sw ); |
339 | } | 354 | } |
340 | else if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Up || | 355 | else if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Up || |
341 | s->minimizeDirection() == KDGanttMinimizeSplitter::Down ) { | 356 | s->minimizeDirection() == KDGanttMinimizeSplitter::Down ) { |
342 | int mid = width()/2; | 357 | int mid = width()/2; |
343 | p.drawLine( mid -sw, 1, mid +sw, 1 ); | 358 | p.drawLine( mid -sw, 1, mid +sw, 1 ); |
344 | p.drawLine( mid -sw, 3, mid +sw, 3 ); | 359 | p.drawLine( mid -sw, 3, mid +sw, 3 ); |
345 | } | 360 | } |
346 | bitBlt( this, 0, 0, &buffer ); | 361 | bitBlt( this, 0, 0, &buffer ); |
347 | 362 | ||
348 | } | 363 | } |
349 | #endif | 364 | #endif |
350 | 365 | ||
351 | class QSplitterLayoutStruct | 366 | class QSplitterLayoutStruct |
352 | { | 367 | { |
353 | public: | 368 | public: |
354 | KDGanttMinimizeSplitter::ResizeMode mode; | 369 | KDGanttMinimizeSplitter::ResizeMode mode; |
355 | QCOORD sizer; | 370 | QCOORD sizer; |
356 | bool isSplitter; | 371 | bool isSplitter; |
357 | QWidget *wid; | 372 | QWidget *wid; |
358 | }; | 373 | }; |
359 | 374 | ||
360 | class QSplitterData | 375 | class QSplitterData |
361 | { | 376 | { |
362 | public: | 377 | public: |
363 | QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {} | 378 | QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {} |
364 | 379 | ||
365 | QPtrList<QSplitterLayoutStruct> list; | 380 | QPtrList<QSplitterLayoutStruct> list; |
366 | bool opaque; | 381 | bool opaque; |
367 | bool firstShow; | 382 | bool firstShow; |
368 | }; | 383 | }; |
369 | 384 | ||
370 | void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, | 385 | void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, |
371 | int space, int spacer ); | 386 | int space, int spacer ); |
372 | #endif // DOXYGEN_SKIP_INTERNAL | 387 | #endif // DOXYGEN_SKIP_INTERNAL |
373 | 388 | ||
374 | 389 | ||
375 | /*! | 390 | /*! |
376 | \class KDGanttMinimizeSplitter KDGanttMinimizeSplitter.h | 391 | \class KDGanttMinimizeSplitter KDGanttMinimizeSplitter.h |
377 | \brief The KDGanttMinimizeSplitter class implements a splitter | 392 | \brief The KDGanttMinimizeSplitter class implements a splitter |
378 | widget with minimize buttons. | 393 | widget with minimize buttons. |
379 | 394 | ||
380 | This class (and its documentation) is largely a copy of Qt's | 395 | This class (and its documentation) is largely a copy of Qt's |
381 | QSplitter; the copying was necessary because QSplitter is not | 396 | QSplitter; the copying was necessary because QSplitter is not |
382 | extensible at all. QSplitter and its documentation are licensed | 397 | extensible at all. QSplitter and its documentation are licensed |
383 | according to the GPL and the Qt Professional License (if you hold | 398 | according to the GPL and the Qt Professional License (if you hold |
384 | such a license) and are (C) Trolltech AS. | 399 | such a license) and are (C) Trolltech AS. |
385 | 400 | ||
386 | A splitter lets the user control the size of child widgets by | 401 | A splitter lets the user control the size of child widgets by |
387 | dragging the boundary between the children. Any number of widgets | 402 | dragging the boundary between the children. Any number of widgets |
388 | may be controlled. | 403 | may be controlled. |
389 | 404 | ||
390 | To show a QListBox, a QListView and a QTextEdit side by side: | 405 | To show a QListBox, a QListView and a QTextEdit side by side: |
391 | 406 | ||
392 | \code | 407 | \code |
393 | KDGanttMinimizeSplitter *split = new KDGanttMinimizeSplitter( parent ); | 408 | KDGanttMinimizeSplitter *split = new KDGanttMinimizeSplitter( parent ); |
394 | QListBox *lb = new QListBox( split ); | 409 | QListBox *lb = new QListBox( split ); |
395 | QListView *lv = new QListView( split ); | 410 | QListView *lv = new QListView( split ); |
396 | QTextEdit *ed = new QTextEdit( split ); | 411 | QTextEdit *ed = new QTextEdit( split ); |
397 | \endcode | 412 | \endcode |
398 | 413 | ||
399 | In KDGanttMinimizeSplitter, the boundary can be either horizontal or | 414 | In KDGanttMinimizeSplitter, the boundary can be either horizontal or |
400 | vertical. The default is horizontal (the children are side by side) | 415 | vertical. The default is horizontal (the children are side by side) |
401 | but you can use setOrientation( QSplitter::Vertical ) to set it to | 416 | but you can use setOrientation( QSplitter::Vertical ) to set it to |
402 | vertical. | 417 | vertical. |
403 | 418 | ||
404 | Use setResizeMode() to specify | 419 | Use setResizeMode() to specify |
405 | that a widget should keep its size when the splitter is resized. | 420 | that a widget should keep its size when the splitter is resized. |
406 | 421 | ||
407 | Although KDGanttMinimizeSplitter normally resizes the children only | 422 | Although KDGanttMinimizeSplitter normally resizes the children only |
408 | at the end of a resize operation, if you call setOpaqueResize( TRUE | 423 | at the end of a resize operation, if you call setOpaqueResize( TRUE |
409 | ) the widgets are resized as often as possible. | 424 | ) the widgets are resized as often as possible. |
410 | 425 | ||
411 | The initial distribution of size between the widgets is determined | 426 | The initial distribution of size between the widgets is determined |
412 | by the initial size of each widget. You can also use setSizes() to | 427 | by the initial size of each widget. You can also use setSizes() to |
413 | set the sizes of all the widgets. The function sizes() returns the | 428 | set the sizes of all the widgets. The function sizes() returns the |
414 | sizes set by the user. | 429 | sizes set by the user. |
415 | 430 | ||
416 | If you hide() a child, its space will be distributed among the other | 431 | If you hide() a child, its space will be distributed among the other |
417 | children. It will be reinstated when you show() it again. It is also | 432 | children. It will be reinstated when you show() it again. It is also |
418 | possible to reorder the widgets within the splitter using | 433 | possible to reorder the widgets within the splitter using |
419 | moveToFirst() and moveToLast(). | 434 | moveToFirst() and moveToLast(). |
420 | */ | 435 | */ |
421 | 436 | ||
422 | 437 | ||
423 | 438 | ||
424 | static QSize minSize( const QWidget* /*w*/ ) | 439 | static QSize minSize( const QWidget* /*w*/ ) |
425 | { | 440 | { |
426 | return QSize(0,0); | 441 | return QSize(0,0); |
427 | } | 442 | } |
428 | 443 | ||
429 | // This is the original version of minSize | 444 | // This is the original version of minSize |
430 | static QSize minSizeHint( const QWidget* w ) | 445 | static QSize minSizeHint( const QWidget* w ) |
431 | { | 446 | { |
432 | QSize min = w->minimumSize(); | 447 | QSize min = w->minimumSize(); |
433 | QSize s; | 448 | QSize s; |
434 | if ( min.height() <= 0 || min.width() <= 0 ) | 449 | if ( min.height() <= 0 || min.width() <= 0 ) |
435 | s = w->minimumSizeHint(); | 450 | s = w->minimumSizeHint(); |
436 | if ( min.height() > 0 ) | 451 | if ( min.height() > 0 ) |
437 | s.setHeight( min.height() ); | 452 | s.setHeight( min.height() ); |
438 | if ( min.width() > 0 ) | 453 | if ( min.width() > 0 ) |
439 | s.setWidth( min.width() ); | 454 | s.setWidth( min.width() ); |
440 | return s.expandedTo(QSize(0,0)); | 455 | return s.expandedTo(QSize(0,0)); |
441 | } | 456 | } |
442 | 457 | ||
443 | 458 | ||
444 | /*! | 459 | /*! |
445 | Constructs a horizontal splitter with the \a parent and \a | 460 | Constructs a horizontal splitter with the \a parent and \a |
446 | name arguments being passed on to the QFrame constructor. | 461 | name arguments being passed on to the QFrame constructor. |
447 | */ | 462 | */ |
448 | KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *name ) | 463 | KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *name ) |
449 | :QFrame(parent,name,WPaintUnclipped) | 464 | :QFrame(parent,name,WPaintUnclipped) |
450 | { | 465 | { |
451 | mRubberBand = 0; | 466 | mRubberBand = 0; |
452 | mFirstHandle = 0; | 467 | mFirstHandle = 0; |
453 | #if QT_VERSION >= 232 | 468 | #if QT_VERSION >= 232 |
454 | orient = Horizontal; | 469 | orient = Horizontal; |
455 | init(); | 470 | init(); |
456 | #endif | 471 | #endif |
457 | } | 472 | } |
458 | 473 | ||
459 | /*! | 474 | /*! |
460 | Constructs a splitter with orientation \a o with the \a parent | 475 | Constructs a splitter with orientation \a o with the \a parent |
461 | and \a name arguments being passed on to the QFrame constructor. | 476 | and \a name arguments being passed on to the QFrame constructor. |
462 | */ | 477 | */ |
463 | KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Orientation o, QWidget *parent, const char *name ) | 478 | KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Orientation o, QWidget *parent, const char *name ) |
464 | :QFrame(parent,name,WPaintUnclipped) | 479 | :QFrame(parent,name,WPaintUnclipped) |
465 | { | 480 | { |
466 | 481 | ||
467 | mRubberBand = 0; | 482 | mRubberBand = 0; |
468 | mFirstHandle = 0; | 483 | mFirstHandle = 0; |
469 | #if QT_VERSION >= 232 | 484 | #if QT_VERSION >= 232 |
470 | orient = o; | 485 | orient = o; |
471 | init(); | 486 | init(); |
472 | #endif | 487 | #endif |
473 | } | 488 | } |
474 | 489 | ||
475 | /*! | 490 | /*! |
476 | Destroys the splitter and any children. | 491 | Destroys the splitter and any children. |
477 | */ | 492 | */ |
478 | KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter() | 493 | KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter() |
479 | { | 494 | { |
480 | #if QT_VERSION >= 232 | 495 | #if QT_VERSION >= 232 |
481 | data->list.setAutoDelete( TRUE ); | 496 | data->list.setAutoDelete( TRUE ); |
482 | delete data; | 497 | delete data; |
483 | #endif | 498 | #endif |
484 | if ( mRubberBand ) | 499 | if ( mRubberBand ) |
485 | delete mRubberBand; | 500 | delete mRubberBand; |
486 | } | 501 | } |
487 | 502 | ||
488 | 503 | ||
489 | #if QT_VERSION >= 232 | 504 | #if QT_VERSION >= 232 |
490 | void KDGanttMinimizeSplitter::init() | 505 | void KDGanttMinimizeSplitter::init() |
491 | { | 506 | { |
492 | data = new QSplitterData; | 507 | data = new QSplitterData; |
493 | if ( orient == Horizontal ) | 508 | if ( orient == Horizontal ) |
494 | setSizePolicy( QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum) ); | 509 | setSizePolicy( QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum) ); |
495 | else | 510 | else |
496 | setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding) ); | 511 | setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding) ); |
497 | #ifndef DESKTOP_VERSION | 512 | #ifndef DESKTOP_VERSION |
498 | setOpaqueResize( false ); | 513 | setOpaqueResize( false ); |
499 | #else | 514 | #else |
500 | setOpaqueResize( true ); | 515 | setOpaqueResize( true ); |
501 | #endif | 516 | #endif |
502 | } | 517 | } |
503 | #endif | 518 | #endif |
504 | 519 | ||
505 | 520 | ||
506 | void KDGanttMinimizeSplitter::toggle() | 521 | void KDGanttMinimizeSplitter::toggle() |
507 | { | 522 | { |
508 | if ( mFirstHandle ) | 523 | if ( mFirstHandle ) |
509 | mFirstHandle->toggle(); | 524 | mFirstHandle->toggle(); |
510 | else | 525 | else |
511 | qDebug("KDGanttMinimizeSplitter::toggle::sorry, handle not available "); | 526 | qDebug("KDGanttMinimizeSplitter::toggle::sorry, handle not available "); |
512 | 527 | ||
513 | } | 528 | } |
514 | 529 | ||
515 | 530 | ||
516 | /*! | 531 | /*! |
517 | \brief the orientation of the splitter | 532 | \brief the orientation of the splitter |
518 | 533 | ||
519 | By default the orientation is horizontal (the widgets are side by side). | 534 | By default the orientation is horizontal (the widgets are side by side). |
520 | The possible orientations are Qt:Vertical and Qt::Horizontal (the default). | 535 | The possible orientations are Qt:Vertical and Qt::Horizontal (the default). |
521 | */ | 536 | */ |
522 | void KDGanttMinimizeSplitter::setOrientation( Orientation o ) | 537 | void KDGanttMinimizeSplitter::setOrientation( Orientation o ) |
523 | { | 538 | { |
524 | #if QT_VERSION >= 232 | 539 | #if QT_VERSION >= 232 |
525 | if ( orient == o ) | 540 | if ( orient == o ) |
526 | return; | 541 | return; |
527 | orient = o; | 542 | orient = o; |
528 | 543 | ||
529 | if ( orient == Horizontal ) | 544 | if ( orient == Horizontal ) |
530 | setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); | 545 | setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); |
531 | else | 546 | else |
532 | setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); | 547 | setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); |
533 | 548 | ||
534 | QSplitterLayoutStruct *s = data->list.first(); | 549 | QSplitterLayoutStruct *s = data->list.first(); |
535 | while ( s ) { | 550 | while ( s ) { |
536 | if ( s->isSplitter ) | 551 | if ( s->isSplitter ) |
537 | ((KDGanttSplitterHandle*)s->wid)->setOrientation( o ); | 552 | ((KDGanttSplitterHandle*)s->wid)->setOrientation( o ); |
538 | s = data->list.next(); // ### next at end of loop, no iterator | 553 | s = data->list.next(); // ### next at end of loop, no iterator |
539 | } | 554 | } |
540 | recalc( isVisible() ); | 555 | recalc( isVisible() ); |
541 | #endif | 556 | #endif |
542 | } | 557 | } |
543 | 558 | ||
544 | 559 | ||
545 | #if QT_VERSION >= 232 | 560 | #if QT_VERSION >= 232 |
546 | /*! | 561 | /*! |
547 | \reimp | 562 | \reimp |
548 | */ | 563 | */ |
549 | void KDGanttMinimizeSplitter::resizeEvent( QResizeEvent * ) | 564 | void KDGanttMinimizeSplitter::resizeEvent( QResizeEvent * ) |
550 | { | 565 | { |
551 | doResize(); | 566 | doResize(); |
552 | } | 567 | } |
553 | 568 | ||
554 | 569 | ||
555 | /* | 570 | /* |
556 | Inserts the widget \a w at the end (or at the beginning if \a first | 571 | Inserts the widget \a w at the end (or at the beginning if \a first |
557 | is TRUE) of the splitter's list of widgets. | 572 | is TRUE) of the splitter's list of widgets. |
558 | 573 | ||
559 | It is the responsibility of the caller of this function to make sure | 574 | It is the responsibility of the caller of this function to make sure |
560 | that \a w is not already in the splitter and to call recalcId if | 575 | that \a w is not already in the splitter and to call recalcId if |
561 | needed. (If \a first is TRUE, then recalcId is very probably | 576 | needed. (If \a first is TRUE, then recalcId is very probably |
562 | needed.) | 577 | needed.) |
563 | */ | 578 | */ |
564 | QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool first ) | 579 | QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool first ) |
565 | { | 580 | { |
566 | QSplitterLayoutStruct *s; | 581 | QSplitterLayoutStruct *s; |
567 | KDGanttSplitterHandle *newHandle = 0; | 582 | KDGanttSplitterHandle *newHandle = 0; |
568 | if ( data->list.count() > 0 ) { | 583 | if ( data->list.count() > 0 ) { |
569 | s = new QSplitterLayoutStruct; | 584 | s = new QSplitterLayoutStruct; |
570 | s->mode = KeepSize; | 585 | s->mode = KeepSize; |
571 | QString tmp = "qt_splithandle_"; | 586 | QString tmp = "qt_splithandle_"; |
572 | tmp += w->name(); | 587 | tmp += w->name(); |
573 | newHandle = new KDGanttSplitterHandle( orientation(), this, tmp.latin1() ); | 588 | newHandle = new KDGanttSplitterHandle( orientation(), this, tmp.latin1() ); |
574 | if ( ! mFirstHandle ) | 589 | if ( ! mFirstHandle ) |
575 | mFirstHandle = newHandle; | 590 | mFirstHandle = newHandle; |
576 | s->wid = newHandle; | 591 | s->wid = newHandle; |
577 | newHandle->setId(data->list.count()); | 592 | newHandle->setId(data->list.count()); |
578 | s->isSplitter = TRUE; | 593 | s->isSplitter = TRUE; |
579 | s->sizer = pick( newHandle->sizeHint() ); | 594 | s->sizer = pick( newHandle->sizeHint() ); |
580 | if ( first ) | 595 | if ( first ) |
581 | data->list.insert( 0, s ); | 596 | data->list.insert( 0, s ); |
582 | else | 597 | else |
583 | data->list.append( s ); | 598 | data->list.append( s ); |
584 | } | 599 | } |
585 | s = new QSplitterLayoutStruct; | 600 | s = new QSplitterLayoutStruct; |
586 | s->mode = Stretch; | 601 | s->mode = Stretch; |
587 | s->wid = w; | 602 | s->wid = w; |
588 | if ( !testWState( WState_Resized ) && w->sizeHint().isValid() ) | 603 | if ( !testWState( WState_Resized ) && w->sizeHint().isValid() ) |
589 | s->sizer = pick( w->sizeHint() ); | 604 | s->sizer = pick( w->sizeHint() ); |
590 | else | 605 | else |
591 | s->sizer = pick( w->size() ); | 606 | s->sizer = pick( w->size() ); |
592 | s->isSplitter = FALSE; | 607 | s->isSplitter = FALSE; |
593 | if ( first ) | 608 | if ( first ) |
594 | data->list.insert( 0, s ); | 609 | data->list.insert( 0, s ); |
595 | else | 610 | else |
596 | data->list.append( s ); | 611 | data->list.append( s ); |
597 | if ( newHandle && isVisible() ) | 612 | if ( newHandle && isVisible() ) |
598 | newHandle->show(); //will trigger sending of post events | 613 | newHandle->show(); //will trigger sending of post events |
599 | return s; | 614 | return s; |
600 | } | 615 | } |
601 | 616 | ||
602 | 617 | ||
603 | /*! | 618 | /*! |
604 | Tells the splitter that a child widget has been inserted or removed. | 619 | Tells the splitter that a child widget has been inserted or removed. |
605 | The event is passed in \a c. | 620 | The event is passed in \a c. |
606 | */ | 621 | */ |
607 | void KDGanttMinimizeSplitter::childEvent( QChildEvent *c ) | 622 | void KDGanttMinimizeSplitter::childEvent( QChildEvent *c ) |
608 | { | 623 | { |
609 | if ( c->type() == QEvent::ChildInserted ) { | 624 | if ( c->type() == QEvent::ChildInserted ) { |
610 | if ( !c->child()->isWidgetType() ) | 625 | if ( !c->child()->isWidgetType() ) |
611 | return; | 626 | return; |
612 | 627 | ||
613 | if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) ) | 628 | if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) ) |
614 | return; | 629 | return; |
615 | 630 | ||
616 | QSplitterLayoutStruct *s = data->list.first(); | 631 | QSplitterLayoutStruct *s = data->list.first(); |
617 | while ( s ) { | 632 | while ( s ) { |
618 | if ( s->wid == c->child() ) | 633 | if ( s->wid == c->child() ) |
619 | return; | 634 | return; |
620 | s = data->list.next(); | 635 | s = data->list.next(); |
621 | } | 636 | } |
622 | addWidget( (QWidget*)c->child() ); | 637 | addWidget( (QWidget*)c->child() ); |
623 | recalc( isVisible() ); | 638 | recalc( isVisible() ); |
624 | 639 | ||
625 | } else if ( c->type() == QEvent::ChildRemoved ) { | 640 | } else if ( c->type() == QEvent::ChildRemoved ) { |
626 | QSplitterLayoutStruct *p = 0; | 641 | QSplitterLayoutStruct *p = 0; |
627 | if ( data->list.count() > 1 ) | 642 | if ( data->list.count() > 1 ) |
628 | p = data->list.at(1); //remove handle _after_ first widget. | 643 | p = data->list.at(1); //remove handle _after_ first widget. |
629 | QSplitterLayoutStruct *s = data->list.first(); | 644 | QSplitterLayoutStruct *s = data->list.first(); |
630 | while ( s ) { | 645 | while ( s ) { |
631 | if ( s->wid == c->child() ) { | 646 | if ( s->wid == c->child() ) { |
632 | data->list.removeRef( s ); | 647 | data->list.removeRef( s ); |
633 | delete s; | 648 | delete s; |
634 | if ( p && p->isSplitter ) { | 649 | if ( p && p->isSplitter ) { |
635 | data->list.removeRef( p ); | 650 | data->list.removeRef( p ); |
636 | delete p->wid; //will call childEvent | 651 | delete p->wid; //will call childEvent |
637 | delete p; | 652 | delete p; |
638 | } | 653 | } |
639 | recalcId(); | 654 | recalcId(); |
640 | doResize(); | 655 | doResize(); |
641 | return; | 656 | return; |
642 | } | 657 | } |
643 | p = s; | 658 | p = s; |
644 | s = data->list.next(); | 659 | s = data->list.next(); |
645 | } | 660 | } |
646 | } | 661 | } |
647 | } | 662 | } |
648 | 663 | ||
649 | 664 | ||
650 | /*! | 665 | /*! |
651 | Shows a rubber band at position \a p. If \a p is negative, the | 666 | Shows a rubber band at position \a p. If \a p is negative, the |
652 | rubber band is removed. | 667 | rubber band is removed. |
653 | */ | 668 | */ |
654 | void KDGanttMinimizeSplitter::setRubberband( int p ) | 669 | void KDGanttMinimizeSplitter::setRubberband( int p ) |
655 | { | 670 | { |
656 | #ifdef DESKTOP_VERSION | 671 | #ifdef DESKTOP_VERSION |
657 | QPainter paint( this ); | 672 | QPainter paint( this ); |
658 | paint.setPen( gray ); | 673 | paint.setPen( gray ); |
659 | paint.setBrush( gray ); | 674 | paint.setBrush( gray ); |
660 | paint.setRasterOp( XorROP ); | 675 | paint.setRasterOp( XorROP ); |
661 | QRect r = contentsRect(); | 676 | QRect r = contentsRect(); |
662 | const int rBord = 3; //Themable???? | 677 | const int rBord = 3; //Themable???? |
663 | #if QT_VERSION >= 0x030000 | 678 | #if QT_VERSION >= 0x030000 |
664 | int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); | 679 | int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); |
665 | #else | 680 | #else |
666 | int sw = style().splitterWidth(); | 681 | int sw = style().splitterWidth(); |
667 | #endif | 682 | #endif |
668 | if ( orient == Horizontal ) { | 683 | if ( orient == Horizontal ) { |
669 | if ( opaqueOldPos >= 0 ) | 684 | if ( opaqueOldPos >= 0 ) |
670 | paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(), | 685 | paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(), |
671 | 2*rBord, r.height() ); | 686 | 2*rBord, r.height() ); |
672 | if ( p >= 0 ) | 687 | if ( p >= 0 ) |
673 | paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() ); | 688 | paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() ); |
674 | } else { | 689 | } else { |
675 | if ( opaqueOldPos >= 0 ) | 690 | if ( opaqueOldPos >= 0 ) |
676 | paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord, | 691 | paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord, |
677 | r.width(), 2*rBord ); | 692 | r.width(), 2*rBord ); |
678 | if ( p >= 0 ) | 693 | if ( p >= 0 ) |
679 | paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord ); | 694 | paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord ); |
680 | } | 695 | } |
681 | opaqueOldPos = p; | 696 | opaqueOldPos = p; |
682 | #else | 697 | #else |
683 | if ( !mRubberBand ) { | 698 | if ( !mRubberBand ) { |
684 | mRubberBand = new QFrame( 0, "rubber", WStyle_NoBorder | WStyle_Customize | WStyle_StaysOnTop); | 699 | mRubberBand = new KDRubberBand( 0, "rubber", WStyle_NoBorder | WStyle_Customize | WStyle_StaysOnTop); |
685 | mRubberBand->setFrameStyle( Box | Raised ); | 700 | mRubberBand->setFrameStyle( Box | Raised ); |
686 | //mRubberBand->setPalette( QPalette ( Qt::red.light(),Qt::red.dark() ) ); | 701 | //mRubberBand->setPalette( QPalette ( Qt::red.light(),Qt::red.dark() ) ); |
687 | mRubberBand->setPalette( QPalette ( colorGroup().background().light(), colorGroup().background().dark() )); | 702 | mRubberBand->setPalette( QPalette ( colorGroup().background().light(), colorGroup().background().dark() )); |
688 | } | 703 | } |
689 | QRect r = contentsRect(); | 704 | QRect r = contentsRect(); |
690 | static int rBord = 0; //Themable???? | 705 | static int rBord = 0; //Themable???? |
691 | if ( !rBord ) { | 706 | if ( !rBord ) { |
692 | if (QApplication::desktop()->width() <= 320 ) | 707 | if (QApplication::desktop()->width() <= 320 ) |
693 | rBord = 3; | 708 | rBord = 3; |
694 | else | 709 | else |
695 | rBord = 4; | 710 | rBord = 4; |
696 | } | 711 | } |
697 | int sw = style().splitterWidth(); | 712 | int sw = style().splitterWidth(); |
698 | if ( orient == Horizontal ) { | 713 | if ( orient == Horizontal ) { |
699 | if ( p >= 0 ) { | 714 | if ( p >= 0 ) { |
700 | QPoint geo = mapToGlobal (QPoint ( p + sw/2 - rBord, r.y())); | 715 | QPoint geo = mapToGlobal (QPoint ( p + sw/2 - rBord, r.y())); |
701 | mRubberBand->setGeometry( geo.x(), geo.y(), 2*rBord, r.height() ); | 716 | mRubberBand->setGeometry( geo.x(), geo.y(), 2*rBord, r.height() ); |
702 | } | 717 | } |
703 | } else { | 718 | } else { |
704 | if ( p >= 0 ) { | 719 | if ( p >= 0 ) { |
705 | QPoint geo = mapToGlobal (QPoint ( r.x(), p + sw/2 - rBord)); | 720 | QPoint geo = mapToGlobal (QPoint ( r.x(), p + sw/2 - rBord)); |
706 | mRubberBand->setGeometry( geo.x(), geo.y(), r.width(), 2*rBord); | 721 | mRubberBand->setGeometry( geo.x(), geo.y(), r.width(), 2*rBord); |
707 | } | 722 | } |
708 | } | 723 | } |
709 | opaqueOldPos = p; | 724 | opaqueOldPos = p; |
710 | if ( ! mRubberBand->isVisible() ) { | 725 | if ( ! mRubberBand->isVisible() ) { |
711 | mRubberBand->show(); | 726 | mRubberBand->show(); |
712 | } | 727 | } |
713 | #endif | 728 | #endif |
714 | } | 729 | } |
715 | 730 | ||
716 | 731 | ||
717 | /*! \reimp */ | 732 | /*! \reimp */ |
718 | bool KDGanttMinimizeSplitter::event( QEvent *e ) | 733 | bool KDGanttMinimizeSplitter::event( QEvent *e ) |
719 | { | 734 | { |
720 | if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) { | 735 | if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) { |
721 | recalc( isVisible() ); | 736 | recalc( isVisible() ); |
722 | if ( e->type() == QEvent::Show ) | 737 | if ( e->type() == QEvent::Show ) |
723 | data->firstShow = FALSE; | 738 | data->firstShow = FALSE; |
724 | } | 739 | } |
725 | return QWidget::event( e ); | 740 | return QWidget::event( e ); |
726 | } | 741 | } |
727 | 742 | ||
728 | 743 | ||
729 | /*! | 744 | /*! |
730 | \obsolete | 745 | \obsolete |
731 | 746 | ||
732 | Draws the splitter handle in the rectangle described by \a x, \a y, | 747 | Draws the splitter handle in the rectangle described by \a x, \a y, |
733 | \a w, \a h using painter \a p. | 748 | \a w, \a h using painter \a p. |
734 | \sa QStyle::drawPrimitive() | 749 | \sa QStyle::drawPrimitive() |
735 | */ | 750 | */ |
736 | void KDGanttMinimizeSplitter::drawSplitter( QPainter *p, | 751 | void KDGanttMinimizeSplitter::drawSplitter( QPainter *p, |
737 | QCOORD x, QCOORD y, QCOORD w, QCOORD h ) | 752 | QCOORD x, QCOORD y, QCOORD w, QCOORD h ) |
738 | { | 753 | { |
739 | #if 0 | 754 | #if 0 |
740 | // LR | 755 | // LR |
741 | style().drawPrimitive(QStyle::PE_Splitter, p, QRect(x, y, w, h), colorGroup(), | 756 | style().drawPrimitive(QStyle::PE_Splitter, p, QRect(x, y, w, h), colorGroup(), |
742 | (orientation() == Qt::Horizontal ? | 757 | (orientation() == Qt::Horizontal ? |
743 | QStyle::Style_Horizontal : 0)); | 758 | QStyle::Style_Horizontal : 0)); |
744 | #endif | 759 | #endif |
745 | } | 760 | } |
746 | 761 | ||
747 | 762 | ||
748 | /*! | 763 | /*! |
749 | Returns the id of the splitter to the right of or below the widget \a w, | 764 | Returns the id of the splitter to the right of or below the widget \a w, |
750 | or 0 if there is no such splitter | 765 | or 0 if there is no such splitter |
751 | (i.e. it is either not in this KDGanttMinimizeSplitter or it is at the end). | 766 | (i.e. it is either not in this KDGanttMinimizeSplitter or it is at the end). |
752 | */ | 767 | */ |
753 | int KDGanttMinimizeSplitter::idAfter( QWidget* w ) const | 768 | int KDGanttMinimizeSplitter::idAfter( QWidget* w ) const |
754 | { | 769 | { |
755 | QSplitterLayoutStruct *s = data->list.first(); | 770 | QSplitterLayoutStruct *s = data->list.first(); |
756 | bool seen_w = FALSE; | 771 | bool seen_w = FALSE; |
757 | while ( s ) { | 772 | while ( s ) { |
758 | if ( s->isSplitter && seen_w ) | 773 | if ( s->isSplitter && seen_w ) |
759 | return data->list.at(); | 774 | return data->list.at(); |
760 | if ( !s->isSplitter && s->wid == w ) | 775 | if ( !s->isSplitter && s->wid == w ) |
761 | seen_w = TRUE; | 776 | seen_w = TRUE; |
762 | s = data->list.next(); | 777 | s = data->list.next(); |
763 | } | 778 | } |
764 | return 0; | 779 | return 0; |
765 | } | 780 | } |
766 | 781 | ||
767 | 782 | ||
768 | /*! | 783 | /*! |
769 | Moves the left/top edge of the splitter handle with id \a id as | 784 | Moves the left/top edge of the splitter handle with id \a id as |
770 | close as possible to position \a p, which is the distance from the | 785 | close as possible to position \a p, which is the distance from the |
771 | left (or top) edge of the widget. | 786 | left (or top) edge of the widget. |
772 | 787 | ||
773 | For Arabic and Hebrew the layout is reversed, and using this | 788 | For Arabic and Hebrew the layout is reversed, and using this |
774 | function to set the position of the splitter might lead to | 789 | function to set the position of the splitter might lead to |
775 | unexpected results, since in Arabic and Hebrew the position of | 790 | unexpected results, since in Arabic and Hebrew the position of |
776 | splitter one is to the left of the position of splitter zero. | 791 | splitter one is to the left of the position of splitter zero. |
777 | 792 | ||
778 | \sa idAfter() | 793 | \sa idAfter() |
779 | */ | 794 | */ |
780 | void KDGanttMinimizeSplitter::moveSplitter( QCOORD p, int id ) | 795 | void KDGanttMinimizeSplitter::moveSplitter( QCOORD p, int id ) |
781 | { | 796 | { |
782 | p = adjustPos( p, id ); | 797 | p = adjustPos( p, id ); |
783 | QSplitterLayoutStruct *s = data->list.at(id); | 798 | QSplitterLayoutStruct *s = data->list.at(id); |
784 | int oldP = orient == Horizontal ? s->wid->x() : s->wid->y(); | 799 | int oldP = orient == Horizontal ? s->wid->x() : s->wid->y(); |
785 | bool upLeft; | 800 | bool upLeft; |
786 | if ( false && orient == Horizontal ) { | 801 | if ( false && orient == Horizontal ) { |
787 | p += s->wid->width(); | 802 | p += s->wid->width(); |
788 | upLeft = p > oldP; | 803 | upLeft = p > oldP; |
789 | } else | 804 | } else |
790 | upLeft = p < oldP; | 805 | upLeft = p < oldP; |
791 | 806 | ||
792 | moveAfter( p, id, upLeft ); | 807 | moveAfter( p, id, upLeft ); |
793 | moveBefore( p-1, id-1, upLeft ); | 808 | moveBefore( p-1, id-1, upLeft ); |
794 | 809 | ||
795 | storeSizes(); | 810 | storeSizes(); |
796 | } | 811 | } |
797 | 812 | ||
798 | 813 | ||
799 | void KDGanttMinimizeSplitter::setG( QWidget *w, int p, int s, bool isSplitter ) | 814 | void KDGanttMinimizeSplitter::setG( QWidget *w, int p, int s, bool isSplitter ) |
800 | { | 815 | { |
801 | if ( orient == Horizontal ) { | 816 | if ( orient == Horizontal ) { |
802 | if ( false && orient == Horizontal && !isSplitter ) | 817 | if ( false && orient == Horizontal && !isSplitter ) |
803 | p = contentsRect().width() - p - s; | 818 | p = contentsRect().width() - p - s; |
804 | w->setGeometry( p, contentsRect().y(), s, contentsRect().height() ); | 819 | w->setGeometry( p, contentsRect().y(), s, contentsRect().height() ); |
805 | } else | 820 | } else |
806 | w->setGeometry( contentsRect().x(), p, contentsRect().width(), s ); | 821 | w->setGeometry( contentsRect().x(), p, contentsRect().width(), s ); |
807 | } | 822 | } |
808 | 823 | ||
809 | 824 | ||
810 | /* | 825 | /* |
811 | Places the right/bottom edge of the widget at \a id at position \a pos. | 826 | Places the right/bottom edge of the widget at \a id at position \a pos. |
812 | 827 | ||
813 | \sa idAfter() | 828 | \sa idAfter() |
814 | */ | 829 | */ |
815 | void KDGanttMinimizeSplitter::moveBefore( int pos, int id, bool upLeft ) | 830 | void KDGanttMinimizeSplitter::moveBefore( int pos, int id, bool upLeft ) |
816 | { | 831 | { |
817 | if( id < 0 ) | 832 | if( id < 0 ) |
818 | return; | 833 | return; |
819 | QSplitterLayoutStruct *s = data->list.at(id); | 834 | QSplitterLayoutStruct *s = data->list.at(id); |
820 | if ( !s ) | 835 | if ( !s ) |
821 | return; | 836 | return; |
822 | QWidget *w = s->wid; | 837 | QWidget *w = s->wid; |
823 | if ( w->isHidden() ) { | 838 | if ( w->isHidden() ) { |
824 | moveBefore( pos, id-1, upLeft ); | 839 | moveBefore( pos, id-1, upLeft ); |
825 | } else if ( s->isSplitter ) { | 840 | } else if ( s->isSplitter ) { |
826 | int pos1, pos2; | 841 | int pos1, pos2; |
827 | int dd = s->sizer; | 842 | int dd = s->sizer; |
828 | if( false && orient == Horizontal ) { | 843 | if( false && orient == Horizontal ) { |
829 | pos1 = pos; | 844 | pos1 = pos; |
830 | pos2 = pos + dd; | 845 | pos2 = pos + dd; |
831 | } else { | 846 | } else { |
832 | pos2 = pos - dd; | 847 | pos2 = pos - dd; |
833 | pos1 = pos2 + 1; | 848 | pos1 = pos2 + 1; |
834 | } | 849 | } |
835 | if ( upLeft ) { | 850 | if ( upLeft ) { |
836 | setG( w, pos1, dd, TRUE ); | 851 | setG( w, pos1, dd, TRUE ); |
837 | moveBefore( pos2, id-1, upLeft ); | 852 | moveBefore( pos2, id-1, upLeft ); |
838 | } else { | 853 | } else { |
839 | moveBefore( pos2, id-1, upLeft ); | 854 | moveBefore( pos2, id-1, upLeft ); |
840 | setG( w, pos1, dd, TRUE ); | 855 | setG( w, pos1, dd, TRUE ); |
841 | } | 856 | } |
842 | } else { | 857 | } else { |
843 | int dd, newLeft, nextPos; | 858 | int dd, newLeft, nextPos; |
844 | if( false && orient == Horizontal ) { | 859 | if( false && orient == Horizontal ) { |
845 | dd = w->geometry().right() - pos; | 860 | dd = w->geometry().right() - pos; |
846 | dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); | 861 | dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); |
847 | newLeft = pos+1; | 862 | newLeft = pos+1; |
848 | nextPos = newLeft + dd; | 863 | nextPos = newLeft + dd; |
849 | } else { | 864 | } else { |
850 | dd = pos - pick( w->pos() ) + 1; | 865 | dd = pos - pick( w->pos() ) + 1; |
851 | dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); | 866 | dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); |
852 | newLeft = pos-dd+1; | 867 | newLeft = pos-dd+1; |
853 | nextPos = newLeft - 1; | 868 | nextPos = newLeft - 1; |
854 | } | 869 | } |
855 | setG( w, newLeft, dd, TRUE ); | 870 | setG( w, newLeft, dd, TRUE ); |
856 | moveBefore( nextPos, id-1, upLeft ); | 871 | moveBefore( nextPos, id-1, upLeft ); |
857 | } | 872 | } |
858 | } | 873 | } |
859 | 874 | ||
860 | 875 | ||
861 | /* | 876 | /* |
862 | Places the left/top edge of the widget at \a id at position \a pos. | 877 | Places the left/top edge of the widget at \a id at position \a pos. |
863 | 878 | ||
864 | \sa idAfter() | 879 | \sa idAfter() |
865 | */ | 880 | */ |
866 | void KDGanttMinimizeSplitter::moveAfter( int pos, int id, bool upLeft ) | 881 | void KDGanttMinimizeSplitter::moveAfter( int pos, int id, bool upLeft ) |
867 | { | 882 | { |
868 | QSplitterLayoutStruct *s = id < int(data->list.count()) ? | 883 | QSplitterLayoutStruct *s = id < int(data->list.count()) ? |
869 | data->list.at(id) : 0; | 884 | data->list.at(id) : 0; |
870 | if ( !s ) | 885 | if ( !s ) |
871 | return; | 886 | return; |
872 | QWidget *w = s->wid; | 887 | QWidget *w = s->wid; |
873 | if ( w->isHidden() ) { | 888 | if ( w->isHidden() ) { |
874 | moveAfter( pos, id+1, upLeft ); | 889 | moveAfter( pos, id+1, upLeft ); |
875 | } else if ( pick( w->pos() ) == pos ) { | 890 | } else if ( pick( w->pos() ) == pos ) { |
876 | //No need to do anything if it's already there. | 891 | //No need to do anything if it's already there. |
877 | return; | 892 | return; |
878 | } else if ( s->isSplitter ) { | 893 | } else if ( s->isSplitter ) { |
879 | int dd = s->sizer; | 894 | int dd = s->sizer; |
880 | int pos1, pos2; | 895 | int pos1, pos2; |
881 | if( false && orient == Horizontal ) { | 896 | if( false && orient == Horizontal ) { |
882 | pos2 = pos - dd; | 897 | pos2 = pos - dd; |
883 | pos1 = pos2 + 1; | 898 | pos1 = pos2 + 1; |
884 | } else { | 899 | } else { |
885 | pos1 = pos; | 900 | pos1 = pos; |
886 | pos2 = pos + dd; | 901 | pos2 = pos + dd; |
887 | } | 902 | } |
888 | if ( upLeft ) { | 903 | if ( upLeft ) { |
889 | setG( w, pos1, dd, TRUE ); | 904 | setG( w, pos1, dd, TRUE ); |
890 | moveAfter( pos2, id+1, upLeft ); | 905 | moveAfter( pos2, id+1, upLeft ); |
891 | } else { | 906 | } else { |
892 | moveAfter( pos2, id+1, upLeft ); | 907 | moveAfter( pos2, id+1, upLeft ); |
893 | setG( w, pos1, dd, TRUE ); | 908 | setG( w, pos1, dd, TRUE ); |
894 | } | 909 | } |
895 | } else { | 910 | } else { |
896 | int left = pick( w->pos() ); | 911 | int left = pick( w->pos() ); |
897 | int right, dd,/* newRight,*/ newLeft, nextPos; | 912 | int right, dd,/* newRight,*/ newLeft, nextPos; |
898 | if ( false && orient == Horizontal ) { | 913 | if ( false && orient == Horizontal ) { |
899 | dd = pos - left + 1; | 914 | dd = pos - left + 1; |
900 | dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); | 915 | dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); |
901 | newLeft = pos-dd+1; | 916 | newLeft = pos-dd+1; |
902 | nextPos = newLeft - 1; | 917 | nextPos = newLeft - 1; |
903 | } else { | 918 | } else { |
904 | right = pick( w->geometry().bottomRight() ); | 919 | right = pick( w->geometry().bottomRight() ); |
905 | dd = right - pos + 1; | 920 | dd = right - pos + 1; |
906 | dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); | 921 | dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); |
907 | /*newRight = pos+dd-1;*/ | 922 | /*newRight = pos+dd-1;*/ |
908 | newLeft = pos; | 923 | newLeft = pos; |
909 | nextPos = newLeft + dd; | 924 | nextPos = newLeft + dd; |
910 | } | 925 | } |
911 | setG( w, newLeft, dd, TRUE ); | 926 | setG( w, newLeft, dd, TRUE ); |
912 | /*if( right != newRight )*/ | 927 | /*if( right != newRight )*/ |
913 | moveAfter( nextPos, id+1, upLeft ); | 928 | moveAfter( nextPos, id+1, upLeft ); |
914 | } | 929 | } |
915 | } | 930 | } |
916 | 931 | ||
917 | 932 | ||
918 | void KDGanttMinimizeSplitter::expandPos( int id, int* min, int* max ) | 933 | void KDGanttMinimizeSplitter::expandPos( int id, int* min, int* max ) |
919 | { | 934 | { |
920 | QSplitterLayoutStruct *s = data->list.at(id-1); | 935 | QSplitterLayoutStruct *s = data->list.at(id-1); |
921 | QWidget* w = s->wid; | 936 | QWidget* w = s->wid; |
922 | *min = pick( w->mapToParent( QPoint(0,0) ) ); | 937 | *min = pick( w->mapToParent( QPoint(0,0) ) ); |
923 | 938 | ||
924 | if ( (uint) id == data->list.count() ) { | 939 | if ( (uint) id == data->list.count() ) { |
925 | pick( size() ); | 940 | pick( size() ); |
926 | } | 941 | } |
927 | else { | 942 | else { |
928 | QSplitterLayoutStruct *s = data->list.at(id+1); | 943 | QSplitterLayoutStruct *s = data->list.at(id+1); |
929 | QWidget* w = s->wid; | 944 | QWidget* w = s->wid; |
930 | *max = pick( w->mapToParent( QPoint( w->width(), w->height() ) ) ) -8; | 945 | *max = pick( w->mapToParent( QPoint( w->width(), w->height() ) ) ) -8; |
931 | } | 946 | } |
932 | } | 947 | } |
933 | 948 | ||
934 | 949 | ||
935 | /*! | 950 | /*! |
936 | Returns the valid range of the splitter with id \a id in \a *min and \a *max. | 951 | Returns the valid range of the splitter with id \a id in \a *min and \a *max. |
937 | 952 | ||
938 | \sa idAfter() | 953 | \sa idAfter() |
939 | */ | 954 | */ |
940 | 955 | ||
diff --git a/microkde/KDGanttMinimizeSplitter.h b/microkde/KDGanttMinimizeSplitter.h index 585298d..3042e0a 100644 --- a/microkde/KDGanttMinimizeSplitter.h +++ b/microkde/KDGanttMinimizeSplitter.h | |||
@@ -1,191 +1,192 @@ | |||
1 | /* -*- Mode: C++ -*- | 1 | /* -*- Mode: C++ -*- |
2 | $Id$ | 2 | $Id$ |
3 | */ | 3 | */ |
4 | 4 | ||
5 | /**************************************************************************** | 5 | /**************************************************************************** |
6 | ** Copyright (C) 2001-2004 Klarälvdalens Datakonsult AB. All rights reserved. | 6 | ** Copyright (C) 2001-2004 Klarälvdalens Datakonsult AB. All rights reserved. |
7 | ** | 7 | ** |
8 | ** This file is part of the KDGantt library. | 8 | ** This file is part of the KDGantt library. |
9 | ** | 9 | ** |
10 | ** This file may be distributed and/or modified under the terms of the | 10 | ** This file may be distributed and/or modified under the terms of the |
11 | ** GNU General Public License version 2 as published by the Free Software | 11 | ** GNU General Public License version 2 as published by the Free Software |
12 | ** Foundation and appearing in the file LICENSE.GPL included in the | 12 | ** Foundation and appearing in the file LICENSE.GPL included in the |
13 | ** packaging of this file. | 13 | ** packaging of this file. |
14 | ** | 14 | ** |
15 | ** Licensees holding valid commercial KDGantt licenses may use this file in | 15 | ** Licensees holding valid commercial KDGantt licenses may use this file in |
16 | ** accordance with the KDGantt Commercial License Agreement provided with | 16 | ** accordance with the KDGantt Commercial License Agreement provided with |
17 | ** the Software. | 17 | ** the Software. |
18 | ** | 18 | ** |
19 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 19 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
20 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 20 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
21 | ** | 21 | ** |
22 | ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for | 22 | ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for |
23 | ** information about KDGantt Commercial License Agreements. | 23 | ** information about KDGantt Commercial License Agreements. |
24 | ** | 24 | ** |
25 | ** Contact info@klaralvdalens-datakonsult.se if any conditions of this | 25 | ** Contact info@klaralvdalens-datakonsult.se if any conditions of this |
26 | ** licensing are not clear to you. | 26 | ** licensing are not clear to you. |
27 | ** | 27 | ** |
28 | ** As a special exception, permission is given to link this program | 28 | ** As a special exception, permission is given to link this program |
29 | ** with any edition of Qt, and distribute the resulting executable, | 29 | ** with any edition of Qt, and distribute the resulting executable, |
30 | ** without including the source code for Qt in the source distribution. | 30 | ** without including the source code for Qt in the source distribution. |
31 | ** | 31 | ** |
32 | **********************************************************************/ | 32 | **********************************************************************/ |
33 | 33 | ||
34 | #ifndef KDGANTTMINIMIZESPLITTER_H | 34 | #ifndef KDGANTTMINIMIZESPLITTER_H |
35 | #define KDGANTTMINIMIZESPLITTER_H | 35 | #define KDGANTTMINIMIZESPLITTER_H |
36 | 36 | ||
37 | #ifndef QT_H | 37 | #ifndef QT_H |
38 | #include "qframe.h" | 38 | #include "qframe.h" |
39 | #include "qvaluelist.h" | 39 | #include "qvaluelist.h" |
40 | #endif // QT_H | 40 | #endif // QT_H |
41 | 41 | ||
42 | #ifndef QT_NO_SPLITTER___ | 42 | #ifndef QT_NO_SPLITTER___ |
43 | class QSplitterData; | 43 | class QSplitterData; |
44 | class QSplitterLayoutStruct; | 44 | class QSplitterLayoutStruct; |
45 | class KDGanttSplitterHandle; | 45 | class KDGanttSplitterHandle; |
46 | class KDRubberBand; | ||
46 | class KDGanttMinimizeSplitter : public QFrame | 47 | class KDGanttMinimizeSplitter : public QFrame |
47 | { | 48 | { |
48 | Q_OBJECT | 49 | Q_OBJECT |
49 | // Q_ENUMS( Direction ) | 50 | // Q_ENUMS( Direction ) |
50 | // Q_PROPERTY( Orientation orientation READ orientation WRITE setOrientation ) | 51 | // Q_PROPERTY( Orientation orientation READ orientation WRITE setOrientation ) |
51 | // Q_PROPERTY( Direction minimizeDirection READ minimizeDirection WRITE setMinimizeDirection ) | 52 | // Q_PROPERTY( Direction minimizeDirection READ minimizeDirection WRITE setMinimizeDirection ) |
52 | 53 | ||
53 | public: | 54 | public: |
54 | enum ResizeMode { Stretch, KeepSize, FollowSizeHint }; | 55 | enum ResizeMode { Stretch, KeepSize, FollowSizeHint }; |
55 | enum Direction { Left, Right, Up, Down }; | 56 | enum Direction { Left, Right, Up, Down }; |
56 | 57 | ||
57 | KDGanttMinimizeSplitter( QWidget* parent=0, const char* name=0 ); | 58 | KDGanttMinimizeSplitter( QWidget* parent=0, const char* name=0 ); |
58 | KDGanttMinimizeSplitter( Orientation, QWidget* parent=0, const char* name=0 ); | 59 | KDGanttMinimizeSplitter( Orientation, QWidget* parent=0, const char* name=0 ); |
59 | ~KDGanttMinimizeSplitter(); | 60 | ~KDGanttMinimizeSplitter(); |
60 | 61 | ||
61 | virtual void setOrientation( Orientation ); | 62 | virtual void setOrientation( Orientation ); |
62 | Orientation orientation() const { return orient; } | 63 | Orientation orientation() const { return orient; } |
63 | 64 | ||
64 | void setMinimizeDirection( Direction ); | 65 | void setMinimizeDirection( Direction ); |
65 | Direction minimizeDirection() const; | 66 | Direction minimizeDirection() const; |
66 | 67 | ||
67 | #if QT_VERSION >= 232 | 68 | #if QT_VERSION >= 232 |
68 | virtual void setResizeMode( QWidget *w, ResizeMode ); | 69 | virtual void setResizeMode( QWidget *w, ResizeMode ); |
69 | virtual void setOpaqueResize( bool = TRUE ); | 70 | virtual void setOpaqueResize( bool = TRUE ); |
70 | bool opaqueResize() const; | 71 | bool opaqueResize() const; |
71 | 72 | ||
72 | void moveToFirst( QWidget * ); | 73 | void moveToFirst( QWidget * ); |
73 | void moveToLast( QWidget * ); | 74 | void moveToLast( QWidget * ); |
74 | 75 | ||
75 | void refresh() { recalc( TRUE ); } | 76 | void refresh() { recalc( TRUE ); } |
76 | QSize sizeHint() const; | 77 | QSize sizeHint() const; |
77 | QSize minimumSizeHint() const; | 78 | QSize minimumSizeHint() const; |
78 | 79 | ||
79 | QValueList<int> sizes() const; | 80 | QValueList<int> sizes() const; |
80 | void setSizes( QValueList<int> ); | 81 | void setSizes( QValueList<int> ); |
81 | KDGanttSplitterHandle* firstHandle(){ return mFirstHandle;} | 82 | KDGanttSplitterHandle* firstHandle(){ return mFirstHandle;} |
82 | void expandPos( int id, int* min, int* max ); | 83 | void expandPos( int id, int* min, int* max ); |
83 | QFrame* rubberBand() { return mRubberBand ;} | 84 | KDRubberBand* rubberBand() { return mRubberBand ;} |
84 | public slots: | 85 | public slots: |
85 | void toggle(); | 86 | void toggle(); |
86 | protected: | 87 | protected: |
87 | void childEvent( QChildEvent * ); | 88 | void childEvent( QChildEvent * ); |
88 | 89 | ||
89 | bool event( QEvent * ); | 90 | bool event( QEvent * ); |
90 | void resizeEvent( QResizeEvent * ); | 91 | void resizeEvent( QResizeEvent * ); |
91 | 92 | ||
92 | int idAfter( QWidget* ) const; | 93 | int idAfter( QWidget* ) const; |
93 | 94 | ||
94 | void moveSplitter( QCOORD pos, int id ); | 95 | void moveSplitter( QCOORD pos, int id ); |
95 | virtual void drawSplitter( QPainter*, QCOORD x, QCOORD y, | 96 | virtual void drawSplitter( QPainter*, QCOORD x, QCOORD y, |
96 | QCOORD w, QCOORD h ); | 97 | QCOORD w, QCOORD h ); |
97 | void styleChange( QStyle& ); | 98 | void styleChange( QStyle& ); |
98 | int adjustPos( int , int ); | 99 | int adjustPos( int , int ); |
99 | virtual void setRubberband( int ); | 100 | virtual void setRubberband( int ); |
100 | void getRange( int id, int*, int* ); | 101 | void getRange( int id, int*, int* ); |
101 | 102 | ||
102 | private: | 103 | private: |
103 | QFrame* mRubberBand; | 104 | KDRubberBand* mRubberBand; |
104 | void init(); | 105 | void init(); |
105 | void recalc( bool update = FALSE ); | 106 | void recalc( bool update = FALSE ); |
106 | void doResize(); | 107 | void doResize(); |
107 | void storeSizes(); | 108 | void storeSizes(); |
108 | void processChildEvents(); | 109 | void processChildEvents(); |
109 | QSplitterLayoutStruct *addWidget( QWidget*, bool first = FALSE ); | 110 | QSplitterLayoutStruct *addWidget( QWidget*, bool first = FALSE ); |
110 | void recalcId(); | 111 | void recalcId(); |
111 | void moveBefore( int pos, int id, bool upLeft ); | 112 | void moveBefore( int pos, int id, bool upLeft ); |
112 | void moveAfter( int pos, int id, bool upLeft ); | 113 | void moveAfter( int pos, int id, bool upLeft ); |
113 | void setG( QWidget *w, int p, int s, bool isSplitter = FALSE ); | 114 | void setG( QWidget *w, int p, int s, bool isSplitter = FALSE ); |
114 | 115 | ||
115 | QCOORD pick( const QPoint &p ) const | 116 | QCOORD pick( const QPoint &p ) const |
116 | { return orient == Horizontal ? p.x() : p.y(); } | 117 | { return orient == Horizontal ? p.x() : p.y(); } |
117 | QCOORD pick( const QSize &s ) const | 118 | QCOORD pick( const QSize &s ) const |
118 | { return orient == Horizontal ? s.width() : s.height(); } | 119 | { return orient == Horizontal ? s.width() : s.height(); } |
119 | 120 | ||
120 | QCOORD trans( const QPoint &p ) const | 121 | QCOORD trans( const QPoint &p ) const |
121 | { return orient == Vertical ? p.x() : p.y(); } | 122 | { return orient == Vertical ? p.x() : p.y(); } |
122 | QCOORD trans( const QSize &s ) const | 123 | QCOORD trans( const QSize &s ) const |
123 | { return orient == Vertical ? s.width() : s.height(); } | 124 | { return orient == Vertical ? s.width() : s.height(); } |
124 | KDGanttSplitterHandle* mFirstHandle; | 125 | KDGanttSplitterHandle* mFirstHandle; |
125 | QSplitterData *data; | 126 | QSplitterData *data; |
126 | #endif | 127 | #endif |
127 | 128 | ||
128 | private: | 129 | private: |
129 | Orientation orient; | 130 | Orientation orient; |
130 | Direction _direction; | 131 | Direction _direction; |
131 | #ifndef DOXYGEN_SKIP_INTERNAL | 132 | #ifndef DOXYGEN_SKIP_INTERNAL |
132 | friend class KDGanttSplitterHandle; | 133 | friend class KDGanttSplitterHandle; |
133 | #endif | 134 | #endif |
134 | private:// Disabled copy constructor and operator= | 135 | private:// Disabled copy constructor and operator= |
135 | #if defined(Q_DISABLE_COPY) | 136 | #if defined(Q_DISABLE_COPY) |
136 | KDGanttMinimizeSplitter( const KDGanttMinimizeSplitter & ); | 137 | KDGanttMinimizeSplitter( const KDGanttMinimizeSplitter & ); |
137 | KDGanttMinimizeSplitter& operator=( const KDGanttMinimizeSplitter & ); | 138 | KDGanttMinimizeSplitter& operator=( const KDGanttMinimizeSplitter & ); |
138 | #endif | 139 | #endif |
139 | }; | 140 | }; |
140 | 141 | ||
141 | #ifndef DOXYGEN_SKIP_INTERNAL | 142 | #ifndef DOXYGEN_SKIP_INTERNAL |
142 | // This class was continued from a verbatim copy of the | 143 | // This class was continued from a verbatim copy of the |
143 | // QSplitterHandle pertaining to the Qt Enterprise License and the | 144 | // QSplitterHandle pertaining to the Qt Enterprise License and the |
144 | // GPL. It has only been renamed to KDGanttSplitterHandler in order to | 145 | // GPL. It has only been renamed to KDGanttSplitterHandler in order to |
145 | // avoid a symbol clash on some platforms. | 146 | // avoid a symbol clash on some platforms. |
146 | class KDGanttSplitterHandle : public QWidget | 147 | class KDGanttSplitterHandle : public QWidget |
147 | { | 148 | { |
148 | Q_OBJECT | 149 | Q_OBJECT |
149 | #if QT_VERSION >= 232 | 150 | #if QT_VERSION >= 232 |
150 | public: | 151 | public: |
151 | KDGanttSplitterHandle( Qt::Orientation o, | 152 | KDGanttSplitterHandle( Qt::Orientation o, |
152 | KDGanttMinimizeSplitter *parent, const char* name=0 ); | 153 | KDGanttMinimizeSplitter *parent, const char* name=0 ); |
153 | void setOrientation( Qt::Orientation o ); | 154 | void setOrientation( Qt::Orientation o ); |
154 | Qt::Orientation orientation() const { return orient; } | 155 | Qt::Orientation orientation() const { return orient; } |
155 | 156 | ||
156 | bool opaque() const { return s->opaqueResize(); } | 157 | bool opaque() const { return s->opaqueResize(); } |
157 | 158 | ||
158 | QSize sizeHint() const; | 159 | QSize sizeHint() const; |
159 | void toggle(); | 160 | void toggle(); |
160 | 161 | ||
161 | int id() const { return myId; } // data->list.at(id())->wid == this | 162 | int id() const { return myId; } // data->list.at(id())->wid == this |
162 | void setId( int i ) { myId = i; } | 163 | void setId( int i ) { myId = i; } |
163 | 164 | ||
164 | protected: | 165 | protected: |
165 | QValueList<QPointArray> buttonRegions(); | 166 | QValueList<QPointArray> buttonRegions(); |
166 | void paintEvent( QPaintEvent * ); | 167 | void paintEvent( QPaintEvent * ); |
167 | void mouseMoveEvent( QMouseEvent * ); | 168 | void mouseMoveEvent( QMouseEvent * ); |
168 | void mousePressEvent( QMouseEvent * ); | 169 | void mousePressEvent( QMouseEvent * ); |
169 | void mouseReleaseEvent( QMouseEvent * ); | 170 | void mouseReleaseEvent( QMouseEvent * ); |
170 | int onButton( const QPoint& p ); | 171 | int onButton( const QPoint& p ); |
171 | void updateCursor( const QPoint& p ); | 172 | void updateCursor( const QPoint& p ); |
172 | 173 | ||
173 | private: | 174 | private: |
174 | bool mMouseDown; | 175 | bool mMouseDown; |
175 | QSize mSizeHint; | 176 | QSize mSizeHint; |
176 | bool mUseOffset; | 177 | bool mUseOffset; |
177 | Qt::Orientation orient; | 178 | Qt::Orientation orient; |
178 | bool opaq; | 179 | bool opaq; |
179 | int myId; | 180 | int myId; |
180 | 181 | ||
181 | KDGanttMinimizeSplitter *s; | 182 | KDGanttMinimizeSplitter *s; |
182 | int _activeButton; | 183 | int _activeButton; |
183 | bool _collapsed; | 184 | bool _collapsed; |
184 | int _origPos; | 185 | int _origPos; |
185 | #endif | 186 | #endif |
186 | }; | 187 | }; |
187 | #endif | 188 | #endif |
188 | 189 | ||
189 | #endif // QT_NO_SPLITTER | 190 | #endif // QT_NO_SPLITTER |
190 | 191 | ||
191 | #endif // KDGANTTMINIMIZESPLITTER_H | 192 | #endif // KDGANTTMINIMIZESPLITTER_H |