Diffstat (limited to 'microkde/KDGanttMinimizeSplitter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | microkde/KDGanttMinimizeSplitter.cpp | 194 |
1 files changed, 103 insertions, 91 deletions
diff --git a/microkde/KDGanttMinimizeSplitter.cpp b/microkde/KDGanttMinimizeSplitter.cpp index 72c4e60..4172cd0 100644 --- a/microkde/KDGanttMinimizeSplitter.cpp +++ b/microkde/KDGanttMinimizeSplitter.cpp | |||
@@ -25,150 +25,160 @@ | |||
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 "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 |
59 | 68 | ||
60 | 69 | ||
61 | 70 | ||
62 | #ifndef DOXYGEN_SKIP_INTERNAL | 71 | #ifndef DOXYGEN_SKIP_INTERNAL |
63 | 72 | ||
64 | #if QT_VERSION >= 232 | 73 | #if QT_VERSION >= 232 |
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 * ) |
75 | { | 84 | { |
76 | close(); | 85 | close(); |
77 | }; | 86 | }; |
78 | 87 | ||
79 | }; | 88 | }; |
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; |
89 | } else { | 99 | } else { |
90 | mSizeHint = QSize(6,6); | 100 | mSizeHint = QSize(6,6); |
91 | mUseOffset = false; | 101 | mUseOffset = false; |
92 | } | 102 | } |
93 | s = parent; | 103 | s = parent; |
94 | setOrientation(o); | 104 | setOrientation(o); |
95 | setMouseTracking( true ); | 105 | setMouseTracking( true ); |
96 | mMouseDown = false; | 106 | mMouseDown = false; |
97 | //setMaximumHeight( 5 ); // test only | 107 | //setMaximumHeight( 5 ); // test only |
98 | } | 108 | } |
99 | 109 | ||
100 | QSize KDGanttSplitterHandle::sizeHint() const | 110 | QSize KDGanttSplitterHandle::sizeHint() const |
101 | { | 111 | { |
102 | return mSizeHint; | 112 | return mSizeHint; |
103 | } | 113 | } |
104 | 114 | ||
105 | void KDGanttSplitterHandle::setOrientation( Qt::Orientation o ) | 115 | 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 | ||
116 | 126 | ||
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) |
124 | return; | 134 | return; |
125 | 135 | ||
126 | QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) | 136 | QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) |
127 | - mouseOffset; | 137 | - mouseOffset; |
128 | if ( opaque() ) { | 138 | if ( opaque() ) { |
129 | s->moveSplitter( pos, id() ); | 139 | s->moveSplitter( pos, id() ); |
130 | } else { | 140 | } else { |
131 | int min = pos; int max = pos; | 141 | int min = pos; int max = pos; |
132 | s->getRange( id(), &min, &max ); | 142 | s->getRange( id(), &min, &max ); |
133 | s->setRubberband( QMAX( min, QMIN(max, pos ))); | 143 | s->setRubberband( QMAX( min, QMIN(max, pos ))); |
134 | } | 144 | } |
135 | _collapsed = false; | 145 | _collapsed = false; |
136 | } | 146 | } |
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; |
144 | repaint(); | 154 | repaint(); |
145 | updateCursor( e->pos() ); | 155 | updateCursor( e->pos() ); |
146 | } | 156 | } |
147 | } | 157 | } |
148 | 158 | ||
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() |
162 | { | 172 | { |
163 | int pos; | 173 | int pos; |
164 | int min, max; | 174 | int min, max; |
165 | if ( !_collapsed ) { | 175 | if ( !_collapsed ) { |
166 | s->expandPos( id(), &min, &max ); | 176 | s->expandPos( id(), &min, &max ); |
167 | if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left | 177 | if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left |
168 | || s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { | 178 | || s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { |
169 | pos = min; | 179 | pos = min; |
170 | } | 180 | } |
171 | else { | 181 | else { |
172 | pos = max; | 182 | pos = max; |
173 | } | 183 | } |
174 | 184 | ||
@@ -182,76 +192,76 @@ void KDGanttSplitterHandle::toggle() | |||
182 | } | 192 | } |
183 | repaint(); | 193 | repaint(); |
184 | } | 194 | } |
185 | 195 | ||
186 | void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) | 196 | void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) |
187 | { | 197 | { |
188 | mMouseDown = false; | 198 | mMouseDown = false; |
189 | if ( _activeButton != 0 ) { | 199 | if ( _activeButton != 0 ) { |
190 | if ( onButton( e->pos() ) == _activeButton ) | 200 | if ( onButton( e->pos() ) == _activeButton ) |
191 | { | 201 | { |
192 | toggle(); | 202 | toggle(); |
193 | } | 203 | } |
194 | _activeButton = 0; | 204 | _activeButton = 0; |
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 ); |
202 | s->moveSplitter( pos, id() ); | 212 | s->moveSplitter( pos, id() ); |
203 | } | 213 | } |
204 | } | 214 | } |
205 | if ( s->rubberBand() ) { | 215 | if ( s->rubberBand() ) { |
206 | //qDebug("hide rubberband "); | 216 | //qDebug("hide rubberband "); |
207 | s->rubberBand()->close(); | 217 | s->rubberBand()->close(); |
208 | } | 218 | } |
209 | repaint(); | 219 | repaint(); |
210 | } | 220 | } |
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); |
221 | rect.setTop( rect.top()- add ); | 231 | rect.setTop( rect.top()- add ); |
222 | rect.setBottom( rect.bottom() + add); | 232 | rect.setBottom( rect.bottom() + add); |
223 | if ( rect.contains( p ) ) { | 233 | if ( rect.contains( p ) ) { |
224 | return index; | 234 | return index; |
225 | } | 235 | } |
226 | index++; | 236 | index++; |
227 | } | 237 | } |
228 | return 0; | 238 | return 0; |
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]; |
245 | arr.setPoints( 3, | 255 | arr.setPoints( 3, |
246 | 1-xxx, mid - sw + 4, | 256 | 1-xxx, mid - sw + 4, |
247 | sw-3-xxx, mid, | 257 | sw-3-xxx, mid, |
248 | 1-xxx, mid + sw -4); | 258 | 1-xxx, mid + sw -4); |
249 | } | 259 | } |
250 | else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left || | 260 | else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left || |
251 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { | 261 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { |
252 | int mid = height()/2 + voffset[i]; | 262 | int mid = height()/2 + voffset[i]; |
253 | arr.setPoints( 3, | 263 | arr.setPoints( 3, |
254 | sw-4, mid - sw + 4, | 264 | sw-4, mid - sw + 4, |
255 | 0, mid, | 265 | 0, mid, |
256 | sw-4, mid + sw - 4); | 266 | sw-4, mid + sw - 4); |
257 | } | 267 | } |
@@ -298,37 +308,37 @@ void KDGanttSplitterHandle::paintEvent( QPaintEvent * ) | |||
298 | int sw = 8; // Hardcoded, given I didn't use styles anymore, I didn't like to use their size | 308 | int sw = 8; // Hardcoded, given I didn't use styles anymore, I didn't like to use their size |
299 | 309 | ||
300 | // arrow color | 310 | // arrow color |
301 | QColor col; | 311 | QColor col; |
302 | if ( _activeButton ) | 312 | if ( _activeButton ) |
303 | col = colorGroup().background().dark( 250 ); | 313 | col = colorGroup().background().dark( 250 ); |
304 | else { | 314 | else { |
305 | if ( mMouseDown ) | 315 | if ( mMouseDown ) |
306 | col = Qt::white; | 316 | col = Qt::white; |
307 | else | 317 | else |
308 | col = colorGroup().background().dark( 150 ); | 318 | col = colorGroup().background().dark( 150 ); |
309 | } | 319 | } |
310 | //QColor col = backgroundColor().dark( 130 ); | 320 | //QColor col = backgroundColor().dark( 130 ); |
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 | /* |
322 | if ( ! _collapsed ) { | 332 | if ( ! _collapsed ) { |
323 | p.save(); | 333 | p.save(); |
324 | // p.translate( parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftHorizontal ), | 334 | // p.translate( parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftHorizontal ), |
325 | // parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftVertical ) ); | 335 | // parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftVertical ) ); |
326 | p.translate( -1, 0 ); | 336 | p.translate( -1, 0 ); |
327 | p.drawPolygon( *it, true ); | 337 | p.drawPolygon( *it, true ); |
328 | p.restore(); } else | 338 | p.restore(); } else |
329 | */ | 339 | */ |
330 | p.drawPolygon( *it, true ); | 340 | p.drawPolygon( *it, true ); |
331 | 341 | ||
332 | } | 342 | } |
333 | else { | 343 | else { |
334 | /* | 344 | /* |
@@ -364,38 +374,38 @@ void KDGanttSplitterHandle::paintEvent( QPaintEvent * ) | |||
364 | #endif | 374 | #endif |
365 | 375 | ||
366 | class QSplitterLayoutStruct | 376 | class QSplitterLayoutStruct |
367 | { | 377 | { |
368 | public: | 378 | public: |
369 | KDGanttMinimizeSplitter::ResizeMode mode; | 379 | KDGanttMinimizeSplitter::ResizeMode mode; |
370 | QCOORD sizer; | 380 | QCOORD sizer; |
371 | bool isSplitter; | 381 | bool isSplitter; |
372 | QWidget *wid; | 382 | QWidget *wid; |
373 | }; | 383 | }; |
374 | 384 | ||
375 | class QSplitterData | 385 | class QSplitterData |
376 | { | 386 | { |
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 | ||
389 | 399 | ||
390 | /*! | 400 | /*! |
391 | \class KDGanttMinimizeSplitter KDGanttMinimizeSplitter.h | 401 | \class KDGanttMinimizeSplitter KDGanttMinimizeSplitter.h |
392 | \brief The KDGanttMinimizeSplitter class implements a splitter | 402 | \brief The KDGanttMinimizeSplitter class implements a splitter |
393 | widget with minimize buttons. | 403 | widget with minimize buttons. |
394 | 404 | ||
395 | This class (and its documentation) is largely a copy of Qt's | 405 | This class (and its documentation) is largely a copy of Qt's |
396 | QSplitter; the copying was necessary because QSplitter is not | 406 | QSplitter; the copying was necessary because QSplitter is not |
397 | extensible at all. QSplitter and its documentation are licensed | 407 | extensible at all. QSplitter and its documentation are licensed |
398 | according to the GPL and the Qt Professional License (if you hold | 408 | according to the GPL and the Qt Professional License (if you hold |
399 | such a license) and are (C) Trolltech AS. | 409 | such a license) and are (C) Trolltech AS. |
400 | 410 | ||
401 | A splitter lets the user control the size of child widgets by | 411 | A splitter lets the user control the size of child widgets by |
@@ -448,113 +458,114 @@ static QSize minSizeHint( const QWidget* w ) | |||
448 | QSize s; | 458 | QSize s; |
449 | if ( min.height() <= 0 || min.width() <= 0 ) | 459 | if ( min.height() <= 0 || min.width() <= 0 ) |
450 | s = w->minimumSizeHint(); | 460 | s = w->minimumSizeHint(); |
451 | if ( min.height() > 0 ) | 461 | if ( min.height() > 0 ) |
452 | s.setHeight( min.height() ); | 462 | s.setHeight( min.height() ); |
453 | if ( min.width() > 0 ) | 463 | if ( min.width() > 0 ) |
454 | s.setWidth( min.width() ); | 464 | s.setWidth( min.width() ); |
455 | return s.expandedTo(QSize(0,0)); | 465 | return s.expandedTo(QSize(0,0)); |
456 | } | 466 | } |
457 | 467 | ||
458 | 468 | ||
459 | /*! | 469 | /*! |
460 | Constructs a horizontal splitter with the \a parent and \a | 470 | Constructs a horizontal splitter with the \a parent and \a |
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 | } |
473 | 484 | ||
474 | /*! | 485 | /*! |
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 |
485 | orient = o; | 496 | orient = o; |
486 | init(); | 497 | init(); |
487 | #endif | 498 | #endif |
488 | } | 499 | } |
489 | 500 | ||
490 | /*! | 501 | /*! |
491 | Destroys the splitter and any children. | 502 | Destroys the splitter and any children. |
492 | */ | 503 | */ |
493 | KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter() | 504 | KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter() |
494 | { | 505 | { |
495 | #if QT_VERSION >= 232 | 506 | #if QT_VERSION >= 232 |
496 | data->list.setAutoDelete( TRUE ); | 507 | data->list.setAutoDelete( TRUE ); |
497 | delete data; | 508 | delete data; |
498 | #endif | 509 | #endif |
499 | if ( mRubberBand ) | 510 | if ( mRubberBand ) |
500 | delete mRubberBand; | 511 | delete mRubberBand; |
501 | } | 512 | } |
502 | 513 | ||
503 | 514 | ||
504 | #if QT_VERSION >= 232 | 515 | #if QT_VERSION >= 232 |
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) ); |
512 | #ifndef DESKTOP_VERSION | 523 | #ifndef DESKTOP_VERSION |
513 | setOpaqueResize( false ); | 524 | setOpaqueResize( false ); |
514 | #else | 525 | #else |
515 | setOpaqueResize( true ); | 526 | setOpaqueResize( true ); |
516 | #endif | 527 | #endif |
517 | } | 528 | } |
518 | #endif | 529 | #endif |
519 | 530 | ||
520 | 531 | ||
521 | void KDGanttMinimizeSplitter::toggle() | 532 | void KDGanttMinimizeSplitter::toggle() |
522 | { | 533 | { |
523 | if ( mFirstHandle ) | 534 | if ( mFirstHandle ) |
524 | mFirstHandle->toggle(); | 535 | mFirstHandle->toggle(); |
525 | else | 536 | else |
526 | qDebug("KDGanttMinimizeSplitter::toggle::sorry, handle not available "); | 537 | qDebug("KDGanttMinimizeSplitter::toggle::sorry, handle not available "); |
527 | 538 | ||
528 | } | 539 | } |
529 | 540 | ||
530 | 541 | ||
531 | /*! | 542 | /*! |
532 | \brief the orientation of the splitter | 543 | \brief the orientation of the splitter |
533 | 544 | ||
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 ) ); |
548 | 559 | ||
549 | QSplitterLayoutStruct *s = data->list.first(); | 560 | QSplitterLayoutStruct *s = data->list.first(); |
550 | while ( s ) { | 561 | while ( s ) { |
551 | if ( s->isSplitter ) | 562 | if ( s->isSplitter ) |
552 | ((KDGanttSplitterHandle*)s->wid)->setOrientation( o ); | 563 | ((KDGanttSplitterHandle*)s->wid)->setOrientation( o ); |
553 | s = data->list.next(); // ### next at end of loop, no iterator | 564 | s = data->list.next(); // ### next at end of loop, no iterator |
554 | } | 565 | } |
555 | recalc( isVisible() ); | 566 | recalc( isVisible() ); |
556 | #endif | 567 | #endif |
557 | } | 568 | } |
558 | 569 | ||
559 | 570 | ||
560 | #if QT_VERSION >= 232 | 571 | #if QT_VERSION >= 232 |
@@ -573,81 +584,87 @@ void KDGanttMinimizeSplitter::resizeEvent( QResizeEvent * ) | |||
573 | 584 | ||
574 | It is the responsibility of the caller of this function to make sure | 585 | It is the responsibility of the caller of this function to make sure |
575 | that \a w is not already in the splitter and to call recalcId if | 586 | that \a w is not already in the splitter and to call recalcId if |
576 | needed. (If \a first is TRUE, then recalcId is very probably | 587 | needed. (If \a first is TRUE, then recalcId is very probably |
577 | needed.) | 588 | needed.) |
578 | */ | 589 | */ |
579 | QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool first ) | 590 | QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool first ) |
580 | { | 591 | { |
581 | QSplitterLayoutStruct *s; | 592 | QSplitterLayoutStruct *s; |
582 | KDGanttSplitterHandle *newHandle = 0; | 593 | KDGanttSplitterHandle *newHandle = 0; |
583 | if ( data->list.count() > 0 ) { | 594 | if ( data->list.count() > 0 ) { |
584 | s = new QSplitterLayoutStruct; | 595 | s = new QSplitterLayoutStruct; |
585 | s->mode = KeepSize; | 596 | s->mode = KeepSize; |
586 | QString tmp = "qt_splithandle_"; | 597 | QString tmp = "qt_splithandle_"; |
587 | tmp += w->name(); | 598 | tmp += w->name(); |
588 | newHandle = new KDGanttSplitterHandle( orientation(), this, tmp.latin1() ); | 599 | newHandle = new KDGanttSplitterHandle( orientation(), this, tmp.latin1() ); |
589 | if ( ! mFirstHandle ) | 600 | if ( ! mFirstHandle ) |
590 | mFirstHandle = newHandle; | 601 | mFirstHandle = newHandle; |
591 | s->wid = newHandle; | 602 | s->wid = newHandle; |
592 | newHandle->setId(data->list.count()); | 603 | newHandle->setId(data->list.count()); |
593 | s->isSplitter = TRUE; | 604 | s->isSplitter = TRUE; |
594 | s->sizer = pick( newHandle->sizeHint() ); | 605 | s->sizer = pick( newHandle->sizeHint() ); |
595 | if ( first ) | 606 | if ( first ) |
596 | data->list.insert( 0, s ); | 607 | data->list.insert( 0, s ); |
597 | else | 608 | else |
598 | data->list.append( s ); | 609 | data->list.append( s ); |
599 | } | 610 | } |
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() ); |
607 | s->isSplitter = FALSE; | 618 | s->isSplitter = FALSE; |
608 | if ( first ) | 619 | if ( first ) |
609 | data->list.insert( 0, s ); | 620 | data->list.insert( 0, s ); |
610 | else | 621 | else |
611 | data->list.append( s ); | 622 | data->list.append( s ); |
612 | if ( newHandle && isVisible() ) | 623 | if ( newHandle && isVisible() ) |
613 | newHandle->show(); //will trigger sending of post events | 624 | newHandle->show(); //will trigger sending of post events |
614 | return s; | 625 | return s; |
615 | } | 626 | } |
616 | 627 | ||
617 | 628 | ||
618 | /*! | 629 | /*! |
619 | Tells the splitter that a child widget has been inserted or removed. | 630 | Tells the splitter that a child widget has been inserted or removed. |
620 | The event is passed in \a c. | 631 | The event is passed in \a c. |
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 ) { |
641 | QSplitterLayoutStruct *p = 0; | 658 | QSplitterLayoutStruct *p = 0; |
642 | if ( data->list.count() > 1 ) | 659 | if ( data->list.count() > 1 ) |
643 | p = data->list.at(1); //remove handle _after_ first widget. | 660 | p = data->list.at(1); //remove handle _after_ first widget. |
644 | QSplitterLayoutStruct *s = data->list.first(); | 661 | QSplitterLayoutStruct *s = data->list.first(); |
645 | while ( s ) { | 662 | while ( s ) { |
646 | if ( s->wid == c->child() ) { | 663 | if ( s->wid == c->child() ) { |
647 | data->list.removeRef( s ); | 664 | data->list.removeRef( s ); |
648 | delete s; | 665 | delete s; |
649 | if ( p && p->isSplitter ) { | 666 | if ( p && p->isSplitter ) { |
650 | data->list.removeRef( p ); | 667 | data->list.removeRef( p ); |
651 | delete p->wid; //will call childEvent | 668 | delete p->wid; //will call childEvent |
652 | delete p; | 669 | delete p; |
653 | } | 670 | } |
@@ -657,118 +674,118 @@ void KDGanttMinimizeSplitter::childEvent( QChildEvent *c ) | |||
657 | } | 674 | } |
658 | p = s; | 675 | p = s; |
659 | s = data->list.next(); | 676 | s = data->list.next(); |
660 | } | 677 | } |
661 | } | 678 | } |
662 | } | 679 | } |
663 | 680 | ||
664 | 681 | ||
665 | /*! | 682 | /*! |
666 | Shows a rubber band at position \a p. If \a p is negative, the | 683 | Shows a rubber band at position \a p. If \a p is negative, the |
667 | rubber band is removed. | 684 | rubber band is removed. |
668 | */ | 685 | */ |
669 | void KDGanttMinimizeSplitter::setRubberband( int p ) | 686 | 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() ); |
687 | if ( p >= 0 ) | 704 | if ( p >= 0 ) |
688 | paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() ); | 705 | paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() ); |
689 | } else { | 706 | } else { |
690 | if ( opaqueOldPos >= 0 ) | 707 | if ( opaqueOldPos >= 0 ) |
691 | paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord, | 708 | paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord, |
692 | r.width(), 2*rBord ); | 709 | r.width(), 2*rBord ); |
693 | if ( p >= 0 ) | 710 | if ( p >= 0 ) |
694 | paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord ); | 711 | paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord ); |
695 | } | 712 | } |
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() )); |
703 | } | 720 | } |
704 | QRect r = contentsRect(); | 721 | QRect r = contentsRect(); |
705 | static int rBord = 0; //Themable???? | 722 | static int rBord = 0; //Themable???? |
706 | if ( !rBord ) { | 723 | if ( !rBord ) { |
707 | if (QApplication::desktop()->width() <= 320 ) | 724 | if (QApplication::desktop()->width() <= 320 ) |
708 | rBord = 3; | 725 | rBord = 3; |
709 | else | 726 | else |
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() ); |
717 | } | 734 | } |
718 | } else { | 735 | } else { |
719 | if ( p >= 0 ) { | 736 | if ( p >= 0 ) { |
720 | QPoint geo = mapToGlobal (QPoint ( r.x(), p + sw/2 - rBord)); | 737 | QPoint geo = mapToGlobal (QPoint ( r.x(), p + sw/2 - rBord)); |
721 | mRubberBand->setGeometry( geo.x(), geo.y(), r.width(), 2*rBord); | 738 | mRubberBand->setGeometry( geo.x(), geo.y(), r.width(), 2*rBord); |
722 | } | 739 | } |
723 | } | 740 | } |
724 | opaqueOldPos = p; | 741 | opaqueOldPos = p; |
725 | if ( ! mRubberBand->isVisible() ) { | 742 | if ( ! mRubberBand->isVisible() ) { |
726 | mRubberBand->show(); | 743 | mRubberBand->show(); |
727 | } | 744 | } |
728 | #endif | 745 | #endif |
729 | } | 746 | } |
730 | 747 | ||
731 | 748 | ||
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; |
739 | } | 756 | } |
740 | return QWidget::event( e ); | 757 | return QWidget::event( e ); |
741 | } | 758 | } |
742 | 759 | ||
743 | 760 | ||
744 | /*! | 761 | /*! |
745 | \obsolete | 762 | \obsolete |
746 | 763 | ||
747 | Draws the splitter handle in the rectangle described by \a x, \a y, | 764 | Draws the splitter handle in the rectangle described by \a x, \a y, |
748 | \a w, \a h using painter \a p. | 765 | \a w, \a h using painter \a p. |
749 | \sa QStyle::drawPrimitive() | 766 | \sa QStyle::drawPrimitive() |
750 | */ | 767 | */ |
751 | void KDGanttMinimizeSplitter::drawSplitter( QPainter *p, | 768 | void KDGanttMinimizeSplitter::drawSplitter( QPainter *p, |
752 | QCOORD x, QCOORD y, QCOORD w, QCOORD h ) | 769 | QCOORD x, QCOORD y, QCOORD w, QCOORD h ) |
753 | { | 770 | { |
754 | #if 0 | 771 | #if 0 |
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 | ||
762 | 779 | ||
763 | /*! | 780 | /*! |
764 | Returns the id of the splitter to the right of or below the widget \a w, | 781 | Returns the id of the splitter to the right of or below the widget \a w, |
765 | or 0 if there is no such splitter | 782 | or 0 if there is no such splitter |
766 | (i.e. it is either not in this KDGanttMinimizeSplitter or it is at the end). | 783 | (i.e. it is either not in this KDGanttMinimizeSplitter or it is at the end). |
767 | */ | 784 | */ |
768 | int KDGanttMinimizeSplitter::idAfter( QWidget* w ) const | 785 | int KDGanttMinimizeSplitter::idAfter( QWidget* w ) const |
769 | { | 786 | { |
770 | QSplitterLayoutStruct *s = data->list.first(); | 787 | QSplitterLayoutStruct *s = data->list.first(); |
771 | bool seen_w = FALSE; | 788 | bool seen_w = FALSE; |
772 | while ( s ) { | 789 | while ( s ) { |
773 | if ( s->isSplitter && seen_w ) | 790 | if ( s->isSplitter && seen_w ) |
774 | return data->list.at(); | 791 | return data->list.at(); |
@@ -783,93 +800,93 @@ int KDGanttMinimizeSplitter::idAfter( QWidget* w ) const | |||
783 | /*! | 800 | /*! |
784 | Moves the left/top edge of the splitter handle with id \a id as | 801 | Moves the left/top edge of the splitter handle with id \a id as |
785 | close as possible to position \a p, which is the distance from the | 802 | close as possible to position \a p, which is the distance from the |
786 | left (or top) edge of the widget. | 803 | left (or top) edge of the widget. |
787 | 804 | ||
788 | For Arabic and Hebrew the layout is reversed, and using this | 805 | For Arabic and Hebrew the layout is reversed, and using this |
789 | function to set the position of the splitter might lead to | 806 | function to set the position of the splitter might lead to |
790 | unexpected results, since in Arabic and Hebrew the position of | 807 | unexpected results, since in Arabic and Hebrew the position of |
791 | splitter one is to the left of the position of splitter zero. | 808 | splitter one is to the left of the position of splitter zero. |
792 | 809 | ||
793 | \sa idAfter() | 810 | \sa idAfter() |
794 | */ | 811 | */ |
795 | void KDGanttMinimizeSplitter::moveSplitter( QCOORD p, int id ) | 812 | 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 |
805 | upLeft = p < oldP; | 822 | upLeft = p < oldP; |
806 | 823 | ||
807 | moveAfter( p, id, upLeft ); | 824 | moveAfter( p, id, upLeft ); |
808 | moveBefore( p-1, id-1, upLeft ); | 825 | moveBefore( p-1, id-1, upLeft ); |
809 | 826 | ||
810 | storeSizes(); | 827 | storeSizes(); |
811 | } | 828 | } |
812 | 829 | ||
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 |
821 | w->setGeometry( contentsRect().x(), p, contentsRect().width(), s ); | 838 | w->setGeometry( contentsRect().x(), p, contentsRect().width(), s ); |
822 | } | 839 | } |
823 | 840 | ||
824 | 841 | ||
825 | /* | 842 | /* |
826 | Places the right/bottom edge of the widget at \a id at position \a pos. | 843 | Places the right/bottom edge of the widget at \a id at position \a pos. |
827 | 844 | ||
828 | \sa idAfter() | 845 | \sa idAfter() |
829 | */ | 846 | */ |
830 | void KDGanttMinimizeSplitter::moveBefore( int pos, int id, bool upLeft ) | 847 | void KDGanttMinimizeSplitter::moveBefore( int pos, int id, bool upLeft ) |
831 | { | 848 | { |
832 | if( id < 0 ) | 849 | if( id < 0 ) |
833 | return; | 850 | return; |
834 | QSplitterLayoutStruct *s = data->list.at(id); | 851 | QSplitterLayoutStruct *s = data->list.at(id); |
835 | if ( !s ) | 852 | if ( !s ) |
836 | return; | 853 | return; |
837 | QWidget *w = s->wid; | 854 | QWidget *w = s->wid; |
838 | if ( w->isHidden() ) { | 855 | if ( w->isHidden() ) { |
839 | moveBefore( pos, id-1, upLeft ); | 856 | moveBefore( pos, id-1, 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 { |
847 | pos2 = pos - dd; | 864 | pos2 = pos - dd; |
848 | pos1 = pos2 + 1; | 865 | pos1 = pos2 + 1; |
849 | } | 866 | } |
850 | if ( upLeft ) { | 867 | if ( upLeft ) { |
851 | setG( w, pos1, dd, TRUE ); | 868 | setG( w, pos1, dd, TRUE ); |
852 | moveBefore( pos2, id-1, upLeft ); | 869 | moveBefore( pos2, id-1, upLeft ); |
853 | } else { | 870 | } else { |
854 | moveBefore( pos2, id-1, upLeft ); | 871 | moveBefore( pos2, id-1, upLeft ); |
855 | setG( w, pos1, dd, TRUE ); | 872 | setG( w, pos1, dd, TRUE ); |
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; |
863 | nextPos = newLeft + dd; | 880 | nextPos = newLeft + dd; |
864 | } else { | 881 | } else { |
865 | dd = pos - pick( w->pos() ) + 1; | 882 | dd = pos - pick( w->pos() ) + 1; |
866 | dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); | 883 | dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); |
867 | newLeft = pos-dd+1; | 884 | newLeft = pos-dd+1; |
868 | nextPos = newLeft - 1; | 885 | nextPos = newLeft - 1; |
869 | } | 886 | } |
870 | setG( w, newLeft, dd, TRUE ); | 887 | setG( w, newLeft, dd, TRUE ); |
871 | moveBefore( nextPos, id-1, upLeft ); | 888 | moveBefore( nextPos, id-1, upLeft ); |
872 | } | 889 | } |
873 | } | 890 | } |
874 | 891 | ||
875 | 892 | ||
@@ -880,50 +897,50 @@ void KDGanttMinimizeSplitter::moveBefore( int pos, int id, bool upLeft ) | |||
880 | */ | 897 | */ |
881 | void KDGanttMinimizeSplitter::moveAfter( int pos, int id, bool upLeft ) | 898 | void KDGanttMinimizeSplitter::moveAfter( int pos, int id, bool upLeft ) |
882 | { | 899 | { |
883 | QSplitterLayoutStruct *s = id < int(data->list.count()) ? | 900 | QSplitterLayoutStruct *s = id < int(data->list.count()) ? |
884 | data->list.at(id) : 0; | 901 | data->list.at(id) : 0; |
885 | if ( !s ) | 902 | if ( !s ) |
886 | return; | 903 | return; |
887 | QWidget *w = s->wid; | 904 | QWidget *w = s->wid; |
888 | if ( w->isHidden() ) { | 905 | if ( w->isHidden() ) { |
889 | moveAfter( pos, id+1, upLeft ); | 906 | moveAfter( pos, id+1, upLeft ); |
890 | } else if ( pick( w->pos() ) == pos ) { | 907 | } else if ( pick( w->pos() ) == pos ) { |
891 | //No need to do anything if it's already there. | 908 | //No need to do anything if it's already there. |
892 | return; | 909 | return; |
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 { |
900 | pos1 = pos; | 917 | pos1 = pos; |
901 | pos2 = pos + dd; | 918 | pos2 = pos + dd; |
902 | } | 919 | } |
903 | if ( upLeft ) { | 920 | if ( upLeft ) { |
904 | setG( w, pos1, dd, TRUE ); | 921 | setG( w, pos1, dd, TRUE ); |
905 | moveAfter( pos2, id+1, upLeft ); | 922 | moveAfter( pos2, id+1, upLeft ); |
906 | } else { | 923 | } else { |
907 | moveAfter( pos2, id+1, upLeft ); | 924 | moveAfter( pos2, id+1, upLeft ); |
908 | setG( w, pos1, dd, TRUE ); | 925 | setG( w, pos1, dd, TRUE ); |
909 | } | 926 | } |
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; |
917 | nextPos = newLeft - 1; | 934 | nextPos = newLeft - 1; |
918 | } else { | 935 | } else { |
919 | right = pick( w->geometry().bottomRight() ); | 936 | right = pick( w->geometry().bottomRight() ); |
920 | dd = right - pos + 1; | 937 | dd = right - pos + 1; |
921 | dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); | 938 | dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); |
922 | /*newRight = pos+dd-1;*/ | 939 | /*newRight = pos+dd-1;*/ |
923 | newLeft = pos; | 940 | newLeft = pos; |
924 | nextPos = newLeft + dd; | 941 | nextPos = newLeft + dd; |
925 | } | 942 | } |
926 | setG( w, newLeft, dd, TRUE ); | 943 | setG( w, newLeft, dd, TRUE ); |
927 | /*if( right != newRight )*/ | 944 | /*if( right != newRight )*/ |
928 | moveAfter( nextPos, id+1, upLeft ); | 945 | moveAfter( nextPos, id+1, upLeft ); |
929 | } | 946 | } |
@@ -975,35 +992,35 @@ void KDGanttMinimizeSplitter::getRange( int id, int *min, int *max ) | |||
975 | maxB += pick( s->wid->maximumSize() ); | 992 | maxB += pick( s->wid->maximumSize() ); |
976 | } | 993 | } |
977 | } | 994 | } |
978 | for ( i = id; i < n; i++ ) { | 995 | for ( i = id; i < n; i++ ) { |
979 | QSplitterLayoutStruct *s = data->list.at(i); | 996 | QSplitterLayoutStruct *s = data->list.at(i); |
980 | if ( s->wid->isHidden() ) { | 997 | if ( s->wid->isHidden() ) { |
981 | //ignore | 998 | //ignore |
982 | } else if ( s->isSplitter ) { | 999 | } else if ( s->isSplitter ) { |
983 | minA += s->sizer; | 1000 | minA += s->sizer; |
984 | maxA += s->sizer; | 1001 | maxA += s->sizer; |
985 | } else { | 1002 | } else { |
986 | minA += pick( minSize(s->wid) ); | 1003 | minA += pick( minSize(s->wid) ); |
987 | maxA += pick( s->wid->maximumSize() ); | 1004 | maxA += pick( s->wid->maximumSize() ); |
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 |
997 | 1014 | ||
998 | if ( min ) | 1015 | if ( min ) |
999 | *min = pick(r.topRight()) - QMIN( maxB, pick(r.size())-minA ) - splitterWidth; | 1016 | *min = pick(r.topRight()) - QMIN( maxB, pick(r.size())-minA ) - splitterWidth; |
1000 | if ( max ) | 1017 | if ( max ) |
1001 | *max = pick(r.topRight()) - QMAX( minB, pick(r.size())-maxA ) - splitterWidth; | 1018 | *max = pick(r.topRight()) - QMAX( minB, pick(r.size())-maxA ) - splitterWidth; |
1002 | } else { | 1019 | } else { |
1003 | if ( min ) | 1020 | if ( min ) |
1004 | *min = pick(r.topLeft()) + QMAX( minB, pick(r.size())-maxA ); | 1021 | *min = pick(r.topLeft()) + QMAX( minB, pick(r.size())-maxA ); |
1005 | if ( max ) | 1022 | if ( max ) |
1006 | *max = pick(r.topLeft()) + QMIN( maxB, pick(r.size())-minA ); | 1023 | *max = pick(r.topLeft()) + QMIN( maxB, pick(r.size())-minA ); |
1007 | } | 1024 | } |
1008 | } | 1025 | } |
1009 | 1026 | ||
@@ -1017,33 +1034,33 @@ void KDGanttMinimizeSplitter::getRange( int id, int *min, int *max ) | |||
1017 | int KDGanttMinimizeSplitter::adjustPos( int p, int id ) | 1034 | int KDGanttMinimizeSplitter::adjustPos( int p, int id ) |
1018 | { | 1035 | { |
1019 | int min = 0; | 1036 | int min = 0; |
1020 | int max = 0; | 1037 | int max = 0; |
1021 | getRange( id, &min, &max ); | 1038 | getRange( id, &min, &max ); |
1022 | p = QMAX( min, QMIN( p, max ) ); | 1039 | p = QMAX( min, QMIN( p, max ) ); |
1023 | 1040 | ||
1024 | return p; | 1041 | return p; |
1025 | } | 1042 | } |
1026 | 1043 | ||
1027 | 1044 | ||
1028 | void KDGanttMinimizeSplitter::doResize() | 1045 | void KDGanttMinimizeSplitter::doResize() |
1029 | { | 1046 | { |
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); |
1037 | if ( s->wid->isHidden() ) { | 1054 | if ( s->wid->isHidden() ) { |
1038 | a[i].stretch = 0; | 1055 | a[i].stretch = 0; |
1039 | a[i].sizeHint = a[i].minimumSize = 0; | 1056 | a[i].sizeHint = a[i].minimumSize = 0; |
1040 | a[i].maximumSize = 0; | 1057 | a[i].maximumSize = 0; |
1041 | } else if ( s->isSplitter ) { | 1058 | } else if ( s->isSplitter ) { |
1042 | a[i].stretch = 0; | 1059 | a[i].stretch = 0; |
1043 | a[i].sizeHint = a[i].minimumSize = a[i].maximumSize = s->sizer; | 1060 | a[i].sizeHint = a[i].minimumSize = a[i].maximumSize = s->sizer; |
1044 | a[i].empty = FALSE; | 1061 | a[i].empty = FALSE; |
1045 | } else if ( s->mode == KeepSize ) { | 1062 | } else if ( s->mode == KeepSize ) { |
1046 | a[i].stretch = 0; | 1063 | a[i].stretch = 0; |
1047 | a[i].minimumSize = pick( minSize(s->wid) ); | 1064 | a[i].minimumSize = pick( minSize(s->wid) ); |
1048 | a[i].sizeHint = s->sizer; | 1065 | a[i].sizeHint = s->sizer; |
1049 | a[i].maximumSize = pick( s->wid->maximumSize() ); | 1066 | a[i].maximumSize = pick( s->wid->maximumSize() ); |
@@ -1119,33 +1136,33 @@ void KDGanttMinimizeSplitter::recalc( bool update ) | |||
1119 | } | 1136 | } |
1120 | } | 1137 | } |
1121 | if ( empty ) { | 1138 | if ( empty ) { |
1122 | if ( parentWidget() != 0 && parentWidget()->inherits("KDGanttMinimizeSplitter") ) { | 1139 | if ( parentWidget() != 0 && parentWidget()->inherits("KDGanttMinimizeSplitter") ) { |
1123 | // nested splitters; be nice | 1140 | // nested splitters; be nice |
1124 | maxl = maxt = 0; | 1141 | maxl = maxt = 0; |
1125 | } else { | 1142 | } else { |
1126 | // KDGanttMinimizeSplitter with no children yet | 1143 | // KDGanttMinimizeSplitter with no children yet |
1127 | maxl = QWIDGETSIZE_MAX; | 1144 | maxl = QWIDGETSIZE_MAX; |
1128 | } | 1145 | } |
1129 | } else { | 1146 | } else { |
1130 | maxl = QMIN( maxl, QWIDGETSIZE_MAX ); | 1147 | maxl = QMIN( maxl, QWIDGETSIZE_MAX ); |
1131 | } | 1148 | } |
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 { |
1139 | setMaximumSize( maxt, maxl ); | 1156 | setMaximumSize( maxt, maxl ); |
1140 | setMinimumSize( mint, minl ); | 1157 | setMinimumSize( mint, minl ); |
1141 | } | 1158 | } |
1142 | if ( update ) | 1159 | if ( update ) |
1143 | doResize(); | 1160 | doResize(); |
1144 | } | 1161 | } |
1145 | 1162 | ||
1146 | /*! | 1163 | /*! |
1147 | Sets resize mode of \a w to \a mode. | 1164 | Sets resize mode of \a w to \a mode. |
1148 | 1165 | ||
1149 | \sa ResizeMode | 1166 | \sa ResizeMode |
1150 | */ | 1167 | */ |
1151 | 1168 | ||
@@ -1254,80 +1271,74 @@ void KDGanttMinimizeSplitter::recalcId() | |||
1254 | int n = data->list.count(); | 1271 | int n = data->list.count(); |
1255 | for ( int i = 0; i < n; i++ ) { | 1272 | for ( int i = 0; i < n; i++ ) { |
1256 | QSplitterLayoutStruct *s = data->list.at(i); | 1273 | QSplitterLayoutStruct *s = data->list.at(i); |
1257 | if ( s->isSplitter ) | 1274 | if ( s->isSplitter ) |
1258 | ((KDGanttSplitterHandle*)s->wid)->setId(i); | 1275 | ((KDGanttSplitterHandle*)s->wid)->setId(i); |
1259 | } | 1276 | } |
1260 | } | 1277 | } |
1261 | 1278 | ||
1262 | 1279 | ||
1263 | /*!\reimp | 1280 | /*!\reimp |
1264 | */ | 1281 | */ |
1265 | QSize KDGanttMinimizeSplitter::sizeHint() const | 1282 | QSize KDGanttMinimizeSplitter::sizeHint() const |
1266 | { | 1283 | { |
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(); |
1280 | if ( s.isValid() ) { | 1294 | if ( s.isValid() ) { |
1281 | l += pick( s ); | 1295 | l += pick( s ); |
1282 | t = QMAX( t, trans( s ) ); | 1296 | t = QMAX( t, trans( s ) ); |
1283 | } | 1297 | } |
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 | ||
1291 | /*! | 1305 | /*! |
1292 | \reimp | 1306 | \reimp |
1293 | */ | 1307 | */ |
1294 | 1308 | ||
1295 | QSize KDGanttMinimizeSplitter::minimumSizeHint() const | 1309 | QSize KDGanttMinimizeSplitter::minimumSizeHint() const |
1296 | { | 1310 | { |
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); |
1310 | if ( s.isValid() ) { | 1321 | if ( s.isValid() ) { |
1311 | l += pick( s ); | 1322 | l += pick( s ); |
1312 | t = QMAX( t, trans( s ) ); | 1323 | t = QMAX( t, trans( s ) ); |
1313 | } | 1324 | } |
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 | ||
1321 | /* | 1332 | /* |
1322 | Calculates stretch parameters from current sizes | 1333 | Calculates stretch parameters from current sizes |
1323 | */ | 1334 | */ |
1324 | 1335 | ||
1325 | void KDGanttMinimizeSplitter::storeSizes() | 1336 | void KDGanttMinimizeSplitter::storeSizes() |
1326 | { | 1337 | { |
1327 | QSplitterLayoutStruct *s = data->list.first(); | 1338 | QSplitterLayoutStruct *s = data->list.first(); |
1328 | while ( s ) { | 1339 | while ( s ) { |
1329 | if ( !s->isSplitter ) | 1340 | if ( !s->isSplitter ) |
1330 | s->sizer = pick( s->wid->size() ); | 1341 | s->sizer = pick( s->wid->size() ); |
1331 | s = data->list.next(); | 1342 | s = data->list.next(); |
1332 | } | 1343 | } |
1333 | } | 1344 | } |
@@ -1389,143 +1400,144 @@ bool KDGanttMinimizeSplitter::isHidden( QWidget *w ) const | |||
1389 | produce a splitter with the same layout as this one. | 1400 | produce a splitter with the same layout as this one. |
1390 | 1401 | ||
1391 | Note that if you want to iterate over the list, you should | 1402 | Note that if you want to iterate over the list, you should |
1392 | iterate over a copy, e.g. | 1403 | iterate over a copy, e.g. |
1393 | \code | 1404 | \code |
1394 | QValueList<int> list = mySplitter.sizes(); | 1405 | QValueList<int> list = mySplitter.sizes(); |
1395 | QValueList<int>::Iterator it = list.begin(); | 1406 | QValueList<int>::Iterator it = list.begin(); |
1396 | while( it != list.end() ) { | 1407 | while( it != list.end() ) { |
1397 | myProcessing( *it ); | 1408 | myProcessing( *it ); |
1398 | ++it; | 1409 | ++it; |
1399 | } | 1410 | } |
1400 | \endcode | 1411 | \endcode |
1401 | 1412 | ||
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 ) |
1415 | list.append( s->sizer ); | 1427 | list.append( s->sizer ); |
1416 | s = data->list.next(); | 1428 | s = data->list.next(); |
1417 | } | 1429 | } |
1418 | return list; | 1430 | return list; |
1419 | } | 1431 | } |
1420 | 1432 | ||
1421 | 1433 | ||
1422 | 1434 | ||
1423 | /*! | 1435 | /*! |
1424 | Sets the size parameters to the values given in \a list. | 1436 | Sets the size parameters to the values given in \a list. |
1425 | If the splitter is horizontal, the values set the sizes from | 1437 | If the splitter is horizontal, the values set the sizes from |
1426 | left to right. If it is vertical, the sizes are applied from | 1438 | left to right. If it is vertical, the sizes are applied from |
1427 | top to bottom. | 1439 | top to bottom. |
1428 | Extra values in \a list are ignored. | 1440 | Extra values in \a list are ignored. |
1429 | 1441 | ||
1430 | If \a list contains too few values, the result is undefined | 1442 | If \a list contains too few values, the result is undefined |
1431 | but the program will still be well-behaved. | 1443 | but the program will still be well-behaved. |
1432 | 1444 | ||
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 ) { |
1443 | s->sizer = *it; | 1455 | s->sizer = *it; |
1444 | ++it; | 1456 | ++it; |
1445 | } | 1457 | } |
1446 | s = data->list.next(); | 1458 | s = data->list.next(); |
1447 | } | 1459 | } |
1448 | doResize(); | 1460 | doResize(); |
1449 | } | 1461 | } |
1450 | 1462 | ||
1451 | 1463 | ||
1452 | /*! | 1464 | /*! |
1453 | Gets all posted child events, ensuring that the internal state of | 1465 | Gets all posted child events, ensuring that the internal state of |
1454 | the splitter is consistent. | 1466 | the splitter is consistent. |
1455 | */ | 1467 | */ |
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 | ||
1463 | /*! | 1475 | /*! |
1464 | \reimp | 1476 | \reimp |
1465 | */ | 1477 | */ |
1466 | 1478 | ||
1467 | void KDGanttMinimizeSplitter::styleChange( QStyle& old ) | 1479 | 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 |
1475 | QSplitterLayoutStruct *s = data->list.first(); | 1487 | QSplitterLayoutStruct *s = data->list.first(); |
1476 | while ( s ) { | 1488 | while ( s ) { |
1477 | if ( s->isSplitter ) | 1489 | if ( s->isSplitter ) |
1478 | s->sizer = sw; | 1490 | s->sizer = sw; |
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 |
1486 | 1498 | ||
1487 | /*! | 1499 | /*! |
1488 | Specifies the direction of the minimize buttons. | 1500 | Specifies the direction of the minimize buttons. |
1489 | If the orientation of the splitter is horizontal then with | 1501 | If the orientation of the splitter is horizontal then with |
1490 | KDGanttMinimizeSplitter::Left or KDGanttMinimizeSplitter::Right should be used, | 1502 | KDGanttMinimizeSplitter::Left or KDGanttMinimizeSplitter::Right should be used, |
1491 | otherwise either KDGanttMinimizeSplitter::Up or KDGanttMinimizeSplitter::Down | 1503 | otherwise either KDGanttMinimizeSplitter::Up or KDGanttMinimizeSplitter::Down |
1492 | should be used. | 1504 | should be used. |
1493 | */ | 1505 | */ |
1494 | void KDGanttMinimizeSplitter::setMinimizeDirection( Direction direction ) | 1506 | void KDGanttMinimizeSplitter::setMinimizeDirection( Direction direction ) |
1495 | { | 1507 | { |
1496 | _direction = direction; | 1508 | _direction = direction; |
1497 | } | 1509 | } |
1498 | 1510 | ||
1499 | /*! | 1511 | /*! |
1500 | Returns the direction of the minimize buttons. | 1512 | Returns the direction of the minimize buttons. |
1501 | */ | 1513 | */ |
1502 | KDGanttMinimizeSplitter::Direction KDGanttMinimizeSplitter::minimizeDirection() const | 1514 | KDGanttMinimizeSplitter::Direction KDGanttMinimizeSplitter::minimizeDirection() const |
1503 | { | 1515 | { |
1504 | return _direction; | 1516 | return _direction; |
1505 | } | 1517 | } |
1506 | 1518 | ||
1507 | /* | 1519 | /* |
1508 | This is a copy of qGeomCalc() in qlayoutengine.cpp which | 1520 | This is a copy of qGeomCalc() in qlayoutengine.cpp which |
1509 | unfortunately isn't exported. | 1521 | unfortunately isn't exported. |
1510 | */ | 1522 | */ |
1511 | static inline int toFixed( int i ) { return i * 256; } | 1523 | 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; |
1519 | int cHint = 0; | 1531 | int cHint = 0; |
1520 | int cMin = 0; | 1532 | int cMin = 0; |
1521 | int cMax = 0; | 1533 | int cMax = 0; |
1522 | int sumStretch = 0; | 1534 | int sumStretch = 0; |
1523 | int spacerCount = 0; | 1535 | int spacerCount = 0; |
1524 | 1536 | ||
1525 | bool wannaGrow = FALSE; // anyone who really wants to grow? | 1537 | bool wannaGrow = FALSE; // anyone who really wants to grow? |
1526 | // bool canShrink = FALSE; // anyone who could be persuaded to shrink? | 1538 | // bool canShrink = FALSE; // anyone who could be persuaded to shrink? |
1527 | 1539 | ||
1528 | int i; | 1540 | int i; |
1529 | for ( i = start; i < start + count; i++ ) { | 1541 | for ( i = start; i < start + count; i++ ) { |
1530 | chain[i].done = FALSE; | 1542 | chain[i].done = FALSE; |
1531 | cHint += chain[i].sizeHint; | 1543 | cHint += chain[i].sizeHint; |