Diffstat (limited to 'microkde/KDGanttMinimizeSplitter.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | microkde/KDGanttMinimizeSplitter.cpp | 190 |
1 files changed, 101 insertions, 89 deletions
diff --git a/microkde/KDGanttMinimizeSplitter.cpp b/microkde/KDGanttMinimizeSplitter.cpp index 72c4e60..4172cd0 100644 --- a/microkde/KDGanttMinimizeSplitter.cpp +++ b/microkde/KDGanttMinimizeSplitter.cpp | |||
@@ -38,21 +38,30 @@ | |||
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 "q3ptrlist.h" |
42 | #include "qmemarray.h" | 42 | #include "q3memarray.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 Q3PtrList QList |
47 | #define QMemArray QArray | 47 | #define Q3MemArray QArray |
48 | #endif | 48 | #endif |
49 | #include "qlayoutengine_p.h" | 49 | #include "qlayoutengine_p.h" |
50 | #include "qobjectlist.h" | 50 | #include "qobject.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 <q3valuelist.h> |
54 | #include <qcursor.h> | 54 | #include <qcursor.h> |
55 | #include <qframe.h> | 55 | #include <q3frame.h> |
56 | #include <QDesktopWidget> | ||
57 | //Added by qt3to4: | ||
58 | #include <Q3PointArray> | ||
59 | #include <QPixmap> | ||
60 | #include <QResizeEvent> | ||
61 | #include <QMouseEvent> | ||
62 | #include <QChildEvent> | ||
63 | #include <QEvent> | ||
64 | #include <QPaintEvent> | ||
56 | #ifndef KDGANTT_MASTER_CVS | 65 | #ifndef KDGANTT_MASTER_CVS |
57 | //#include "KDGanttMinimizeSplitter.moc" | 66 | //#include "KDGanttMinimizeSplitter.moc" |
58 | #endif | 67 | #endif |
@@ -65,10 +74,10 @@ | |||
65 | static int mouseOffset; | 74 | static int mouseOffset; |
66 | static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky | 75 | static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky |
67 | 76 | ||
68 | class KDRubberBand: public QFrame | 77 | class KDRubberBand: public Q3Frame |
69 | { | 78 | { |
70 | public: | 79 | public: |
71 | KDRubberBand( QWidget *parent, const char * name, WFlags f ) :QFrame ( parent, name, f ) {;} | 80 | KDRubberBand( QWidget *parent, const char * name, Qt::WFlags f ) :Q3Frame ( parent, name, f ) {;} |
72 | 81 | ||
73 | protected: | 82 | protected: |
74 | virtual void mousePressEvent ( QMouseEvent * ) | 83 | virtual void mousePressEvent ( QMouseEvent * ) |
@@ -80,9 +89,10 @@ protected: | |||
80 | 89 | ||
81 | KDGanttSplitterHandle::KDGanttSplitterHandle( Qt::Orientation o, | 90 | KDGanttSplitterHandle::KDGanttSplitterHandle( Qt::Orientation o, |
82 | KDGanttMinimizeSplitter *parent, const char * name ) | 91 | KDGanttMinimizeSplitter *parent, const char * name ) |
83 | : QWidget( parent, name ), _activeButton( 0 ), _collapsed( false ) | 92 | : _activeButton( 0 ), _collapsed( false ) |
84 | { | 93 | { |
85 | 94 | setObjectName(name); | |
95 | setParent(parent); | ||
86 | if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->width() < 650 ) { | 96 | if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->width() < 650 ) { |
87 | mSizeHint = QSize(7,7); | 97 | mSizeHint = QSize(7,7); |
88 | mUseOffset = true; | 98 | mUseOffset = true; |
@@ -106,10 +116,10 @@ void KDGanttSplitterHandle::setOrientation( Qt::Orientation o ) | |||
106 | { | 116 | { |
107 | orient = o; | 117 | orient = o; |
108 | #ifndef QT_NO_CURSOR | 118 | #ifndef QT_NO_CURSOR |
109 | if ( o == KDGanttMinimizeSplitter::Horizontal ) | 119 | if ( o == Qt::Horizontal ) |
110 | setCursor( splitHCursor ); | 120 | setCursor( Qt::splitHCursor ); |
111 | else | 121 | else |
112 | setCursor( splitVCursor ); | 122 | setCursor( Qt::splitVCursor ); |
113 | #endif | 123 | #endif |
114 | } | 124 | } |
115 | 125 | ||
@@ -117,7 +127,7 @@ void KDGanttSplitterHandle::setOrientation( Qt::Orientation o ) | |||
117 | void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e ) | 127 | void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e ) |
118 | { | 128 | { |
119 | updateCursor( e->pos() ); | 129 | updateCursor( e->pos() ); |
120 | if ( !(e->state()&LeftButton) ) | 130 | if ( !(e->state()&Qt::LeftButton) ) |
121 | return; | 131 | return; |
122 | 132 | ||
123 | if ( _activeButton != 0) | 133 | if ( _activeButton != 0) |
@@ -137,7 +147,7 @@ void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e ) | |||
137 | 147 | ||
138 | void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e ) | 148 | void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e ) |
139 | { | 149 | { |
140 | if ( e->button() == LeftButton ) { | 150 | if ( e->button() == Qt::LeftButton ) { |
141 | _activeButton = onButton( e->pos() ); | 151 | _activeButton = onButton( e->pos() ); |
142 | mouseOffset = s->pick(e->pos()); | 152 | mouseOffset = s->pick(e->pos()); |
143 | mMouseDown = true; | 153 | mMouseDown = true; |
@@ -149,13 +159,13 @@ void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e ) | |||
149 | void KDGanttSplitterHandle::updateCursor( const QPoint& p) | 159 | void KDGanttSplitterHandle::updateCursor( const QPoint& p) |
150 | { | 160 | { |
151 | if ( onButton( p ) != 0 ) { | 161 | if ( onButton( p ) != 0 ) { |
152 | setCursor( arrowCursor ); | 162 | setCursor( Qt::arrowCursor ); |
153 | } | 163 | } |
154 | else { | 164 | else { |
155 | if ( orient == KDGanttMinimizeSplitter::Horizontal ) | 165 | if ( orient == Qt::Horizontal ) |
156 | setCursor( splitHCursor ); | 166 | setCursor( Qt::splitHCursor ); |
157 | else | 167 | else |
158 | setCursor( splitVCursor ); | 168 | setCursor( Qt::splitVCursor ); |
159 | } | 169 | } |
160 | } | 170 | } |
161 | void KDGanttSplitterHandle::toggle() | 171 | void KDGanttSplitterHandle::toggle() |
@@ -195,7 +205,7 @@ void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) | |||
195 | updateCursor( e->pos() ); | 205 | updateCursor( e->pos() ); |
196 | } | 206 | } |
197 | else { | 207 | else { |
198 | if ( !opaque() && e->button() == LeftButton ) { | 208 | if ( !opaque() && e->button() == Qt::LeftButton ) { |
199 | QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) | 209 | QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) |
200 | - mouseOffset; | 210 | - mouseOffset; |
201 | s->setRubberband( -1 ); | 211 | s->setRubberband( -1 ); |
@@ -211,10 +221,10 @@ void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) | |||
211 | 221 | ||
212 | int KDGanttSplitterHandle::onButton( const QPoint& p ) | 222 | int KDGanttSplitterHandle::onButton( const QPoint& p ) |
213 | { | 223 | { |
214 | QValueList<QPointArray> list = buttonRegions(); | 224 | Q3ValueList<Q3PointArray> list = buttonRegions(); |
215 | int index = 1; | 225 | int index = 1; |
216 | int add = 12; | 226 | int add = 12; |
217 | for( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { | 227 | for( Q3ValueList<Q3PointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { |
218 | QRect rect = (*it).boundingRect(); | 228 | QRect rect = (*it).boundingRect(); |
219 | rect.setLeft( rect.left()- add ); | 229 | rect.setLeft( rect.left()- add ); |
220 | rect.setRight( rect.right() + add); | 230 | rect.setRight( rect.right() + add); |
@@ -229,16 +239,16 @@ int KDGanttSplitterHandle::onButton( const QPoint& p ) | |||
229 | } | 239 | } |
230 | 240 | ||
231 | 241 | ||
232 | QValueList<QPointArray> KDGanttSplitterHandle::buttonRegions() | 242 | Q3ValueList<Q3PointArray> KDGanttSplitterHandle::buttonRegions() |
233 | { | 243 | { |
234 | QValueList<QPointArray> list; | 244 | Q3ValueList<Q3PointArray> list; |
235 | 245 | ||
236 | int sw = 8; | 246 | int sw = 8; |
237 | int yyy = 1; | 247 | int yyy = 1; |
238 | int xxx = 1; | 248 | int xxx = 1; |
239 | int voffset[] = { (int) -sw*3, (int) sw*3 }; | 249 | int voffset[] = { (int) -sw*3, (int) sw*3 }; |
240 | for ( int i = 0; i < 2; i++ ) { | 250 | for ( int i = 0; i < 2; i++ ) { |
241 | QPointArray arr; | 251 | Q3PointArray arr; |
242 | if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right || | 252 | if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right || |
243 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left) { | 253 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left) { |
244 | int mid = height()/2 + voffset[i]; | 254 | int mid = height()/2 + voffset[i]; |
@@ -311,11 +321,11 @@ void KDGanttSplitterHandle::paintEvent( QPaintEvent * ) | |||
311 | p.setBrush( col ); | 321 | p.setBrush( col ); |
312 | p.setPen( col ); | 322 | p.setPen( col ); |
313 | 323 | ||
314 | QValueList<QPointArray> list = buttonRegions(); | 324 | Q3ValueList<Q3PointArray> list = buttonRegions(); |
315 | int index = 1; | 325 | int index = 1; |
316 | if ( mUseOffset ) | 326 | if ( mUseOffset ) |
317 | p.translate( 0, 1 ); | 327 | p.translate( 0, 1 ); |
318 | for ( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { | 328 | for ( Q3ValueList<Q3PointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { |
319 | if ( index == _activeButton ) { | 329 | if ( index == _activeButton ) { |
320 | 330 | ||
321 | /* | 331 | /* |
@@ -377,12 +387,12 @@ class QSplitterData | |||
377 | public: | 387 | public: |
378 | QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {} | 388 | QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {} |
379 | 389 | ||
380 | QPtrList<QSplitterLayoutStruct> list; | 390 | Q3PtrList<QSplitterLayoutStruct> list; |
381 | bool opaque; | 391 | bool opaque; |
382 | bool firstShow; | 392 | bool firstShow; |
383 | }; | 393 | }; |
384 | 394 | ||
385 | void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, | 395 | void kdganttGeomCalc( Q3MemArray<QLayoutStruct> &chain, int start, int count, int pos, |
386 | int space, int spacer ); | 396 | int space, int spacer ); |
387 | #endif // DOXYGEN_SKIP_INTERNAL | 397 | #endif // DOXYGEN_SKIP_INTERNAL |
388 | 398 | ||
@@ -461,12 +471,13 @@ static QSize minSizeHint( const QWidget* w ) | |||
461 | name arguments being passed on to the QFrame constructor. | 471 | name arguments being passed on to the QFrame constructor. |
462 | */ | 472 | */ |
463 | KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *name ) | 473 | KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *name ) |
464 | :QFrame(parent,name,WPaintUnclipped) | 474 | :Q3Frame(parent,name) |
465 | { | 475 | { |
476 | setAttribute(Qt::WA_PaintUnclipped); | ||
466 | mRubberBand = 0; | 477 | mRubberBand = 0; |
467 | mFirstHandle = 0; | 478 | mFirstHandle = 0; |
468 | #if QT_VERSION >= 232 | 479 | #if QT_VERSION >= 232 |
469 | orient = Horizontal; | 480 | orient = Qt::Horizontal; |
470 | init(); | 481 | init(); |
471 | #endif | 482 | #endif |
472 | } | 483 | } |
@@ -475,10 +486,10 @@ KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *n | |||
475 | Constructs a splitter with orientation \a o with the \a parent | 486 | Constructs a splitter with orientation \a o with the \a parent |
476 | and \a name arguments being passed on to the QFrame constructor. | 487 | and \a name arguments being passed on to the QFrame constructor. |
477 | */ | 488 | */ |
478 | KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Orientation o, QWidget *parent, const char *name ) | 489 | KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Qt::Orientation o, QWidget *parent, const char *name ) |
479 | :QFrame(parent,name,WPaintUnclipped) | 490 | :Q3Frame(parent,name) |
480 | { | 491 | { |
481 | 492 | setAttribute(Qt::WA_PaintUnclipped); | |
482 | mRubberBand = 0; | 493 | mRubberBand = 0; |
483 | mFirstHandle = 0; | 494 | mFirstHandle = 0; |
484 | #if QT_VERSION >= 232 | 495 | #if QT_VERSION >= 232 |
@@ -505,7 +516,7 @@ KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter() | |||
505 | void KDGanttMinimizeSplitter::init() | 516 | void KDGanttMinimizeSplitter::init() |
506 | { | 517 | { |
507 | data = new QSplitterData; | 518 | data = new QSplitterData; |
508 | if ( orient == Horizontal ) | 519 | if ( orient == Qt::Horizontal ) |
509 | setSizePolicy( QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum) ); | 520 | setSizePolicy( QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum) ); |
510 | else | 521 | else |
511 | setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding) ); | 522 | setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding) ); |
@@ -534,14 +545,14 @@ void KDGanttMinimizeSplitter::toggle() | |||
534 | By default the orientation is horizontal (the widgets are side by side). | 545 | By default the orientation is horizontal (the widgets are side by side). |
535 | The possible orientations are Qt:Vertical and Qt::Horizontal (the default). | 546 | The possible orientations are Qt:Vertical and Qt::Horizontal (the default). |
536 | */ | 547 | */ |
537 | void KDGanttMinimizeSplitter::setOrientation( Orientation o ) | 548 | void KDGanttMinimizeSplitter::setOrientation( Qt::Orientation o ) |
538 | { | 549 | { |
539 | #if QT_VERSION >= 232 | 550 | #if QT_VERSION >= 232 |
540 | if ( orient == o ) | 551 | if ( orient == o ) |
541 | return; | 552 | return; |
542 | orient = o; | 553 | orient = o; |
543 | 554 | ||
544 | if ( orient == Horizontal ) | 555 | if ( orient == Qt::Horizontal ) |
545 | setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); | 556 | setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); |
546 | else | 557 | else |
547 | setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); | 558 | setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); |
@@ -600,7 +611,7 @@ QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool firs | |||
600 | s = new QSplitterLayoutStruct; | 611 | s = new QSplitterLayoutStruct; |
601 | s->mode = Stretch; | 612 | s->mode = Stretch; |
602 | s->wid = w; | 613 | s->wid = w; |
603 | if ( !testWState( WState_Resized ) && w->sizeHint().isValid() ) | 614 | if ( !testAttribute( Qt::WA_Resized ) && w->sizeHint().isValid() ) |
604 | s->sizer = pick( w->sizeHint() ); | 615 | s->sizer = pick( w->sizeHint() ); |
605 | else | 616 | else |
606 | s->sizer = pick( w->size() ); | 617 | s->sizer = pick( w->size() ); |
@@ -621,20 +632,26 @@ QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool firs | |||
621 | */ | 632 | */ |
622 | void KDGanttMinimizeSplitter::childEvent( QChildEvent *c ) | 633 | void KDGanttMinimizeSplitter::childEvent( QChildEvent *c ) |
623 | { | 634 | { |
624 | if ( c->type() == QEvent::ChildInserted ) { | 635 | if ( c->type() == QEvent::ChildAdded ) { |
625 | if ( !c->child()->isWidgetType() ) | 636 | if ( !c->child()->isWidgetType() ) |
626 | return; | 637 | return; |
627 | 638 | ||
628 | if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) ) | 639 | QWidget *cw = (QWidget*)c->child(); |
640 | |||
641 | if ( (cw->windowFlags())&Qt::Window ) | ||
642 | return; | ||
643 | |||
644 | // avoid infinite recursion | ||
645 | if(cw->objectName().startsWith("qt_splithandle_")) | ||
629 | return; | 646 | return; |
630 | 647 | ||
631 | QSplitterLayoutStruct *s = data->list.first(); | 648 | QSplitterLayoutStruct *s = data->list.first(); |
632 | while ( s ) { | 649 | while ( s ) { |
633 | if ( s->wid == c->child() ) | 650 | if ( s->wid == cw ) |
634 | return; | 651 | return; |
635 | s = data->list.next(); | 652 | s = data->list.next(); |
636 | } | 653 | } |
637 | addWidget( (QWidget*)c->child() ); | 654 | addWidget( cw ); |
638 | recalc( isVisible() ); | 655 | recalc( isVisible() ); |
639 | 656 | ||
640 | } else if ( c->type() == QEvent::ChildRemoved ) { | 657 | } else if ( c->type() == QEvent::ChildRemoved ) { |
@@ -670,17 +687,17 @@ void KDGanttMinimizeSplitter::setRubberband( int p ) | |||
670 | { | 687 | { |
671 | #ifdef DESKTOP_VERSION | 688 | #ifdef DESKTOP_VERSION |
672 | QPainter paint( this ); | 689 | QPainter paint( this ); |
673 | paint.setPen( gray ); | 690 | paint.setPen( Qt::gray ); |
674 | paint.setBrush( gray ); | 691 | paint.setBrush( Qt::gray ); |
675 | paint.setRasterOp( XorROP ); | 692 | paint.setCompositionMode( QPainter::CompositionMode_Xor ); |
676 | QRect r = contentsRect(); | 693 | QRect r = contentsRect(); |
677 | const int rBord = 3; //Themable???? | 694 | const int rBord = 3; //Themable???? |
678 | #if QT_VERSION >= 0x030000 | 695 | #if QT_VERSION >= 0x030000 |
679 | int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); | 696 | int sw = style()->pixelMetric(QStyle::PM_SplitterWidth, 0, this); |
680 | #else | 697 | #else |
681 | int sw = style().splitterWidth(); | 698 | int sw = style().splitterWidth(); |
682 | #endif | 699 | #endif |
683 | if ( orient == Horizontal ) { | 700 | if ( orient == Qt::Horizontal ) { |
684 | if ( opaqueOldPos >= 0 ) | 701 | if ( opaqueOldPos >= 0 ) |
685 | paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(), | 702 | paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(), |
686 | 2*rBord, r.height() ); | 703 | 2*rBord, r.height() ); |
@@ -696,7 +713,7 @@ void KDGanttMinimizeSplitter::setRubberband( int p ) | |||
696 | opaqueOldPos = p; | 713 | opaqueOldPos = p; |
697 | #else | 714 | #else |
698 | if ( !mRubberBand ) { | 715 | if ( !mRubberBand ) { |
699 | mRubberBand = new KDRubberBand( 0, "rubber", WStyle_NoBorder | WStyle_Customize | WStyle_StaysOnTop); | 716 | mRubberBand = new KDRubberBand( 0, "rubber", Qt::WStyle_NoBorder | Qt::WStyle_Customize | Qt::WStyle_StaysOnTop); |
700 | mRubberBand->setFrameStyle( Box | Raised ); | 717 | mRubberBand->setFrameStyle( Box | Raised ); |
701 | //mRubberBand->setPalette( QPalette ( Qt::red.light(),Qt::red.dark() ) ); | 718 | //mRubberBand->setPalette( QPalette ( Qt::red.light(),Qt::red.dark() ) ); |
702 | mRubberBand->setPalette( QPalette ( colorGroup().background().light(), colorGroup().background().dark() )); | 719 | mRubberBand->setPalette( QPalette ( colorGroup().background().light(), colorGroup().background().dark() )); |
@@ -710,7 +727,7 @@ void KDGanttMinimizeSplitter::setRubberband( int p ) | |||
710 | rBord = 4; | 727 | rBord = 4; |
711 | } | 728 | } |
712 | int sw = style().splitterWidth(); | 729 | int sw = style().splitterWidth(); |
713 | if ( orient == Horizontal ) { | 730 | if ( orient == Qt::Horizontal ) { |
714 | if ( p >= 0 ) { | 731 | if ( p >= 0 ) { |
715 | QPoint geo = mapToGlobal (QPoint ( p + sw/2 - rBord, r.y())); | 732 | QPoint geo = mapToGlobal (QPoint ( p + sw/2 - rBord, r.y())); |
716 | mRubberBand->setGeometry( geo.x(), geo.y(), 2*rBord, r.height() ); | 733 | mRubberBand->setGeometry( geo.x(), geo.y(), 2*rBord, r.height() ); |
@@ -732,7 +749,7 @@ void KDGanttMinimizeSplitter::setRubberband( int p ) | |||
732 | /*! \reimp */ | 749 | /*! \reimp */ |
733 | bool KDGanttMinimizeSplitter::event( QEvent *e ) | 750 | bool KDGanttMinimizeSplitter::event( QEvent *e ) |
734 | { | 751 | { |
735 | if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) { | 752 | if ( e->type() == QEvent::LayoutRequest || ( e->type() == QEvent::Show && data->firstShow ) ) { |
736 | recalc( isVisible() ); | 753 | recalc( isVisible() ); |
737 | if ( e->type() == QEvent::Show ) | 754 | if ( e->type() == QEvent::Show ) |
738 | data->firstShow = FALSE; | 755 | data->firstShow = FALSE; |
@@ -755,7 +772,7 @@ void KDGanttMinimizeSplitter::drawSplitter( QPainter *p, | |||
755 | // LR | 772 | // LR |
756 | style().drawPrimitive(QStyle::PE_Splitter, p, QRect(x, y, w, h), colorGroup(), | 773 | style().drawPrimitive(QStyle::PE_Splitter, p, QRect(x, y, w, h), colorGroup(), |
757 | (orientation() == Qt::Horizontal ? | 774 | (orientation() == Qt::Horizontal ? |
758 | QStyle::Style_Horizontal : 0)); | 775 | QStyle::State_Horizontal : 0)); |
759 | #endif | 776 | #endif |
760 | } | 777 | } |
761 | 778 | ||
@@ -796,9 +813,9 @@ void KDGanttMinimizeSplitter::moveSplitter( QCOORD p, int id ) | |||
796 | { | 813 | { |
797 | p = adjustPos( p, id ); | 814 | p = adjustPos( p, id ); |
798 | QSplitterLayoutStruct *s = data->list.at(id); | 815 | QSplitterLayoutStruct *s = data->list.at(id); |
799 | int oldP = orient == Horizontal ? s->wid->x() : s->wid->y(); | 816 | int oldP = orient == Qt::Horizontal ? s->wid->x() : s->wid->y(); |
800 | bool upLeft; | 817 | bool upLeft; |
801 | if ( false && orient == Horizontal ) { | 818 | if ( false && orient == Qt::Horizontal ) { |
802 | p += s->wid->width(); | 819 | p += s->wid->width(); |
803 | upLeft = p > oldP; | 820 | upLeft = p > oldP; |
804 | } else | 821 | } else |
@@ -813,8 +830,8 @@ void KDGanttMinimizeSplitter::moveSplitter( QCOORD p, int id ) | |||
813 | 830 | ||
814 | void KDGanttMinimizeSplitter::setG( QWidget *w, int p, int s, bool isSplitter ) | 831 | void KDGanttMinimizeSplitter::setG( QWidget *w, int p, int s, bool isSplitter ) |
815 | { | 832 | { |
816 | if ( orient == Horizontal ) { | 833 | if ( orient == Qt::Horizontal ) { |
817 | if ( false && orient == Horizontal && !isSplitter ) | 834 | if ( false && orient == Qt::Horizontal && !isSplitter ) |
818 | p = contentsRect().width() - p - s; | 835 | p = contentsRect().width() - p - s; |
819 | w->setGeometry( p, contentsRect().y(), s, contentsRect().height() ); | 836 | w->setGeometry( p, contentsRect().y(), s, contentsRect().height() ); |
820 | } else | 837 | } else |
@@ -840,7 +857,7 @@ void KDGanttMinimizeSplitter::moveBefore( int pos, int id, bool upLeft ) | |||
840 | } else if ( s->isSplitter ) { | 857 | } else if ( s->isSplitter ) { |
841 | int pos1, pos2; | 858 | int pos1, pos2; |
842 | int dd = s->sizer; | 859 | int dd = s->sizer; |
843 | if( false && orient == Horizontal ) { | 860 | if( false && orient == Qt::Horizontal ) { |
844 | pos1 = pos; | 861 | pos1 = pos; |
845 | pos2 = pos + dd; | 862 | pos2 = pos + dd; |
846 | } else { | 863 | } else { |
@@ -856,7 +873,7 @@ void KDGanttMinimizeSplitter::moveBefore( int pos, int id, bool upLeft ) | |||
856 | } | 873 | } |
857 | } else { | 874 | } else { |
858 | int dd, newLeft, nextPos; | 875 | int dd, newLeft, nextPos; |
859 | if( false && orient == Horizontal ) { | 876 | if( false && orient == Qt::Horizontal ) { |
860 | dd = w->geometry().right() - pos; | 877 | dd = w->geometry().right() - pos; |
861 | dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); | 878 | dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); |
862 | newLeft = pos+1; | 879 | newLeft = pos+1; |
@@ -893,7 +910,7 @@ void KDGanttMinimizeSplitter::moveAfter( int pos, int id, bool upLeft ) | |||
893 | } else if ( s->isSplitter ) { | 910 | } else if ( s->isSplitter ) { |
894 | int dd = s->sizer; | 911 | int dd = s->sizer; |
895 | int pos1, pos2; | 912 | int pos1, pos2; |
896 | if( false && orient == Horizontal ) { | 913 | if( false && orient == Qt::Horizontal ) { |
897 | pos2 = pos - dd; | 914 | pos2 = pos - dd; |
898 | pos1 = pos2 + 1; | 915 | pos1 = pos2 + 1; |
899 | } else { | 916 | } else { |
@@ -910,7 +927,7 @@ void KDGanttMinimizeSplitter::moveAfter( int pos, int id, bool upLeft ) | |||
910 | } else { | 927 | } else { |
911 | int left = pick( w->pos() ); | 928 | int left = pick( w->pos() ); |
912 | int right, dd,/* newRight,*/ newLeft, nextPos; | 929 | int right, dd,/* newRight,*/ newLeft, nextPos; |
913 | if ( false && orient == Horizontal ) { | 930 | if ( false && orient == Qt::Horizontal ) { |
914 | dd = pos - left + 1; | 931 | dd = pos - left + 1; |
915 | dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); | 932 | dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); |
916 | newLeft = pos-dd+1; | 933 | newLeft = pos-dd+1; |
@@ -988,9 +1005,9 @@ void KDGanttMinimizeSplitter::getRange( int id, int *min, int *max ) | |||
988 | } | 1005 | } |
989 | } | 1006 | } |
990 | QRect r = contentsRect(); | 1007 | QRect r = contentsRect(); |
991 | if ( orient == Horizontal && false ) { | 1008 | if ( orient == Qt::Horizontal && false ) { |
992 | #if QT_VERSION >= 0x030000 | 1009 | #if QT_VERSION >= 0x030000 |
993 | int splitterWidth = style().pixelMetric(QStyle::PM_SplitterWidth, this); | 1010 | int splitterWidth = style()->pixelMetric(QStyle::PM_SplitterWidth, 0,this); |
994 | #else | 1011 | #else |
995 | int splitterWidth = style().splitterWidth(); | 1012 | int splitterWidth = style().splitterWidth(); |
996 | #endif | 1013 | #endif |
@@ -1030,7 +1047,7 @@ void KDGanttMinimizeSplitter::doResize() | |||
1030 | QRect r = contentsRect(); | 1047 | QRect r = contentsRect(); |
1031 | int i; | 1048 | int i; |
1032 | int n = data->list.count(); | 1049 | int n = data->list.count(); |
1033 | QMemArray<QLayoutStruct> a( n ); | 1050 | Q3MemArray<QLayoutStruct> a( n ); |
1034 | for ( i = 0; i< n; i++ ) { | 1051 | for ( i = 0; i< n; i++ ) { |
1035 | a[i].init(); | 1052 | a[i].init(); |
1036 | QSplitterLayoutStruct *s = data->list.at(i); | 1053 | QSplitterLayoutStruct *s = data->list.at(i); |
@@ -1132,7 +1149,7 @@ void KDGanttMinimizeSplitter::recalc( bool update ) | |||
1132 | if ( maxt < mint ) | 1149 | if ( maxt < mint ) |
1133 | maxt = mint; | 1150 | maxt = mint; |
1134 | 1151 | ||
1135 | if ( orient == Horizontal ) { | 1152 | if ( orient == Qt::Horizontal ) { |
1136 | setMaximumSize( maxl, maxt ); | 1153 | setMaximumSize( maxl, maxt ); |
1137 | setMinimumSize( minl, mint ); | 1154 | setMinimumSize( minl, mint ); |
1138 | } else { | 1155 | } else { |
@@ -1267,13 +1284,10 @@ QSize KDGanttMinimizeSplitter::sizeHint() const | |||
1267 | constPolish(); | 1284 | constPolish(); |
1268 | int l = 0; | 1285 | int l = 0; |
1269 | int t = 0; | 1286 | int t = 0; |
1270 | if ( children() ) { | 1287 | if ( !children().empty() ) { |
1271 | const QObjectList * c = children(); | 1288 | const QObjectList c = children(); |
1272 | QObjectListIt it( *c ); | 1289 | for(QObjectList::const_iterator i=c.begin();i!=c.end();++i) { |
1273 | QObject * o; | 1290 | QObject * o = *i; |
1274 | |||
1275 | while( (o=it.current()) != 0 ) { | ||
1276 | ++it; | ||
1277 | if ( o->isWidgetType() && | 1291 | if ( o->isWidgetType() && |
1278 | !((QWidget*)o)->isHidden() ) { | 1292 | !((QWidget*)o)->isHidden() ) { |
1279 | QSize s = ((QWidget*)o)->sizeHint(); | 1293 | QSize s = ((QWidget*)o)->sizeHint(); |
@@ -1284,7 +1298,7 @@ QSize KDGanttMinimizeSplitter::sizeHint() const | |||
1284 | } | 1298 | } |
1285 | } | 1299 | } |
1286 | } | 1300 | } |
1287 | return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l ); | 1301 | return orientation() == Qt::Horizontal ? QSize( l, t ) : QSize( t, l ); |
1288 | } | 1302 | } |
1289 | 1303 | ||
1290 | 1304 | ||
@@ -1297,13 +1311,10 @@ QSize KDGanttMinimizeSplitter::minimumSizeHint() const | |||
1297 | constPolish(); | 1311 | constPolish(); |
1298 | int l = 0; | 1312 | int l = 0; |
1299 | int t = 0; | 1313 | int t = 0; |
1300 | if ( children() ) { | 1314 | if ( !children().empty() ) { |
1301 | const QObjectList * c = children(); | 1315 | const QObjectList c = children(); |
1302 | QObjectListIt it( *c ); | 1316 | for(QObjectList::const_iterator i=c.begin();i!=c.end();++i) { |
1303 | QObject * o; | 1317 | QObject * o = *i; |
1304 | |||
1305 | while( (o=it.current()) != 0 ) { | ||
1306 | ++it; | ||
1307 | if ( o->isWidgetType() && | 1318 | if ( o->isWidgetType() && |
1308 | !((QWidget*)o)->isHidden() ) { | 1319 | !((QWidget*)o)->isHidden() ) { |
1309 | QSize s = minSizeHint((QWidget*)o); | 1320 | QSize s = minSizeHint((QWidget*)o); |
@@ -1314,7 +1325,7 @@ QSize KDGanttMinimizeSplitter::minimumSizeHint() const | |||
1314 | } | 1325 | } |
1315 | } | 1326 | } |
1316 | } | 1327 | } |
1317 | return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l ); | 1328 | return orientation() == Qt::Horizontal ? QSize( l, t ) : QSize( t, l ); |
1318 | } | 1329 | } |
1319 | 1330 | ||
1320 | 1331 | ||
@@ -1402,13 +1413,14 @@ bool KDGanttMinimizeSplitter::isHidden( QWidget *w ) const | |||
1402 | \sa setSizes() | 1413 | \sa setSizes() |
1403 | */ | 1414 | */ |
1404 | 1415 | ||
1405 | QValueList<int> KDGanttMinimizeSplitter::sizes() const | 1416 | Q3ValueList<int> KDGanttMinimizeSplitter::sizes() const |
1406 | { | 1417 | { |
1418 | /* TODO: hacker | ||
1407 | if ( !testWState(WState_Polished) ) { | 1419 | if ( !testWState(WState_Polished) ) { |
1408 | QWidget* that = (QWidget*) this; | 1420 | QWidget* that = (QWidget*) this; |
1409 | that->polish(); | 1421 | that->polish(); |
1410 | } | 1422 | } */ |
1411 | QValueList<int> list; | 1423 | Q3ValueList<int> list; |
1412 | QSplitterLayoutStruct *s = data->list.first(); | 1424 | QSplitterLayoutStruct *s = data->list.first(); |
1413 | while ( s ) { | 1425 | while ( s ) { |
1414 | if ( !s->isSplitter ) | 1426 | if ( !s->isSplitter ) |
@@ -1433,10 +1445,10 @@ QValueList<int> KDGanttMinimizeSplitter::sizes() const | |||
1433 | \sa sizes() | 1445 | \sa sizes() |
1434 | */ | 1446 | */ |
1435 | 1447 | ||
1436 | void KDGanttMinimizeSplitter::setSizes( QValueList<int> list ) | 1448 | void KDGanttMinimizeSplitter::setSizes( Q3ValueList<int> list ) |
1437 | { | 1449 | { |
1438 | processChildEvents(); | 1450 | processChildEvents(); |
1439 | QValueList<int>::Iterator it = list.begin(); | 1451 | Q3ValueList<int>::Iterator it = list.begin(); |
1440 | QSplitterLayoutStruct *s = data->list.first(); | 1452 | QSplitterLayoutStruct *s = data->list.first(); |
1441 | while ( s && it != list.end() ) { | 1453 | while ( s && it != list.end() ) { |
1442 | if ( !s->isSplitter ) { | 1454 | if ( !s->isSplitter ) { |
@@ -1456,7 +1468,7 @@ void KDGanttMinimizeSplitter::setSizes( QValueList<int> list ) | |||
1456 | 1468 | ||
1457 | void KDGanttMinimizeSplitter::processChildEvents() | 1469 | void KDGanttMinimizeSplitter::processChildEvents() |
1458 | { | 1470 | { |
1459 | QApplication::sendPostedEvents( this, QEvent::ChildInserted ); | 1471 | QApplication::sendPostedEvents( this, QEvent::ChildAdded ); |
1460 | } | 1472 | } |
1461 | 1473 | ||
1462 | 1474 | ||
@@ -1468,7 +1480,7 @@ void KDGanttMinimizeSplitter::styleChange( QStyle& old ) | |||
1468 | { | 1480 | { |
1469 | 1481 | ||
1470 | #if QT_VERSION >= 0x030000 | 1482 | #if QT_VERSION >= 0x030000 |
1471 | int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); | 1483 | int sw = style()->pixelMetric(QStyle::PM_SplitterWidth, 0, this); |
1472 | #else | 1484 | #else |
1473 | int sw = style().splitterWidth(); | 1485 | int sw = style().splitterWidth(); |
1474 | #endif | 1486 | #endif |
@@ -1479,7 +1491,7 @@ void KDGanttMinimizeSplitter::styleChange( QStyle& old ) | |||
1479 | s = data->list.next(); | 1491 | s = data->list.next(); |
1480 | } | 1492 | } |
1481 | doResize(); | 1493 | doResize(); |
1482 | QFrame::styleChange( old ); | 1494 | Q3Frame::styleChange( old ); |
1483 | } | 1495 | } |
1484 | 1496 | ||
1485 | #endif | 1497 | #endif |
@@ -1512,7 +1524,7 @@ static inline int toFixed( int i ) { return i * 256; } | |||
1512 | static inline int fRound( int i ) { | 1524 | static inline int fRound( int i ) { |
1513 | return ( i % 256 < 128 ) ? i / 256 : 1 + i / 256; | 1525 | return ( i % 256 < 128 ) ? i / 256 : 1 + i / 256; |
1514 | } | 1526 | } |
1515 | void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, | 1527 | void kdganttGeomCalc( Q3MemArray<QLayoutStruct> &chain, int start, int count, int pos, |
1516 | int space, int spacer ) | 1528 | int space, int spacer ) |
1517 | { | 1529 | { |
1518 | typedef int fixed; | 1530 | typedef int fixed; |