summaryrefslogtreecommitdiffabout
path: root/microkde/KDGanttMinimizeSplitter.cpp
authorzautrix <zautrix>2005-04-01 18:10:09 (UTC)
committer zautrix <zautrix>2005-04-01 18:10:09 (UTC)
commitedc032c21ae3788d02a632ea8066e4ac5a4feedb (patch) (unidiff)
tree8e59c8dcf1cc3021694025627d36e152f7adc389 /microkde/KDGanttMinimizeSplitter.cpp
parent5d88f92b76a760f100384ea5fa6ed143088d19bb (diff)
downloadkdepimpi-edc032c21ae3788d02a632ea8066e4ac5a4feedb.zip
kdepimpi-edc032c21ae3788d02a632ea8066e4ac5a4feedb.tar.gz
kdepimpi-edc032c21ae3788d02a632ea8066e4ac5a4feedb.tar.bz2
fixes
Diffstat (limited to 'microkde/KDGanttMinimizeSplitter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/KDGanttMinimizeSplitter.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/microkde/KDGanttMinimizeSplitter.cpp b/microkde/KDGanttMinimizeSplitter.cpp
index ea3a329..d675517 100644
--- a/microkde/KDGanttMinimizeSplitter.cpp
+++ b/microkde/KDGanttMinimizeSplitter.cpp
@@ -297,786 +297,794 @@ void KDGanttSplitterHandle::paintEvent( QPaintEvent * )
297 p.translate( 0, 1 ); 297 p.translate( 0, 1 );
298 for ( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { 298 for ( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) {
299 if ( index == _activeButton ) { 299 if ( index == _activeButton ) {
300 300
301 /* 301 /*
302 if ( ! _collapsed ) { 302 if ( ! _collapsed ) {
303 p.save(); 303 p.save();
304 // p.translate( parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftHorizontal ), 304 // p.translate( parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftHorizontal ),
305 // parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftVertical ) ); 305 // parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftVertical ) );
306 p.translate( -1, 0 ); 306 p.translate( -1, 0 );
307 p.drawPolygon( *it, true ); 307 p.drawPolygon( *it, true );
308 p.restore(); } else 308 p.restore(); } else
309 */ 309 */
310 p.drawPolygon( *it, true ); 310 p.drawPolygon( *it, true );
311 311
312 } 312 }
313 else { 313 else {
314 /* 314 /*
315 if ( ! _collapsed ) { 315 if ( ! _collapsed ) {
316 p.save(); 316 p.save();
317 p.translate( -1, 0 ); 317 p.translate( -1, 0 );
318 p.drawPolygon( *it, true ); 318 p.drawPolygon( *it, true );
319 p.restore(); 319 p.restore();
320 } else 320 } else
321 */ 321 */
322 p.drawPolygon( *it, true ); 322 p.drawPolygon( *it, true );
323 323
324 } 324 }
325 index++; 325 index++;
326 } 326 }
327 327
328 // Draw the lines between the arrows 328 // Draw the lines between the arrows
329 if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left || 329 if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left ||
330 s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { 330 s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) {
331 int mid = height()/2; 331 int mid = height()/2;
332 p.drawLine ( 1, mid - sw, 1, mid + sw ); 332 p.drawLine ( 1, mid - sw, 1, mid + sw );
333 p.drawLine ( 3, mid - sw, 3, mid + sw ); 333 p.drawLine ( 3, mid - sw, 3, mid + sw );
334 } 334 }
335 else if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Up || 335 else if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Up ||
336 s->minimizeDirection() == KDGanttMinimizeSplitter::Down ) { 336 s->minimizeDirection() == KDGanttMinimizeSplitter::Down ) {
337 int mid = width()/2; 337 int mid = width()/2;
338 p.drawLine( mid -sw, 1, mid +sw, 1 ); 338 p.drawLine( mid -sw, 1, mid +sw, 1 );
339 p.drawLine( mid -sw, 3, mid +sw, 3 ); 339 p.drawLine( mid -sw, 3, mid +sw, 3 );
340 } 340 }
341 bitBlt( this, 0, 0, &buffer ); 341 bitBlt( this, 0, 0, &buffer );
342 342
343} 343}
344#endif 344#endif
345 345
346class QSplitterLayoutStruct 346class QSplitterLayoutStruct
347{ 347{
348public: 348public:
349 KDGanttMinimizeSplitter::ResizeMode mode; 349 KDGanttMinimizeSplitter::ResizeMode mode;
350 QCOORD sizer; 350 QCOORD sizer;
351 bool isSplitter; 351 bool isSplitter;
352 QWidget *wid; 352 QWidget *wid;
353}; 353};
354 354
355class QSplitterData 355class QSplitterData
356{ 356{
357public: 357public:
358 QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {} 358 QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {}
359 359
360 QPtrList<QSplitterLayoutStruct> list; 360 QPtrList<QSplitterLayoutStruct> list;
361 bool opaque; 361 bool opaque;
362 bool firstShow; 362 bool firstShow;
363}; 363};
364 364
365void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, 365void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos,
366 int space, int spacer ); 366 int space, int spacer );
367#endif // DOXYGEN_SKIP_INTERNAL 367#endif // DOXYGEN_SKIP_INTERNAL
368 368
369 369
370/*! 370/*!
371 \class KDGanttMinimizeSplitter KDGanttMinimizeSplitter.h 371 \class KDGanttMinimizeSplitter KDGanttMinimizeSplitter.h
372 \brief The KDGanttMinimizeSplitter class implements a splitter 372 \brief The KDGanttMinimizeSplitter class implements a splitter
373 widget with minimize buttons. 373 widget with minimize buttons.
374 374
375 This class (and its documentation) is largely a copy of Qt's 375 This class (and its documentation) is largely a copy of Qt's
376 QSplitter; the copying was necessary because QSplitter is not 376 QSplitter; the copying was necessary because QSplitter is not
377 extensible at all. QSplitter and its documentation are licensed 377 extensible at all. QSplitter and its documentation are licensed
378 according to the GPL and the Qt Professional License (if you hold 378 according to the GPL and the Qt Professional License (if you hold
379 such a license) and are (C) Trolltech AS. 379 such a license) and are (C) Trolltech AS.
380 380
381 A splitter lets the user control the size of child widgets by 381 A splitter lets the user control the size of child widgets by
382 dragging the boundary between the children. Any number of widgets 382 dragging the boundary between the children. Any number of widgets
383 may be controlled. 383 may be controlled.
384 384
385 To show a QListBox, a QListView and a QTextEdit side by side: 385 To show a QListBox, a QListView and a QTextEdit side by side:
386 386
387 \code 387 \code
388 KDGanttMinimizeSplitter *split = new KDGanttMinimizeSplitter( parent ); 388 KDGanttMinimizeSplitter *split = new KDGanttMinimizeSplitter( parent );
389 QListBox *lb = new QListBox( split ); 389 QListBox *lb = new QListBox( split );
390 QListView *lv = new QListView( split ); 390 QListView *lv = new QListView( split );
391 QTextEdit *ed = new QTextEdit( split ); 391 QTextEdit *ed = new QTextEdit( split );
392 \endcode 392 \endcode
393 393
394 In KDGanttMinimizeSplitter, the boundary can be either horizontal or 394 In KDGanttMinimizeSplitter, the boundary can be either horizontal or
395 vertical. The default is horizontal (the children are side by side) 395 vertical. The default is horizontal (the children are side by side)
396 but you can use setOrientation( QSplitter::Vertical ) to set it to 396 but you can use setOrientation( QSplitter::Vertical ) to set it to
397 vertical. 397 vertical.
398 398
399 Use setResizeMode() to specify 399 Use setResizeMode() to specify
400 that a widget should keep its size when the splitter is resized. 400 that a widget should keep its size when the splitter is resized.
401 401
402 Although KDGanttMinimizeSplitter normally resizes the children only 402 Although KDGanttMinimizeSplitter normally resizes the children only
403 at the end of a resize operation, if you call setOpaqueResize( TRUE 403 at the end of a resize operation, if you call setOpaqueResize( TRUE
404 ) the widgets are resized as often as possible. 404 ) the widgets are resized as often as possible.
405 405
406 The initial distribution of size between the widgets is determined 406 The initial distribution of size between the widgets is determined
407 by the initial size of each widget. You can also use setSizes() to 407 by the initial size of each widget. You can also use setSizes() to
408 set the sizes of all the widgets. The function sizes() returns the 408 set the sizes of all the widgets. The function sizes() returns the
409 sizes set by the user. 409 sizes set by the user.
410 410
411 If you hide() a child, its space will be distributed among the other 411 If you hide() a child, its space will be distributed among the other
412 children. It will be reinstated when you show() it again. It is also 412 children. It will be reinstated when you show() it again. It is also
413 possible to reorder the widgets within the splitter using 413 possible to reorder the widgets within the splitter using
414 moveToFirst() and moveToLast(). 414 moveToFirst() and moveToLast().
415*/ 415*/
416 416
417 417
418 418
419static QSize minSize( const QWidget* /*w*/ ) 419static QSize minSize( const QWidget* /*w*/ )
420{ 420{
421 return QSize(0,0); 421 return QSize(0,0);
422} 422}
423 423
424// This is the original version of minSize 424// This is the original version of minSize
425static QSize minSizeHint( const QWidget* w ) 425static QSize minSizeHint( const QWidget* w )
426{ 426{
427 QSize min = w->minimumSize(); 427 QSize min = w->minimumSize();
428 QSize s; 428 QSize s;
429 if ( min.height() <= 0 || min.width() <= 0 ) 429 if ( min.height() <= 0 || min.width() <= 0 )
430 s = w->minimumSizeHint(); 430 s = w->minimumSizeHint();
431 if ( min.height() > 0 ) 431 if ( min.height() > 0 )
432 s.setHeight( min.height() ); 432 s.setHeight( min.height() );
433 if ( min.width() > 0 ) 433 if ( min.width() > 0 )
434 s.setWidth( min.width() ); 434 s.setWidth( min.width() );
435 return s.expandedTo(QSize(0,0)); 435 return s.expandedTo(QSize(0,0));
436} 436}
437 437
438 438
439/*! 439/*!
440 Constructs a horizontal splitter with the \a parent and \a 440 Constructs a horizontal splitter with the \a parent and \a
441 name arguments being passed on to the QFrame constructor. 441 name arguments being passed on to the QFrame constructor.
442*/ 442*/
443KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *name ) 443KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *name )
444 :QFrame(parent,name,WPaintUnclipped) 444 :QFrame(parent,name,WPaintUnclipped)
445{ 445{
446 mRubberBand = 0; 446 mRubberBand = 0;
447 mFirstHandle = 0; 447 mFirstHandle = 0;
448#if QT_VERSION >= 232 448#if QT_VERSION >= 232
449 orient = Horizontal; 449 orient = Horizontal;
450 init(); 450 init();
451#endif 451#endif
452} 452}
453 453
454/*! 454/*!
455 Constructs a splitter with orientation \a o with the \a parent 455 Constructs a splitter with orientation \a o with the \a parent
456 and \a name arguments being passed on to the QFrame constructor. 456 and \a name arguments being passed on to the QFrame constructor.
457*/ 457*/
458KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Orientation o, QWidget *parent, const char *name ) 458KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Orientation o, QWidget *parent, const char *name )
459 :QFrame(parent,name,WPaintUnclipped) 459 :QFrame(parent,name,WPaintUnclipped)
460{ 460{
461 461
462 mRubberBand = 0; 462 mRubberBand = 0;
463 mFirstHandle = 0; 463 mFirstHandle = 0;
464#if QT_VERSION >= 232 464#if QT_VERSION >= 232
465 orient = o; 465 orient = o;
466 init(); 466 init();
467#endif 467#endif
468} 468}
469 469
470/*! 470/*!
471 Destroys the splitter and any children. 471 Destroys the splitter and any children.
472*/ 472*/
473KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter() 473KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter()
474{ 474{
475#if QT_VERSION >= 232 475#if QT_VERSION >= 232
476 data->list.setAutoDelete( TRUE ); 476 data->list.setAutoDelete( TRUE );
477 delete data; 477 delete data;
478#endif 478#endif
479 if ( mRubberBand ) 479 if ( mRubberBand )
480 delete mRubberBand; 480 delete mRubberBand;
481} 481}
482 482
483 483
484#if QT_VERSION >= 232 484#if QT_VERSION >= 232
485void KDGanttMinimizeSplitter::init() 485void KDGanttMinimizeSplitter::init()
486{ 486{
487 data = new QSplitterData; 487 data = new QSplitterData;
488 if ( orient == Horizontal ) 488 if ( orient == Horizontal )
489 setSizePolicy( QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum) ); 489 setSizePolicy( QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum) );
490 else 490 else
491 setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding) ); 491 setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding) );
492#ifndef DESKTOP_VERSION 492#ifndef DESKTOP_VERSION
493 setOpaqueResize( false ); 493 setOpaqueResize( false );
494#else 494#else
495 setOpaqueResize( true ); 495 setOpaqueResize( true );
496#endif 496#endif
497} 497}
498#endif 498#endif
499 499
500 500
501void KDGanttMinimizeSplitter::toggle() 501void KDGanttMinimizeSplitter::toggle()
502{ 502{
503 if ( mFirstHandle ) 503 if ( mFirstHandle )
504 mFirstHandle->toggle(); 504 mFirstHandle->toggle();
505 else 505 else
506 qDebug("KDGanttMinimizeSplitter::toggle::sorry, handle not available "); 506 qDebug("KDGanttMinimizeSplitter::toggle::sorry, handle not available ");
507 507
508} 508}
509 509
510 510
511/*! 511/*!
512 \brief the orientation of the splitter 512 \brief the orientation of the splitter
513 513
514 By default the orientation is horizontal (the widgets are side by side). 514 By default the orientation is horizontal (the widgets are side by side).
515 The possible orientations are Qt:Vertical and Qt::Horizontal (the default). 515 The possible orientations are Qt:Vertical and Qt::Horizontal (the default).
516*/ 516*/
517void KDGanttMinimizeSplitter::setOrientation( Orientation o ) 517void KDGanttMinimizeSplitter::setOrientation( Orientation o )
518{ 518{
519#if QT_VERSION >= 232 519#if QT_VERSION >= 232
520 if ( orient == o ) 520 if ( orient == o )
521 return; 521 return;
522 orient = o; 522 orient = o;
523 523
524 if ( orient == Horizontal ) 524 if ( orient == Horizontal )
525 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); 525 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
526 else 526 else
527 setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); 527 setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) );
528 528
529 QSplitterLayoutStruct *s = data->list.first(); 529 QSplitterLayoutStruct *s = data->list.first();
530 while ( s ) { 530 while ( s ) {
531 if ( s->isSplitter ) 531 if ( s->isSplitter )
532 ((KDGanttSplitterHandle*)s->wid)->setOrientation( o ); 532 ((KDGanttSplitterHandle*)s->wid)->setOrientation( o );
533 s = data->list.next(); // ### next at end of loop, no iterator 533 s = data->list.next(); // ### next at end of loop, no iterator
534 } 534 }
535 recalc( isVisible() ); 535 recalc( isVisible() );
536#endif 536#endif
537} 537}
538 538
539 539
540#if QT_VERSION >= 232 540#if QT_VERSION >= 232
541/*! 541/*!
542 \reimp 542 \reimp
543*/ 543*/
544void KDGanttMinimizeSplitter::resizeEvent( QResizeEvent * ) 544void KDGanttMinimizeSplitter::resizeEvent( QResizeEvent * )
545{ 545{
546 doResize(); 546 doResize();
547} 547}
548 548
549 549
550/* 550/*
551 Inserts the widget \a w at the end (or at the beginning if \a first 551 Inserts the widget \a w at the end (or at the beginning if \a first
552 is TRUE) of the splitter's list of widgets. 552 is TRUE) of the splitter's list of widgets.
553 553
554 It is the responsibility of the caller of this function to make sure 554 It is the responsibility of the caller of this function to make sure
555 that \a w is not already in the splitter and to call recalcId if 555 that \a w is not already in the splitter and to call recalcId if
556 needed. (If \a first is TRUE, then recalcId is very probably 556 needed. (If \a first is TRUE, then recalcId is very probably
557 needed.) 557 needed.)
558*/ 558*/
559QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool first ) 559QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool first )
560{ 560{
561 QSplitterLayoutStruct *s; 561 QSplitterLayoutStruct *s;
562 KDGanttSplitterHandle *newHandle = 0; 562 KDGanttSplitterHandle *newHandle = 0;
563 if ( data->list.count() > 0 ) { 563 if ( data->list.count() > 0 ) {
564 s = new QSplitterLayoutStruct; 564 s = new QSplitterLayoutStruct;
565 s->mode = KeepSize; 565 s->mode = KeepSize;
566 QString tmp = "qt_splithandle_"; 566 QString tmp = "qt_splithandle_";
567 tmp += w->name(); 567 tmp += w->name();
568 newHandle = new KDGanttSplitterHandle( orientation(), this, tmp.latin1() ); 568 newHandle = new KDGanttSplitterHandle( orientation(), this, tmp.latin1() );
569 if ( ! mFirstHandle ) 569 if ( ! mFirstHandle )
570 mFirstHandle = newHandle; 570 mFirstHandle = newHandle;
571 s->wid = newHandle; 571 s->wid = newHandle;
572 newHandle->setId(data->list.count()); 572 newHandle->setId(data->list.count());
573 s->isSplitter = TRUE; 573 s->isSplitter = TRUE;
574 s->sizer = pick( newHandle->sizeHint() ); 574 s->sizer = pick( newHandle->sizeHint() );
575 if ( first ) 575 if ( first )
576 data->list.insert( 0, s ); 576 data->list.insert( 0, s );
577 else 577 else
578 data->list.append( s ); 578 data->list.append( s );
579 } 579 }
580 s = new QSplitterLayoutStruct; 580 s = new QSplitterLayoutStruct;
581 s->mode = Stretch; 581 s->mode = Stretch;
582 s->wid = w; 582 s->wid = w;
583 if ( !testWState( WState_Resized ) && w->sizeHint().isValid() ) 583 if ( !testWState( WState_Resized ) && w->sizeHint().isValid() )
584 s->sizer = pick( w->sizeHint() ); 584 s->sizer = pick( w->sizeHint() );
585 else 585 else
586 s->sizer = pick( w->size() ); 586 s->sizer = pick( w->size() );
587 s->isSplitter = FALSE; 587 s->isSplitter = FALSE;
588 if ( first ) 588 if ( first )
589 data->list.insert( 0, s ); 589 data->list.insert( 0, s );
590 else 590 else
591 data->list.append( s ); 591 data->list.append( s );
592 if ( newHandle && isVisible() ) 592 if ( newHandle && isVisible() )
593 newHandle->show(); //will trigger sending of post events 593 newHandle->show(); //will trigger sending of post events
594 return s; 594 return s;
595} 595}
596 596
597 597
598/*! 598/*!
599 Tells the splitter that a child widget has been inserted or removed. 599 Tells the splitter that a child widget has been inserted or removed.
600 The event is passed in \a c. 600 The event is passed in \a c.
601*/ 601*/
602void KDGanttMinimizeSplitter::childEvent( QChildEvent *c ) 602void KDGanttMinimizeSplitter::childEvent( QChildEvent *c )
603{ 603{
604 if ( c->type() == QEvent::ChildInserted ) { 604 if ( c->type() == QEvent::ChildInserted ) {
605 if ( !c->child()->isWidgetType() ) 605 if ( !c->child()->isWidgetType() )
606 return; 606 return;
607 607
608 if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) ) 608 if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) )
609 return; 609 return;
610 610
611 QSplitterLayoutStruct *s = data->list.first(); 611 QSplitterLayoutStruct *s = data->list.first();
612 while ( s ) { 612 while ( s ) {
613 if ( s->wid == c->child() ) 613 if ( s->wid == c->child() )
614 return; 614 return;
615 s = data->list.next(); 615 s = data->list.next();
616 } 616 }
617 addWidget( (QWidget*)c->child() ); 617 addWidget( (QWidget*)c->child() );
618 recalc( isVisible() ); 618 recalc( isVisible() );
619 619
620 } else if ( c->type() == QEvent::ChildRemoved ) { 620 } else if ( c->type() == QEvent::ChildRemoved ) {
621 QSplitterLayoutStruct *p = 0; 621 QSplitterLayoutStruct *p = 0;
622 if ( data->list.count() > 1 ) 622 if ( data->list.count() > 1 )
623 p = data->list.at(1); //remove handle _after_ first widget. 623 p = data->list.at(1); //remove handle _after_ first widget.
624 QSplitterLayoutStruct *s = data->list.first(); 624 QSplitterLayoutStruct *s = data->list.first();
625 while ( s ) { 625 while ( s ) {
626 if ( s->wid == c->child() ) { 626 if ( s->wid == c->child() ) {
627 data->list.removeRef( s ); 627 data->list.removeRef( s );
628 delete s; 628 delete s;
629 if ( p && p->isSplitter ) { 629 if ( p && p->isSplitter ) {
630 data->list.removeRef( p ); 630 data->list.removeRef( p );
631 delete p->wid; //will call childEvent 631 delete p->wid; //will call childEvent
632 delete p; 632 delete p;
633 } 633 }
634 recalcId(); 634 recalcId();
635 doResize(); 635 doResize();
636 return; 636 return;
637 } 637 }
638 p = s; 638 p = s;
639 s = data->list.next(); 639 s = data->list.next();
640 } 640 }
641 } 641 }
642} 642}
643 643
644 644
645/*! 645/*!
646 Shows a rubber band at position \a p. If \a p is negative, the 646 Shows a rubber band at position \a p. If \a p is negative, the
647 rubber band is removed. 647 rubber band is removed.
648*/ 648*/
649void KDGanttMinimizeSplitter::setRubberband( int p ) 649void KDGanttMinimizeSplitter::setRubberband( int p )
650{ 650{
651#ifdef DESKTOP_VERSION 651#ifdef DESKTOP_VERSION
652 QPainter paint( this ); 652 QPainter paint( this );
653 paint.setPen( gray ); 653 paint.setPen( gray );
654 paint.setBrush( gray ); 654 paint.setBrush( gray );
655 paint.setRasterOp( XorROP ); 655 paint.setRasterOp( XorROP );
656 QRect r = contentsRect(); 656 QRect r = contentsRect();
657 const int rBord = 3; //Themable???? 657 const int rBord = 3; //Themable????
658#if QT_VERSION >= 0x030000 658#if QT_VERSION >= 0x030000
659 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); 659 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this);
660#else 660#else
661 int sw = style().splitterWidth(); 661 int sw = style().splitterWidth();
662#endif 662#endif
663 if ( orient == Horizontal ) { 663 if ( orient == Horizontal ) {
664 if ( opaqueOldPos >= 0 ) 664 if ( opaqueOldPos >= 0 )
665 paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(), 665 paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(),
666 2*rBord, r.height() ); 666 2*rBord, r.height() );
667 if ( p >= 0 ) 667 if ( p >= 0 )
668 paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() ); 668 paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() );
669 } else { 669 } else {
670 if ( opaqueOldPos >= 0 ) 670 if ( opaqueOldPos >= 0 )
671 paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord, 671 paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord,
672 r.width(), 2*rBord ); 672 r.width(), 2*rBord );
673 if ( p >= 0 ) 673 if ( p >= 0 )
674 paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord ); 674 paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord );
675 } 675 }
676 opaqueOldPos = p; 676 opaqueOldPos = p;
677#else 677#else
678 if ( !mRubberBand ) { 678 if ( !mRubberBand ) {
679 mRubberBand = new QFrame( 0, "rubber", WStyle_NoBorder | WStyle_Customize | WStyle_StaysOnTop); 679 mRubberBand = new QFrame( 0, "rubber", WStyle_NoBorder | WStyle_Customize | WStyle_StaysOnTop);
680 mRubberBand->setFrameStyle( Box | Raised ); 680 mRubberBand->setFrameStyle( Box | Raised );
681 mRubberBand->setPalette( QPalette ( Qt::green.light(),Qt::green.dark() ) ); 681 mRubberBand->setPalette( QPalette ( Qt::red.light(),Qt::red.dark() ) );
682 } 682 }
683 QRect r = contentsRect(); 683 QRect r = contentsRect();
684 const int rBord = 5; //Themable???? 684 static int rBord = 0; //Themable????
685 if ( !rBord ) {
686 if (QApplication::desktop()->width() <= 320 )
687 rBord = 4;
688 else
689 rBord = 5;
690 }
685 int sw = style().splitterWidth(); 691 int sw = style().splitterWidth();
686 if ( orient == Horizontal ) { 692 if ( orient == Horizontal ) {
687 if ( p >= 0 ) { 693 if ( p >= 0 ) {
688 QPoint geo = mapToGlobal (QPoint ( p + sw/2 - rBord, r.y())); 694 QPoint geo = mapToGlobal (QPoint ( p + sw/2 - rBord, r.y()));
689 mRubberBand->setGeometry( geo.x(), geo.y(), 2*rBord, r.height() ); 695 mRubberBand->setGeometry( geo.x(), geo.y(), 2*rBord, r.height() );
690 } 696 }
691 } else { 697 } else {
692 if ( p >= 0 ) { 698 if ( p >= 0 ) {
693 QPoint geo = mapToGlobal (QPoint ( r.x(), p + sw/2 - rBord)); 699 QPoint geo = mapToGlobal (QPoint ( r.x(), p + sw/2 - rBord));
694 mRubberBand->setGeometry( geo.x(), geo.y(), r.width(), 2*rBord); 700 mRubberBand->setGeometry( geo.x(), geo.y(), r.width(), 2*rBord);
695 } 701 }
696 } 702 }
697 opaqueOldPos = p; 703 opaqueOldPos = p;
698 mRubberBand->show(); 704 if ( ! mRubberBand->isVisible() ) {
705 mRubberBand->show();
706 }
699#endif 707#endif
700} 708}
701 709
702 710
703/*! \reimp */ 711/*! \reimp */
704bool KDGanttMinimizeSplitter::event( QEvent *e ) 712bool KDGanttMinimizeSplitter::event( QEvent *e )
705{ 713{
706 if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) { 714 if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) {
707 recalc( isVisible() ); 715 recalc( isVisible() );
708 if ( e->type() == QEvent::Show ) 716 if ( e->type() == QEvent::Show )
709 data->firstShow = FALSE; 717 data->firstShow = FALSE;
710 } 718 }
711 return QWidget::event( e ); 719 return QWidget::event( e );
712} 720}
713 721
714 722
715/*! 723/*!
716 \obsolete 724 \obsolete
717 725
718 Draws the splitter handle in the rectangle described by \a x, \a y, 726 Draws the splitter handle in the rectangle described by \a x, \a y,
719 \a w, \a h using painter \a p. 727 \a w, \a h using painter \a p.
720 \sa QStyle::drawPrimitive() 728 \sa QStyle::drawPrimitive()
721*/ 729*/
722void KDGanttMinimizeSplitter::drawSplitter( QPainter *p, 730void KDGanttMinimizeSplitter::drawSplitter( QPainter *p,
723 QCOORD x, QCOORD y, QCOORD w, QCOORD h ) 731 QCOORD x, QCOORD y, QCOORD w, QCOORD h )
724{ 732{
725#if 0 733#if 0
726 // LR 734 // LR
727 style().drawPrimitive(QStyle::PE_Splitter, p, QRect(x, y, w, h), colorGroup(), 735 style().drawPrimitive(QStyle::PE_Splitter, p, QRect(x, y, w, h), colorGroup(),
728 (orientation() == Qt::Horizontal ? 736 (orientation() == Qt::Horizontal ?
729 QStyle::Style_Horizontal : 0)); 737 QStyle::Style_Horizontal : 0));
730#endif 738#endif
731} 739}
732 740
733 741
734/*! 742/*!
735 Returns the id of the splitter to the right of or below the widget \a w, 743 Returns the id of the splitter to the right of or below the widget \a w,
736 or 0 if there is no such splitter 744 or 0 if there is no such splitter
737 (i.e. it is either not in this KDGanttMinimizeSplitter or it is at the end). 745 (i.e. it is either not in this KDGanttMinimizeSplitter or it is at the end).
738*/ 746*/
739int KDGanttMinimizeSplitter::idAfter( QWidget* w ) const 747int KDGanttMinimizeSplitter::idAfter( QWidget* w ) const
740{ 748{
741 QSplitterLayoutStruct *s = data->list.first(); 749 QSplitterLayoutStruct *s = data->list.first();
742 bool seen_w = FALSE; 750 bool seen_w = FALSE;
743 while ( s ) { 751 while ( s ) {
744 if ( s->isSplitter && seen_w ) 752 if ( s->isSplitter && seen_w )
745 return data->list.at(); 753 return data->list.at();
746 if ( !s->isSplitter && s->wid == w ) 754 if ( !s->isSplitter && s->wid == w )
747 seen_w = TRUE; 755 seen_w = TRUE;
748 s = data->list.next(); 756 s = data->list.next();
749 } 757 }
750 return 0; 758 return 0;
751} 759}
752 760
753 761
754/*! 762/*!
755 Moves the left/top edge of the splitter handle with id \a id as 763 Moves the left/top edge of the splitter handle with id \a id as
756 close as possible to position \a p, which is the distance from the 764 close as possible to position \a p, which is the distance from the
757 left (or top) edge of the widget. 765 left (or top) edge of the widget.
758 766
759 For Arabic and Hebrew the layout is reversed, and using this 767 For Arabic and Hebrew the layout is reversed, and using this
760 function to set the position of the splitter might lead to 768 function to set the position of the splitter might lead to
761 unexpected results, since in Arabic and Hebrew the position of 769 unexpected results, since in Arabic and Hebrew the position of
762 splitter one is to the left of the position of splitter zero. 770 splitter one is to the left of the position of splitter zero.
763 771
764 \sa idAfter() 772 \sa idAfter()
765*/ 773*/
766void KDGanttMinimizeSplitter::moveSplitter( QCOORD p, int id ) 774void KDGanttMinimizeSplitter::moveSplitter( QCOORD p, int id )
767{ 775{
768 p = adjustPos( p, id ); 776 p = adjustPos( p, id );
769 QSplitterLayoutStruct *s = data->list.at(id); 777 QSplitterLayoutStruct *s = data->list.at(id);
770 int oldP = orient == Horizontal ? s->wid->x() : s->wid->y(); 778 int oldP = orient == Horizontal ? s->wid->x() : s->wid->y();
771 bool upLeft; 779 bool upLeft;
772 if ( false && orient == Horizontal ) { 780 if ( false && orient == Horizontal ) {
773 p += s->wid->width(); 781 p += s->wid->width();
774 upLeft = p > oldP; 782 upLeft = p > oldP;
775 } else 783 } else
776 upLeft = p < oldP; 784 upLeft = p < oldP;
777 785
778 moveAfter( p, id, upLeft ); 786 moveAfter( p, id, upLeft );
779 moveBefore( p-1, id-1, upLeft ); 787 moveBefore( p-1, id-1, upLeft );
780 788
781 storeSizes(); 789 storeSizes();
782} 790}
783 791
784 792
785void KDGanttMinimizeSplitter::setG( QWidget *w, int p, int s, bool isSplitter ) 793void KDGanttMinimizeSplitter::setG( QWidget *w, int p, int s, bool isSplitter )
786{ 794{
787 if ( orient == Horizontal ) { 795 if ( orient == Horizontal ) {
788 if ( false && orient == Horizontal && !isSplitter ) 796 if ( false && orient == Horizontal && !isSplitter )
789 p = contentsRect().width() - p - s; 797 p = contentsRect().width() - p - s;
790 w->setGeometry( p, contentsRect().y(), s, contentsRect().height() ); 798 w->setGeometry( p, contentsRect().y(), s, contentsRect().height() );
791 } else 799 } else
792 w->setGeometry( contentsRect().x(), p, contentsRect().width(), s ); 800 w->setGeometry( contentsRect().x(), p, contentsRect().width(), s );
793} 801}
794 802
795 803
796/* 804/*
797 Places the right/bottom edge of the widget at \a id at position \a pos. 805 Places the right/bottom edge of the widget at \a id at position \a pos.
798 806
799 \sa idAfter() 807 \sa idAfter()
800*/ 808*/
801void KDGanttMinimizeSplitter::moveBefore( int pos, int id, bool upLeft ) 809void KDGanttMinimizeSplitter::moveBefore( int pos, int id, bool upLeft )
802{ 810{
803 if( id < 0 ) 811 if( id < 0 )
804 return; 812 return;
805 QSplitterLayoutStruct *s = data->list.at(id); 813 QSplitterLayoutStruct *s = data->list.at(id);
806 if ( !s ) 814 if ( !s )
807 return; 815 return;
808 QWidget *w = s->wid; 816 QWidget *w = s->wid;
809 if ( w->isHidden() ) { 817 if ( w->isHidden() ) {
810 moveBefore( pos, id-1, upLeft ); 818 moveBefore( pos, id-1, upLeft );
811 } else if ( s->isSplitter ) { 819 } else if ( s->isSplitter ) {
812 int pos1, pos2; 820 int pos1, pos2;
813 int dd = s->sizer; 821 int dd = s->sizer;
814 if( false && orient == Horizontal ) { 822 if( false && orient == Horizontal ) {
815 pos1 = pos; 823 pos1 = pos;
816 pos2 = pos + dd; 824 pos2 = pos + dd;
817 } else { 825 } else {
818 pos2 = pos - dd; 826 pos2 = pos - dd;
819 pos1 = pos2 + 1; 827 pos1 = pos2 + 1;
820 } 828 }
821 if ( upLeft ) { 829 if ( upLeft ) {
822 setG( w, pos1, dd, TRUE ); 830 setG( w, pos1, dd, TRUE );
823 moveBefore( pos2, id-1, upLeft ); 831 moveBefore( pos2, id-1, upLeft );
824 } else { 832 } else {
825 moveBefore( pos2, id-1, upLeft ); 833 moveBefore( pos2, id-1, upLeft );
826 setG( w, pos1, dd, TRUE ); 834 setG( w, pos1, dd, TRUE );
827 } 835 }
828 } else { 836 } else {
829 int dd, newLeft, nextPos; 837 int dd, newLeft, nextPos;
830 if( false && orient == Horizontal ) { 838 if( false && orient == Horizontal ) {
831 dd = w->geometry().right() - pos; 839 dd = w->geometry().right() - pos;
832 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); 840 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize())));
833 newLeft = pos+1; 841 newLeft = pos+1;
834 nextPos = newLeft + dd; 842 nextPos = newLeft + dd;
835 } else { 843 } else {
836 dd = pos - pick( w->pos() ) + 1; 844 dd = pos - pick( w->pos() ) + 1;
837 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); 845 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize())));
838 newLeft = pos-dd+1; 846 newLeft = pos-dd+1;
839 nextPos = newLeft - 1; 847 nextPos = newLeft - 1;
840 } 848 }
841 setG( w, newLeft, dd, TRUE ); 849 setG( w, newLeft, dd, TRUE );
842 moveBefore( nextPos, id-1, upLeft ); 850 moveBefore( nextPos, id-1, upLeft );
843 } 851 }
844} 852}
845 853
846 854
847/* 855/*
848 Places the left/top edge of the widget at \a id at position \a pos. 856 Places the left/top edge of the widget at \a id at position \a pos.
849 857
850 \sa idAfter() 858 \sa idAfter()
851*/ 859*/
852void KDGanttMinimizeSplitter::moveAfter( int pos, int id, bool upLeft ) 860void KDGanttMinimizeSplitter::moveAfter( int pos, int id, bool upLeft )
853{ 861{
854 QSplitterLayoutStruct *s = id < int(data->list.count()) ? 862 QSplitterLayoutStruct *s = id < int(data->list.count()) ?
855 data->list.at(id) : 0; 863 data->list.at(id) : 0;
856 if ( !s ) 864 if ( !s )
857 return; 865 return;
858 QWidget *w = s->wid; 866 QWidget *w = s->wid;
859 if ( w->isHidden() ) { 867 if ( w->isHidden() ) {
860 moveAfter( pos, id+1, upLeft ); 868 moveAfter( pos, id+1, upLeft );
861 } else if ( pick( w->pos() ) == pos ) { 869 } else if ( pick( w->pos() ) == pos ) {
862 //No need to do anything if it's already there. 870 //No need to do anything if it's already there.
863 return; 871 return;
864 } else if ( s->isSplitter ) { 872 } else if ( s->isSplitter ) {
865 int dd = s->sizer; 873 int dd = s->sizer;
866 int pos1, pos2; 874 int pos1, pos2;
867 if( false && orient == Horizontal ) { 875 if( false && orient == Horizontal ) {
868 pos2 = pos - dd; 876 pos2 = pos - dd;
869 pos1 = pos2 + 1; 877 pos1 = pos2 + 1;
870 } else { 878 } else {
871 pos1 = pos; 879 pos1 = pos;
872 pos2 = pos + dd; 880 pos2 = pos + dd;
873 } 881 }
874 if ( upLeft ) { 882 if ( upLeft ) {
875 setG( w, pos1, dd, TRUE ); 883 setG( w, pos1, dd, TRUE );
876 moveAfter( pos2, id+1, upLeft ); 884 moveAfter( pos2, id+1, upLeft );
877 } else { 885 } else {
878 moveAfter( pos2, id+1, upLeft ); 886 moveAfter( pos2, id+1, upLeft );
879 setG( w, pos1, dd, TRUE ); 887 setG( w, pos1, dd, TRUE );
880 } 888 }
881 } else { 889 } else {
882 int left = pick( w->pos() ); 890 int left = pick( w->pos() );
883 int right, dd,/* newRight,*/ newLeft, nextPos; 891 int right, dd,/* newRight,*/ newLeft, nextPos;
884 if ( false && orient == Horizontal ) { 892 if ( false && orient == Horizontal ) {
885 dd = pos - left + 1; 893 dd = pos - left + 1;
886 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); 894 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize())));
887 newLeft = pos-dd+1; 895 newLeft = pos-dd+1;
888 nextPos = newLeft - 1; 896 nextPos = newLeft - 1;
889 } else { 897 } else {
890 right = pick( w->geometry().bottomRight() ); 898 right = pick( w->geometry().bottomRight() );
891 dd = right - pos + 1; 899 dd = right - pos + 1;
892 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); 900 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize())));
893 /*newRight = pos+dd-1;*/ 901 /*newRight = pos+dd-1;*/
894 newLeft = pos; 902 newLeft = pos;
895 nextPos = newLeft + dd; 903 nextPos = newLeft + dd;
896 } 904 }
897 setG( w, newLeft, dd, TRUE ); 905 setG( w, newLeft, dd, TRUE );
898 /*if( right != newRight )*/ 906 /*if( right != newRight )*/
899 moveAfter( nextPos, id+1, upLeft ); 907 moveAfter( nextPos, id+1, upLeft );
900 } 908 }
901} 909}
902 910
903 911
904void KDGanttMinimizeSplitter::expandPos( int id, int* min, int* max ) 912void KDGanttMinimizeSplitter::expandPos( int id, int* min, int* max )
905{ 913{
906 QSplitterLayoutStruct *s = data->list.at(id-1); 914 QSplitterLayoutStruct *s = data->list.at(id-1);
907 QWidget* w = s->wid; 915 QWidget* w = s->wid;
908 *min = pick( w->mapToParent( QPoint(0,0) ) ); 916 *min = pick( w->mapToParent( QPoint(0,0) ) );
909 917
910 if ( (uint) id == data->list.count() ) { 918 if ( (uint) id == data->list.count() ) {
911 pick( size() ); 919 pick( size() );
912 } 920 }
913 else { 921 else {
914 QSplitterLayoutStruct *s = data->list.at(id+1); 922 QSplitterLayoutStruct *s = data->list.at(id+1);
915 QWidget* w = s->wid; 923 QWidget* w = s->wid;
916 *max = pick( w->mapToParent( QPoint( w->width(), w->height() ) ) ) -8; 924 *max = pick( w->mapToParent( QPoint( w->width(), w->height() ) ) ) -8;
917 } 925 }
918} 926}
919 927
920 928
921/*! 929/*!
922 Returns the valid range of the splitter with id \a id in \a *min and \a *max. 930 Returns the valid range of the splitter with id \a id in \a *min and \a *max.
923 931
924 \sa idAfter() 932 \sa idAfter()
925*/ 933*/
926 934
927void KDGanttMinimizeSplitter::getRange( int id, int *min, int *max ) 935void KDGanttMinimizeSplitter::getRange( int id, int *min, int *max )
928{ 936{
929 int minB = 0;//before 937 int minB = 0;//before
930 int maxB = 0; 938 int maxB = 0;
931 int minA = 0; 939 int minA = 0;
932 int maxA = 0;//after 940 int maxA = 0;//after
933 int n = data->list.count(); 941 int n = data->list.count();
934 if ( id < 0 || id >= n ) 942 if ( id < 0 || id >= n )
935 return; 943 return;
936 int i; 944 int i;
937 for ( i = 0; i < id; i++ ) { 945 for ( i = 0; i < id; i++ ) {
938 QSplitterLayoutStruct *s = data->list.at(i); 946 QSplitterLayoutStruct *s = data->list.at(i);
939 if ( s->wid->isHidden() ) { 947 if ( s->wid->isHidden() ) {
940 //ignore 948 //ignore
941 } else if ( s->isSplitter ) { 949 } else if ( s->isSplitter ) {
942 minB += s->sizer; 950 minB += s->sizer;
943 maxB += s->sizer; 951 maxB += s->sizer;
944 } else { 952 } else {
945 minB += pick( minSize(s->wid) ); 953 minB += pick( minSize(s->wid) );
946 maxB += pick( s->wid->maximumSize() ); 954 maxB += pick( s->wid->maximumSize() );
947 } 955 }
948 } 956 }
949 for ( i = id; i < n; i++ ) { 957 for ( i = id; i < n; i++ ) {
950 QSplitterLayoutStruct *s = data->list.at(i); 958 QSplitterLayoutStruct *s = data->list.at(i);
951 if ( s->wid->isHidden() ) { 959 if ( s->wid->isHidden() ) {
952 //ignore 960 //ignore
953 } else if ( s->isSplitter ) { 961 } else if ( s->isSplitter ) {
954 minA += s->sizer; 962 minA += s->sizer;
955 maxA += s->sizer; 963 maxA += s->sizer;
956 } else { 964 } else {
957 minA += pick( minSize(s->wid) ); 965 minA += pick( minSize(s->wid) );
958 maxA += pick( s->wid->maximumSize() ); 966 maxA += pick( s->wid->maximumSize() );
959 } 967 }
960 } 968 }
961 QRect r = contentsRect(); 969 QRect r = contentsRect();
962 if ( orient == Horizontal && false ) { 970 if ( orient == Horizontal && false ) {
963#if QT_VERSION >= 0x030000 971#if QT_VERSION >= 0x030000
964 int splitterWidth = style().pixelMetric(QStyle::PM_SplitterWidth, this); 972 int splitterWidth = style().pixelMetric(QStyle::PM_SplitterWidth, this);
965#else 973#else
966 int splitterWidth = style().splitterWidth(); 974 int splitterWidth = style().splitterWidth();
967#endif 975#endif
968 976
969 if ( min ) 977 if ( min )
970 *min = pick(r.topRight()) - QMIN( maxB, pick(r.size())-minA ) - splitterWidth; 978 *min = pick(r.topRight()) - QMIN( maxB, pick(r.size())-minA ) - splitterWidth;
971 if ( max ) 979 if ( max )
972 *max = pick(r.topRight()) - QMAX( minB, pick(r.size())-maxA ) - splitterWidth; 980 *max = pick(r.topRight()) - QMAX( minB, pick(r.size())-maxA ) - splitterWidth;
973 } else { 981 } else {
974 if ( min ) 982 if ( min )
975 *min = pick(r.topLeft()) + QMAX( minB, pick(r.size())-maxA ); 983 *min = pick(r.topLeft()) + QMAX( minB, pick(r.size())-maxA );
976 if ( max ) 984 if ( max )
977 *max = pick(r.topLeft()) + QMIN( maxB, pick(r.size())-minA ); 985 *max = pick(r.topLeft()) + QMIN( maxB, pick(r.size())-minA );
978 } 986 }
979} 987}
980 988
981 989
982/*! 990/*!
983 Returns the closest legal position to \a p of the splitter with id \a id. 991 Returns the closest legal position to \a p of the splitter with id \a id.
984 992
985 \sa idAfter() 993 \sa idAfter()
986*/ 994*/
987 995
988int KDGanttMinimizeSplitter::adjustPos( int p, int id ) 996int KDGanttMinimizeSplitter::adjustPos( int p, int id )
989{ 997{
990 int min = 0; 998 int min = 0;
991 int max = 0; 999 int max = 0;
992 getRange( id, &min, &max ); 1000 getRange( id, &min, &max );
993 p = QMAX( min, QMIN( p, max ) ); 1001 p = QMAX( min, QMIN( p, max ) );
994 1002
995 return p; 1003 return p;
996} 1004}
997 1005
998 1006
999void KDGanttMinimizeSplitter::doResize() 1007void KDGanttMinimizeSplitter::doResize()
1000{ 1008{
1001 QRect r = contentsRect(); 1009 QRect r = contentsRect();
1002 int i; 1010 int i;
1003 int n = data->list.count(); 1011 int n = data->list.count();
1004 QMemArray<QLayoutStruct> a( n ); 1012 QMemArray<QLayoutStruct> a( n );
1005 for ( i = 0; i< n; i++ ) { 1013 for ( i = 0; i< n; i++ ) {
1006 a[i].init(); 1014 a[i].init();
1007 QSplitterLayoutStruct *s = data->list.at(i); 1015 QSplitterLayoutStruct *s = data->list.at(i);
1008 if ( s->wid->isHidden() ) { 1016 if ( s->wid->isHidden() ) {
1009 a[i].stretch = 0; 1017 a[i].stretch = 0;
1010 a[i].sizeHint = a[i].minimumSize = 0; 1018 a[i].sizeHint = a[i].minimumSize = 0;
1011 a[i].maximumSize = 0; 1019 a[i].maximumSize = 0;
1012 } else if ( s->isSplitter ) { 1020 } else if ( s->isSplitter ) {
1013 a[i].stretch = 0; 1021 a[i].stretch = 0;
1014 a[i].sizeHint = a[i].minimumSize = a[i].maximumSize = s->sizer; 1022 a[i].sizeHint = a[i].minimumSize = a[i].maximumSize = s->sizer;
1015 a[i].empty = FALSE; 1023 a[i].empty = FALSE;
1016 } else if ( s->mode == KeepSize ) { 1024 } else if ( s->mode == KeepSize ) {
1017 a[i].stretch = 0; 1025 a[i].stretch = 0;
1018 a[i].minimumSize = pick( minSize(s->wid) ); 1026 a[i].minimumSize = pick( minSize(s->wid) );
1019 a[i].sizeHint = s->sizer; 1027 a[i].sizeHint = s->sizer;
1020 a[i].maximumSize = pick( s->wid->maximumSize() ); 1028 a[i].maximumSize = pick( s->wid->maximumSize() );
1021 a[i].empty = FALSE; 1029 a[i].empty = FALSE;
1022 } else if ( s->mode == FollowSizeHint ) { 1030 } else if ( s->mode == FollowSizeHint ) {
1023 a[i].stretch = 0; 1031 a[i].stretch = 0;
1024 a[i].minimumSize = a[i].sizeHint = pick( s->wid->sizeHint() ); 1032 a[i].minimumSize = a[i].sizeHint = pick( s->wid->sizeHint() );
1025 a[i].maximumSize = pick( s->wid->maximumSize() ); 1033 a[i].maximumSize = pick( s->wid->maximumSize() );
1026 a[i].empty = FALSE; 1034 a[i].empty = FALSE;
1027 } else { //proportional 1035 } else { //proportional
1028 a[i].stretch = s->sizer; 1036 a[i].stretch = s->sizer;
1029 a[i].maximumSize = pick( s->wid->maximumSize() ); 1037 a[i].maximumSize = pick( s->wid->maximumSize() );
1030 a[i].sizeHint = a[i].minimumSize = pick( minSize(s->wid) ); 1038 a[i].sizeHint = a[i].minimumSize = pick( minSize(s->wid) );
1031 a[i].empty = FALSE; 1039 a[i].empty = FALSE;
1032 } 1040 }
1033 } 1041 }
1034 1042
1035 kdganttGeomCalc( a, 0, n, pick( r.topLeft() ), pick( r.size() ), 0 ); 1043 kdganttGeomCalc( a, 0, n, pick( r.topLeft() ), pick( r.size() ), 0 );
1036 1044
1037 for ( i = 0; i< n; i++ ) { 1045 for ( i = 0; i< n; i++ ) {
1038 QSplitterLayoutStruct *s = data->list.at(i); 1046 QSplitterLayoutStruct *s = data->list.at(i);
1039 setG( s->wid, a[i].pos, a[i].size ); 1047 setG( s->wid, a[i].pos, a[i].size );
1040 } 1048 }
1041 1049
1042} 1050}
1043 1051
1044 1052
1045void KDGanttMinimizeSplitter::recalc( bool update ) 1053void KDGanttMinimizeSplitter::recalc( bool update )
1046{ 1054{
1047 int fi = 2*frameWidth(); 1055 int fi = 2*frameWidth();
1048 int maxl = fi; 1056 int maxl = fi;
1049 int minl = fi; 1057 int minl = fi;
1050 int maxt = QWIDGETSIZE_MAX; 1058 int maxt = QWIDGETSIZE_MAX;
1051 int mint = fi; 1059 int mint = fi;
1052 int n = data->list.count(); 1060 int n = data->list.count();
1053 bool first = TRUE; 1061 bool first = TRUE;
1054 /* 1062 /*
1055 The splitter before a hidden widget is always hidden. 1063 The splitter before a hidden widget is always hidden.
1056 The splitter before the first visible widget is hidden. 1064 The splitter before the first visible widget is hidden.
1057 The splitter before any other visible widget is visible. 1065 The splitter before any other visible widget is visible.
1058 */ 1066 */
1059 for ( int i = 0; i< n; i++ ) { 1067 for ( int i = 0; i< n; i++ ) {
1060 QSplitterLayoutStruct *s = data->list.at(i); 1068 QSplitterLayoutStruct *s = data->list.at(i);
1061 if ( !s->isSplitter ) { 1069 if ( !s->isSplitter ) {
1062 QSplitterLayoutStruct *p = (i > 0) ? p = data->list.at( i-1 ) : 0; 1070 QSplitterLayoutStruct *p = (i > 0) ? p = data->list.at( i-1 ) : 0;
1063 if ( p && p->isSplitter ) 1071 if ( p && p->isSplitter )
1064 if ( first || s->wid->isHidden() ) 1072 if ( first || s->wid->isHidden() )
1065 p->wid->hide(); //may trigger new recalc 1073 p->wid->hide(); //may trigger new recalc
1066 else 1074 else
1067 p->wid->show(); //may trigger new recalc 1075 p->wid->show(); //may trigger new recalc
1068 if ( !s->wid->isHidden() ) 1076 if ( !s->wid->isHidden() )
1069 first = FALSE; 1077 first = FALSE;
1070 } 1078 }
1071 } 1079 }
1072 1080
1073 bool empty=TRUE; 1081 bool empty=TRUE;
1074 for ( int j = 0; j< n; j++ ) { 1082 for ( int j = 0; j< n; j++ ) {
1075 QSplitterLayoutStruct *s = data->list.at(j); 1083 QSplitterLayoutStruct *s = data->list.at(j);
1076 if ( !s->wid->isHidden() ) { 1084 if ( !s->wid->isHidden() ) {
1077 empty = FALSE; 1085 empty = FALSE;
1078 if ( s->isSplitter ) { 1086 if ( s->isSplitter ) {
1079 minl += s->sizer; 1087 minl += s->sizer;
1080 maxl += s->sizer; 1088 maxl += s->sizer;
1081 } else { 1089 } else {
1082 QSize minS = minSize(s->wid); 1090 QSize minS = minSize(s->wid);