Diffstat (limited to 'microkde/KDGanttMinimizeSplitter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | microkde/KDGanttMinimizeSplitter.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/microkde/KDGanttMinimizeSplitter.cpp b/microkde/KDGanttMinimizeSplitter.cpp index d675517..6cb1f31 100644 --- a/microkde/KDGanttMinimizeSplitter.cpp +++ b/microkde/KDGanttMinimizeSplitter.cpp | |||
@@ -585,201 +585,202 @@ QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool firs | |||
585 | else | 585 | else |
586 | s->sizer = pick( w->size() ); | 586 | s->sizer = pick( w->size() ); |
587 | s->isSplitter = FALSE; | 587 | s->isSplitter = FALSE; |
588 | if ( first ) | 588 | if ( first ) |
589 | data->list.insert( 0, s ); | 589 | data->list.insert( 0, s ); |
590 | else | 590 | else |
591 | data->list.append( s ); | 591 | data->list.append( s ); |
592 | if ( newHandle && isVisible() ) | 592 | if ( newHandle && isVisible() ) |
593 | newHandle->show(); //will trigger sending of post events | 593 | newHandle->show(); //will trigger sending of post events |
594 | return s; | 594 | return s; |
595 | } | 595 | } |
596 | 596 | ||
597 | 597 | ||
598 | /*! | 598 | /*! |
599 | Tells the splitter that a child widget has been inserted or removed. | 599 | Tells the splitter that a child widget has been inserted or removed. |
600 | The event is passed in \a c. | 600 | The event is passed in \a c. |
601 | */ | 601 | */ |
602 | void KDGanttMinimizeSplitter::childEvent( QChildEvent *c ) | 602 | void KDGanttMinimizeSplitter::childEvent( QChildEvent *c ) |
603 | { | 603 | { |
604 | if ( c->type() == QEvent::ChildInserted ) { | 604 | if ( c->type() == QEvent::ChildInserted ) { |
605 | if ( !c->child()->isWidgetType() ) | 605 | if ( !c->child()->isWidgetType() ) |
606 | return; | 606 | return; |
607 | 607 | ||
608 | if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) ) | 608 | if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) ) |
609 | return; | 609 | return; |
610 | 610 | ||
611 | QSplitterLayoutStruct *s = data->list.first(); | 611 | QSplitterLayoutStruct *s = data->list.first(); |
612 | while ( s ) { | 612 | while ( s ) { |
613 | if ( s->wid == c->child() ) | 613 | if ( s->wid == c->child() ) |
614 | return; | 614 | return; |
615 | s = data->list.next(); | 615 | s = data->list.next(); |
616 | } | 616 | } |
617 | addWidget( (QWidget*)c->child() ); | 617 | addWidget( (QWidget*)c->child() ); |
618 | recalc( isVisible() ); | 618 | recalc( isVisible() ); |
619 | 619 | ||
620 | } else if ( c->type() == QEvent::ChildRemoved ) { | 620 | } else if ( c->type() == QEvent::ChildRemoved ) { |
621 | QSplitterLayoutStruct *p = 0; | 621 | QSplitterLayoutStruct *p = 0; |
622 | if ( data->list.count() > 1 ) | 622 | if ( data->list.count() > 1 ) |
623 | p = data->list.at(1); //remove handle _after_ first widget. | 623 | p = data->list.at(1); //remove handle _after_ first widget. |
624 | QSplitterLayoutStruct *s = data->list.first(); | 624 | QSplitterLayoutStruct *s = data->list.first(); |
625 | while ( s ) { | 625 | while ( s ) { |
626 | if ( s->wid == c->child() ) { | 626 | if ( s->wid == c->child() ) { |
627 | data->list.removeRef( s ); | 627 | data->list.removeRef( s ); |
628 | delete s; | 628 | delete s; |
629 | if ( p && p->isSplitter ) { | 629 | if ( p && p->isSplitter ) { |
630 | data->list.removeRef( p ); | 630 | data->list.removeRef( p ); |
631 | delete p->wid; //will call childEvent | 631 | delete p->wid; //will call childEvent |
632 | delete p; | 632 | delete p; |
633 | } | 633 | } |
634 | recalcId(); | 634 | recalcId(); |
635 | doResize(); | 635 | doResize(); |
636 | return; | 636 | return; |
637 | } | 637 | } |
638 | p = s; | 638 | p = s; |
639 | s = data->list.next(); | 639 | s = data->list.next(); |
640 | } | 640 | } |
641 | } | 641 | } |
642 | } | 642 | } |
643 | 643 | ||
644 | 644 | ||
645 | /*! | 645 | /*! |
646 | Shows a rubber band at position \a p. If \a p is negative, the | 646 | Shows a rubber band at position \a p. If \a p is negative, the |
647 | rubber band is removed. | 647 | rubber band is removed. |
648 | */ | 648 | */ |
649 | void KDGanttMinimizeSplitter::setRubberband( int p ) | 649 | void KDGanttMinimizeSplitter::setRubberband( int p ) |
650 | { | 650 | { |
651 | #ifdef DESKTOP_VERSION | 651 | #ifdef DESKTOP_VERSION |
652 | QPainter paint( this ); | 652 | QPainter paint( this ); |
653 | paint.setPen( gray ); | 653 | paint.setPen( gray ); |
654 | paint.setBrush( gray ); | 654 | paint.setBrush( gray ); |
655 | paint.setRasterOp( XorROP ); | 655 | paint.setRasterOp( XorROP ); |
656 | QRect r = contentsRect(); | 656 | QRect r = contentsRect(); |
657 | const int rBord = 3; //Themable???? | 657 | const int rBord = 3; //Themable???? |
658 | #if QT_VERSION >= 0x030000 | 658 | #if QT_VERSION >= 0x030000 |
659 | int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); | 659 | int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); |
660 | #else | 660 | #else |
661 | int sw = style().splitterWidth(); | 661 | int sw = style().splitterWidth(); |
662 | #endif | 662 | #endif |
663 | if ( orient == Horizontal ) { | 663 | if ( orient == Horizontal ) { |
664 | if ( opaqueOldPos >= 0 ) | 664 | if ( opaqueOldPos >= 0 ) |
665 | paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(), | 665 | paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(), |
666 | 2*rBord, r.height() ); | 666 | 2*rBord, r.height() ); |
667 | if ( p >= 0 ) | 667 | if ( p >= 0 ) |
668 | paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() ); | 668 | paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() ); |
669 | } else { | 669 | } else { |
670 | if ( opaqueOldPos >= 0 ) | 670 | if ( opaqueOldPos >= 0 ) |
671 | paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord, | 671 | paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord, |
672 | r.width(), 2*rBord ); | 672 | r.width(), 2*rBord ); |
673 | if ( p >= 0 ) | 673 | if ( p >= 0 ) |
674 | paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord ); | 674 | paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord ); |
675 | } | 675 | } |
676 | opaqueOldPos = p; | 676 | opaqueOldPos = p; |
677 | #else | 677 | #else |
678 | if ( !mRubberBand ) { | 678 | if ( !mRubberBand ) { |
679 | mRubberBand = new QFrame( 0, "rubber", WStyle_NoBorder | WStyle_Customize | WStyle_StaysOnTop); | 679 | mRubberBand = new QFrame( 0, "rubber", WStyle_NoBorder | WStyle_Customize | WStyle_StaysOnTop); |
680 | mRubberBand->setFrameStyle( Box | Raised ); | 680 | mRubberBand->setFrameStyle( Box | Raised ); |
681 | mRubberBand->setPalette( QPalette ( Qt::red.light(),Qt::red.dark() ) ); | 681 | //mRubberBand->setPalette( QPalette ( Qt::red.light(),Qt::red.dark() ) ); |
682 | mRubberBand->setPalette( QPalette ( QColor( 178,18,188), QColor( 242,27,255 ) )); | ||
682 | } | 683 | } |
683 | QRect r = contentsRect(); | 684 | QRect r = contentsRect(); |
684 | static int rBord = 0; //Themable???? | 685 | static int rBord = 0; //Themable???? |
685 | if ( !rBord ) { | 686 | if ( !rBord ) { |
686 | if (QApplication::desktop()->width() <= 320 ) | 687 | if (QApplication::desktop()->width() <= 320 ) |
687 | rBord = 4; | 688 | rBord = 3; |
688 | else | 689 | else |
689 | rBord = 5; | 690 | rBord = 4; |
690 | } | 691 | } |
691 | int sw = style().splitterWidth(); | 692 | int sw = style().splitterWidth(); |
692 | if ( orient == Horizontal ) { | 693 | if ( orient == Horizontal ) { |
693 | if ( p >= 0 ) { | 694 | if ( p >= 0 ) { |
694 | QPoint geo = mapToGlobal (QPoint ( p + sw/2 - rBord, r.y())); | 695 | QPoint geo = mapToGlobal (QPoint ( p + sw/2 - rBord, r.y())); |
695 | mRubberBand->setGeometry( geo.x(), geo.y(), 2*rBord, r.height() ); | 696 | mRubberBand->setGeometry( geo.x(), geo.y(), 2*rBord, r.height() ); |
696 | } | 697 | } |
697 | } else { | 698 | } else { |
698 | if ( p >= 0 ) { | 699 | if ( p >= 0 ) { |
699 | QPoint geo = mapToGlobal (QPoint ( r.x(), p + sw/2 - rBord)); | 700 | QPoint geo = mapToGlobal (QPoint ( r.x(), p + sw/2 - rBord)); |
700 | mRubberBand->setGeometry( geo.x(), geo.y(), r.width(), 2*rBord); | 701 | mRubberBand->setGeometry( geo.x(), geo.y(), r.width(), 2*rBord); |
701 | } | 702 | } |
702 | } | 703 | } |
703 | opaqueOldPos = p; | 704 | opaqueOldPos = p; |
704 | if ( ! mRubberBand->isVisible() ) { | 705 | if ( ! mRubberBand->isVisible() ) { |
705 | mRubberBand->show(); | 706 | mRubberBand->show(); |
706 | } | 707 | } |
707 | #endif | 708 | #endif |
708 | } | 709 | } |
709 | 710 | ||
710 | 711 | ||
711 | /*! \reimp */ | 712 | /*! \reimp */ |
712 | bool KDGanttMinimizeSplitter::event( QEvent *e ) | 713 | bool KDGanttMinimizeSplitter::event( QEvent *e ) |
713 | { | 714 | { |
714 | if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) { | 715 | if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) { |
715 | recalc( isVisible() ); | 716 | recalc( isVisible() ); |
716 | if ( e->type() == QEvent::Show ) | 717 | if ( e->type() == QEvent::Show ) |
717 | data->firstShow = FALSE; | 718 | data->firstShow = FALSE; |
718 | } | 719 | } |
719 | return QWidget::event( e ); | 720 | return QWidget::event( e ); |
720 | } | 721 | } |
721 | 722 | ||
722 | 723 | ||
723 | /*! | 724 | /*! |
724 | \obsolete | 725 | \obsolete |
725 | 726 | ||
726 | Draws the splitter handle in the rectangle described by \a x, \a y, | 727 | Draws the splitter handle in the rectangle described by \a x, \a y, |
727 | \a w, \a h using painter \a p. | 728 | \a w, \a h using painter \a p. |
728 | \sa QStyle::drawPrimitive() | 729 | \sa QStyle::drawPrimitive() |
729 | */ | 730 | */ |
730 | void KDGanttMinimizeSplitter::drawSplitter( QPainter *p, | 731 | void KDGanttMinimizeSplitter::drawSplitter( QPainter *p, |
731 | QCOORD x, QCOORD y, QCOORD w, QCOORD h ) | 732 | QCOORD x, QCOORD y, QCOORD w, QCOORD h ) |
732 | { | 733 | { |
733 | #if 0 | 734 | #if 0 |
734 | // LR | 735 | // LR |
735 | style().drawPrimitive(QStyle::PE_Splitter, p, QRect(x, y, w, h), colorGroup(), | 736 | style().drawPrimitive(QStyle::PE_Splitter, p, QRect(x, y, w, h), colorGroup(), |
736 | (orientation() == Qt::Horizontal ? | 737 | (orientation() == Qt::Horizontal ? |
737 | QStyle::Style_Horizontal : 0)); | 738 | QStyle::Style_Horizontal : 0)); |
738 | #endif | 739 | #endif |
739 | } | 740 | } |
740 | 741 | ||
741 | 742 | ||
742 | /*! | 743 | /*! |
743 | Returns the id of the splitter to the right of or below the widget \a w, | 744 | Returns the id of the splitter to the right of or below the widget \a w, |
744 | or 0 if there is no such splitter | 745 | or 0 if there is no such splitter |
745 | (i.e. it is either not in this KDGanttMinimizeSplitter or it is at the end). | 746 | (i.e. it is either not in this KDGanttMinimizeSplitter or it is at the end). |
746 | */ | 747 | */ |
747 | int KDGanttMinimizeSplitter::idAfter( QWidget* w ) const | 748 | int KDGanttMinimizeSplitter::idAfter( QWidget* w ) const |
748 | { | 749 | { |
749 | QSplitterLayoutStruct *s = data->list.first(); | 750 | QSplitterLayoutStruct *s = data->list.first(); |
750 | bool seen_w = FALSE; | 751 | bool seen_w = FALSE; |
751 | while ( s ) { | 752 | while ( s ) { |
752 | if ( s->isSplitter && seen_w ) | 753 | if ( s->isSplitter && seen_w ) |
753 | return data->list.at(); | 754 | return data->list.at(); |
754 | if ( !s->isSplitter && s->wid == w ) | 755 | if ( !s->isSplitter && s->wid == w ) |
755 | seen_w = TRUE; | 756 | seen_w = TRUE; |
756 | s = data->list.next(); | 757 | s = data->list.next(); |
757 | } | 758 | } |
758 | return 0; | 759 | return 0; |
759 | } | 760 | } |
760 | 761 | ||
761 | 762 | ||
762 | /*! | 763 | /*! |
763 | Moves the left/top edge of the splitter handle with id \a id as | 764 | Moves the left/top edge of the splitter handle with id \a id as |
764 | close as possible to position \a p, which is the distance from the | 765 | close as possible to position \a p, which is the distance from the |
765 | left (or top) edge of the widget. | 766 | left (or top) edge of the widget. |
766 | 767 | ||
767 | For Arabic and Hebrew the layout is reversed, and using this | 768 | For Arabic and Hebrew the layout is reversed, and using this |
768 | function to set the position of the splitter might lead to | 769 | function to set the position of the splitter might lead to |
769 | unexpected results, since in Arabic and Hebrew the position of | 770 | unexpected results, since in Arabic and Hebrew the position of |
770 | splitter one is to the left of the position of splitter zero. | 771 | splitter one is to the left of the position of splitter zero. |
771 | 772 | ||
772 | \sa idAfter() | 773 | \sa idAfter() |
773 | */ | 774 | */ |
774 | void KDGanttMinimizeSplitter::moveSplitter( QCOORD p, int id ) | 775 | void KDGanttMinimizeSplitter::moveSplitter( QCOORD p, int id ) |
775 | { | 776 | { |
776 | p = adjustPos( p, id ); | 777 | p = adjustPos( p, id ); |
777 | QSplitterLayoutStruct *s = data->list.at(id); | 778 | QSplitterLayoutStruct *s = data->list.at(id); |
778 | int oldP = orient == Horizontal ? s->wid->x() : s->wid->y(); | 779 | int oldP = orient == Horizontal ? s->wid->x() : s->wid->y(); |
779 | bool upLeft; | 780 | bool upLeft; |
780 | if ( false && orient == Horizontal ) { | 781 | if ( false && orient == Horizontal ) { |
781 | p += s->wid->width(); | 782 | p += s->wid->width(); |
782 | upLeft = p > oldP; | 783 | upLeft = p > oldP; |
783 | } else | 784 | } else |
784 | upLeft = p < oldP; | 785 | upLeft = p < oldP; |
785 | 786 | ||