author | zecke <zecke> | 2003-09-02 21:28:27 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-09-02 21:28:27 (UTC) |
commit | 88d625d9695582d57852f94581f71bb18c00a8a1 (patch) (unidiff) | |
tree | c04adb455e19c160a755c50b9bdf95425bfd06e1 /libopie/big-screen/osplitter.cpp | |
parent | 3cf3fc001922a7ef34c7ff95751beb569809383b (diff) | |
download | opie-88d625d9695582d57852f94581f71bb18c00a8a1.zip opie-88d625d9695582d57852f94581f71bb18c00a8a1.tar.gz opie-88d625d9695582d57852f94581f71bb18c00a8a1.tar.bz2 |
New impressive example and test suite
Now OSplitter is almost done
Diffstat (limited to 'libopie/big-screen/osplitter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie/big-screen/osplitter.cpp | 55 |
1 files changed, 38 insertions, 17 deletions
diff --git a/libopie/big-screen/osplitter.cpp b/libopie/big-screen/osplitter.cpp index d06568f..47f856d 100644 --- a/libopie/big-screen/osplitter.cpp +++ b/libopie/big-screen/osplitter.cpp | |||
@@ -76,6 +76,7 @@ OSplitter::OSplitter( Orientation orient, QWidget* parent, const char* name, WFl | |||
76 | * @see addWidget | 76 | * @see addWidget |
77 | */ | 77 | */ |
78 | OSplitter::~OSplitter() { | 78 | OSplitter::~OSplitter() { |
79 | qWarning("Deleted Splitter"); | ||
79 | m_splitter.setAutoDelete( true ); | 80 | m_splitter.setAutoDelete( true ); |
80 | m_splitter.clear(); | 81 | m_splitter.clear(); |
81 | 82 | ||
@@ -154,7 +155,7 @@ void OSplitter::addWidget( OSplitter* split ) { | |||
154 | * set tab widget | 155 | * set tab widget |
155 | */ | 156 | */ |
156 | if (m_tabWidget ) | 157 | if (m_tabWidget ) |
157 | split->setTabWidget( m_tabWidget ); | 158 | setTabWidget( m_parentTab ); |
158 | else{ | 159 | else{ |
159 | Opie::OSplitterContainer con; | 160 | Opie::OSplitterContainer con; |
160 | con.widget =split; | 161 | con.widget =split; |
@@ -306,13 +307,14 @@ QWidget* OSplitter::currentWidget() const{ | |||
306 | return 0l; | 307 | return 0l; |
307 | } | 308 | } |
308 | 309 | ||
309 | #if 0 | 310 | |
310 | /** | 311 | /** |
311 | * @reimplented for internal reasons | 312 | * @reimplented for internal reasons |
312 | * returns the sizeHint of one of its sub widgets | 313 | * returns the sizeHint of one of its sub widgets |
313 | */ | 314 | */ |
314 | QSize OSplitter::sizeHint()const { | 315 | QSize OSplitter::sizeHint()const { |
315 | return QSize(10, 10); | 316 | if (m_parentTab ) |
317 | return QFrame::sizeHint(); | ||
316 | 318 | ||
317 | if (m_hbox ) | 319 | if (m_hbox ) |
318 | return m_hbox->sizeHint(); | 320 | return m_hbox->sizeHint(); |
@@ -321,9 +323,14 @@ QSize OSplitter::sizeHint()const { | |||
321 | } | 323 | } |
322 | 324 | ||
323 | QSize OSplitter::minimumSizeHint()const { | 325 | QSize OSplitter::minimumSizeHint()const { |
324 | return QSize(10, 10 ); | 326 | if (m_parentTab ) |
327 | return QFrame::minimumSizeHint(); | ||
328 | if (m_hbox) | ||
329 | return m_hbox->sizeHint(); | ||
330 | else | ||
331 | return m_tabWidget->sizeHint(); | ||
325 | } | 332 | } |
326 | #endif | 333 | |
327 | 334 | ||
328 | /** | 335 | /** |
329 | * @reimplemented for internal reasons | 336 | * @reimplemented for internal reasons |
@@ -335,7 +342,7 @@ void OSplitter::resizeEvent( QResizeEvent* res ) { | |||
335 | */ | 342 | */ |
336 | // 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() ); |
337 | bool mode = true; | 344 | bool mode = true; |
338 | qWarning("New size is width = %d height = %d", res->size().width(), res->size().height() ); | 345 | qWarning("New size is width = %d height = %d %s", res->size().width(), res->size().height(), name() ); |
339 | if ( res->size().width() > m_size_policy && | 346 | if ( res->size().width() > m_size_policy && |
340 | m_orient == Horizontal ) { | 347 | m_orient == Horizontal ) { |
341 | changeHBox(); | 348 | changeHBox(); |
@@ -346,7 +353,8 @@ void OSplitter::resizeEvent( QResizeEvent* res ) { | |||
346 | m_orient == Vertical ) ) { | 353 | m_orient == Vertical ) ) { |
347 | changeTab(); | 354 | changeTab(); |
348 | }else if ( res->size().height() > m_size_policy && | 355 | }else if ( res->size().height() > m_size_policy && |
349 | m_size_policy == Vertical ) { | 356 | m_orient == Vertical ) { |
357 | qWarning("Changng to vbox %s", name() ); | ||
350 | changeVBox(); | 358 | changeVBox(); |
351 | mode = false; | 359 | mode = false; |
352 | } | 360 | } |
@@ -398,7 +406,7 @@ void OSplitter::changeTab() { | |||
398 | return; | 406 | return; |
399 | } | 407 | } |
400 | 408 | ||
401 | qWarning(" New Tab Widget "); | 409 | qWarning(" New Tab Widget %s", name() ); |
402 | /* | 410 | /* |
403 | * and add all widgets this will reparent them | 411 | * and add all widgets this will reparent them |
404 | * delete m_hbox set it to 0 | 412 | * delete m_hbox set it to 0 |
@@ -407,7 +415,12 @@ void OSplitter::changeTab() { | |||
407 | OTabWidget *tab; | 415 | OTabWidget *tab; |
408 | if ( m_parentTab ) { | 416 | if ( m_parentTab ) { |
409 | tab = m_parentTab; | 417 | tab = m_parentTab; |
410 | tab->removePage( this ); | 418 | /* expensive but needed cause we're called from setTabWidget and resizeEvent*/ |
419 | if (!m_container.isEmpty() ) { | ||
420 | ContainerList::Iterator it = m_container.begin(); | ||
421 | for (; it != m_container.end(); ++it ) | ||
422 | m_parentTab->removePage( (*it).widget ); | ||
423 | } | ||
411 | }else | 424 | }else |
412 | tab = m_tabWidget = new OTabWidget( this ); | 425 | tab = m_tabWidget = new OTabWidget( this ); |
413 | 426 | ||
@@ -419,8 +432,10 @@ void OSplitter::changeTab() { | |||
419 | addToTab( (*it) ); | 432 | addToTab( (*it) ); |
420 | } | 433 | } |
421 | 434 | ||
422 | for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() ) | 435 | for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() ) { |
436 | split->reparent(this, 0, QPoint(0, 0) ); | ||
423 | split->setTabWidget( tab ); | 437 | split->setTabWidget( tab ); |
438 | } | ||
424 | 439 | ||
425 | 440 | ||
426 | delete m_hbox; | 441 | delete m_hbox; |
@@ -443,7 +458,7 @@ void OSplitter::changeHBox() { | |||
443 | return; | 458 | return; |
444 | } | 459 | } |
445 | 460 | ||
446 | qWarning("new HBox"); | 461 | qWarning("new HBox %s", name() ); |
447 | m_hbox = new QHBox( this ); | 462 | m_hbox = new QHBox( this ); |
448 | commonChangeBox(); | 463 | commonChangeBox(); |
449 | } | 464 | } |
@@ -454,7 +469,7 @@ void OSplitter::changeVBox() { | |||
454 | return; | 469 | return; |
455 | } | 470 | } |
456 | 471 | ||
457 | qWarning("New VBOX"); | 472 | qWarning("New VBOX %s", name() ); |
458 | m_hbox = new QVBox( this ); | 473 | m_hbox = new QVBox( this ); |
459 | 474 | ||
460 | commonChangeBox(); | 475 | commonChangeBox(); |
@@ -468,6 +483,7 @@ void OSplitter::changeVBox() { | |||
468 | * it is recursive as well due the call to setTabWidget | 483 | * it is recursive as well due the call to setTabWidget |
469 | */ | 484 | */ |
470 | void OSplitter::commonChangeBox() { | 485 | void OSplitter::commonChangeBox() { |
486 | qWarning(" Name of Splitters is %s", name() ); | ||
471 | 487 | ||
472 | for (ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it ) { | 488 | for (ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it ) { |
473 | /* only if parent tab.. m_tabWidgets gets deleted and would do that as well */ | 489 | /* only if parent tab.. m_tabWidgets gets deleted and would do that as well */ |
@@ -481,14 +497,17 @@ void OSplitter::commonChangeBox() { | |||
481 | split->setTabWidget( 0 ); | 497 | split->setTabWidget( 0 ); |
482 | Opie::OSplitterContainer con; | 498 | Opie::OSplitterContainer con; |
483 | con.widget = split; | 499 | con.widget = split; |
500 | // con.widget = split->m_tabWidget ? static_cast<QWidget*>(split->m_tabWidget) | ||
501 | // : static_cast<QWidget*>(split->m_hbox); | ||
484 | addToBox( con ); | 502 | addToBox( con ); |
485 | } | 503 | } |
486 | 504 | ||
487 | 505 | ||
488 | 506 | ||
489 | if (m_parentTab ) | 507 | if (m_parentTab ) |
490 | m_parentTab->addTab(this, iconName(), label() ); | 508 | m_parentTab->addTab(m_hbox, iconName(), label() ); |
491 | else { | 509 | else { |
510 | qWarning(" setting Box geometry for %s", name() ); | ||
492 | m_hbox->setGeometry( frameRect() ); | 511 | m_hbox->setGeometry( frameRect() ); |
493 | m_hbox->show(); | 512 | m_hbox->show(); |
494 | delete m_tabWidget; | 513 | delete m_tabWidget; |
@@ -503,7 +522,7 @@ void OSplitter::setTabWidget( OTabWidget* wid) { | |||
503 | /* clean up cause m_parentTab will not be available for us */ | 522 | /* clean up cause m_parentTab will not be available for us */ |
504 | if ( m_parentTab ) { | 523 | if ( m_parentTab ) { |
505 | if (m_hbox ) | 524 | if (m_hbox ) |
506 | m_parentTab->removePage( this ); | 525 | m_parentTab->removePage( m_hbox ); |
507 | else if (!m_container.isEmpty() ){ | 526 | else if (!m_container.isEmpty() ){ |
508 | ContainerList::Iterator it = m_container.begin(); | 527 | ContainerList::Iterator it = m_container.begin(); |
509 | for ( ; it != m_container.end(); ++it ) | 528 | for ( ; it != m_container.end(); ++it ) |
@@ -526,8 +545,10 @@ void OSplitter::setTabWidget( OTabWidget* wid) { | |||
526 | changeVBox(); | 545 | changeVBox(); |
527 | 546 | ||
528 | /* our own crap is added and children from change* */ | 547 | /* our own crap is added and children from change* */ |
529 | delete tab; | 548 | if (m_parentTab ) { |
530 | delete box; | 549 | delete tab; |
550 | delete box; | ||
551 | } | ||
531 | } | 552 | } |
532 | 553 | ||
533 | 554 | ||
@@ -552,7 +573,7 @@ bool OSplitter::layoutMode()const { | |||
552 | m_orient == Horizontal ) { | 573 | m_orient == Horizontal ) { |
553 | return false; | 574 | return false; |
554 | }else if ( size().height() > m_size_policy && | 575 | }else if ( size().height() > m_size_policy && |
555 | m_size_policy == Vertical ) { | 576 | m_orient == Vertical ) { |
556 | return false; | 577 | return false; |
557 | } | 578 | } |
558 | 579 | ||