summaryrefslogtreecommitdiffabout
path: root/microkde
authorzautrix <zautrix>2005-01-28 03:22:17 (UTC)
committer zautrix <zautrix>2005-01-28 03:22:17 (UTC)
commit94f0e8140c07696174dc3774dc2c11efad2ffa68 (patch) (unidiff)
treed95cc80e5c5221e8d9ce1cbf4b01cbf78fdf843a /microkde
parent6fb044008531ec883fc25a3ef2b43904930cfff6 (diff)
downloadkdepimpi-94f0e8140c07696174dc3774dc2c11efad2ffa68.zip
kdepimpi-94f0e8140c07696174dc3774dc2c11efad2ffa68.tar.gz
kdepimpi-94f0e8140c07696174dc3774dc2c11efad2ffa68.tar.bz2
missing config
Diffstat (limited to 'microkde') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/KDGanttMinimizeSplitter.cpp10
-rw-r--r--microkde/KDGanttMinimizeSplitter.h2
2 files changed, 12 insertions, 0 deletions
diff --git a/microkde/KDGanttMinimizeSplitter.cpp b/microkde/KDGanttMinimizeSplitter.cpp
index 567ae54..84edc0d 100644
--- a/microkde/KDGanttMinimizeSplitter.cpp
+++ b/microkde/KDGanttMinimizeSplitter.cpp
@@ -1,1636 +1,1646 @@
1/* -*- Mode: C++ -*- 1/* -*- Mode: C++ -*-
2 $Id$ 2 $Id$
3*/ 3*/
4 4
5/**************************************************************************** 5/****************************************************************************
6 ** Copyright (C) 2002-2004 Klarälvdalens Datakonsult AB. All rights reserved. 6 ** Copyright (C) 2002-2004 Klarälvdalens Datakonsult AB. All rights reserved.
7 ** 7 **
8 ** This file is part of the KDGantt library. 8 ** This file is part of the KDGantt library.
9 ** 9 **
10 ** This file may be distributed and/or modified under the terms of the 10 ** This file may be distributed and/or modified under the terms of the
11 ** GNU General Public License version 2 as published by the Free Software 11 ** GNU General Public License version 2 as published by the Free Software
12 ** Foundation and appearing in the file LICENSE.GPL included in the 12 ** Foundation and appearing in the file LICENSE.GPL included in the
13 ** packaging of this file. 13 ** packaging of this file.
14 ** 14 **
15 ** Licensees holding valid commercial KDGantt licenses may use this file in 15 ** Licensees holding valid commercial KDGantt licenses may use this file in
16 ** accordance with the KDGantt Commercial License Agreement provided with 16 ** accordance with the KDGantt Commercial License Agreement provided with
17 ** the Software. 17 ** the Software.
18 ** 18 **
19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 ** 21 **
22 ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for 22 ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for
23 ** information about KDGantt Commercial License Agreements. 23 ** information about KDGantt Commercial License Agreements.
24 ** 24 **
25 ** Contact info@klaralvdalens-datakonsult.se if any conditions of this 25 ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
26 ** licensing are not clear to you. 26 ** licensing are not clear to you.
27 ** 27 **
28 ** As a special exception, permission is given to link this program 28 ** As a special exception, permission is given to link this program
29 ** with any edition of Qt, and distribute the resulting executable, 29 ** with any edition of Qt, and distribute the resulting executable,
30 ** without including the source code for Qt in the source distribution. 30 ** without including the source code for Qt in the source distribution.
31 ** 31 **
32 **********************************************************************/ 32 **********************************************************************/
33 33
34#include "KDGanttMinimizeSplitter.h" 34#include "KDGanttMinimizeSplitter.h"
35#ifndef QT_NO_SPLITTER___ 35#ifndef QT_NO_SPLITTER___
36 36
37#include "qpainter.h" 37#include "qpainter.h"
38#include "qdrawutil.h" 38#include "qdrawutil.h"
39#include "qbitmap.h" 39#include "qbitmap.h"
40#if QT_VERSION >= 0x030000 40#if QT_VERSION >= 0x030000
41#include "qptrlist.h" 41#include "qptrlist.h"
42#include "qmemarray.h" 42#include "qmemarray.h"
43#else 43#else
44#include <qlist.h> 44#include <qlist.h>
45#include <qarray.h> 45#include <qarray.h>
46#define QPtrList QList 46#define QPtrList QList
47#define QMemArray QArray 47#define QMemArray QArray
48#endif 48#endif
49#include "qlayoutengine_p.h" 49#include "qlayoutengine_p.h"
50#include "qobjectlist.h" 50#include "qobjectlist.h"
51#include "qstyle.h" 51#include "qstyle.h"
52#include "qapplication.h" //sendPostedEvents 52#include "qapplication.h" //sendPostedEvents
53#include <qvaluelist.h> 53#include <qvaluelist.h>
54#include <qcursor.h> 54#include <qcursor.h>
55#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
64static int mouseOffset; 64static int mouseOffset;
65static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky 65static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky
66 66
67 67
68KDGanttSplitterHandle::KDGanttSplitterHandle( Qt::Orientation o, 68KDGanttSplitterHandle::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 //setMaximumHeight( 5 ); // test only 83 //setMaximumHeight( 5 ); // test only
84} 84}
85 85
86QSize KDGanttSplitterHandle::sizeHint() const 86QSize KDGanttSplitterHandle::sizeHint() const
87{ 87{
88 return mSizeHint; 88 return mSizeHint;
89} 89}
90 90
91void KDGanttSplitterHandle::setOrientation( Qt::Orientation o ) 91void KDGanttSplitterHandle::setOrientation( Qt::Orientation o )
92{ 92{
93 orient = o; 93 orient = o;
94#ifndef QT_NO_CURSOR 94#ifndef QT_NO_CURSOR
95 if ( o == KDGanttMinimizeSplitter::Horizontal ) 95 if ( o == KDGanttMinimizeSplitter::Horizontal )
96 setCursor( splitHCursor ); 96 setCursor( splitHCursor );
97 else 97 else
98 setCursor( splitVCursor ); 98 setCursor( splitVCursor );
99#endif 99#endif
100} 100}
101 101
102 102
103void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e ) 103void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e )
104{ 104{
105 updateCursor( e->pos() ); 105 updateCursor( e->pos() );
106 if ( !(e->state()&LeftButton) ) 106 if ( !(e->state()&LeftButton) )
107 return; 107 return;
108 108
109 if ( _activeButton != 0) 109 if ( _activeButton != 0)
110 return; 110 return;
111 111
112 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) 112 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos()))
113 - mouseOffset; 113 - mouseOffset;
114 if ( true /*opaque()*/ ) { 114 if ( true /*opaque()*/ ) {
115 s->moveSplitter( pos, id() ); 115 s->moveSplitter( pos, id() );
116 } else { 116 } else {
117 int min = pos; int max = pos; 117 int min = pos; int max = pos;
118 s->getRange( id(), &min, &max ); 118 s->getRange( id(), &min, &max );
119 s->setRubberband( QMAX( min, QMIN(max, pos ))); 119 s->setRubberband( QMAX( min, QMIN(max, pos )));
120 } 120 }
121 _collapsed = false; 121 _collapsed = false;
122} 122}
123 123
124void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e ) 124void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e )
125{ 125{
126 if ( e->button() == LeftButton ) { 126 if ( e->button() == LeftButton ) {
127 _activeButton = onButton( e->pos() ); 127 _activeButton = onButton( e->pos() );
128 mouseOffset = s->pick(e->pos()); 128 mouseOffset = s->pick(e->pos());
129 if ( _activeButton != 0) 129 if ( _activeButton != 0)
130 repaint(); 130 repaint();
131 updateCursor( e->pos() ); 131 updateCursor( e->pos() );
132 } 132 }
133} 133}
134 134
135void KDGanttSplitterHandle::updateCursor( const QPoint& p) 135void KDGanttSplitterHandle::updateCursor( const QPoint& p)
136{ 136{
137 if ( onButton( p ) != 0 ) { 137 if ( onButton( p ) != 0 ) {
138 setCursor( arrowCursor ); 138 setCursor( arrowCursor );
139 } 139 }
140 else { 140 else {
141 if ( orient == KDGanttMinimizeSplitter::Horizontal ) 141 if ( orient == KDGanttMinimizeSplitter::Horizontal )
142 setCursor( splitHCursor ); 142 setCursor( splitHCursor );
143 else 143 else
144 setCursor( splitVCursor ); 144 setCursor( splitVCursor );
145 } 145 }
146} 146}
147void KDGanttSplitterHandle::toggle() 147void KDGanttSplitterHandle::toggle()
148{ 148{
149 int pos; 149 int pos;
150 int min, max; 150 int min, max;
151 if ( !_collapsed ) { 151 if ( !_collapsed ) {
152 s->expandPos( id(), &min, &max ); 152 s->expandPos( id(), &min, &max );
153 if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left 153 if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left
154 || s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { 154 || s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) {
155 pos = min; 155 pos = min;
156 } 156 }
157 else { 157 else {
158 pos = max; 158 pos = max;
159 } 159 }
160 160
161 _origPos = s->pick(mapToParent( QPoint( 0,0 ) )); 161 _origPos = s->pick(mapToParent( QPoint( 0,0 ) ));
162 s->moveSplitter( pos, id() ); 162 s->moveSplitter( pos, id() );
163 _collapsed = true; 163 _collapsed = true;
164 } 164 }
165 else { 165 else {
166 s->moveSplitter( _origPos, id() ); 166 s->moveSplitter( _origPos, id() );
167 _collapsed = false; 167 _collapsed = false;
168 } 168 }
169 repaint();
169} 170}
170 171
171void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) 172void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e )
172{ 173{
173 if ( _activeButton != 0 ) { 174 if ( _activeButton != 0 ) {
174 if ( onButton( e->pos() ) == _activeButton ) 175 if ( onButton( e->pos() ) == _activeButton )
175 { 176 {
176 toggle(); 177 toggle();
177 } 178 }
178 _activeButton = 0; 179 _activeButton = 0;
179 updateCursor( e->pos() ); 180 updateCursor( e->pos() );
180 } 181 }
181 else { 182 else {
182 if ( !opaque() && e->button() == LeftButton ) { 183 if ( !opaque() && e->button() == LeftButton ) {
183 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) 184 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos()))
184 - mouseOffset; 185 - mouseOffset;
185 s->setRubberband( -1 ); 186 s->setRubberband( -1 );
186 s->moveSplitter( pos, id() ); 187 s->moveSplitter( pos, id() );
187 } 188 }
188 } 189 }
189 repaint(); 190 repaint();
190} 191}
191 192
192int KDGanttSplitterHandle::onButton( const QPoint& p ) 193int KDGanttSplitterHandle::onButton( const QPoint& p )
193{ 194{
194 QValueList<QPointArray> list = buttonRegions(); 195 QValueList<QPointArray> list = buttonRegions();
195 int index = 1; 196 int index = 1;
196 int add = 12; 197 int add = 12;
197 for( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { 198 for( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) {
198 QRect rect = (*it).boundingRect(); 199 QRect rect = (*it).boundingRect();
199 rect.setLeft( rect.left()- add ); 200 rect.setLeft( rect.left()- add );
200 rect.setRight( rect.right() + add); 201 rect.setRight( rect.right() + add);
201 rect.setTop( rect.top()- add ); 202 rect.setTop( rect.top()- add );
202 rect.setBottom( rect.bottom() + add); 203 rect.setBottom( rect.bottom() + add);
203 if ( rect.contains( p ) ) { 204 if ( rect.contains( p ) ) {
204 return index; 205 return index;
205 } 206 }
206 index++; 207 index++;
207 } 208 }
208 return 0; 209 return 0;
209} 210}
210 211
211 212
212QValueList<QPointArray> KDGanttSplitterHandle::buttonRegions() 213QValueList<QPointArray> KDGanttSplitterHandle::buttonRegions()
213{ 214{
214 QValueList<QPointArray> list; 215 QValueList<QPointArray> list;
215 216
216 int sw = 8; 217 int sw = 8;
217 int yyy = 1; 218 int yyy = 1;
218 int xxx = 1; 219 int xxx = 1;
219 int voffset[] = { (int) -sw*3, (int) sw*3 }; 220 int voffset[] = { (int) -sw*3, (int) sw*3 };
220 for ( int i = 0; i < 2; i++ ) { 221 for ( int i = 0; i < 2; i++ ) {
221 QPointArray arr; 222 QPointArray arr;
222 if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right || 223 if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ||
223 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left) { 224 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left) {
224 int mid = height()/2 + voffset[i]; 225 int mid = height()/2 + voffset[i];
225 arr.setPoints( 3, 226 arr.setPoints( 3,
226 1-xxx, mid - sw + 4, 227 1-xxx, mid - sw + 4,
227 sw-3-xxx, mid, 228 sw-3-xxx, mid,
228 1-xxx, mid + sw -4); 229 1-xxx, mid + sw -4);
229 } 230 }
230 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left || 231 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left ||
231 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { 232 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) {
232 int mid = height()/2 + voffset[i]; 233 int mid = height()/2 + voffset[i];
233 arr.setPoints( 3, 234 arr.setPoints( 3,
234 sw-4, mid - sw + 4, 235 sw-4, mid - sw + 4,
235 0, mid, 236 0, mid,
236 sw-4, mid + sw - 4); 237 sw-4, mid + sw - 4);
237 } 238 }
238 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up || 239 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up ||
239 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down) { 240 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down) {
240 int mid = width()/2 + voffset[i]; 241 int mid = width()/2 + voffset[i];
241 arr.setPoints( 3, 242 arr.setPoints( 3,
242 mid - sw + 4, sw-4, 243 mid - sw + 4, sw-4,
243 mid, 0, 244 mid, 0,
244 mid + sw - 4, sw-4 ); 245 mid + sw - 4, sw-4 );
245 } 246 }
246 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down || 247 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down ||
247 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { 248 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) {
248 int mid = width()/2 + voffset[i]; 249 int mid = width()/2 + voffset[i];
249 arr.setPoints( 3, 250 arr.setPoints( 3,
250 mid - sw + 4, 1-yyy, 251 mid - sw + 4, 1-yyy,
251 mid, sw-3-yyy, 252 mid, sw-3-yyy,
252 mid + sw -4, 1-yyy); 253 mid + sw -4, 1-yyy);
253 } 254 }
254 list.append( arr ); 255 list.append( arr );
255 } 256 }
256 return list; 257 return list;
257} 258}
258 259
259void KDGanttSplitterHandle::paintEvent( QPaintEvent * ) 260void KDGanttSplitterHandle::paintEvent( QPaintEvent * )
260{ 261{
261 QPixmap buffer( size() ); 262 QPixmap buffer( size() );
262 QPainter p( &buffer ); 263 QPainter p( &buffer );
263 264
264 //LR 265 //LR
265 // Draw the splitter rectangle 266 // Draw the splitter rectangle
266 p.setBrush( colorGroup().background() ); 267 p.setBrush( colorGroup().background() );
267 p.setPen( colorGroup().foreground() ); 268 p.setPen( colorGroup().foreground() );
268 //p.drawRect( rect() ); 269 //p.drawRect( rect() );
269 buffer.fill( colorGroup().background() ); 270 buffer.fill( colorGroup().background() );
270 //buffer.fill( backgroundColor() ); 271 //buffer.fill( backgroundColor() );
271 // parentWidget()->style().drawPrimitive( QStyle::PE_Panel, &p, rect(), parentWidget()->colorGroup()); 272 // parentWidget()->style().drawPrimitive( QStyle::PE_Panel, &p, rect(), parentWidget()->colorGroup());
272 273
273 int sw = 8; // Hardcoded, given I didn't use styles anymore, I didn't like to use their size 274 int sw = 8; // Hardcoded, given I didn't use styles anymore, I didn't like to use their size
274 275
275 // arrow color 276 // arrow color
276 QColor col; 277 QColor col;
277 if ( _activeButton ) 278 if ( _activeButton )
278 col = colorGroup().background().dark( 250 ); 279 col = colorGroup().background().dark( 250 );
279 else 280 else
280 col = colorGroup().background().dark( 150 ); 281 col = colorGroup().background().dark( 150 );
281 //QColor col = backgroundColor().dark( 130 ); 282 //QColor col = backgroundColor().dark( 130 );
282 p.setBrush( col ); 283 p.setBrush( col );
283 p.setPen( col ); 284 p.setPen( col );
284 285
285 QValueList<QPointArray> list = buttonRegions(); 286 QValueList<QPointArray> list = buttonRegions();
286 int index = 1; 287 int index = 1;
287 if ( mUseOffset ) 288 if ( mUseOffset )
288 p.translate( 0, 1 ); 289 p.translate( 0, 1 );
289 for ( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { 290 for ( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) {
290 if ( index == _activeButton ) { 291 if ( index == _activeButton ) {
291 292
292 /* 293 /*
293 if ( ! _collapsed ) { 294 if ( ! _collapsed ) {
294 p.save(); 295 p.save();
295 // p.translate( parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftHorizontal ), 296 // p.translate( parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftHorizontal ),
296 // parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftVertical ) ); 297 // parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftVertical ) );
297 p.translate( -1, 0 ); 298 p.translate( -1, 0 );
298 p.drawPolygon( *it, true ); 299 p.drawPolygon( *it, true );
299 p.restore(); } else 300 p.restore(); } else
300 */ 301 */
301 p.drawPolygon( *it, true ); 302 p.drawPolygon( *it, true );
302 303
303 } 304 }
304 else { 305 else {
305 /* 306 /*
306 if ( ! _collapsed ) { 307 if ( ! _collapsed ) {
307 p.save(); 308 p.save();
308 p.translate( -1, 0 ); 309 p.translate( -1, 0 );
309 p.drawPolygon( *it, true ); 310 p.drawPolygon( *it, true );
310 p.restore(); 311 p.restore();
311 } else 312 } else
312 */ 313 */
313 p.drawPolygon( *it, true ); 314 p.drawPolygon( *it, true );
314 315
315 } 316 }
316 index++; 317 index++;
317 } 318 }
318 319
319 // Draw the lines between the arrows 320 // Draw the lines between the arrows
320 if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left || 321 if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left ||
321 s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { 322 s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) {
322 int mid = height()/2; 323 int mid = height()/2;
323 p.drawLine ( 1, mid - sw, 1, mid + sw ); 324 p.drawLine ( 1, mid - sw, 1, mid + sw );
324 p.drawLine ( 3, mid - sw, 3, mid + sw ); 325 p.drawLine ( 3, mid - sw, 3, mid + sw );
325 } 326 }
326 else if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Up || 327 else if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Up ||
327 s->minimizeDirection() == KDGanttMinimizeSplitter::Down ) { 328 s->minimizeDirection() == KDGanttMinimizeSplitter::Down ) {
328 int mid = width()/2; 329 int mid = width()/2;
329 p.drawLine( mid -sw, 1, mid +sw, 1 ); 330 p.drawLine( mid -sw, 1, mid +sw, 1 );
330 p.drawLine( mid -sw, 3, mid +sw, 3 ); 331 p.drawLine( mid -sw, 3, mid +sw, 3 );
331 } 332 }
332 bitBlt( this, 0, 0, &buffer ); 333 bitBlt( this, 0, 0, &buffer );
333 334
334} 335}
335#endif 336#endif
336 337
337class QSplitterLayoutStruct 338class QSplitterLayoutStruct
338{ 339{
339public: 340public:
340 KDGanttMinimizeSplitter::ResizeMode mode; 341 KDGanttMinimizeSplitter::ResizeMode mode;
341 QCOORD sizer; 342 QCOORD sizer;
342 bool isSplitter; 343 bool isSplitter;
343 QWidget *wid; 344 QWidget *wid;
344}; 345};
345 346
346class QSplitterData 347class QSplitterData
347{ 348{
348public: 349public:
349 QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {} 350 QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {}
350 351
351 QPtrList<QSplitterLayoutStruct> list; 352 QPtrList<QSplitterLayoutStruct> list;
352 bool opaque; 353 bool opaque;
353 bool firstShow; 354 bool firstShow;
354}; 355};
355 356
356void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, 357void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos,
357 int space, int spacer ); 358 int space, int spacer );
358#endif // DOXYGEN_SKIP_INTERNAL 359#endif // DOXYGEN_SKIP_INTERNAL
359 360
360 361
361/*! 362/*!
362 \class KDGanttMinimizeSplitter KDGanttMinimizeSplitter.h 363 \class KDGanttMinimizeSplitter KDGanttMinimizeSplitter.h
363 \brief The KDGanttMinimizeSplitter class implements a splitter 364 \brief The KDGanttMinimizeSplitter class implements a splitter
364 widget with minimize buttons. 365 widget with minimize buttons.
365 366
366 This class (and its documentation) is largely a copy of Qt's 367 This class (and its documentation) is largely a copy of Qt's
367 QSplitter; the copying was necessary because QSplitter is not 368 QSplitter; the copying was necessary because QSplitter is not
368 extensible at all. QSplitter and its documentation are licensed 369 extensible at all. QSplitter and its documentation are licensed
369 according to the GPL and the Qt Professional License (if you hold 370 according to the GPL and the Qt Professional License (if you hold
370 such a license) and are (C) Trolltech AS. 371 such a license) and are (C) Trolltech AS.
371 372
372 A splitter lets the user control the size of child widgets by 373 A splitter lets the user control the size of child widgets by
373 dragging the boundary between the children. Any number of widgets 374 dragging the boundary between the children. Any number of widgets
374 may be controlled. 375 may be controlled.
375 376
376 To show a QListBox, a QListView and a QTextEdit side by side: 377 To show a QListBox, a QListView and a QTextEdit side by side:
377 378
378 \code 379 \code
379 KDGanttMinimizeSplitter *split = new KDGanttMinimizeSplitter( parent ); 380 KDGanttMinimizeSplitter *split = new KDGanttMinimizeSplitter( parent );
380 QListBox *lb = new QListBox( split ); 381 QListBox *lb = new QListBox( split );
381 QListView *lv = new QListView( split ); 382 QListView *lv = new QListView( split );
382 QTextEdit *ed = new QTextEdit( split ); 383 QTextEdit *ed = new QTextEdit( split );
383 \endcode 384 \endcode
384 385
385 In KDGanttMinimizeSplitter, the boundary can be either horizontal or 386 In KDGanttMinimizeSplitter, the boundary can be either horizontal or
386 vertical. The default is horizontal (the children are side by side) 387 vertical. The default is horizontal (the children are side by side)
387 but you can use setOrientation( QSplitter::Vertical ) to set it to 388 but you can use setOrientation( QSplitter::Vertical ) to set it to
388 vertical. 389 vertical.
389 390
390 Use setResizeMode() to specify 391 Use setResizeMode() to specify
391 that a widget should keep its size when the splitter is resized. 392 that a widget should keep its size when the splitter is resized.
392 393
393 Although KDGanttMinimizeSplitter normally resizes the children only 394 Although KDGanttMinimizeSplitter normally resizes the children only
394 at the end of a resize operation, if you call setOpaqueResize( TRUE 395 at the end of a resize operation, if you call setOpaqueResize( TRUE
395 ) the widgets are resized as often as possible. 396 ) the widgets are resized as often as possible.
396 397
397 The initial distribution of size between the widgets is determined 398 The initial distribution of size between the widgets is determined
398 by the initial size of each widget. You can also use setSizes() to 399 by the initial size of each widget. You can also use setSizes() to
399 set the sizes of all the widgets. The function sizes() returns the 400 set the sizes of all the widgets. The function sizes() returns the
400 sizes set by the user. 401 sizes set by the user.
401 402
402 If you hide() a child, its space will be distributed among the other 403 If you hide() a child, its space will be distributed among the other
403 children. It will be reinstated when you show() it again. It is also 404 children. It will be reinstated when you show() it again. It is also
404 possible to reorder the widgets within the splitter using 405 possible to reorder the widgets within the splitter using
405 moveToFirst() and moveToLast(). 406 moveToFirst() and moveToLast().
406*/ 407*/
407 408
408 409
409 410
410static QSize minSize( const QWidget* /*w*/ ) 411static QSize minSize( const QWidget* /*w*/ )
411{ 412{
412 return QSize(0,0); 413 return QSize(0,0);
413} 414}
414 415
415// This is the original version of minSize 416// This is the original version of minSize
416static QSize minSizeHint( const QWidget* w ) 417static QSize minSizeHint( const QWidget* w )
417{ 418{
418 QSize min = w->minimumSize(); 419 QSize min = w->minimumSize();
419 QSize s; 420 QSize s;
420 if ( min.height() <= 0 || min.width() <= 0 ) 421 if ( min.height() <= 0 || min.width() <= 0 )
421 s = w->minimumSizeHint(); 422 s = w->minimumSizeHint();
422 if ( min.height() > 0 ) 423 if ( min.height() > 0 )
423 s.setHeight( min.height() ); 424 s.setHeight( min.height() );
424 if ( min.width() > 0 ) 425 if ( min.width() > 0 )
425 s.setWidth( min.width() ); 426 s.setWidth( min.width() );
426 return s.expandedTo(QSize(0,0)); 427 return s.expandedTo(QSize(0,0));
427} 428}
428 429
429 430
430 431
431/*! 432/*!
432 Constructs a horizontal splitter with the \a parent and \a 433 Constructs a horizontal splitter with the \a parent and \a
433 name arguments being passed on to the QFrame constructor. 434 name arguments being passed on to the QFrame constructor.
434*/ 435*/
435KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *name ) 436KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *name )
436 :QFrame(parent,name,WPaintUnclipped) 437 :QFrame(parent,name,WPaintUnclipped)
437{ 438{
438 mFirstHandle = 0; 439 mFirstHandle = 0;
439#if QT_VERSION >= 232 440#if QT_VERSION >= 232
440 orient = Horizontal; 441 orient = Horizontal;
441 init(); 442 init();
442#endif 443#endif
443} 444}
444 445
445/*! 446/*!
446 Constructs a splitter with orientation \a o with the \a parent 447 Constructs a splitter with orientation \a o with the \a parent
447 and \a name arguments being passed on to the QFrame constructor. 448 and \a name arguments being passed on to the QFrame constructor.
448*/ 449*/
449KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Orientation o, QWidget *parent, const char *name ) 450KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Orientation o, QWidget *parent, const char *name )
450 :QFrame(parent,name,WPaintUnclipped) 451 :QFrame(parent,name,WPaintUnclipped)
451{ 452{
452 mFirstHandle = 0; 453 mFirstHandle = 0;
453#if QT_VERSION >= 232 454#if QT_VERSION >= 232
454 orient = o; 455 orient = o;
455 init(); 456 init();
456#endif 457#endif
457} 458}
458 459
459/*! 460/*!
460 Destroys the splitter and any children. 461 Destroys the splitter and any children.
461*/ 462*/
462KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter() 463KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter()
463{ 464{
464#if QT_VERSION >= 232 465#if QT_VERSION >= 232
465 data->list.setAutoDelete( TRUE ); 466 data->list.setAutoDelete( TRUE );
466 delete data; 467 delete data;
467#endif 468#endif
468} 469}
469 470
470 471
471#if QT_VERSION >= 232 472#if QT_VERSION >= 232
472void KDGanttMinimizeSplitter::init() 473void KDGanttMinimizeSplitter::init()
473{ 474{
474 data = new QSplitterData; 475 data = new QSplitterData;
475 if ( orient == Horizontal ) 476 if ( orient == Horizontal )
476 setSizePolicy( QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum) ); 477 setSizePolicy( QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum) );
477 else 478 else
478 setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding) ); 479 setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding) );
479} 480}
480#endif 481#endif
481 482
482 483
484void KDGanttMinimizeSplitter::toggle()
485{
486 if ( mFirstHandle )
487 mFirstHandle->toggle();
488 else
489 qDebug("KDGanttMinimizeSplitter::toggle::sorry, handle not available ");
490
491}
492
483 493
484/*! 494/*!
485 \brief the orientation of the splitter 495 \brief the orientation of the splitter
486 496
487 By default the orientation is horizontal (the widgets are side by side). 497 By default the orientation is horizontal (the widgets are side by side).
488 The possible orientations are Qt:Vertical and Qt::Horizontal (the default). 498 The possible orientations are Qt:Vertical and Qt::Horizontal (the default).
489*/ 499*/
490void KDGanttMinimizeSplitter::setOrientation( Orientation o ) 500void KDGanttMinimizeSplitter::setOrientation( Orientation o )
491{ 501{
492#if QT_VERSION >= 232 502#if QT_VERSION >= 232
493 if ( orient == o ) 503 if ( orient == o )
494 return; 504 return;
495 orient = o; 505 orient = o;
496 506
497 if ( orient == Horizontal ) 507 if ( orient == Horizontal )
498 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); 508 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
499 else 509 else
500 setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); 510 setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) );
501 511
502 QSplitterLayoutStruct *s = data->list.first(); 512 QSplitterLayoutStruct *s = data->list.first();
503 while ( s ) { 513 while ( s ) {
504 if ( s->isSplitter ) 514 if ( s->isSplitter )
505 ((KDGanttSplitterHandle*)s->wid)->setOrientation( o ); 515 ((KDGanttSplitterHandle*)s->wid)->setOrientation( o );
506 s = data->list.next(); // ### next at end of loop, no iterator 516 s = data->list.next(); // ### next at end of loop, no iterator
507 } 517 }
508 recalc( isVisible() ); 518 recalc( isVisible() );
509#endif 519#endif
510} 520}
511 521
512 522
513#if QT_VERSION >= 232 523#if QT_VERSION >= 232
514/*! 524/*!
515 \reimp 525 \reimp
516*/ 526*/
517void KDGanttMinimizeSplitter::resizeEvent( QResizeEvent * ) 527void KDGanttMinimizeSplitter::resizeEvent( QResizeEvent * )
518{ 528{
519 doResize(); 529 doResize();
520} 530}
521 531
522 532
523/* 533/*
524 Inserts the widget \a w at the end (or at the beginning if \a first 534 Inserts the widget \a w at the end (or at the beginning if \a first
525 is TRUE) of the splitter's list of widgets. 535 is TRUE) of the splitter's list of widgets.
526 536
527 It is the responsibility of the caller of this function to make sure 537 It is the responsibility of the caller of this function to make sure
528 that \a w is not already in the splitter and to call recalcId if 538 that \a w is not already in the splitter and to call recalcId if
529 needed. (If \a first is TRUE, then recalcId is very probably 539 needed. (If \a first is TRUE, then recalcId is very probably
530 needed.) 540 needed.)
531*/ 541*/
532QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool first ) 542QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool first )
533{ 543{
534 QSplitterLayoutStruct *s; 544 QSplitterLayoutStruct *s;
535 KDGanttSplitterHandle *newHandle = 0; 545 KDGanttSplitterHandle *newHandle = 0;
536 if ( data->list.count() > 0 ) { 546 if ( data->list.count() > 0 ) {
537 s = new QSplitterLayoutStruct; 547 s = new QSplitterLayoutStruct;
538 s->mode = KeepSize; 548 s->mode = KeepSize;
539 QString tmp = "qt_splithandle_"; 549 QString tmp = "qt_splithandle_";
540 tmp += w->name(); 550 tmp += w->name();
541 newHandle = new KDGanttSplitterHandle( orientation(), this, tmp.latin1() ); 551 newHandle = new KDGanttSplitterHandle( orientation(), this, tmp.latin1() );
542 if ( ! mFirstHandle ) 552 if ( ! mFirstHandle )
543 mFirstHandle = newHandle; 553 mFirstHandle = newHandle;
544 s->wid = newHandle; 554 s->wid = newHandle;
545 newHandle->setId(data->list.count()); 555 newHandle->setId(data->list.count());
546 s->isSplitter = TRUE; 556 s->isSplitter = TRUE;
547 s->sizer = pick( newHandle->sizeHint() ); 557 s->sizer = pick( newHandle->sizeHint() );
548 if ( first ) 558 if ( first )
549 data->list.insert( 0, s ); 559 data->list.insert( 0, s );
550 else 560 else
551 data->list.append( s ); 561 data->list.append( s );
552 } 562 }
553 s = new QSplitterLayoutStruct; 563 s = new QSplitterLayoutStruct;
554 s->mode = Stretch; 564 s->mode = Stretch;
555 s->wid = w; 565 s->wid = w;
556 if ( !testWState( WState_Resized ) && w->sizeHint().isValid() ) 566 if ( !testWState( WState_Resized ) && w->sizeHint().isValid() )
557 s->sizer = pick( w->sizeHint() ); 567 s->sizer = pick( w->sizeHint() );
558 else 568 else
559 s->sizer = pick( w->size() ); 569 s->sizer = pick( w->size() );
560 s->isSplitter = FALSE; 570 s->isSplitter = FALSE;
561 if ( first ) 571 if ( first )
562 data->list.insert( 0, s ); 572 data->list.insert( 0, s );
563 else 573 else
564 data->list.append( s ); 574 data->list.append( s );
565 if ( newHandle && isVisible() ) 575 if ( newHandle && isVisible() )
566 newHandle->show(); //will trigger sending of post events 576 newHandle->show(); //will trigger sending of post events
567 return s; 577 return s;
568} 578}
569 579
570 580
571/*! 581/*!
572 Tells the splitter that a child widget has been inserted or removed. 582 Tells the splitter that a child widget has been inserted or removed.
573 The event is passed in \a c. 583 The event is passed in \a c.
574*/ 584*/
575void KDGanttMinimizeSplitter::childEvent( QChildEvent *c ) 585void KDGanttMinimizeSplitter::childEvent( QChildEvent *c )
576{ 586{
577 if ( c->type() == QEvent::ChildInserted ) { 587 if ( c->type() == QEvent::ChildInserted ) {
578 if ( !c->child()->isWidgetType() ) 588 if ( !c->child()->isWidgetType() )
579 return; 589 return;
580 590
581 if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) ) 591 if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) )
582 return; 592 return;
583 593
584 QSplitterLayoutStruct *s = data->list.first(); 594 QSplitterLayoutStruct *s = data->list.first();
585 while ( s ) { 595 while ( s ) {
586 if ( s->wid == c->child() ) 596 if ( s->wid == c->child() )
587 return; 597 return;
588 s = data->list.next(); 598 s = data->list.next();
589 } 599 }
590 addWidget( (QWidget*)c->child() ); 600 addWidget( (QWidget*)c->child() );
591 recalc( isVisible() ); 601 recalc( isVisible() );
592 602
593 } else if ( c->type() == QEvent::ChildRemoved ) { 603 } else if ( c->type() == QEvent::ChildRemoved ) {
594 QSplitterLayoutStruct *p = 0; 604 QSplitterLayoutStruct *p = 0;
595 if ( data->list.count() > 1 ) 605 if ( data->list.count() > 1 )
596 p = data->list.at(1); //remove handle _after_ first widget. 606 p = data->list.at(1); //remove handle _after_ first widget.
597 QSplitterLayoutStruct *s = data->list.first(); 607 QSplitterLayoutStruct *s = data->list.first();
598 while ( s ) { 608 while ( s ) {
599 if ( s->wid == c->child() ) { 609 if ( s->wid == c->child() ) {
600 data->list.removeRef( s ); 610 data->list.removeRef( s );
601 delete s; 611 delete s;
602 if ( p && p->isSplitter ) { 612 if ( p && p->isSplitter ) {
603 data->list.removeRef( p ); 613 data->list.removeRef( p );
604 delete p->wid; //will call childEvent 614 delete p->wid; //will call childEvent
605 delete p; 615 delete p;
606 } 616 }
607 recalcId(); 617 recalcId();
608 doResize(); 618 doResize();
609 return; 619 return;
610 } 620 }
611 p = s; 621 p = s;
612 s = data->list.next(); 622 s = data->list.next();
613 } 623 }
614 } 624 }
615} 625}
616 626
617 627
618/*! 628/*!
619 Shows a rubber band at position \a p. If \a p is negative, the 629 Shows a rubber band at position \a p. If \a p is negative, the
620 rubber band is removed. 630 rubber band is removed.
621*/ 631*/
622void KDGanttMinimizeSplitter::setRubberband( int p ) 632void KDGanttMinimizeSplitter::setRubberband( int p )
623{ 633{
624 QPainter paint( this ); 634 QPainter paint( this );
625 paint.setPen( gray ); 635 paint.setPen( gray );
626 paint.setBrush( gray ); 636 paint.setBrush( gray );
627 paint.setRasterOp( XorROP ); 637 paint.setRasterOp( XorROP );
628 QRect r = contentsRect(); 638 QRect r = contentsRect();
629 const int rBord = 3; //Themable???? 639 const int rBord = 3; //Themable????
630#if QT_VERSION >= 0x030000 640#if QT_VERSION >= 0x030000
631 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); 641 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this);
632#else 642#else
633 int sw = style().splitterWidth(); 643 int sw = style().splitterWidth();
634#endif 644#endif
635 if ( orient == Horizontal ) { 645 if ( orient == Horizontal ) {
636 if ( opaqueOldPos >= 0 ) 646 if ( opaqueOldPos >= 0 )
637 paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(), 647 paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(),
638 2*rBord, r.height() ); 648 2*rBord, r.height() );
639 if ( p >= 0 ) 649 if ( p >= 0 )
640 paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() ); 650 paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() );
641 } else { 651 } else {
642 if ( opaqueOldPos >= 0 ) 652 if ( opaqueOldPos >= 0 )
643 paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord, 653 paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord,
644 r.width(), 2*rBord ); 654 r.width(), 2*rBord );
645 if ( p >= 0 ) 655 if ( p >= 0 )
646 paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord ); 656 paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord );
647 } 657 }
648 opaqueOldPos = p; 658 opaqueOldPos = p;
649} 659}
650 660
651 661
652/*! \reimp */ 662/*! \reimp */
653bool KDGanttMinimizeSplitter::event( QEvent *e ) 663bool KDGanttMinimizeSplitter::event( QEvent *e )
654{ 664{
655 if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) { 665 if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) {
656 recalc( isVisible() ); 666 recalc( isVisible() );
657 if ( e->type() == QEvent::Show ) 667 if ( e->type() == QEvent::Show )
658 data->firstShow = FALSE; 668 data->firstShow = FALSE;
659 } 669 }
660 return QWidget::event( e ); 670 return QWidget::event( e );
661} 671}
662 672
663 673
664/*! 674/*!
665 \obsolete 675 \obsolete
666 676
667 Draws the splitter handle in the rectangle described by \a x, \a y, 677 Draws the splitter handle in the rectangle described by \a x, \a y,
668 \a w, \a h using painter \a p. 678 \a w, \a h using painter \a p.
669 \sa QStyle::drawPrimitive() 679 \sa QStyle::drawPrimitive()
670*/ 680*/
671void KDGanttMinimizeSplitter::drawSplitter( QPainter *p, 681void KDGanttMinimizeSplitter::drawSplitter( QPainter *p,
672 QCOORD x, QCOORD y, QCOORD w, QCOORD h ) 682 QCOORD x, QCOORD y, QCOORD w, QCOORD h )
673{ 683{
674#if 0 684#if 0
675 // LR 685 // LR
676 style().drawPrimitive(QStyle::PE_Splitter, p, QRect(x, y, w, h), colorGroup(), 686 style().drawPrimitive(QStyle::PE_Splitter, p, QRect(x, y, w, h), colorGroup(),
677 (orientation() == Qt::Horizontal ? 687 (orientation() == Qt::Horizontal ?
678 QStyle::Style_Horizontal : 0)); 688 QStyle::Style_Horizontal : 0));
679#endif 689#endif
680} 690}
681 691
682 692
683/*! 693/*!
684 Returns the id of the splitter to the right of or below the widget \a w, 694 Returns the id of the splitter to the right of or below the widget \a w,
685 or 0 if there is no such splitter 695 or 0 if there is no such splitter
686 (i.e. it is either not in this KDGanttMinimizeSplitter or it is at the end). 696 (i.e. it is either not in this KDGanttMinimizeSplitter or it is at the end).
687*/ 697*/
688int KDGanttMinimizeSplitter::idAfter( QWidget* w ) const 698int KDGanttMinimizeSplitter::idAfter( QWidget* w ) const
689{ 699{
690 QSplitterLayoutStruct *s = data->list.first(); 700 QSplitterLayoutStruct *s = data->list.first();
691 bool seen_w = FALSE; 701 bool seen_w = FALSE;
692 while ( s ) { 702 while ( s ) {
693 if ( s->isSplitter && seen_w ) 703 if ( s->isSplitter && seen_w )
694 return data->list.at(); 704 return data->list.at();
695 if ( !s->isSplitter && s->wid == w ) 705 if ( !s->isSplitter && s->wid == w )
696 seen_w = TRUE; 706 seen_w = TRUE;
697 s = data->list.next(); 707 s = data->list.next();
698 } 708 }
699 return 0; 709 return 0;
700} 710}
701 711
702 712
703/*! 713/*!
704 Moves the left/top edge of the splitter handle with id \a id as 714 Moves the left/top edge of the splitter handle with id \a id as
705 close as possible to position \a p, which is the distance from the 715 close as possible to position \a p, which is the distance from the
706 left (or top) edge of the widget. 716 left (or top) edge of the widget.
707 717
708 For Arabic and Hebrew the layout is reversed, and using this 718 For Arabic and Hebrew the layout is reversed, and using this
709 function to set the position of the splitter might lead to 719 function to set the position of the splitter might lead to
710 unexpected results, since in Arabic and Hebrew the position of 720 unexpected results, since in Arabic and Hebrew the position of
711 splitter one is to the left of the position of splitter zero. 721 splitter one is to the left of the position of splitter zero.
712 722
713 \sa idAfter() 723 \sa idAfter()
714*/ 724*/
715void KDGanttMinimizeSplitter::moveSplitter( QCOORD p, int id ) 725void KDGanttMinimizeSplitter::moveSplitter( QCOORD p, int id )
716{ 726{
717 p = adjustPos( p, id ); 727 p = adjustPos( p, id );
718 QSplitterLayoutStruct *s = data->list.at(id); 728 QSplitterLayoutStruct *s = data->list.at(id);
719 int oldP = orient == Horizontal ? s->wid->x() : s->wid->y(); 729 int oldP = orient == Horizontal ? s->wid->x() : s->wid->y();
720 bool upLeft; 730 bool upLeft;
721 if ( false && orient == Horizontal ) { 731 if ( false && orient == Horizontal ) {
722 p += s->wid->width(); 732 p += s->wid->width();
723 upLeft = p > oldP; 733 upLeft = p > oldP;
724 } else 734 } else
725 upLeft = p < oldP; 735 upLeft = p < oldP;
726 736
727 moveAfter( p, id, upLeft ); 737 moveAfter( p, id, upLeft );
728 moveBefore( p-1, id-1, upLeft ); 738 moveBefore( p-1, id-1, upLeft );
729 739
730 storeSizes(); 740 storeSizes();
731} 741}
732 742
733 743
734void KDGanttMinimizeSplitter::setG( QWidget *w, int p, int s, bool isSplitter ) 744void KDGanttMinimizeSplitter::setG( QWidget *w, int p, int s, bool isSplitter )
735{ 745{
736 if ( orient == Horizontal ) { 746 if ( orient == Horizontal ) {
737 if ( false && orient == Horizontal && !isSplitter ) 747 if ( false && orient == Horizontal && !isSplitter )
738 p = contentsRect().width() - p - s; 748 p = contentsRect().width() - p - s;
739 w->setGeometry( p, contentsRect().y(), s, contentsRect().height() ); 749 w->setGeometry( p, contentsRect().y(), s, contentsRect().height() );
740 } else 750 } else
741 w->setGeometry( contentsRect().x(), p, contentsRect().width(), s ); 751 w->setGeometry( contentsRect().x(), p, contentsRect().width(), s );
742} 752}
743 753
744 754
745/* 755/*
746 Places the right/bottom edge of the widget at \a id at position \a pos. 756 Places the right/bottom edge of the widget at \a id at position \a pos.
747 757
748 \sa idAfter() 758 \sa idAfter()
749*/ 759*/
750void KDGanttMinimizeSplitter::moveBefore( int pos, int id, bool upLeft ) 760void KDGanttMinimizeSplitter::moveBefore( int pos, int id, bool upLeft )
751{ 761{
752 if( id < 0 ) 762 if( id < 0 )
753 return; 763 return;
754 QSplitterLayoutStruct *s = data->list.at(id); 764 QSplitterLayoutStruct *s = data->list.at(id);
755 if ( !s ) 765 if ( !s )
756 return; 766 return;
757 QWidget *w = s->wid; 767 QWidget *w = s->wid;
758 if ( w->isHidden() ) { 768 if ( w->isHidden() ) {
759 moveBefore( pos, id-1, upLeft ); 769 moveBefore( pos, id-1, upLeft );
760 } else if ( s->isSplitter ) { 770 } else if ( s->isSplitter ) {
761 int pos1, pos2; 771 int pos1, pos2;
762 int dd = s->sizer; 772 int dd = s->sizer;
763 if( false && orient == Horizontal ) { 773 if( false && orient == Horizontal ) {
764 pos1 = pos; 774 pos1 = pos;
765 pos2 = pos + dd; 775 pos2 = pos + dd;
766 } else { 776 } else {
767 pos2 = pos - dd; 777 pos2 = pos - dd;
768 pos1 = pos2 + 1; 778 pos1 = pos2 + 1;
769 } 779 }
770 if ( upLeft ) { 780 if ( upLeft ) {
771 setG( w, pos1, dd, TRUE ); 781 setG( w, pos1, dd, TRUE );
772 moveBefore( pos2, id-1, upLeft ); 782 moveBefore( pos2, id-1, upLeft );
773 } else { 783 } else {
774 moveBefore( pos2, id-1, upLeft ); 784 moveBefore( pos2, id-1, upLeft );
775 setG( w, pos1, dd, TRUE ); 785 setG( w, pos1, dd, TRUE );
776 } 786 }
777 } else { 787 } else {
778 int dd, newLeft, nextPos; 788 int dd, newLeft, nextPos;
779 if( false && orient == Horizontal ) { 789 if( false && orient == Horizontal ) {
780 dd = w->geometry().right() - pos; 790 dd = w->geometry().right() - pos;
781 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); 791 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize())));
782 newLeft = pos+1; 792 newLeft = pos+1;
783 nextPos = newLeft + dd; 793 nextPos = newLeft + dd;
784 } else { 794 } else {
785 dd = pos - pick( w->pos() ) + 1; 795 dd = pos - pick( w->pos() ) + 1;
786 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); 796 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize())));
787 newLeft = pos-dd+1; 797 newLeft = pos-dd+1;
788 nextPos = newLeft - 1; 798 nextPos = newLeft - 1;
789 } 799 }
790 setG( w, newLeft, dd, TRUE ); 800 setG( w, newLeft, dd, TRUE );
791 moveBefore( nextPos, id-1, upLeft ); 801 moveBefore( nextPos, id-1, upLeft );
792 } 802 }
793} 803}
794 804
795 805
796/* 806/*
797 Places the left/top edge of the widget at \a id at position \a pos. 807 Places the left/top edge of the widget at \a id at position \a pos.
798 808
799 \sa idAfter() 809 \sa idAfter()
800*/ 810*/
801void KDGanttMinimizeSplitter::moveAfter( int pos, int id, bool upLeft ) 811void KDGanttMinimizeSplitter::moveAfter( int pos, int id, bool upLeft )
802{ 812{
803 QSplitterLayoutStruct *s = id < int(data->list.count()) ? 813 QSplitterLayoutStruct *s = id < int(data->list.count()) ?
804 data->list.at(id) : 0; 814 data->list.at(id) : 0;
805 if ( !s ) 815 if ( !s )
806 return; 816 return;
807 QWidget *w = s->wid; 817 QWidget *w = s->wid;
808 if ( w->isHidden() ) { 818 if ( w->isHidden() ) {
809 moveAfter( pos, id+1, upLeft ); 819 moveAfter( pos, id+1, upLeft );
810 } else if ( pick( w->pos() ) == pos ) { 820 } else if ( pick( w->pos() ) == pos ) {
811 //No need to do anything if it's already there. 821 //No need to do anything if it's already there.
812 return; 822 return;
813 } else if ( s->isSplitter ) { 823 } else if ( s->isSplitter ) {
814 int dd = s->sizer; 824 int dd = s->sizer;
815 int pos1, pos2; 825 int pos1, pos2;
816 if( false && orient == Horizontal ) { 826 if( false && orient == Horizontal ) {
817 pos2 = pos - dd; 827 pos2 = pos - dd;
818 pos1 = pos2 + 1; 828 pos1 = pos2 + 1;
819 } else { 829 } else {
820 pos1 = pos; 830 pos1 = pos;
821 pos2 = pos + dd; 831 pos2 = pos + dd;
822 } 832 }
823 if ( upLeft ) { 833 if ( upLeft ) {
824 setG( w, pos1, dd, TRUE ); 834 setG( w, pos1, dd, TRUE );
825 moveAfter( pos2, id+1, upLeft ); 835 moveAfter( pos2, id+1, upLeft );
826 } else { 836 } else {
827 moveAfter( pos2, id+1, upLeft ); 837 moveAfter( pos2, id+1, upLeft );
828 setG( w, pos1, dd, TRUE ); 838 setG( w, pos1, dd, TRUE );
829 } 839 }
830 } else { 840 } else {
831 int left = pick( w->pos() ); 841 int left = pick( w->pos() );
832 int right, dd,/* newRight,*/ newLeft, nextPos; 842 int right, dd,/* newRight,*/ newLeft, nextPos;
833 if ( false && orient == Horizontal ) { 843 if ( false && orient == Horizontal ) {
834 dd = pos - left + 1; 844 dd = pos - left + 1;
835 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); 845 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize())));
836 newLeft = pos-dd+1; 846 newLeft = pos-dd+1;
837 nextPos = newLeft - 1; 847 nextPos = newLeft - 1;
838 } else { 848 } else {
839 right = pick( w->geometry().bottomRight() ); 849 right = pick( w->geometry().bottomRight() );
840 dd = right - pos + 1; 850 dd = right - pos + 1;
841 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); 851 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize())));
842 /*newRight = pos+dd-1;*/ 852 /*newRight = pos+dd-1;*/
843 newLeft = pos; 853 newLeft = pos;
844 nextPos = newLeft + dd; 854 nextPos = newLeft + dd;
845 } 855 }
846 setG( w, newLeft, dd, TRUE ); 856 setG( w, newLeft, dd, TRUE );
847 /*if( right != newRight )*/ 857 /*if( right != newRight )*/
848 moveAfter( nextPos, id+1, upLeft ); 858 moveAfter( nextPos, id+1, upLeft );
849 } 859 }
850} 860}
851 861
852 862
853void KDGanttMinimizeSplitter::expandPos( int id, int* min, int* max ) 863void KDGanttMinimizeSplitter::expandPos( int id, int* min, int* max )
854{ 864{
855 QSplitterLayoutStruct *s = data->list.at(id-1); 865 QSplitterLayoutStruct *s = data->list.at(id-1);
856 QWidget* w = s->wid; 866 QWidget* w = s->wid;
857 *min = pick( w->mapToParent( QPoint(0,0) ) ); 867 *min = pick( w->mapToParent( QPoint(0,0) ) );
858 868
859 if ( (uint) id == data->list.count() ) { 869 if ( (uint) id == data->list.count() ) {
860 pick( size() ); 870 pick( size() );
861 } 871 }
862 else { 872 else {
863 QSplitterLayoutStruct *s = data->list.at(id+1); 873 QSplitterLayoutStruct *s = data->list.at(id+1);
864 QWidget* w = s->wid; 874 QWidget* w = s->wid;
865 *max = pick( w->mapToParent( QPoint( w->width(), w->height() ) ) ) -8; 875 *max = pick( w->mapToParent( QPoint( w->width(), w->height() ) ) ) -8;
866 } 876 }
867} 877}
868 878
869 879
870/*! 880/*!
871 Returns the valid range of the splitter with id \a id in \a *min and \a *max. 881 Returns the valid range of the splitter with id \a id in \a *min and \a *max.
872 882
873 \sa idAfter() 883 \sa idAfter()
874*/ 884*/
875 885
876void KDGanttMinimizeSplitter::getRange( int id, int *min, int *max ) 886void KDGanttMinimizeSplitter::getRange( int id, int *min, int *max )
877{ 887{
878 int minB = 0;//before 888 int minB = 0;//before
879 int maxB = 0; 889 int maxB = 0;
880 int minA = 0; 890 int minA = 0;
881 int maxA = 0;//after 891 int maxA = 0;//after
882 int n = data->list.count(); 892 int n = data->list.count();
883 if ( id < 0 || id >= n ) 893 if ( id < 0 || id >= n )
884 return; 894 return;
885 int i; 895 int i;
886 for ( i = 0; i < id; i++ ) { 896 for ( i = 0; i < id; i++ ) {
887 QSplitterLayoutStruct *s = data->list.at(i); 897 QSplitterLayoutStruct *s = data->list.at(i);
888 if ( s->wid->isHidden() ) { 898 if ( s->wid->isHidden() ) {
889 //ignore 899 //ignore
890 } else if ( s->isSplitter ) { 900 } else if ( s->isSplitter ) {
891 minB += s->sizer; 901 minB += s->sizer;
892 maxB += s->sizer; 902 maxB += s->sizer;
893 } else { 903 } else {
894 minB += pick( minSize(s->wid) ); 904 minB += pick( minSize(s->wid) );
895 maxB += pick( s->wid->maximumSize() ); 905 maxB += pick( s->wid->maximumSize() );
896 } 906 }
897 } 907 }
898 for ( i = id; i < n; i++ ) { 908 for ( i = id; i < n; i++ ) {
899 QSplitterLayoutStruct *s = data->list.at(i); 909 QSplitterLayoutStruct *s = data->list.at(i);
900 if ( s->wid->isHidden() ) { 910 if ( s->wid->isHidden() ) {
901 //ignore 911 //ignore
902 } else if ( s->isSplitter ) { 912 } else if ( s->isSplitter ) {
903 minA += s->sizer; 913 minA += s->sizer;
904 maxA += s->sizer; 914 maxA += s->sizer;
905 } else { 915 } else {
906 minA += pick( minSize(s->wid) ); 916 minA += pick( minSize(s->wid) );
907 maxA += pick( s->wid->maximumSize() ); 917 maxA += pick( s->wid->maximumSize() );
908 } 918 }
909 } 919 }
910 QRect r = contentsRect(); 920 QRect r = contentsRect();
911 if ( orient == Horizontal && false ) { 921 if ( orient == Horizontal && false ) {
912#if QT_VERSION >= 0x030000 922#if QT_VERSION >= 0x030000
913 int splitterWidth = style().pixelMetric(QStyle::PM_SplitterWidth, this); 923 int splitterWidth = style().pixelMetric(QStyle::PM_SplitterWidth, this);
914#else 924#else
915 int splitterWidth = style().splitterWidth(); 925 int splitterWidth = style().splitterWidth();
916#endif 926#endif
917 927
918 if ( min ) 928 if ( min )
919 *min = pick(r.topRight()) - QMIN( maxB, pick(r.size())-minA ) - splitterWidth; 929 *min = pick(r.topRight()) - QMIN( maxB, pick(r.size())-minA ) - splitterWidth;
920 if ( max ) 930 if ( max )
921 *max = pick(r.topRight()) - QMAX( minB, pick(r.size())-maxA ) - splitterWidth; 931 *max = pick(r.topRight()) - QMAX( minB, pick(r.size())-maxA ) - splitterWidth;
922 } else { 932 } else {
923 if ( min ) 933 if ( min )
924 *min = pick(r.topLeft()) + QMAX( minB, pick(r.size())-maxA ); 934 *min = pick(r.topLeft()) + QMAX( minB, pick(r.size())-maxA );
925 if ( max ) 935 if ( max )
926 *max = pick(r.topLeft()) + QMIN( maxB, pick(r.size())-minA ); 936 *max = pick(r.topLeft()) + QMIN( maxB, pick(r.size())-minA );
927 } 937 }
928} 938}
929 939
930 940
931/*! 941/*!
932 Returns the closest legal position to \a p of the splitter with id \a id. 942 Returns the closest legal position to \a p of the splitter with id \a id.
933 943
934 \sa idAfter() 944 \sa idAfter()
935*/ 945*/
936 946
937int KDGanttMinimizeSplitter::adjustPos( int p, int id ) 947int KDGanttMinimizeSplitter::adjustPos( int p, int id )
938{ 948{
939 int min = 0; 949 int min = 0;
940 int max = 0; 950 int max = 0;
941 getRange( id, &min, &max ); 951 getRange( id, &min, &max );
942 p = QMAX( min, QMIN( p, max ) ); 952 p = QMAX( min, QMIN( p, max ) );
943 953
944 return p; 954 return p;
945} 955}
946 956
947 957
948void KDGanttMinimizeSplitter::doResize() 958void KDGanttMinimizeSplitter::doResize()
949{ 959{
950 QRect r = contentsRect(); 960 QRect r = contentsRect();
951 int i; 961 int i;
952 int n = data->list.count(); 962 int n = data->list.count();
953 QMemArray<QLayoutStruct> a( n ); 963 QMemArray<QLayoutStruct> a( n );
954 for ( i = 0; i< n; i++ ) { 964 for ( i = 0; i< n; i++ ) {
955 a[i].init(); 965 a[i].init();
956 QSplitterLayoutStruct *s = data->list.at(i); 966 QSplitterLayoutStruct *s = data->list.at(i);
957 if ( s->wid->isHidden() ) { 967 if ( s->wid->isHidden() ) {
958 a[i].stretch = 0; 968 a[i].stretch = 0;
959 a[i].sizeHint = a[i].minimumSize = 0; 969 a[i].sizeHint = a[i].minimumSize = 0;
960 a[i].maximumSize = 0; 970 a[i].maximumSize = 0;
961 } else if ( s->isSplitter ) { 971 } else if ( s->isSplitter ) {
962 a[i].stretch = 0; 972 a[i].stretch = 0;
963 a[i].sizeHint = a[i].minimumSize = a[i].maximumSize = s->sizer; 973 a[i].sizeHint = a[i].minimumSize = a[i].maximumSize = s->sizer;
964 a[i].empty = FALSE; 974 a[i].empty = FALSE;
965 } else if ( s->mode == KeepSize ) { 975 } else if ( s->mode == KeepSize ) {
966 a[i].stretch = 0; 976 a[i].stretch = 0;
967 a[i].minimumSize = pick( minSize(s->wid) ); 977 a[i].minimumSize = pick( minSize(s->wid) );
968 a[i].sizeHint = s->sizer; 978 a[i].sizeHint = s->sizer;
969 a[i].maximumSize = pick( s->wid->maximumSize() ); 979 a[i].maximumSize = pick( s->wid->maximumSize() );
970 a[i].empty = FALSE; 980 a[i].empty = FALSE;
971 } else if ( s->mode == FollowSizeHint ) { 981 } else if ( s->mode == FollowSizeHint ) {
972 a[i].stretch = 0; 982 a[i].stretch = 0;
973 a[i].minimumSize = a[i].sizeHint = pick( s->wid->sizeHint() ); 983 a[i].minimumSize = a[i].sizeHint = pick( s->wid->sizeHint() );
974 a[i].maximumSize = pick( s->wid->maximumSize() ); 984 a[i].maximumSize = pick( s->wid->maximumSize() );
975 a[i].empty = FALSE; 985 a[i].empty = FALSE;
976 } else { //proportional 986 } else { //proportional
977 a[i].stretch = s->sizer; 987 a[i].stretch = s->sizer;
978 a[i].maximumSize = pick( s->wid->maximumSize() ); 988 a[i].maximumSize = pick( s->wid->maximumSize() );
979 a[i].sizeHint = a[i].minimumSize = pick( minSize(s->wid) ); 989 a[i].sizeHint = a[i].minimumSize = pick( minSize(s->wid) );
980 a[i].empty = FALSE; 990 a[i].empty = FALSE;
981 } 991 }
982 } 992 }
983 993
984 kdganttGeomCalc( a, 0, n, pick( r.topLeft() ), pick( r.size() ), 0 ); 994 kdganttGeomCalc( a, 0, n, pick( r.topLeft() ), pick( r.size() ), 0 );
985 995
986 for ( i = 0; i< n; i++ ) { 996 for ( i = 0; i< n; i++ ) {
987 QSplitterLayoutStruct *s = data->list.at(i); 997 QSplitterLayoutStruct *s = data->list.at(i);
988 setG( s->wid, a[i].pos, a[i].size ); 998 setG( s->wid, a[i].pos, a[i].size );
989 } 999 }
990 1000
991} 1001}
992 1002
993 1003
994void KDGanttMinimizeSplitter::recalc( bool update ) 1004void KDGanttMinimizeSplitter::recalc( bool update )
995{ 1005{
996 int fi = 2*frameWidth(); 1006 int fi = 2*frameWidth();
997 int maxl = fi; 1007 int maxl = fi;
998 int minl = fi; 1008 int minl = fi;
999 int maxt = QWIDGETSIZE_MAX; 1009 int maxt = QWIDGETSIZE_MAX;
1000 int mint = fi; 1010 int mint = fi;
1001 int n = data->list.count(); 1011 int n = data->list.count();
1002 bool first = TRUE; 1012 bool first = TRUE;
1003 /* 1013 /*
1004 The splitter before a hidden widget is always hidden. 1014 The splitter before a hidden widget is always hidden.
1005 The splitter before the first visible widget is hidden. 1015 The splitter before the first visible widget is hidden.
1006 The splitter before any other visible widget is visible. 1016 The splitter before any other visible widget is visible.
1007 */ 1017 */
1008 for ( int i = 0; i< n; i++ ) { 1018 for ( int i = 0; i< n; i++ ) {
1009 QSplitterLayoutStruct *s = data->list.at(i); 1019 QSplitterLayoutStruct *s = data->list.at(i);
1010 if ( !s->isSplitter ) { 1020 if ( !s->isSplitter ) {
1011 QSplitterLayoutStruct *p = (i > 0) ? p = data->list.at( i-1 ) : 0; 1021 QSplitterLayoutStruct *p = (i > 0) ? p = data->list.at( i-1 ) : 0;
1012 if ( p && p->isSplitter ) 1022 if ( p && p->isSplitter )
1013 if ( first || s->wid->isHidden() ) 1023 if ( first || s->wid->isHidden() )
1014 p->wid->hide(); //may trigger new recalc 1024 p->wid->hide(); //may trigger new recalc
1015 else 1025 else
1016 p->wid->show(); //may trigger new recalc 1026 p->wid->show(); //may trigger new recalc
1017 if ( !s->wid->isHidden() ) 1027 if ( !s->wid->isHidden() )
1018 first = FALSE; 1028 first = FALSE;
1019 } 1029 }
1020 } 1030 }
1021 1031
1022 bool empty=TRUE; 1032 bool empty=TRUE;
1023 for ( int j = 0; j< n; j++ ) { 1033 for ( int j = 0; j< n; j++ ) {
1024 QSplitterLayoutStruct *s = data->list.at(j); 1034 QSplitterLayoutStruct *s = data->list.at(j);
1025 if ( !s->wid->isHidden() ) { 1035 if ( !s->wid->isHidden() ) {
1026 empty = FALSE; 1036 empty = FALSE;
1027 if ( s->isSplitter ) { 1037 if ( s->isSplitter ) {
1028 minl += s->sizer; 1038 minl += s->sizer;
1029 maxl += s->sizer; 1039 maxl += s->sizer;
1030 } else { 1040 } else {
1031 QSize minS = minSize(s->wid); 1041 QSize minS = minSize(s->wid);
1032 minl += pick( minS ); 1042 minl += pick( minS );
1033 maxl += pick( s->wid->maximumSize() ); 1043 maxl += pick( s->wid->maximumSize() );
1034 mint = QMAX( mint, trans( minS )); 1044 mint = QMAX( mint, trans( minS ));
1035 int tm = trans( s->wid->maximumSize() ); 1045 int tm = trans( s->wid->maximumSize() );
1036 if ( tm > 0 ) 1046 if ( tm > 0 )
1037 maxt = QMIN( maxt, tm ); 1047 maxt = QMIN( maxt, tm );
1038 } 1048 }
1039 } 1049 }
1040 } 1050 }
1041 if ( empty ) { 1051 if ( empty ) {
1042 if ( parentWidget() != 0 && parentWidget()->inherits("KDGanttMinimizeSplitter") ) { 1052 if ( parentWidget() != 0 && parentWidget()->inherits("KDGanttMinimizeSplitter") ) {
1043 // nested splitters; be nice 1053 // nested splitters; be nice
1044 maxl = maxt = 0; 1054 maxl = maxt = 0;
1045 } else { 1055 } else {
1046 // KDGanttMinimizeSplitter with no children yet 1056 // KDGanttMinimizeSplitter with no children yet
1047 maxl = QWIDGETSIZE_MAX; 1057 maxl = QWIDGETSIZE_MAX;
1048 } 1058 }
1049 } else { 1059 } else {
1050 maxl = QMIN( maxl, QWIDGETSIZE_MAX ); 1060 maxl = QMIN( maxl, QWIDGETSIZE_MAX );
1051 } 1061 }
1052 if ( maxt < mint ) 1062 if ( maxt < mint )
1053 maxt = mint; 1063 maxt = mint;
1054 1064
1055 if ( orient == Horizontal ) { 1065 if ( orient == Horizontal ) {
1056 setMaximumSize( maxl, maxt ); 1066 setMaximumSize( maxl, maxt );
1057 setMinimumSize( minl, mint ); 1067 setMinimumSize( minl, mint );
1058 } else { 1068 } else {
1059 setMaximumSize( maxt, maxl ); 1069 setMaximumSize( maxt, maxl );
1060 setMinimumSize( mint, minl ); 1070 setMinimumSize( mint, minl );
1061 } 1071 }
1062 if ( update ) 1072 if ( update )
1063 doResize(); 1073 doResize();
1064} 1074}
1065 1075
1066/*! 1076/*!
1067 Sets resize mode of \a w to \a mode. 1077 Sets resize mode of \a w to \a mode.
1068 1078
1069 \sa ResizeMode 1079 \sa ResizeMode
1070*/ 1080*/
1071 1081
1072void KDGanttMinimizeSplitter::setResizeMode( QWidget *w, ResizeMode mode ) 1082void KDGanttMinimizeSplitter::setResizeMode( QWidget *w, ResizeMode mode )
1073{ 1083{
1074 processChildEvents(); 1084 processChildEvents();
1075 QSplitterLayoutStruct *s = data->list.first(); 1085 QSplitterLayoutStruct *s = data->list.first();
1076 while ( s ) { 1086 while ( s ) {
1077 if ( s->wid == w ) { 1087 if ( s->wid == w ) {
1078 s->mode = mode; 1088 s->mode = mode;
1079 return; 1089 return;
1080 } 1090 }
1081 s = data->list.next(); 1091 s = data->list.next();
1082 } 1092 }
1083 s = addWidget( w, TRUE ); 1093 s = addWidget( w, TRUE );
1084 s->mode = mode; 1094 s->mode = mode;
1085} 1095}
1086 1096
1087 1097
1088/*! 1098/*!
1089 Returns TRUE if opaque resize is on; otherwise returns FALSE. 1099 Returns TRUE if opaque resize is on; otherwise returns FALSE.
1090 1100
1091 \sa setOpaqueResize() 1101 \sa setOpaqueResize()
1092*/ 1102*/
1093 1103
1094bool KDGanttMinimizeSplitter::opaqueResize() const 1104bool KDGanttMinimizeSplitter::opaqueResize() const
1095{ 1105{
1096 return data->opaque; 1106 return data->opaque;
1097} 1107}
1098 1108
1099 1109
1100/*! 1110/*!
1101 If \a on is TRUE then opaque resizing is turned on; otherwise 1111 If \a on is TRUE then opaque resizing is turned on; otherwise
1102 opaque resizing is turned off. 1112 opaque resizing is turned off.
1103 Opaque resizing is initially turned off. 1113 Opaque resizing is initially turned off.
1104 1114
1105 \sa opaqueResize() 1115 \sa opaqueResize()
1106*/ 1116*/
1107 1117
1108void KDGanttMinimizeSplitter::setOpaqueResize( bool on ) 1118void KDGanttMinimizeSplitter::setOpaqueResize( bool on )
1109{ 1119{
1110 data->opaque = on; 1120 data->opaque = on;
1111} 1121}
1112 1122
1113 1123
1114/*! 1124/*!
1115 Moves widget \a w to the leftmost/top position. 1125 Moves widget \a w to the leftmost/top position.
1116*/ 1126*/
1117 1127
1118void KDGanttMinimizeSplitter::moveToFirst( QWidget *w ) 1128void KDGanttMinimizeSplitter::moveToFirst( QWidget *w )
1119{ 1129{
1120 processChildEvents(); 1130 processChildEvents();
1121 bool found = FALSE; 1131 bool found = FALSE;
1122 QSplitterLayoutStruct *s = data->list.first(); 1132 QSplitterLayoutStruct *s = data->list.first();
1123 while ( s ) { 1133 while ( s ) {
1124 if ( s->wid == w ) { 1134 if ( s->wid == w ) {
1125 found = TRUE; 1135 found = TRUE;
1126 QSplitterLayoutStruct *p = data->list.prev(); 1136 QSplitterLayoutStruct *p = data->list.prev();
1127 if ( p ) { // not already at first place 1137 if ( p ) { // not already at first place
1128 data->list.take(); //take p 1138 data->list.take(); //take p
1129 data->list.take(); // take s 1139 data->list.take(); // take s
1130 data->list.insert( 0, p ); 1140 data->list.insert( 0, p );
1131 data->list.insert( 0, s ); 1141 data->list.insert( 0, s );
1132 } 1142 }
1133 break; 1143 break;
1134 } 1144 }
1135 s = data->list.next(); 1145 s = data->list.next();
1136 } 1146 }
1137 if ( !found ) 1147 if ( !found )
1138 addWidget( w, TRUE ); 1148 addWidget( w, TRUE );
1139 recalcId(); 1149 recalcId();
1140} 1150}
1141 1151
1142 1152
1143/*! 1153/*!
1144 Moves widget \a w to the rightmost/bottom position. 1154 Moves widget \a w to the rightmost/bottom position.
1145*/ 1155*/
1146 1156
1147void KDGanttMinimizeSplitter::moveToLast( QWidget *w ) 1157void KDGanttMinimizeSplitter::moveToLast( QWidget *w )
1148{ 1158{
1149 processChildEvents(); 1159 processChildEvents();
1150 bool found = FALSE; 1160 bool found = FALSE;
1151 QSplitterLayoutStruct *s = data->list.first(); 1161 QSplitterLayoutStruct *s = data->list.first();
1152 while ( s ) { 1162 while ( s ) {
1153 if ( s->wid == w ) { 1163 if ( s->wid == w ) {
1154 found = TRUE; 1164 found = TRUE;
1155 data->list.take(); // take s 1165 data->list.take(); // take s
1156 QSplitterLayoutStruct *p = data->list.current(); 1166 QSplitterLayoutStruct *p = data->list.current();
1157 if ( p ) { // the splitter handle after s 1167 if ( p ) { // the splitter handle after s
1158 data->list.take(); //take p 1168 data->list.take(); //take p
1159 data->list.append( p ); 1169 data->list.append( p );
1160 } 1170 }
1161 data->list.append( s ); 1171 data->list.append( s );
1162 break; 1172 break;
1163 } 1173 }
1164 s = data->list.next(); 1174 s = data->list.next();
1165 } 1175 }
1166 if ( !found ) 1176 if ( !found )
1167 addWidget( w); 1177 addWidget( w);
1168 recalcId(); 1178 recalcId();
1169} 1179}
1170 1180
1171 1181
1172void KDGanttMinimizeSplitter::recalcId() 1182void KDGanttMinimizeSplitter::recalcId()
1173{ 1183{
1174 int n = data->list.count(); 1184 int n = data->list.count();
1175 for ( int i = 0; i < n; i++ ) { 1185 for ( int i = 0; i < n; i++ ) {
1176 QSplitterLayoutStruct *s = data->list.at(i); 1186 QSplitterLayoutStruct *s = data->list.at(i);
1177 if ( s->isSplitter ) 1187 if ( s->isSplitter )
1178 ((KDGanttSplitterHandle*)s->wid)->setId(i); 1188 ((KDGanttSplitterHandle*)s->wid)->setId(i);
1179 } 1189 }
1180} 1190}
1181 1191
1182 1192
1183/*!\reimp 1193/*!\reimp
1184*/ 1194*/
1185QSize KDGanttMinimizeSplitter::sizeHint() const 1195QSize KDGanttMinimizeSplitter::sizeHint() const
1186{ 1196{
1187 constPolish(); 1197 constPolish();
1188 int l = 0; 1198 int l = 0;
1189 int t = 0; 1199 int t = 0;
1190 if ( children() ) { 1200 if ( children() ) {
1191 const QObjectList * c = children(); 1201 const QObjectList * c = children();
1192 QObjectListIt it( *c ); 1202 QObjectListIt it( *c );
1193 QObject * o; 1203 QObject * o;
1194 1204
1195 while( (o=it.current()) != 0 ) { 1205 while( (o=it.current()) != 0 ) {
1196 ++it; 1206 ++it;
1197 if ( o->isWidgetType() && 1207 if ( o->isWidgetType() &&
1198 !((QWidget*)o)->isHidden() ) { 1208 !((QWidget*)o)->isHidden() ) {
1199 QSize s = ((QWidget*)o)->sizeHint(); 1209 QSize s = ((QWidget*)o)->sizeHint();
1200 if ( s.isValid() ) { 1210 if ( s.isValid() ) {
1201 l += pick( s ); 1211 l += pick( s );
1202 t = QMAX( t, trans( s ) ); 1212 t = QMAX( t, trans( s ) );
1203 } 1213 }
1204 } 1214 }
1205 } 1215 }
1206 } 1216 }
1207 return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l ); 1217 return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l );
1208} 1218}
1209 1219
1210 1220
1211/*! 1221/*!
1212\reimp 1222\reimp
1213*/ 1223*/
1214 1224
1215QSize KDGanttMinimizeSplitter::minimumSizeHint() const 1225QSize KDGanttMinimizeSplitter::minimumSizeHint() const
1216{ 1226{
1217 constPolish(); 1227 constPolish();
1218 int l = 0; 1228 int l = 0;
1219 int t = 0; 1229 int t = 0;
1220 if ( children() ) { 1230 if ( children() ) {
1221 const QObjectList * c = children(); 1231 const QObjectList * c = children();
1222 QObjectListIt it( *c ); 1232 QObjectListIt it( *c );
1223 QObject * o; 1233 QObject * o;
1224 1234
1225 while( (o=it.current()) != 0 ) { 1235 while( (o=it.current()) != 0 ) {
1226 ++it; 1236 ++it;
1227 if ( o->isWidgetType() && 1237 if ( o->isWidgetType() &&
1228 !((QWidget*)o)->isHidden() ) { 1238 !((QWidget*)o)->isHidden() ) {
1229 QSize s = minSizeHint((QWidget*)o); 1239 QSize s = minSizeHint((QWidget*)o);
1230 if ( s.isValid() ) { 1240 if ( s.isValid() ) {
1231 l += pick( s ); 1241 l += pick( s );
1232 t = QMAX( t, trans( s ) ); 1242 t = QMAX( t, trans( s ) );
1233 } 1243 }
1234 } 1244 }
1235 } 1245 }
1236 } 1246 }
1237 return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l ); 1247 return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l );
1238} 1248}
1239 1249
1240 1250
1241/* 1251/*
1242 Calculates stretch parameters from current sizes 1252 Calculates stretch parameters from current sizes
1243*/ 1253*/
1244 1254
1245void KDGanttMinimizeSplitter::storeSizes() 1255void KDGanttMinimizeSplitter::storeSizes()
1246{ 1256{
1247 QSplitterLayoutStruct *s = data->list.first(); 1257 QSplitterLayoutStruct *s = data->list.first();
1248 while ( s ) { 1258 while ( s ) {
1249 if ( !s->isSplitter ) 1259 if ( !s->isSplitter )
1250 s->sizer = pick( s->wid->size() ); 1260 s->sizer = pick( s->wid->size() );
1251 s = data->list.next(); 1261 s = data->list.next();
1252 } 1262 }
1253} 1263}
1254 1264
1255 1265
1256#if 0 // ### remove this code ASAP 1266#if 0 // ### remove this code ASAP
1257 1267
1258/*! 1268/*!
1259 Hides \a w if \a hide is TRUE and updates the splitter. 1269 Hides \a w if \a hide is TRUE and updates the splitter.
1260 1270
1261 \warning Due to a limitation in the current implementation, 1271 \warning Due to a limitation in the current implementation,
1262 calling QWidget::hide() will not work. 1272 calling QWidget::hide() will not work.
1263*/ 1273*/
1264 1274
1265void KDGanttMinimizeSplitter::setHidden( QWidget *w, bool hide ) 1275void KDGanttMinimizeSplitter::setHidden( QWidget *w, bool hide )
1266{ 1276{
1267 if ( w == w1 ) { 1277 if ( w == w1 ) {
1268 w1show = !hide; 1278 w1show = !hide;
1269 } else if ( w == w2 ) { 1279 } else if ( w == w2 ) {
1270 w2show = !hide; 1280 w2show = !hide;
1271 } else { 1281 } else {
1272#ifdef QT_CHECK_RANGE 1282#ifdef QT_CHECK_RANGE
1273 qWarning( "KDGanttMinimizeSplitter::setHidden(), unknown widget" ); 1283 qWarning( "KDGanttMinimizeSplitter::setHidden(), unknown widget" );
1274#endif 1284#endif
1275 return; 1285 return;
1276 } 1286 }
1277 if ( hide ) 1287 if ( hide )
1278 w->hide(); 1288 w->hide();
1279 else 1289 else
1280 w->show(); 1290 w->show();
1281 recalc( TRUE ); 1291 recalc( TRUE );
1282} 1292}
1283 1293
1284 1294
1285/*! 1295/*!
1286 Returns the hidden status of \a w 1296 Returns the hidden status of \a w
1287*/ 1297*/
1288 1298
1289bool KDGanttMinimizeSplitter::isHidden( QWidget *w ) const 1299bool KDGanttMinimizeSplitter::isHidden( QWidget *w ) const
1290{ 1300{
1291 if ( w == w1 ) 1301 if ( w == w1 )
1292 return !w1show; 1302 return !w1show;
1293 else if ( w == w2 ) 1303 else if ( w == w2 )
1294 return !w2show; 1304 return !w2show;
1295#ifdef QT_CHECK_RANGE 1305#ifdef QT_CHECK_RANGE
1296 else 1306 else
1297 qWarning( "KDGanttMinimizeSplitter::isHidden(), unknown widget" ); 1307 qWarning( "KDGanttMinimizeSplitter::isHidden(), unknown widget" );
1298#endif 1308#endif
1299 return FALSE; 1309 return FALSE;
1300} 1310}
1301#endif 1311#endif
1302 1312
1303 1313
1304/*! 1314/*!
1305 Returns a list of the size parameters of all the widgets in this 1315 Returns a list of the size parameters of all the widgets in this
1306 splitter. 1316 splitter.
1307 1317
1308 Giving the values to another splitter's setSizes() function will 1318 Giving the values to another splitter's setSizes() function will
1309 produce a splitter with the same layout as this one. 1319 produce a splitter with the same layout as this one.
1310 1320
1311 Note that if you want to iterate over the list, you should 1321 Note that if you want to iterate over the list, you should
1312 iterate over a copy, e.g. 1322 iterate over a copy, e.g.
1313 \code 1323 \code
1314 QValueList<int> list = mySplitter.sizes(); 1324 QValueList<int> list = mySplitter.sizes();
1315 QValueList<int>::Iterator it = list.begin(); 1325 QValueList<int>::Iterator it = list.begin();
1316 while( it != list.end() ) { 1326 while( it != list.end() ) {
1317 myProcessing( *it ); 1327 myProcessing( *it );
1318 ++it; 1328 ++it;
1319 } 1329 }
1320 \endcode 1330 \endcode
1321 1331
1322 \sa setSizes() 1332 \sa setSizes()
1323*/ 1333*/
1324 1334
1325QValueList<int> KDGanttMinimizeSplitter::sizes() const 1335QValueList<int> KDGanttMinimizeSplitter::sizes() const
1326{ 1336{
1327 if ( !testWState(WState_Polished) ) { 1337 if ( !testWState(WState_Polished) ) {
1328 QWidget* that = (QWidget*) this; 1338 QWidget* that = (QWidget*) this;
1329 that->polish(); 1339 that->polish();
1330 } 1340 }
1331 QValueList<int> list; 1341 QValueList<int> list;
1332 QSplitterLayoutStruct *s = data->list.first(); 1342 QSplitterLayoutStruct *s = data->list.first();
1333 while ( s ) { 1343 while ( s ) {
1334 if ( !s->isSplitter ) 1344 if ( !s->isSplitter )
1335 list.append( s->sizer ); 1345 list.append( s->sizer );
1336 s = data->list.next(); 1346 s = data->list.next();
1337 } 1347 }
1338 return list; 1348 return list;
1339} 1349}
1340 1350
1341 1351
1342 1352
1343/*! 1353/*!
1344 Sets the size parameters to the values given in \a list. 1354 Sets the size parameters to the values given in \a list.
1345 If the splitter is horizontal, the values set the sizes from 1355 If the splitter is horizontal, the values set the sizes from
1346 left to right. If it is vertical, the sizes are applied from 1356 left to right. If it is vertical, the sizes are applied from
1347 top to bottom. 1357 top to bottom.
1348 Extra values in \a list are ignored. 1358 Extra values in \a list are ignored.
1349 1359
1350 If \a list contains too few values, the result is undefined 1360 If \a list contains too few values, the result is undefined
1351 but the program will still be well-behaved. 1361 but the program will still be well-behaved.
1352 1362
1353 \sa sizes() 1363 \sa sizes()
1354*/ 1364*/
1355 1365
1356void KDGanttMinimizeSplitter::setSizes( QValueList<int> list ) 1366void KDGanttMinimizeSplitter::setSizes( QValueList<int> list )
1357{ 1367{
1358 processChildEvents(); 1368 processChildEvents();
1359 QValueList<int>::Iterator it = list.begin(); 1369 QValueList<int>::Iterator it = list.begin();
1360 QSplitterLayoutStruct *s = data->list.first(); 1370 QSplitterLayoutStruct *s = data->list.first();
1361 while ( s && it != list.end() ) { 1371 while ( s && it != list.end() ) {
1362 if ( !s->isSplitter ) { 1372 if ( !s->isSplitter ) {
1363 s->sizer = *it; 1373 s->sizer = *it;
1364 ++it; 1374 ++it;
1365 } 1375 }
1366 s = data->list.next(); 1376 s = data->list.next();
1367 } 1377 }
1368 doResize(); 1378 doResize();
1369} 1379}
1370 1380
1371 1381
1372/*! 1382/*!
1373 Gets all posted child events, ensuring that the internal state of 1383 Gets all posted child events, ensuring that the internal state of
1374 the splitter is consistent. 1384 the splitter is consistent.
1375*/ 1385*/
1376 1386
1377void KDGanttMinimizeSplitter::processChildEvents() 1387void KDGanttMinimizeSplitter::processChildEvents()
1378{ 1388{
1379 QApplication::sendPostedEvents( this, QEvent::ChildInserted ); 1389 QApplication::sendPostedEvents( this, QEvent::ChildInserted );
1380} 1390}
1381 1391
1382 1392
1383/*! 1393/*!
1384 \reimp 1394 \reimp
1385*/ 1395*/
1386 1396
1387void KDGanttMinimizeSplitter::styleChange( QStyle& old ) 1397void KDGanttMinimizeSplitter::styleChange( QStyle& old )
1388{ 1398{
1389 1399
1390#if QT_VERSION >= 0x030000 1400#if QT_VERSION >= 0x030000
1391 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); 1401 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this);
1392#else 1402#else
1393 int sw = style().splitterWidth(); 1403 int sw = style().splitterWidth();
1394#endif 1404#endif
1395 QSplitterLayoutStruct *s = data->list.first(); 1405 QSplitterLayoutStruct *s = data->list.first();
1396 while ( s ) { 1406 while ( s ) {
1397 if ( s->isSplitter ) 1407 if ( s->isSplitter )
1398 s->sizer = sw; 1408 s->sizer = sw;
1399 s = data->list.next(); 1409 s = data->list.next();
1400 } 1410 }
1401 doResize(); 1411 doResize();
1402 QFrame::styleChange( old ); 1412 QFrame::styleChange( old );
1403} 1413}
1404 1414
1405#endif 1415#endif
1406 1416
1407/*! 1417/*!
1408 Specifies the direction of the minimize buttons. 1418 Specifies the direction of the minimize buttons.
1409 If the orientation of the splitter is horizontal then with 1419 If the orientation of the splitter is horizontal then with
1410 KDGanttMinimizeSplitter::Left or KDGanttMinimizeSplitter::Right should be used, 1420 KDGanttMinimizeSplitter::Left or KDGanttMinimizeSplitter::Right should be used,
1411 otherwise either KDGanttMinimizeSplitter::Up or KDGanttMinimizeSplitter::Down 1421 otherwise either KDGanttMinimizeSplitter::Up or KDGanttMinimizeSplitter::Down
1412 should be used. 1422 should be used.
1413*/ 1423*/
1414void KDGanttMinimizeSplitter::setMinimizeDirection( Direction direction ) 1424void KDGanttMinimizeSplitter::setMinimizeDirection( Direction direction )
1415{ 1425{
1416 _direction = direction; 1426 _direction = direction;
1417} 1427}
1418 1428
1419/*! 1429/*!
1420 Returns the direction of the minimize buttons. 1430 Returns the direction of the minimize buttons.
1421*/ 1431*/
1422KDGanttMinimizeSplitter::Direction KDGanttMinimizeSplitter::minimizeDirection() const 1432KDGanttMinimizeSplitter::Direction KDGanttMinimizeSplitter::minimizeDirection() const
1423{ 1433{
1424 return _direction; 1434 return _direction;
1425} 1435}
1426 1436
1427/* 1437/*
1428 This is a copy of qGeomCalc() in qlayoutengine.cpp which 1438 This is a copy of qGeomCalc() in qlayoutengine.cpp which
1429 unfortunately isn't exported. 1439 unfortunately isn't exported.
1430*/ 1440*/
1431static inline int toFixed( int i ) { return i * 256; } 1441static inline int toFixed( int i ) { return i * 256; }
1432static inline int fRound( int i ) { 1442static inline int fRound( int i ) {
1433 return ( i % 256 < 128 ) ? i / 256 : 1 + i / 256; 1443 return ( i % 256 < 128 ) ? i / 256 : 1 + i / 256;
1434} 1444}
1435void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, 1445void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos,
1436 int space, int spacer ) 1446 int space, int spacer )
1437{ 1447{
1438 typedef int fixed; 1448 typedef int fixed;
1439 int cHint = 0; 1449 int cHint = 0;
1440 int cMin = 0; 1450 int cMin = 0;
1441 int cMax = 0; 1451 int cMax = 0;
1442 int sumStretch = 0; 1452 int sumStretch = 0;
1443 int spacerCount = 0; 1453 int spacerCount = 0;
1444 1454
1445 bool wannaGrow = FALSE; // anyone who really wants to grow? 1455 bool wannaGrow = FALSE; // anyone who really wants to grow?
1446 // bool canShrink = FALSE; // anyone who could be persuaded to shrink? 1456 // bool canShrink = FALSE; // anyone who could be persuaded to shrink?
1447 1457
1448 int i; 1458 int i;
1449 for ( i = start; i < start + count; i++ ) { 1459 for ( i = start; i < start + count; i++ ) {
1450 chain[i].done = FALSE; 1460 chain[i].done = FALSE;
1451 cHint += chain[i].sizeHint; 1461 cHint += chain[i].sizeHint;
1452 cMin += chain[i].minimumSize; 1462 cMin += chain[i].minimumSize;
1453 cMax += chain[i].maximumSize; 1463 cMax += chain[i].maximumSize;
1454 sumStretch += chain[i].stretch; 1464 sumStretch += chain[i].stretch;
1455 if ( !chain[i].empty ) 1465 if ( !chain[i].empty )
1456 spacerCount++; 1466 spacerCount++;
1457 wannaGrow = wannaGrow || chain[i].expansive; 1467 wannaGrow = wannaGrow || chain[i].expansive;
1458 } 1468 }
1459 1469
1460 int extraspace = 0; 1470 int extraspace = 0;
1461 if ( spacerCount ) 1471 if ( spacerCount )
1462 spacerCount--; // only spacers between things 1472 spacerCount--; // only spacers between things
1463 if ( space < cMin + spacerCount * spacer ) { 1473 if ( space < cMin + spacerCount * spacer ) {
1464 //qDebug("not enough space"); 1474 //qDebug("not enough space");
1465 for ( i = start; i < start+count; i++ ) { 1475 for ( i = start; i < start+count; i++ ) {
1466 chain[i].size = chain[i].minimumSize; 1476 chain[i].size = chain[i].minimumSize;
1467 chain[i].done = TRUE; 1477 chain[i].done = TRUE;
1468 } 1478 }
1469 } else if ( space < cHint + spacerCount*spacer ) { 1479 } else if ( space < cHint + spacerCount*spacer ) {
1470 // Less space than sizeHint, but more than minimum. 1480 // Less space than sizeHint, but more than minimum.
1471 // Currently take space equally from each, like in Qt 2.x. 1481 // Currently take space equally from each, like in Qt 2.x.
1472 // Commented-out lines will give more space to stretchier items. 1482 // Commented-out lines will give more space to stretchier items.
1473 int n = count; 1483 int n = count;
1474 int space_left = space - spacerCount*spacer; 1484 int space_left = space - spacerCount*spacer;
1475 int overdraft = cHint - space_left; 1485 int overdraft = cHint - space_left;
1476 //first give to the fixed ones: 1486 //first give to the fixed ones:
1477 for ( i = start; i < start+count; i++ ) { 1487 for ( i = start; i < start+count; i++ ) {
1478 if ( !chain[i].done && chain[i].minimumSize >= chain[i].sizeHint) { 1488 if ( !chain[i].done && chain[i].minimumSize >= chain[i].sizeHint) {
1479 chain[i].size = chain[i].sizeHint; 1489 chain[i].size = chain[i].sizeHint;
1480 chain[i].done = TRUE; 1490 chain[i].done = TRUE;
1481 space_left -= chain[i].sizeHint; 1491 space_left -= chain[i].sizeHint;
1482 // sumStretch -= chain[i].stretch; 1492 // sumStretch -= chain[i].stretch;
1483 n--; 1493 n--;
1484 } 1494 }
1485 } 1495 }
1486 bool finished = n == 0; 1496 bool finished = n == 0;
1487 while ( !finished ) { 1497 while ( !finished ) {
1488 finished = TRUE; 1498 finished = TRUE;
1489 fixed fp_over = toFixed( overdraft ); 1499 fixed fp_over = toFixed( overdraft );
1490 fixed fp_w = 0; 1500 fixed fp_w = 0;
1491 1501
1492 for ( i = start; i < start+count; i++ ) { 1502 for ( i = start; i < start+count; i++ ) {
1493 if ( chain[i].done ) 1503 if ( chain[i].done )
1494 continue; 1504 continue;
1495 // if ( sumStretch <= 0 ) 1505 // if ( sumStretch <= 0 )
1496 fp_w += fp_over / n; 1506 fp_w += fp_over / n;
1497 // else 1507 // else
1498 // fp_w += (fp_over * chain[i].stretch) / sumStretch; 1508 // fp_w += (fp_over * chain[i].stretch) / sumStretch;
1499 int w = fRound( fp_w ); 1509 int w = fRound( fp_w );
1500 chain[i].size = chain[i].sizeHint - w; 1510 chain[i].size = chain[i].sizeHint - w;
1501 fp_w -= toFixed( w ); //give the difference to the next 1511 fp_w -= toFixed( w ); //give the difference to the next
1502 if ( chain[i].size < chain[i].minimumSize ) { 1512 if ( chain[i].size < chain[i].minimumSize ) {
1503 chain[i].done = TRUE; 1513 chain[i].done = TRUE;
1504 chain[i].size = chain[i].minimumSize; 1514 chain[i].size = chain[i].minimumSize;
1505 finished = FALSE; 1515 finished = FALSE;
1506 overdraft -= chain[i].sizeHint - chain[i].minimumSize; 1516 overdraft -= chain[i].sizeHint - chain[i].minimumSize;
1507 // sumStretch -= chain[i].stretch; 1517 // sumStretch -= chain[i].stretch;
1508 n--; 1518 n--;
1509 break; 1519 break;
1510 } 1520 }
1511 } 1521 }
1512 } 1522 }
1513 } else { //extra space 1523 } else { //extra space
1514 int n = count; 1524 int n = count;
1515 int space_left = space - spacerCount*spacer; 1525 int space_left = space - spacerCount*spacer;
1516 // first give to the fixed ones, and handle non-expansiveness 1526 // first give to the fixed ones, and handle non-expansiveness
1517 for ( i = start; i < start + count; i++ ) { 1527 for ( i = start; i < start + count; i++ ) {
1518 if ( !chain[i].done && (chain[i].maximumSize <= chain[i].sizeHint 1528 if ( !chain[i].done && (chain[i].maximumSize <= chain[i].sizeHint
1519 || wannaGrow && !chain[i].expansive) ) { 1529 || wannaGrow && !chain[i].expansive) ) {
1520 chain[i].size = chain[i].sizeHint; 1530 chain[i].size = chain[i].sizeHint;
1521 chain[i].done = TRUE; 1531 chain[i].done = TRUE;
1522 space_left -= chain[i].sizeHint; 1532 space_left -= chain[i].sizeHint;
1523 sumStretch -= chain[i].stretch; 1533 sumStretch -= chain[i].stretch;
1524 n--; 1534 n--;
1525 } 1535 }
1526 } 1536 }
1527 extraspace = space_left; 1537 extraspace = space_left;
1528 /* 1538 /*
1529 Do a trial distribution and calculate how much it is off. 1539 Do a trial distribution and calculate how much it is off.
1530 If there are more deficit pixels than surplus pixels, give 1540 If there are more deficit pixels than surplus pixels, give
1531 the minimum size items what they need, and repeat. 1541 the minimum size items what they need, and repeat.
1532 Otherwise give to the maximum size items, and repeat. 1542 Otherwise give to the maximum size items, and repeat.
1533 1543
1534 I have a wonderful mathematical proof for the correctness 1544 I have a wonderful mathematical proof for the correctness
1535 of this principle, but unfortunately this comment is too 1545 of this principle, but unfortunately this comment is too
1536 small to contain it. 1546 small to contain it.
1537 */ 1547 */
1538 int surplus, deficit; 1548 int surplus, deficit;
1539 do { 1549 do {
1540 surplus = deficit = 0; 1550 surplus = deficit = 0;
1541 fixed fp_space = toFixed( space_left ); 1551 fixed fp_space = toFixed( space_left );
1542 fixed fp_w = 0; 1552 fixed fp_w = 0;
1543 for ( i = start; i < start+count; i++ ) { 1553 for ( i = start; i < start+count; i++ ) {
1544 if ( chain[i].done ) 1554 if ( chain[i].done )
1545 continue; 1555 continue;
1546 extraspace = 0; 1556 extraspace = 0;
1547 if ( sumStretch <= 0 ) 1557 if ( sumStretch <= 0 )
1548 fp_w += fp_space / n; 1558 fp_w += fp_space / n;
1549 else 1559 else
1550 fp_w += (fp_space * chain[i].stretch) / sumStretch; 1560 fp_w += (fp_space * chain[i].stretch) / sumStretch;
1551 int w = fRound( fp_w ); 1561 int w = fRound( fp_w );
1552 chain[i].size = w; 1562 chain[i].size = w;
1553 fp_w -= toFixed( w ); // give the difference to the next 1563 fp_w -= toFixed( w ); // give the difference to the next
1554 if ( w < chain[i].sizeHint ) { 1564 if ( w < chain[i].sizeHint ) {
1555 deficit += chain[i].sizeHint - w; 1565 deficit += chain[i].sizeHint - w;
1556 } else if ( w > chain[i].maximumSize ) { 1566 } else if ( w > chain[i].maximumSize ) {
1557 surplus += w - chain[i].maximumSize; 1567 surplus += w - chain[i].maximumSize;
1558 } 1568 }
1559 } 1569 }
1560 if ( deficit > 0 && surplus <= deficit ) { 1570 if ( deficit > 0 && surplus <= deficit ) {
1561 // give to the ones that have too little 1571 // give to the ones that have too little
1562 for ( i = start; i < start+count; i++ ) { 1572 for ( i = start; i < start+count; i++ ) {
1563 if ( !chain[i].done && 1573 if ( !chain[i].done &&
1564 chain[i].size < chain[i].sizeHint ) { 1574 chain[i].size < chain[i].sizeHint ) {
1565 chain[i].size = chain[i].sizeHint; 1575 chain[i].size = chain[i].sizeHint;
1566 chain[i].done = TRUE; 1576 chain[i].done = TRUE;
1567 space_left -= chain[i].sizeHint; 1577 space_left -= chain[i].sizeHint;
1568 sumStretch -= chain[i].stretch; 1578 sumStretch -= chain[i].stretch;
1569 n--; 1579 n--;
1570 } 1580 }
1571 } 1581 }
1572 } 1582 }
1573 if ( surplus > 0 && surplus >= deficit ) { 1583 if ( surplus > 0 && surplus >= deficit ) {
1574 // take from the ones that have too much 1584 // take from the ones that have too much
1575 for ( i = start; i < start+count; i++ ) { 1585 for ( i = start; i < start+count; i++ ) {
1576 if ( !chain[i].done && 1586 if ( !chain[i].done &&
1577 chain[i].size > chain[i].maximumSize ) { 1587 chain[i].size > chain[i].maximumSize ) {
1578 chain[i].size = chain[i].maximumSize; 1588 chain[i].size = chain[i].maximumSize;
1579 chain[i].done = TRUE; 1589 chain[i].done = TRUE;
1580 space_left -= chain[i].maximumSize; 1590 space_left -= chain[i].maximumSize;
1581 sumStretch -= chain[i].stretch; 1591 sumStretch -= chain[i].stretch;
1582 n--; 1592 n--;
1583 } 1593 }
1584 } 1594 }
1585 } 1595 }
1586 } while ( n > 0 && surplus != deficit ); 1596 } while ( n > 0 && surplus != deficit );
1587 if ( n == 0 ) 1597 if ( n == 0 )
1588 extraspace = space_left; 1598 extraspace = space_left;
1589 } 1599 }
1590 1600
1591 // as a last resort, we distribute the unwanted space equally 1601 // as a last resort, we distribute the unwanted space equally
1592 // among the spacers (counting the start and end of the chain). 1602 // among the spacers (counting the start and end of the chain).
1593 1603
1594 //### should do a sub-pixel allocation of extra space 1604 //### should do a sub-pixel allocation of extra space
1595 int extra = extraspace / ( spacerCount + 2 ); 1605 int extra = extraspace / ( spacerCount + 2 );
1596 int p = pos + extra; 1606 int p = pos + extra;
1597 for ( i = start; i < start+count; i++ ) { 1607 for ( i = start; i < start+count; i++ ) {
1598 chain[i].pos = p; 1608 chain[i].pos = p;
1599 p = p + chain[i].size; 1609 p = p + chain[i].size;
1600 if ( !chain[i].empty ) 1610 if ( !chain[i].empty )
1601 p += spacer+extra; 1611 p += spacer+extra;
1602 } 1612 }
1603} 1613}
1604 1614
1605#endif 1615#endif
1606 1616
1607/*! 1617/*!
1608 \enum KDGanttMinimizeSplitter::Direction 1618 \enum KDGanttMinimizeSplitter::Direction
1609 1619
1610 The values of this enumeration describe into which direction the 1620 The values of this enumeration describe into which direction the
1611 splitter will collapse its child widgets. By extension, it also 1621 splitter will collapse its child widgets. By extension, it also
1612 specifies the orientation of the splitter; collapsing to the left or 1622 specifies the orientation of the splitter; collapsing to the left or
1613 to the right results in a horizontal splitter, collapsing to the top 1623 to the right results in a horizontal splitter, collapsing to the top
1614 or bottom in a vertical splitter. 1624 or bottom in a vertical splitter.
1615*/ 1625*/
1616 1626
1617/*! 1627/*!
1618 \fn Orientation KDGanttMinimizeSplitter::orientation() const 1628 \fn Orientation KDGanttMinimizeSplitter::orientation() const
1619 1629
1620 Returns the orientation of the splitter. 1630 Returns the orientation of the splitter.
1621*/ 1631*/
1622 1632
1623/*! \enum KDGanttMinimizeSplitter::ResizeMode 1633/*! \enum KDGanttMinimizeSplitter::ResizeMode
1624 1634
1625 This enum type describes how KDGanttMinimizeSplitter will resize each of its child widgets. The currently defined values are: 1635 This enum type describes how KDGanttMinimizeSplitter will resize each of its child widgets. The currently defined values are:
1626 1636
1627 Stretch: the widget will be resized when the splitter 1637 Stretch: the widget will be resized when the splitter
1628 itself is resized. 1638 itself is resized.
1629 1639
1630 KeepSize: KDGanttMinimizeSplitter will try to keep this widget's size 1640 KeepSize: KDGanttMinimizeSplitter will try to keep this widget's size
1631 unchanged. 1641 unchanged.
1632 1642
1633 FollowSizeHint: KDGanttMinimizeSplitter will resize the widget when the 1643 FollowSizeHint: KDGanttMinimizeSplitter will resize the widget when the
1634 widget's size hint changes. 1644 widget's size hint changes.
1635*/ 1645*/
1636 1646
diff --git a/microkde/KDGanttMinimizeSplitter.h b/microkde/KDGanttMinimizeSplitter.h
index 75e0443..8120d14 100644
--- a/microkde/KDGanttMinimizeSplitter.h
+++ b/microkde/KDGanttMinimizeSplitter.h
@@ -1,186 +1,188 @@
1/* -*- Mode: C++ -*- 1/* -*- Mode: C++ -*-
2 $Id$ 2 $Id$
3*/ 3*/
4 4
5/**************************************************************************** 5/****************************************************************************
6 ** Copyright (C) 2001-2004 Klarälvdalens Datakonsult AB. All rights reserved. 6 ** Copyright (C) 2001-2004 Klarälvdalens Datakonsult AB. All rights reserved.
7 ** 7 **
8 ** This file is part of the KDGantt library. 8 ** This file is part of the KDGantt library.
9 ** 9 **
10 ** This file may be distributed and/or modified under the terms of the 10 ** This file may be distributed and/or modified under the terms of the
11 ** GNU General Public License version 2 as published by the Free Software 11 ** GNU General Public License version 2 as published by the Free Software
12 ** Foundation and appearing in the file LICENSE.GPL included in the 12 ** Foundation and appearing in the file LICENSE.GPL included in the
13 ** packaging of this file. 13 ** packaging of this file.
14 ** 14 **
15 ** Licensees holding valid commercial KDGantt licenses may use this file in 15 ** Licensees holding valid commercial KDGantt licenses may use this file in
16 ** accordance with the KDGantt Commercial License Agreement provided with 16 ** accordance with the KDGantt Commercial License Agreement provided with
17 ** the Software. 17 ** the Software.
18 ** 18 **
19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 ** 21 **
22 ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for 22 ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for
23 ** information about KDGantt Commercial License Agreements. 23 ** information about KDGantt Commercial License Agreements.
24 ** 24 **
25 ** Contact info@klaralvdalens-datakonsult.se if any conditions of this 25 ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
26 ** licensing are not clear to you. 26 ** licensing are not clear to you.
27 ** 27 **
28 ** As a special exception, permission is given to link this program 28 ** As a special exception, permission is given to link this program
29 ** with any edition of Qt, and distribute the resulting executable, 29 ** with any edition of Qt, and distribute the resulting executable,
30 ** without including the source code for Qt in the source distribution. 30 ** without including the source code for Qt in the source distribution.
31 ** 31 **
32 **********************************************************************/ 32 **********************************************************************/
33 33
34#ifndef KDGANTTMINIMIZESPLITTER_H 34#ifndef KDGANTTMINIMIZESPLITTER_H
35#define KDGANTTMINIMIZESPLITTER_H 35#define KDGANTTMINIMIZESPLITTER_H
36 36
37#ifndef QT_H 37#ifndef QT_H
38#include "qframe.h" 38#include "qframe.h"
39#include "qvaluelist.h" 39#include "qvaluelist.h"
40#endif // QT_H 40#endif // QT_H
41 41
42#ifndef QT_NO_SPLITTER___ 42#ifndef QT_NO_SPLITTER___
43class QSplitterData; 43class QSplitterData;
44class QSplitterLayoutStruct; 44class QSplitterLayoutStruct;
45class KDGanttSplitterHandle; 45class KDGanttSplitterHandle;
46class KDGanttMinimizeSplitter : public QFrame 46class KDGanttMinimizeSplitter : public QFrame
47{ 47{
48 Q_OBJECT 48 Q_OBJECT
49 // Q_ENUMS( Direction ) 49 // Q_ENUMS( Direction )
50 // Q_PROPERTY( Orientation orientation READ orientation WRITE setOrientation ) 50 // Q_PROPERTY( Orientation orientation READ orientation WRITE setOrientation )
51 // Q_PROPERTY( Direction minimizeDirection READ minimizeDirection WRITE setMinimizeDirection ) 51 // Q_PROPERTY( Direction minimizeDirection READ minimizeDirection WRITE setMinimizeDirection )
52 52
53public: 53public:
54 enum ResizeMode { Stretch, KeepSize, FollowSizeHint }; 54 enum ResizeMode { Stretch, KeepSize, FollowSizeHint };
55 enum Direction { Left, Right, Up, Down }; 55 enum Direction { Left, Right, Up, Down };
56 56
57 KDGanttMinimizeSplitter( QWidget* parent=0, const char* name=0 ); 57 KDGanttMinimizeSplitter( QWidget* parent=0, const char* name=0 );
58 KDGanttMinimizeSplitter( Orientation, QWidget* parent=0, const char* name=0 ); 58 KDGanttMinimizeSplitter( Orientation, QWidget* parent=0, const char* name=0 );
59 ~KDGanttMinimizeSplitter(); 59 ~KDGanttMinimizeSplitter();
60 60
61 virtual void setOrientation( Orientation ); 61 virtual void setOrientation( Orientation );
62 Orientation orientation() const { return orient; } 62 Orientation orientation() const { return orient; }
63 63
64 void setMinimizeDirection( Direction ); 64 void setMinimizeDirection( Direction );
65 Direction minimizeDirection() const; 65 Direction minimizeDirection() const;
66 66
67#if QT_VERSION >= 232 67#if QT_VERSION >= 232
68 virtual void setResizeMode( QWidget *w, ResizeMode ); 68 virtual void setResizeMode( QWidget *w, ResizeMode );
69 virtual void setOpaqueResize( bool = TRUE ); 69 virtual void setOpaqueResize( bool = TRUE );
70 bool opaqueResize() const; 70 bool opaqueResize() const;
71 71
72 void moveToFirst( QWidget * ); 72 void moveToFirst( QWidget * );
73 void moveToLast( QWidget * ); 73 void moveToLast( QWidget * );
74 74
75 void refresh() { recalc( TRUE ); } 75 void refresh() { recalc( TRUE ); }
76 QSize sizeHint() const; 76 QSize sizeHint() const;
77 QSize minimumSizeHint() const; 77 QSize minimumSizeHint() const;
78 78
79 QValueList<int> sizes() const; 79 QValueList<int> sizes() const;
80 void setSizes( QValueList<int> ); 80 void setSizes( QValueList<int> );
81 KDGanttSplitterHandle* firstHandle(){ return mFirstHandle;} 81 KDGanttSplitterHandle* firstHandle(){ return mFirstHandle;}
82 void expandPos( int id, int* min, int* max ); 82 void expandPos( int id, int* min, int* max );
83public slots:
84 void toggle();
83protected: 85protected:
84 void childEvent( QChildEvent * ); 86 void childEvent( QChildEvent * );
85 87
86 bool event( QEvent * ); 88 bool event( QEvent * );
87 void resizeEvent( QResizeEvent * ); 89 void resizeEvent( QResizeEvent * );
88 90
89 int idAfter( QWidget* ) const; 91 int idAfter( QWidget* ) const;
90 92
91 void moveSplitter( QCOORD pos, int id ); 93 void moveSplitter( QCOORD pos, int id );
92 virtual void drawSplitter( QPainter*, QCOORD x, QCOORD y, 94 virtual void drawSplitter( QPainter*, QCOORD x, QCOORD y,
93 QCOORD w, QCOORD h ); 95 QCOORD w, QCOORD h );
94 void styleChange( QStyle& ); 96 void styleChange( QStyle& );
95 int adjustPos( int , int ); 97 int adjustPos( int , int );
96 virtual void setRubberband( int ); 98 virtual void setRubberband( int );
97 void getRange( int id, int*, int* ); 99 void getRange( int id, int*, int* );
98 100
99private: 101private:
100 void init(); 102 void init();
101 void recalc( bool update = FALSE ); 103 void recalc( bool update = FALSE );
102 void doResize(); 104 void doResize();
103 void storeSizes(); 105 void storeSizes();
104 void processChildEvents(); 106 void processChildEvents();
105 QSplitterLayoutStruct *addWidget( QWidget*, bool first = FALSE ); 107 QSplitterLayoutStruct *addWidget( QWidget*, bool first = FALSE );
106 void recalcId(); 108 void recalcId();
107 void moveBefore( int pos, int id, bool upLeft ); 109 void moveBefore( int pos, int id, bool upLeft );
108 void moveAfter( int pos, int id, bool upLeft ); 110 void moveAfter( int pos, int id, bool upLeft );
109 void setG( QWidget *w, int p, int s, bool isSplitter = FALSE ); 111 void setG( QWidget *w, int p, int s, bool isSplitter = FALSE );
110 112
111 QCOORD pick( const QPoint &p ) const 113 QCOORD pick( const QPoint &p ) const
112 { return orient == Horizontal ? p.x() : p.y(); } 114 { return orient == Horizontal ? p.x() : p.y(); }
113 QCOORD pick( const QSize &s ) const 115 QCOORD pick( const QSize &s ) const
114 { return orient == Horizontal ? s.width() : s.height(); } 116 { return orient == Horizontal ? s.width() : s.height(); }
115 117
116 QCOORD trans( const QPoint &p ) const 118 QCOORD trans( const QPoint &p ) const
117 { return orient == Vertical ? p.x() : p.y(); } 119 { return orient == Vertical ? p.x() : p.y(); }
118 QCOORD trans( const QSize &s ) const 120 QCOORD trans( const QSize &s ) const
119 { return orient == Vertical ? s.width() : s.height(); } 121 { return orient == Vertical ? s.width() : s.height(); }
120 KDGanttSplitterHandle* mFirstHandle; 122 KDGanttSplitterHandle* mFirstHandle;
121 QSplitterData *data; 123 QSplitterData *data;
122#endif 124#endif
123 125
124private: 126private:
125 Orientation orient; 127 Orientation orient;
126 Direction _direction; 128 Direction _direction;
127#ifndef DOXYGEN_SKIP_INTERNAL 129#ifndef DOXYGEN_SKIP_INTERNAL
128 friend class KDGanttSplitterHandle; 130 friend class KDGanttSplitterHandle;
129#endif 131#endif
130 private:// Disabled copy constructor and operator= 132 private:// Disabled copy constructor and operator=
131#if defined(Q_DISABLE_COPY) 133#if defined(Q_DISABLE_COPY)
132 KDGanttMinimizeSplitter( const KDGanttMinimizeSplitter & ); 134 KDGanttMinimizeSplitter( const KDGanttMinimizeSplitter & );
133 KDGanttMinimizeSplitter& operator=( const KDGanttMinimizeSplitter & ); 135 KDGanttMinimizeSplitter& operator=( const KDGanttMinimizeSplitter & );
134#endif 136#endif
135}; 137};
136 138
137#ifndef DOXYGEN_SKIP_INTERNAL 139#ifndef DOXYGEN_SKIP_INTERNAL
138// This class was continued from a verbatim copy of the 140// This class was continued from a verbatim copy of the
139// QSplitterHandle pertaining to the Qt Enterprise License and the 141// QSplitterHandle pertaining to the Qt Enterprise License and the
140// GPL. It has only been renamed to KDGanttSplitterHandler in order to 142// GPL. It has only been renamed to KDGanttSplitterHandler in order to
141// avoid a symbol clash on some platforms. 143// avoid a symbol clash on some platforms.
142class KDGanttSplitterHandle : public QWidget 144class KDGanttSplitterHandle : public QWidget
143{ 145{
144 Q_OBJECT 146 Q_OBJECT
145#if QT_VERSION >= 232 147#if QT_VERSION >= 232
146public: 148public:
147 KDGanttSplitterHandle( Qt::Orientation o, 149 KDGanttSplitterHandle( Qt::Orientation o,
148 KDGanttMinimizeSplitter *parent, const char* name=0 ); 150 KDGanttMinimizeSplitter *parent, const char* name=0 );
149 void setOrientation( Qt::Orientation o ); 151 void setOrientation( Qt::Orientation o );
150 Qt::Orientation orientation() const { return orient; } 152 Qt::Orientation orientation() const { return orient; }
151 153
152 bool opaque() const { return s->opaqueResize(); } 154 bool opaque() const { return s->opaqueResize(); }
153 155
154 QSize sizeHint() const; 156 QSize sizeHint() const;
155 void toggle(); 157 void toggle();
156 158
157 int id() const { return myId; } // data->list.at(id())->wid == this 159 int id() const { return myId; } // data->list.at(id())->wid == this
158 void setId( int i ) { myId = i; } 160 void setId( int i ) { myId = i; }
159 161
160protected: 162protected:
161 QValueList<QPointArray> buttonRegions(); 163 QValueList<QPointArray> buttonRegions();
162 void paintEvent( QPaintEvent * ); 164 void paintEvent( QPaintEvent * );
163 void mouseMoveEvent( QMouseEvent * ); 165 void mouseMoveEvent( QMouseEvent * );
164 void mousePressEvent( QMouseEvent * ); 166 void mousePressEvent( QMouseEvent * );
165 void mouseReleaseEvent( QMouseEvent * ); 167 void mouseReleaseEvent( QMouseEvent * );
166 int onButton( const QPoint& p ); 168 int onButton( const QPoint& p );
167 void updateCursor( const QPoint& p ); 169 void updateCursor( const QPoint& p );
168 170
169private: 171private:
170 QSize mSizeHint; 172 QSize mSizeHint;
171 bool mUseOffset; 173 bool mUseOffset;
172 Qt::Orientation orient; 174 Qt::Orientation orient;
173 bool opaq; 175 bool opaq;
174 int myId; 176 int myId;
175 177
176 KDGanttMinimizeSplitter *s; 178 KDGanttMinimizeSplitter *s;
177 int _activeButton; 179 int _activeButton;
178 bool _collapsed; 180 bool _collapsed;
179 int _origPos; 181 int _origPos;
180#endif 182#endif
181}; 183};
182#endif 184#endif
183 185
184#endif // QT_NO_SPLITTER 186#endif // QT_NO_SPLITTER
185 187
186#endif // KDGANTTMINIMIZESPLITTER_H 188#endif // KDGANTTMINIMIZESPLITTER_H