Diffstat (limited to 'microkde/KDGanttMinimizeSplitter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | microkde/KDGanttMinimizeSplitter.cpp | 10 |
1 files changed, 10 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 | |||
@@ -121,96 +121,97 @@ void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e ) | |||
121 | _collapsed = false; | 121 | _collapsed = false; |
122 | } | 122 | } |
123 | 123 | ||
124 | void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e ) | 124 | void 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 | ||
135 | void KDGanttSplitterHandle::updateCursor( const QPoint& p) | 135 | void 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 | } |
147 | void KDGanttSplitterHandle::toggle() | 147 | void 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 | ||
171 | void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) | 172 | void 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 | ||
192 | int KDGanttSplitterHandle::onButton( const QPoint& p ) | 193 | int 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 | ||
212 | QValueList<QPointArray> KDGanttSplitterHandle::buttonRegions() | 213 | QValueList<QPointArray> KDGanttSplitterHandle::buttonRegions() |
213 | { | 214 | { |
214 | QValueList<QPointArray> list; | 215 | QValueList<QPointArray> list; |
215 | 216 | ||
216 | int sw = 8; | 217 | int sw = 8; |
@@ -435,96 +436,105 @@ static QSize minSizeHint( const QWidget* w ) | |||
435 | KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *name ) | 436 | KDGanttMinimizeSplitter::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 | */ |
449 | KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Orientation o, QWidget *parent, const char *name ) | 450 | KDGanttMinimizeSplitter::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 | */ |
462 | KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter() | 463 | KDGanttMinimizeSplitter::~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 |
472 | void KDGanttMinimizeSplitter::init() | 473 | void 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 | ||
484 | void 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 | */ |
490 | void KDGanttMinimizeSplitter::setOrientation( Orientation o ) | 500 | void 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 | */ |
517 | void KDGanttMinimizeSplitter::resizeEvent( QResizeEvent * ) | 527 | void 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.) |