Diffstat (limited to 'microkde/KDGanttMinimizeSplitter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | microkde/KDGanttMinimizeSplitter.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/microkde/KDGanttMinimizeSplitter.cpp b/microkde/KDGanttMinimizeSplitter.cpp index c60b566..029f14b 100644 --- a/microkde/KDGanttMinimizeSplitter.cpp +++ b/microkde/KDGanttMinimizeSplitter.cpp | |||
@@ -19,193 +19,193 @@ | |||
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 | #ifndef KDGANTT_MASTER_CVS | 55 | #ifndef KDGANTT_MASTER_CVS |
56 | //#include "KDGanttMinimizeSplitter.moc" | 56 | //#include "KDGanttMinimizeSplitter.moc" |
57 | #endif | 57 | #endif |
58 | 58 | ||
59 | 59 | ||
60 | 60 | ||
61 | #ifndef DOXYGEN_SKIP_INTERNAL | 61 | #ifndef DOXYGEN_SKIP_INTERNAL |
62 | 62 | ||
63 | #if QT_VERSION >= 232 | 63 | #if QT_VERSION >= 232 |
64 | static int mouseOffset; | 64 | static int mouseOffset; |
65 | static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky | 65 | static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky |
66 | 66 | ||
67 | 67 | ||
68 | KDGanttSplitterHandle::KDGanttSplitterHandle( Qt::Orientation o, | 68 | KDGanttSplitterHandle::KDGanttSplitterHandle( Qt::Orientation o, |
69 | KDGanttMinimizeSplitter *parent, const char * name ) | 69 | KDGanttMinimizeSplitter *parent, const char * name ) |
70 | : QWidget( parent, name ), _activeButton( 0 ), _collapsed( false ) | 70 | : QWidget( parent, name ), _activeButton( 0 ), _collapsed( false ) |
71 | { | 71 | { |
72 | 72 | ||
73 | if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->width() < 650 ) { | 73 | if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->width() < 650 ) { |
74 | mSizeHint = QSize(7,7); | 74 | mSizeHint = QSize(7,7); |
75 | mUseOffset = true; | 75 | mUseOffset = true; |
76 | } else { | 76 | } else { |
77 | mSizeHint = QSize(6,6); | 77 | mSizeHint = QSize(6,6); |
78 | mUseOffset = false; | 78 | mUseOffset = false; |
79 | } | 79 | } |
80 | s = parent; | 80 | s = parent; |
81 | setOrientation(o); | 81 | setOrientation(o); |
82 | setMouseTracking( true ); | 82 | setMouseTracking( true ); |
83 | mMouseDown = false; | 83 | mMouseDown = false; |
84 | //setMaximumHeight( 5 ); // test only | 84 | //setMaximumHeight( 5 ); // test only |
85 | } | 85 | } |
86 | 86 | ||
87 | QSize KDGanttSplitterHandle::sizeHint() const | 87 | QSize KDGanttSplitterHandle::sizeHint() const |
88 | { | 88 | { |
89 | return mSizeHint; | 89 | return mSizeHint; |
90 | } | 90 | } |
91 | 91 | ||
92 | void KDGanttSplitterHandle::setOrientation( Qt::Orientation o ) | 92 | void KDGanttSplitterHandle::setOrientation( Qt::Orientation o ) |
93 | { | 93 | { |
94 | orient = o; | 94 | orient = o; |
95 | #ifndef QT_NO_CURSOR | 95 | #ifndef QT_NO_CURSOR |
96 | if ( o == KDGanttMinimizeSplitter::Horizontal ) | 96 | if ( o == KDGanttMinimizeSplitter::Horizontal ) |
97 | setCursor( splitHCursor ); | 97 | setCursor( splitHCursor ); |
98 | else | 98 | else |
99 | setCursor( splitVCursor ); | 99 | setCursor( splitVCursor ); |
100 | #endif | 100 | #endif |
101 | } | 101 | } |
102 | 102 | ||
103 | 103 | ||
104 | void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e ) | 104 | void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e ) |
105 | { | 105 | { |
106 | updateCursor( e->pos() ); | 106 | updateCursor( e->pos() ); |
107 | if ( !(e->state()&LeftButton) ) | 107 | if ( !(e->state()&LeftButton) ) |
108 | return; | 108 | return; |
109 | 109 | ||
110 | if ( _activeButton != 0) | 110 | if ( _activeButton != 0) |
111 | return; | 111 | return; |
112 | 112 | ||
113 | QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) | 113 | QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) |
114 | - mouseOffset; | 114 | - mouseOffset; |
115 | if ( true /*opaque()*/ ) { | 115 | if ( opaque() ) { |
116 | s->moveSplitter( pos, id() ); | 116 | s->moveSplitter( pos, id() ); |
117 | } else { | 117 | } else { |
118 | int min = pos; int max = pos; | 118 | int min = pos; int max = pos; |
119 | s->getRange( id(), &min, &max ); | 119 | s->getRange( id(), &min, &max ); |
120 | s->setRubberband( QMAX( min, QMIN(max, pos ))); | 120 | s->setRubberband( QMAX( min, QMIN(max, pos ))); |
121 | } | 121 | } |
122 | _collapsed = false; | 122 | _collapsed = false; |
123 | } | 123 | } |
124 | 124 | ||
125 | void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e ) | 125 | void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e ) |
126 | { | 126 | { |
127 | if ( e->button() == LeftButton ) { | 127 | if ( e->button() == LeftButton ) { |
128 | _activeButton = onButton( e->pos() ); | 128 | _activeButton = onButton( e->pos() ); |
129 | mouseOffset = s->pick(e->pos()); | 129 | mouseOffset = s->pick(e->pos()); |
130 | mMouseDown = true; | 130 | mMouseDown = true; |
131 | repaint(); | 131 | repaint(); |
132 | updateCursor( e->pos() ); | 132 | updateCursor( e->pos() ); |
133 | } | 133 | } |
134 | } | 134 | } |
135 | 135 | ||
136 | void KDGanttSplitterHandle::updateCursor( const QPoint& p) | 136 | void KDGanttSplitterHandle::updateCursor( const QPoint& p) |
137 | { | 137 | { |
138 | if ( onButton( p ) != 0 ) { | 138 | if ( onButton( p ) != 0 ) { |
139 | setCursor( arrowCursor ); | 139 | setCursor( arrowCursor ); |
140 | } | 140 | } |
141 | else { | 141 | else { |
142 | if ( orient == KDGanttMinimizeSplitter::Horizontal ) | 142 | if ( orient == KDGanttMinimizeSplitter::Horizontal ) |
143 | setCursor( splitHCursor ); | 143 | setCursor( splitHCursor ); |
144 | else | 144 | else |
145 | setCursor( splitVCursor ); | 145 | setCursor( splitVCursor ); |
146 | } | 146 | } |
147 | } | 147 | } |
148 | void KDGanttSplitterHandle::toggle() | 148 | void KDGanttSplitterHandle::toggle() |
149 | { | 149 | { |
150 | int pos; | 150 | int pos; |
151 | int min, max; | 151 | int min, max; |
152 | if ( !_collapsed ) { | 152 | if ( !_collapsed ) { |
153 | s->expandPos( id(), &min, &max ); | 153 | s->expandPos( id(), &min, &max ); |
154 | if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left | 154 | if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left |
155 | || s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { | 155 | || s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { |
156 | pos = min; | 156 | pos = min; |
157 | } | 157 | } |
158 | else { | 158 | else { |
159 | pos = max; | 159 | pos = max; |
160 | } | 160 | } |
161 | 161 | ||
162 | _origPos = s->pick(mapToParent( QPoint( 0,0 ) )); | 162 | _origPos = s->pick(mapToParent( QPoint( 0,0 ) )); |
163 | s->moveSplitter( pos, id() ); | 163 | s->moveSplitter( pos, id() ); |
164 | _collapsed = true; | 164 | _collapsed = true; |
165 | } | 165 | } |
166 | else { | 166 | else { |
167 | s->moveSplitter( _origPos, id() ); | 167 | s->moveSplitter( _origPos, id() ); |
168 | _collapsed = false; | 168 | _collapsed = false; |
169 | } | 169 | } |
170 | repaint(); | 170 | repaint(); |
171 | } | 171 | } |
172 | 172 | ||
173 | void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) | 173 | void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) |
174 | { | 174 | { |
175 | mMouseDown = false; | 175 | mMouseDown = false; |
176 | if ( _activeButton != 0 ) { | 176 | if ( _activeButton != 0 ) { |
177 | if ( onButton( e->pos() ) == _activeButton ) | 177 | if ( onButton( e->pos() ) == _activeButton ) |
178 | { | 178 | { |
179 | toggle(); | 179 | toggle(); |
180 | } | 180 | } |
181 | _activeButton = 0; | 181 | _activeButton = 0; |
182 | updateCursor( e->pos() ); | 182 | updateCursor( e->pos() ); |
183 | } | 183 | } |
184 | else { | 184 | else { |
185 | if ( !opaque() && e->button() == LeftButton ) { | 185 | if ( !opaque() && e->button() == LeftButton ) { |
186 | QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) | 186 | QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) |
187 | - mouseOffset; | 187 | - mouseOffset; |
188 | s->setRubberband( -1 ); | 188 | s->setRubberband( -1 ); |
189 | s->moveSplitter( pos, id() ); | 189 | s->moveSplitter( pos, id() ); |
190 | } | 190 | } |
191 | } | 191 | } |
192 | repaint(); | 192 | repaint(); |
193 | } | 193 | } |
194 | 194 | ||
195 | int KDGanttSplitterHandle::onButton( const QPoint& p ) | 195 | int KDGanttSplitterHandle::onButton( const QPoint& p ) |
196 | { | 196 | { |
197 | QValueList<QPointArray> list = buttonRegions(); | 197 | QValueList<QPointArray> list = buttonRegions(); |
198 | int index = 1; | 198 | int index = 1; |
199 | int add = 12; | 199 | int add = 12; |
200 | for( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { | 200 | for( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { |
201 | QRect rect = (*it).boundingRect(); | 201 | QRect rect = (*it).boundingRect(); |
202 | rect.setLeft( rect.left()- add ); | 202 | rect.setLeft( rect.left()- add ); |
203 | rect.setRight( rect.right() + add); | 203 | rect.setRight( rect.right() + add); |
204 | rect.setTop( rect.top()- add ); | 204 | rect.setTop( rect.top()- add ); |
205 | rect.setBottom( rect.bottom() + add); | 205 | rect.setBottom( rect.bottom() + add); |
206 | if ( rect.contains( p ) ) { | 206 | if ( rect.contains( p ) ) { |
207 | return index; | 207 | return index; |
208 | } | 208 | } |
209 | index++; | 209 | index++; |
210 | } | 210 | } |
211 | return 0; | 211 | return 0; |
@@ -390,192 +390,197 @@ void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int | |||
390 | \endcode | 390 | \endcode |
391 | 391 | ||
392 | In KDGanttMinimizeSplitter, the boundary can be either horizontal or | 392 | In KDGanttMinimizeSplitter, the boundary can be either horizontal or |
393 | vertical. The default is horizontal (the children are side by side) | 393 | vertical. The default is horizontal (the children are side by side) |
394 | but you can use setOrientation( QSplitter::Vertical ) to set it to | 394 | but you can use setOrientation( QSplitter::Vertical ) to set it to |
395 | vertical. | 395 | vertical. |
396 | 396 | ||
397 | Use setResizeMode() to specify | 397 | Use setResizeMode() to specify |
398 | that a widget should keep its size when the splitter is resized. | 398 | that a widget should keep its size when the splitter is resized. |
399 | 399 | ||
400 | Although KDGanttMinimizeSplitter normally resizes the children only | 400 | Although KDGanttMinimizeSplitter normally resizes the children only |
401 | at the end of a resize operation, if you call setOpaqueResize( TRUE | 401 | at the end of a resize operation, if you call setOpaqueResize( TRUE |
402 | ) the widgets are resized as often as possible. | 402 | ) the widgets are resized as often as possible. |
403 | 403 | ||
404 | The initial distribution of size between the widgets is determined | 404 | The initial distribution of size between the widgets is determined |
405 | by the initial size of each widget. You can also use setSizes() to | 405 | by the initial size of each widget. You can also use setSizes() to |
406 | set the sizes of all the widgets. The function sizes() returns the | 406 | set the sizes of all the widgets. The function sizes() returns the |
407 | sizes set by the user. | 407 | sizes set by the user. |
408 | 408 | ||
409 | If you hide() a child, its space will be distributed among the other | 409 | If you hide() a child, its space will be distributed among the other |
410 | children. It will be reinstated when you show() it again. It is also | 410 | children. It will be reinstated when you show() it again. It is also |
411 | possible to reorder the widgets within the splitter using | 411 | possible to reorder the widgets within the splitter using |
412 | moveToFirst() and moveToLast(). | 412 | moveToFirst() and moveToLast(). |
413 | */ | 413 | */ |
414 | 414 | ||
415 | 415 | ||
416 | 416 | ||
417 | static QSize minSize( const QWidget* /*w*/ ) | 417 | static QSize minSize( const QWidget* /*w*/ ) |
418 | { | 418 | { |
419 | return QSize(0,0); | 419 | return QSize(0,0); |
420 | } | 420 | } |
421 | 421 | ||
422 | // This is the original version of minSize | 422 | // This is the original version of minSize |
423 | static QSize minSizeHint( const QWidget* w ) | 423 | static QSize minSizeHint( const QWidget* w ) |
424 | { | 424 | { |
425 | QSize min = w->minimumSize(); | 425 | QSize min = w->minimumSize(); |
426 | QSize s; | 426 | QSize s; |
427 | if ( min.height() <= 0 || min.width() <= 0 ) | 427 | if ( min.height() <= 0 || min.width() <= 0 ) |
428 | s = w->minimumSizeHint(); | 428 | s = w->minimumSizeHint(); |
429 | if ( min.height() > 0 ) | 429 | if ( min.height() > 0 ) |
430 | s.setHeight( min.height() ); | 430 | s.setHeight( min.height() ); |
431 | if ( min.width() > 0 ) | 431 | if ( min.width() > 0 ) |
432 | s.setWidth( min.width() ); | 432 | s.setWidth( min.width() ); |
433 | return s.expandedTo(QSize(0,0)); | 433 | return s.expandedTo(QSize(0,0)); |
434 | } | 434 | } |
435 | 435 | ||
436 | 436 | ||
437 | 437 | ||
438 | /*! | 438 | /*! |
439 | Constructs a horizontal splitter with the \a parent and \a | 439 | Constructs a horizontal splitter with the \a parent and \a |
440 | name arguments being passed on to the QFrame constructor. | 440 | name arguments being passed on to the QFrame constructor. |
441 | */ | 441 | */ |
442 | KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *name ) | 442 | KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *name ) |
443 | :QFrame(parent,name,WPaintUnclipped) | 443 | :QFrame(parent,name,WPaintUnclipped) |
444 | { | 444 | { |
445 | mFirstHandle = 0; | 445 | mFirstHandle = 0; |
446 | #if QT_VERSION >= 232 | 446 | #if QT_VERSION >= 232 |
447 | orient = Horizontal; | 447 | orient = Horizontal; |
448 | init(); | 448 | init(); |
449 | #endif | 449 | #endif |
450 | } | 450 | } |
451 | 451 | ||
452 | /*! | 452 | /*! |
453 | Constructs a splitter with orientation \a o with the \a parent | 453 | Constructs a splitter with orientation \a o with the \a parent |
454 | and \a name arguments being passed on to the QFrame constructor. | 454 | and \a name arguments being passed on to the QFrame constructor. |
455 | */ | 455 | */ |
456 | KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Orientation o, QWidget *parent, const char *name ) | 456 | KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Orientation o, QWidget *parent, const char *name ) |
457 | :QFrame(parent,name,WPaintUnclipped) | 457 | :QFrame(parent,name,WPaintUnclipped) |
458 | { | 458 | { |
459 | mFirstHandle = 0; | 459 | mFirstHandle = 0; |
460 | #if QT_VERSION >= 232 | 460 | #if QT_VERSION >= 232 |
461 | orient = o; | 461 | orient = o; |
462 | init(); | 462 | init(); |
463 | #endif | 463 | #endif |
464 | } | 464 | } |
465 | 465 | ||
466 | /*! | 466 | /*! |
467 | Destroys the splitter and any children. | 467 | Destroys the splitter and any children. |
468 | */ | 468 | */ |
469 | KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter() | 469 | KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter() |
470 | { | 470 | { |
471 | #if QT_VERSION >= 232 | 471 | #if QT_VERSION >= 232 |
472 | data->list.setAutoDelete( TRUE ); | 472 | data->list.setAutoDelete( TRUE ); |
473 | delete data; | 473 | delete data; |
474 | #endif | 474 | #endif |
475 | } | 475 | } |
476 | 476 | ||
477 | 477 | ||
478 | #if QT_VERSION >= 232 | 478 | #if QT_VERSION >= 232 |
479 | void KDGanttMinimizeSplitter::init() | 479 | void KDGanttMinimizeSplitter::init() |
480 | { | 480 | { |
481 | data = new QSplitterData; | 481 | data = new QSplitterData; |
482 | if ( orient == Horizontal ) | 482 | if ( orient == Horizontal ) |
483 | setSizePolicy( QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum) ); | 483 | setSizePolicy( QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum) ); |
484 | else | 484 | else |
485 | setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding) ); | 485 | setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding) ); |
486 | #ifndef DESKTOP_VERSION | ||
487 | setOpaqueResize( false ); | ||
488 | #else | ||
489 | setOpaqueResize( true ); | ||
490 | #endif | ||
486 | } | 491 | } |
487 | #endif | 492 | #endif |
488 | 493 | ||
489 | 494 | ||
490 | void KDGanttMinimizeSplitter::toggle() | 495 | void KDGanttMinimizeSplitter::toggle() |
491 | { | 496 | { |
492 | if ( mFirstHandle ) | 497 | if ( mFirstHandle ) |
493 | mFirstHandle->toggle(); | 498 | mFirstHandle->toggle(); |
494 | else | 499 | else |
495 | qDebug("KDGanttMinimizeSplitter::toggle::sorry, handle not available "); | 500 | qDebug("KDGanttMinimizeSplitter::toggle::sorry, handle not available "); |
496 | 501 | ||
497 | } | 502 | } |
498 | 503 | ||
499 | 504 | ||
500 | /*! | 505 | /*! |
501 | \brief the orientation of the splitter | 506 | \brief the orientation of the splitter |
502 | 507 | ||
503 | By default the orientation is horizontal (the widgets are side by side). | 508 | By default the orientation is horizontal (the widgets are side by side). |
504 | The possible orientations are Qt:Vertical and Qt::Horizontal (the default). | 509 | The possible orientations are Qt:Vertical and Qt::Horizontal (the default). |
505 | */ | 510 | */ |
506 | void KDGanttMinimizeSplitter::setOrientation( Orientation o ) | 511 | void KDGanttMinimizeSplitter::setOrientation( Orientation o ) |
507 | { | 512 | { |
508 | #if QT_VERSION >= 232 | 513 | #if QT_VERSION >= 232 |
509 | if ( orient == o ) | 514 | if ( orient == o ) |
510 | return; | 515 | return; |
511 | orient = o; | 516 | orient = o; |
512 | 517 | ||
513 | if ( orient == Horizontal ) | 518 | if ( orient == Horizontal ) |
514 | setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); | 519 | setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); |
515 | else | 520 | else |
516 | setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); | 521 | setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); |
517 | 522 | ||
518 | QSplitterLayoutStruct *s = data->list.first(); | 523 | QSplitterLayoutStruct *s = data->list.first(); |
519 | while ( s ) { | 524 | while ( s ) { |
520 | if ( s->isSplitter ) | 525 | if ( s->isSplitter ) |
521 | ((KDGanttSplitterHandle*)s->wid)->setOrientation( o ); | 526 | ((KDGanttSplitterHandle*)s->wid)->setOrientation( o ); |
522 | s = data->list.next(); // ### next at end of loop, no iterator | 527 | s = data->list.next(); // ### next at end of loop, no iterator |
523 | } | 528 | } |
524 | recalc( isVisible() ); | 529 | recalc( isVisible() ); |
525 | #endif | 530 | #endif |
526 | } | 531 | } |
527 | 532 | ||
528 | 533 | ||
529 | #if QT_VERSION >= 232 | 534 | #if QT_VERSION >= 232 |
530 | /*! | 535 | /*! |
531 | \reimp | 536 | \reimp |
532 | */ | 537 | */ |
533 | void KDGanttMinimizeSplitter::resizeEvent( QResizeEvent * ) | 538 | void KDGanttMinimizeSplitter::resizeEvent( QResizeEvent * ) |
534 | { | 539 | { |
535 | doResize(); | 540 | doResize(); |
536 | } | 541 | } |
537 | 542 | ||
538 | 543 | ||
539 | /* | 544 | /* |
540 | Inserts the widget \a w at the end (or at the beginning if \a first | 545 | Inserts the widget \a w at the end (or at the beginning if \a first |
541 | is TRUE) of the splitter's list of widgets. | 546 | is TRUE) of the splitter's list of widgets. |
542 | 547 | ||
543 | It is the responsibility of the caller of this function to make sure | 548 | It is the responsibility of the caller of this function to make sure |
544 | that \a w is not already in the splitter and to call recalcId if | 549 | that \a w is not already in the splitter and to call recalcId if |
545 | needed. (If \a first is TRUE, then recalcId is very probably | 550 | needed. (If \a first is TRUE, then recalcId is very probably |
546 | needed.) | 551 | needed.) |
547 | */ | 552 | */ |
548 | QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool first ) | 553 | QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool first ) |
549 | { | 554 | { |
550 | QSplitterLayoutStruct *s; | 555 | QSplitterLayoutStruct *s; |
551 | KDGanttSplitterHandle *newHandle = 0; | 556 | KDGanttSplitterHandle *newHandle = 0; |
552 | if ( data->list.count() > 0 ) { | 557 | if ( data->list.count() > 0 ) { |
553 | s = new QSplitterLayoutStruct; | 558 | s = new QSplitterLayoutStruct; |
554 | s->mode = KeepSize; | 559 | s->mode = KeepSize; |
555 | QString tmp = "qt_splithandle_"; | 560 | QString tmp = "qt_splithandle_"; |
556 | tmp += w->name(); | 561 | tmp += w->name(); |
557 | newHandle = new KDGanttSplitterHandle( orientation(), this, tmp.latin1() ); | 562 | newHandle = new KDGanttSplitterHandle( orientation(), this, tmp.latin1() ); |
558 | if ( ! mFirstHandle ) | 563 | if ( ! mFirstHandle ) |
559 | mFirstHandle = newHandle; | 564 | mFirstHandle = newHandle; |
560 | s->wid = newHandle; | 565 | s->wid = newHandle; |
561 | newHandle->setId(data->list.count()); | 566 | newHandle->setId(data->list.count()); |
562 | s->isSplitter = TRUE; | 567 | s->isSplitter = TRUE; |
563 | s->sizer = pick( newHandle->sizeHint() ); | 568 | s->sizer = pick( newHandle->sizeHint() ); |
564 | if ( first ) | 569 | if ( first ) |
565 | data->list.insert( 0, s ); | 570 | data->list.insert( 0, s ); |
566 | else | 571 | else |
567 | data->list.append( s ); | 572 | data->list.append( s ); |
568 | } | 573 | } |
569 | s = new QSplitterLayoutStruct; | 574 | s = new QSplitterLayoutStruct; |
570 | s->mode = Stretch; | 575 | s->mode = Stretch; |
571 | s->wid = w; | 576 | s->wid = w; |
572 | if ( !testWState( WState_Resized ) && w->sizeHint().isValid() ) | 577 | if ( !testWState( WState_Resized ) && w->sizeHint().isValid() ) |
573 | s->sizer = pick( w->sizeHint() ); | 578 | s->sizer = pick( w->sizeHint() ); |
574 | else | 579 | else |
575 | s->sizer = pick( w->size() ); | 580 | s->sizer = pick( w->size() ); |
576 | s->isSplitter = FALSE; | 581 | s->isSplitter = FALSE; |
577 | if ( first ) | 582 | if ( first ) |
578 | data->list.insert( 0, s ); | 583 | data->list.insert( 0, s ); |
579 | else | 584 | else |
580 | data->list.append( s ); | 585 | data->list.append( s ); |
581 | if ( newHandle && isVisible() ) | 586 | if ( newHandle && isVisible() ) |