summaryrefslogtreecommitdiff
authorzecke <zecke>2003-09-04 12:51:49 (UTC)
committer zecke <zecke>2003-09-04 12:51:49 (UTC)
commitd11827ca5879b21488c189fb09f32ecf635644ae (patch) (unidiff)
tree55e050283d70b67d5546745bcece440245055a7e
parent2ec64be7f5250e851f44107552e89aff62922d44 (diff)
downloadopie-d11827ca5879b21488c189fb09f32ecf635644ae.zip
opie-d11827ca5879b21488c189fb09f32ecf635644ae.tar.gz
opie-d11827ca5879b21488c189fb09f32ecf635644ae.tar.bz2
Thanks to eilers for spotting this.
The second osplitter correctly adds it widgets to the tab but is visible as well so better hide it
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/big-screen/osplitter.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/libopie/big-screen/osplitter.cpp b/libopie/big-screen/osplitter.cpp
index 47f856d..b09bc94 100644
--- a/libopie/big-screen/osplitter.cpp
+++ b/libopie/big-screen/osplitter.cpp
@@ -277,305 +277,306 @@ void OSplitter::setCurrentWidget( const QString& label ) {
277 for (it = m_container.begin(); it != m_container.end(); ++it ) { 277 for (it = m_container.begin(); it != m_container.end(); ++it ) {
278 if ( (*it).name == label ) { 278 if ( (*it).name == label ) {
279 setCurrentWidget( (*it).widget ); 279 setCurrentWidget( (*it).widget );
280 break; 280 break;
281 } 281 }
282 } 282 }
283} 283}
284 284
285/** 285/**
286 * This will only work when the TabWidget is active 286 * This will only work when the TabWidget is active
287 * If everything is visible this signal is kindly ignored 287 * If everything is visible this signal is kindly ignored
288 * @see OTabWidget::setCurrentTab(int) 288 * @see OTabWidget::setCurrentTab(int)
289 * 289 *
290 * @param tab The tab to make current 290 * @param tab The tab to make current
291 */ 291 */
292void OSplitter::setCurrentWidget( int tab ) { 292void OSplitter::setCurrentWidget( int tab ) {
293 if (m_tabWidget ) 293 if (m_tabWidget )
294 m_tabWidget->setCurrentTab( tab ); 294 m_tabWidget->setCurrentTab( tab );
295} 295}
296 296
297/** 297/**
298 * return the currently activated widget if in tab widget mode 298 * return the currently activated widget if in tab widget mode
299 * or null because all widgets are visible 299 * or null because all widgets are visible
300 */ 300 */
301QWidget* OSplitter::currentWidget() const{ 301QWidget* OSplitter::currentWidget() const{
302 if (m_tabWidget) 302 if (m_tabWidget)
303 return m_tabWidget->currentWidget(); 303 return m_tabWidget->currentWidget();
304 else if (m_parentTab ) 304 else if (m_parentTab )
305 return m_parentTab->currentWidget(); 305 return m_parentTab->currentWidget();
306 306
307 return 0l; 307 return 0l;
308} 308}
309 309
310 310
311/** 311/**
312 * @reimplented for internal reasons 312 * @reimplented for internal reasons
313 * returns the sizeHint of one of its sub widgets 313 * returns the sizeHint of one of its sub widgets
314 */ 314 */
315QSize OSplitter::sizeHint()const { 315QSize OSplitter::sizeHint()const {
316 if (m_parentTab ) 316 if (m_parentTab )
317 return QFrame::sizeHint(); 317 return QFrame::sizeHint();
318 318
319 if (m_hbox ) 319 if (m_hbox )
320 return m_hbox->sizeHint(); 320 return m_hbox->sizeHint();
321 else 321 else
322 return m_tabWidget->sizeHint(); 322 return m_tabWidget->sizeHint();
323} 323}
324 324
325QSize OSplitter::minimumSizeHint()const { 325QSize OSplitter::minimumSizeHint()const {
326 if (m_parentTab ) 326 if (m_parentTab )
327 return QFrame::minimumSizeHint(); 327 return QFrame::minimumSizeHint();
328 if (m_hbox) 328 if (m_hbox)
329 return m_hbox->sizeHint(); 329 return m_hbox->sizeHint();
330 else 330 else
331 return m_tabWidget->sizeHint(); 331 return m_tabWidget->sizeHint();
332} 332}
333 333
334 334
335/** 335/**
336 * @reimplemented for internal reasons 336 * @reimplemented for internal reasons
337 */ 337 */
338void OSplitter::resizeEvent( QResizeEvent* res ) { 338void OSplitter::resizeEvent( QResizeEvent* res ) {
339 QFrame::resizeEvent( res ); 339 QFrame::resizeEvent( res );
340 /* 340 /*
341 * 341 *
342 */ 342 */
343// qWarning("Old size was width = %d height = %d", res->oldSize().width(), res->oldSize().height() ); 343// qWarning("Old size was width = %d height = %d", res->oldSize().width(), res->oldSize().height() );
344 bool mode = true; 344 bool mode = true;
345 qWarning("New size is width = %d height = %d %s", res->size().width(), res->size().height(), name() ); 345 qWarning("New size is width = %d height = %d %s", res->size().width(), res->size().height(), name() );
346 if ( res->size().width() > m_size_policy && 346 if ( res->size().width() > m_size_policy &&
347 m_orient == Horizontal ) { 347 m_orient == Horizontal ) {
348 changeHBox(); 348 changeHBox();
349 mode = false; 349 mode = false;
350 }else if ( (res->size().width() <= m_size_policy && 350 }else if ( (res->size().width() <= m_size_policy &&
351 m_orient == Horizontal ) || 351 m_orient == Horizontal ) ||
352 (res->size().height() <= m_size_policy && 352 (res->size().height() <= m_size_policy &&
353 m_orient == Vertical ) ) { 353 m_orient == Vertical ) ) {
354 changeTab(); 354 changeTab();
355 }else if ( res->size().height() > m_size_policy && 355 }else if ( res->size().height() > m_size_policy &&
356 m_orient == Vertical ) { 356 m_orient == Vertical ) {
357 qWarning("Changng to vbox %s", name() ); 357 qWarning("Changng to vbox %s", name() );
358 changeVBox(); 358 changeVBox();
359 mode = false; 359 mode = false;
360 } 360 }
361 361
362 emit sizeChanged(mode, m_orient ); 362 emit sizeChanged(mode, m_orient );
363} 363}
364 364
365/* 365/*
366 * Adds a container to a tab either the parent tab 366 * Adds a container to a tab either the parent tab
367 * or our own 367 * or our own
368 */ 368 */
369void OSplitter::addToTab( const Opie::OSplitterContainer& con ) { 369void OSplitter::addToTab( const Opie::OSplitterContainer& con ) {
370 QWidget *wid = con.widget; 370 QWidget *wid = con.widget;
371// not needed widgetstack will reparent as well wid.reparent(m_tabWidget, wid->getWFlags(), QPoint(0, 0) ); 371// not needed widgetstack will reparent as well wid.reparent(m_tabWidget, wid->getWFlags(), QPoint(0, 0) );
372 if (m_parentTab ) 372 if (m_parentTab )
373 m_parentTab->addTab( wid, con.icon, con.name ); 373 m_parentTab->addTab( wid, con.icon, con.name );
374 else 374 else
375 m_tabWidget->addTab( wid, con.icon, con.name ); 375 m_tabWidget->addTab( wid, con.icon, con.name );
376} 376}
377 377
378 378
379/* 379/*
380 * adds a container to the box 380 * adds a container to the box
381 */ 381 */
382void OSplitter::addToBox( const Opie::OSplitterContainer& con ) { 382void OSplitter::addToBox( const Opie::OSplitterContainer& con ) {
383 QWidget* wid = con.widget; 383 QWidget* wid = con.widget;
384 wid->reparent(m_hbox, 0, QPoint(0, 0) ); 384 wid->reparent(m_hbox, 0, QPoint(0, 0) );
385} 385}
386 386
387 387
388/* 388/*
389 * Removes a widget from the tab 389 * Removes a widget from the tab
390 */ 390 */
391void OSplitter::removeFromTab( QWidget* wid ) { 391void OSplitter::removeFromTab( QWidget* wid ) {
392 if (m_parentTab ) 392 if (m_parentTab )
393 m_parentTab->removePage( wid ); 393 m_parentTab->removePage( wid );
394 else 394 else
395 m_tabWidget->removePage( wid ); 395 m_tabWidget->removePage( wid );
396} 396}
397 397
398/* 398/*
399 * switches over to a OTabWidget layout 399 * switches over to a OTabWidget layout
400 * it is recursive 400 * it is recursive
401 */ 401 */
402void OSplitter::changeTab() { 402void OSplitter::changeTab() {
403 /* if we're the owner of the tab widget */ 403 /* if we're the owner of the tab widget */
404 if (m_tabWidget ) { 404 if (m_tabWidget ) {
405 raise();
406 show();
405 m_tabWidget->setGeometry( frameRect() ); 407 m_tabWidget->setGeometry( frameRect() );
406 return; 408 return;
407 } 409 }
408 410
409 qWarning(" New Tab Widget %s", name() ); 411 qWarning(" New Tab Widget %s", name() );
410 /* 412 /*
411 * and add all widgets this will reparent them 413 * and add all widgets this will reparent them
412 * delete m_hbox set it to 0 414 * delete m_hbox set it to 0
413 * 415 *
414 */ 416 */
415 OTabWidget *tab; 417 OTabWidget *tab;
416 if ( m_parentTab ) { 418 if ( m_parentTab ) {
419 hide();
417 tab = m_parentTab; 420 tab = m_parentTab;
418 /* expensive but needed cause we're called from setTabWidget and resizeEvent*/ 421 /* expensive but needed cause we're called from setTabWidget and resizeEvent*/
419 if (!m_container.isEmpty() ) { 422 if (!m_container.isEmpty() ) {
420 ContainerList::Iterator it = m_container.begin(); 423 ContainerList::Iterator it = m_container.begin();
421 for (; it != m_container.end(); ++it ) 424 for (; it != m_container.end(); ++it )
422 m_parentTab->removePage( (*it).widget ); 425 m_parentTab->removePage( (*it).widget );
423 } 426 }
424 }else 427 }else
425 tab = m_tabWidget = new OTabWidget( this ); 428 tab = m_tabWidget = new OTabWidget( this );
426 429
427 connect(tab, SIGNAL(currentChanged(QWidget*) ), 430 connect(tab, SIGNAL(currentChanged(QWidget*) ),
428 this, SIGNAL(currentChanged(QWidget*) ) ); 431 this, SIGNAL(currentChanged(QWidget*) ) );
429 432
430 for ( ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it ) { 433 for ( ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it ) {
431 qWarning("Widget is %s", (*it).name.latin1() ); 434 qWarning("Widget is %s", (*it).name.latin1() );
432 addToTab( (*it) ); 435 addToTab( (*it) );
433 } 436 }
434 437
435 for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() ) { 438 for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() ) {
436 split->reparent(this, 0, QPoint(0, 0) ); 439 split->reparent(this, 0, QPoint(0, 0) );
437 split->setTabWidget( tab ); 440 split->setTabWidget( tab );
438 } 441 }
439 442
440 443
441 delete m_hbox; 444 delete m_hbox;
442 m_hbox = 0; 445 m_hbox = 0;
443 if (!m_tabWidget ) 446 if (!m_tabWidget )
444 return; 447 return;
445 448
446 m_tabWidget->setGeometry( frameRect() ); 449 m_tabWidget->setGeometry( frameRect() );
447 m_tabWidget->show(); 450 m_tabWidget->show();
448 451
449} 452}
450 453
451/* 454/*
452 * changes over to a box 455 * changes over to a box
453 * this is recursive as well 456 * this is recursive as well
454 */ 457 */
455void OSplitter::changeHBox() { 458void OSplitter::changeHBox() {
456 if (m_hbox ) { 459 if (m_hbox ) {
457 m_hbox->setGeometry( frameRect() ); 460 m_hbox->setGeometry( frameRect() );
458 return; 461 return;
459 } 462 }
460 463
461 qWarning("new HBox %s", name() ); 464 qWarning("new HBox %s", name() );
462 m_hbox = new QHBox( this ); 465 m_hbox = new QHBox( this );
463 commonChangeBox(); 466 commonChangeBox();
464} 467}
465 468
466void OSplitter::changeVBox() { 469void OSplitter::changeVBox() {
467 if (m_hbox ) { 470 if (m_hbox ) {
468 m_hbox->setGeometry( frameRect() ); 471 m_hbox->setGeometry( frameRect() );
469 return; 472 return;
470 } 473 }
471 474
472 qWarning("New VBOX %s", name() ); 475 qWarning("New VBOX %s", name() );
473 m_hbox = new QVBox( this ); 476 m_hbox = new QVBox( this );
474 477
475 commonChangeBox(); 478 commonChangeBox();
476 479
477} 480}
478 481
479/* 482/*
480 * common box code 483 * common box code
481 * first remove and add children 484 * first remove and add children
482 * the other splitters 485 * the other splitters
483 * it is recursive as well due the call to setTabWidget 486 * it is recursive as well due the call to setTabWidget
484 */ 487 */
485void OSplitter::commonChangeBox() { 488void OSplitter::commonChangeBox() {
486 qWarning(" Name of Splitters is %s", name() ); 489 qWarning(" Name of Splitters is %s", name() );
487 490
488 for (ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it ) { 491 for (ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it ) {
489 /* only if parent tab.. m_tabWidgets gets deleted and would do that as well */ 492 /* only if parent tab.. m_tabWidgets gets deleted and would do that as well */
490 if (m_parentTab ) 493 if (m_parentTab )
491 removeFromTab( (*it).widget ); 494 removeFromTab( (*it).widget );
492 qWarning("Adding to box %s", (*it).name.latin1() ); 495 qWarning("Adding to box %s", (*it).name.latin1() );
493 addToBox( (*it) ); 496 addToBox( (*it) );
494 } 497 }
495 for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() ) { 498 for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() ) {
496 /* tell them the world had changed */ 499 /* tell them the world had changed */
497 split->setTabWidget( 0 ); 500 split->setTabWidget( 0 );
498 Opie::OSplitterContainer con; 501 Opie::OSplitterContainer con;
499 con.widget = split; 502 con.widget = split;
500// con.widget = split->m_tabWidget ? static_cast<QWidget*>(split->m_tabWidget) 503// con.widget = split->m_tabWidget ? static_cast<QWidget*>(split->m_tabWidget)
501// : static_cast<QWidget*>(split->m_hbox); 504// : static_cast<QWidget*>(split->m_hbox);
502 addToBox( con ); 505 addToBox( con );
503 } 506 }
504 507
505 508
506 509
507 if (m_parentTab ) 510 if (m_parentTab )
508 m_parentTab->addTab(m_hbox, iconName(), label() ); 511 m_parentTab->addTab(m_hbox, iconName(), label() );
509 else { 512 else {
510 qWarning(" setting Box geometry for %s", name() ); 513 qWarning(" setting Box geometry for %s", name() );
511 m_hbox->setGeometry( frameRect() ); 514 m_hbox->setGeometry( frameRect() );
512 m_hbox->show(); 515 m_hbox->show();
513 delete m_tabWidget; 516 delete m_tabWidget;
514 m_tabWidget = 0; 517 m_tabWidget = 0;
515 } 518 }
516} 519}
517 520
518/* 521/*
519 * sets the tabwidget, removes tabs, and relayouts the widget 522 * sets the tabwidget, removes tabs, and relayouts the widget
520 */ 523 */
521void OSplitter::setTabWidget( OTabWidget* wid) { 524void OSplitter::setTabWidget( OTabWidget* wid) {
522 /* clean up cause m_parentTab will not be available for us */ 525 /* clean up cause m_parentTab will not be available for us */
523 if ( m_parentTab ) { 526 if ( m_parentTab ) {
524 if (m_hbox ) 527 if (m_hbox )
525 m_parentTab->removePage( m_hbox ); 528 m_parentTab->removePage( m_hbox );
526 else if (!m_container.isEmpty() ){ 529 else if (!m_container.isEmpty() ){
527 ContainerList::Iterator it = m_container.begin(); 530 ContainerList::Iterator it = m_container.begin();
528 for ( ; it != m_container.end(); ++it ) 531 for ( ; it != m_container.end(); ++it )
529 m_parentTab->removePage( (*it).widget ); 532 m_parentTab->removePage( (*it).widget );
530 } 533 }
531 } 534 }
532 /* the parent Splitter changed so either make us indepent or dep */ 535 /* the parent Splitter changed so either make us indepent or dep */
533 536
534 m_parentTab = wid; 537 m_parentTab = wid;
535 538
536 QWidget *tab = m_tabWidget; 539 QWidget *tab = m_tabWidget;
537 QWidget *box = m_hbox; 540 QWidget *box = m_hbox;
538 m_hbox = 0; m_tabWidget = 0; 541 m_hbox = 0; m_tabWidget = 0;
539 542
540 if ( layoutMode() ) 543 if ( layoutMode() )
541 changeTab(); 544 changeTab();
542 else if (m_orient == Horizontal ) 545 else if (m_orient == Horizontal )
543 changeHBox(); 546 changeHBox();
544 else 547 else
545 changeVBox(); 548 changeVBox();
546 549
547 /* our own crap is added and children from change* */ 550 /* our own crap is added and children from change* */
548 if (m_parentTab ) { 551 delete tab;
549 delete tab; 552 delete box;
550 delete box;
551 }
552} 553}
553 554
554 555
555#if 0 556#if 0
556void OSplitter::reparentAll() { 557void OSplitter::reparentAll() {
557 if (m_container.isEmpty() ) 558 if (m_container.isEmpty() )
558 return; 559 return;
559 560
560 ContainerList::Iterator it = m_container.begin(); 561 ContainerList::Iterator it = m_container.begin();
561 for ( ; it != m_container.end(); ++it ) 562 for ( ; it != m_container.end(); ++it )
562 (*it).wid->reparent(0, 0, QPoint(0, 0) ); 563 (*it).wid->reparent(0, 0, QPoint(0, 0) );
563 564
564 565
565} 566}
566#endif 567#endif
567 568
568/** 569/**
569 * @internal 570 * @internal
570 */ 571 */
571bool OSplitter::layoutMode()const { 572bool OSplitter::layoutMode()const {
572 if ( size().width() > m_size_policy && 573 if ( size().width() > m_size_policy &&
573 m_orient == Horizontal ) { 574 m_orient == Horizontal ) {
574 return false; 575 return false;
575 }else if ( size().height() > m_size_policy && 576 }else if ( size().height() > m_size_policy &&
576 m_orient == Vertical ) { 577 m_orient == Vertical ) {
577 return false; 578 return false;
578 } 579 }
579 580
580 return true; 581 return true;
581} 582}