Diffstat (limited to 'libopie2/opieui/big-screen/osplitter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opieui/big-screen/osplitter.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/libopie2/opieui/big-screen/osplitter.cpp b/libopie2/opieui/big-screen/osplitter.cpp index f0287ed..f50e7f0 100644 --- a/libopie2/opieui/big-screen/osplitter.cpp +++ b/libopie2/opieui/big-screen/osplitter.cpp | |||
@@ -21,24 +21,25 @@ | |||
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "osplitter.h" | 29 | #include "osplitter.h" |
30 | 30 | ||
31 | /* OPIE */ | 31 | /* OPIE */ |
32 | #include <opie2/otabwidget.h> | 32 | #include <opie2/otabwidget.h> |
33 | #include <opie2/odebug.h> | ||
33 | 34 | ||
34 | /* QT */ | 35 | /* QT */ |
35 | #include <qvaluelist.h> | 36 | #include <qvaluelist.h> |
36 | #include <qvbox.h> | 37 | #include <qvbox.h> |
37 | 38 | ||
38 | using namespace Opie::Ui; | 39 | using namespace Opie::Ui; |
39 | using namespace Opie::Ui::Internal; | 40 | using namespace Opie::Ui::Internal; |
40 | 41 | ||
41 | /** | 42 | /** |
42 | * | 43 | * |
43 | * This is the constructor of OSplitter | 44 | * This is the constructor of OSplitter |
44 | * You might want to call setSizeChange to tell | 45 | * You might want to call setSizeChange to tell |
@@ -72,25 +73,25 @@ OSplitter::OSplitter( Orientation orient, QWidget* parent, const char* name, WFl | |||
72 | changeTab(); | 73 | changeTab(); |
73 | 74 | ||
74 | } | 75 | } |
75 | 76 | ||
76 | 77 | ||
77 | /** | 78 | /** |
78 | * Destructor destructs this object and cleans up. All child | 79 | * Destructor destructs this object and cleans up. All child |
79 | * widgets will be deleted | 80 | * widgets will be deleted |
80 | * @see addWidget | 81 | * @see addWidget |
81 | */ | 82 | */ |
82 | OSplitter::~OSplitter() | 83 | OSplitter::~OSplitter() |
83 | { | 84 | { |
84 | qWarning("Deleted Splitter"); | 85 | owarn << "Deleted Splitter" << oendl; |
85 | m_splitter.setAutoDelete( true ); | 86 | m_splitter.setAutoDelete( true ); |
86 | m_splitter.clear(); | 87 | m_splitter.clear(); |
87 | 88 | ||
88 | delete m_hbox; | 89 | delete m_hbox; |
89 | delete m_tabWidget; | 90 | delete m_tabWidget; |
90 | } | 91 | } |
91 | 92 | ||
92 | 93 | ||
93 | /** | 94 | /** |
94 | * Sets the label for the Splitter. This label will be used | 95 | * Sets the label for the Splitter. This label will be used |
95 | * if a parent splitter is arranged as TabWidget but | 96 | * if a parent splitter is arranged as TabWidget but |
96 | * this splitter is in fullscreen mode. Then a tab with OSplitter::label() | 97 | * this splitter is in fullscreen mode. Then a tab with OSplitter::label() |
@@ -201,25 +202,25 @@ void OSplitter::removeWidget( OSplitter* split) | |||
201 | * Warning: No null checking of the widget is done. Only on debug | 202 | * Warning: No null checking of the widget is done. Only on debug |
202 | * a message will be outputtet | 203 | * a message will be outputtet |
203 | * | 204 | * |
204 | * @param wid The widget which will be added | 205 | * @param wid The widget which will be added |
205 | * @param icon The icon of the possible Tab | 206 | * @param icon The icon of the possible Tab |
206 | * @param label The label of the possible Tab | 207 | * @param label The label of the possible Tab |
207 | */ | 208 | */ |
208 | void OSplitter::addWidget( QWidget* wid, const QString& icon, const QString& label ) | 209 | void OSplitter::addWidget( QWidget* wid, const QString& icon, const QString& label ) |
209 | { | 210 | { |
210 | #ifdef DEBUG | 211 | #ifdef DEBUG |
211 | if (!wid ) | 212 | if (!wid ) |
212 | { | 213 | { |
213 | qWarning("Widget is not valid!"); | 214 | owarn << "Widget is not valid!" << oendl; |
214 | return; | 215 | return; |
215 | } | 216 | } |
216 | #endif | 217 | #endif |
217 | OSplitterContainer cont; | 218 | OSplitterContainer cont; |
218 | cont.widget = wid; | 219 | cont.widget = wid; |
219 | cont.icon =icon; | 220 | cont.icon =icon; |
220 | cont.name = label; | 221 | cont.name = label; |
221 | 222 | ||
222 | m_container.append( cont ); | 223 | m_container.append( cont ); |
223 | 224 | ||
224 | /* | 225 | /* |
225 | * | 226 | * |
@@ -357,44 +358,44 @@ QSize OSplitter::minimumSizeHint()const | |||
357 | } | 358 | } |
358 | #endif | 359 | #endif |
359 | 360 | ||
360 | /** | 361 | /** |
361 | * @reimplemented for internal reasons | 362 | * @reimplemented for internal reasons |
362 | */ | 363 | */ |
363 | void OSplitter::resizeEvent( QResizeEvent* res ) | 364 | void OSplitter::resizeEvent( QResizeEvent* res ) |
364 | { | 365 | { |
365 | QFrame::resizeEvent( res ); | 366 | QFrame::resizeEvent( res ); |
366 | /* | 367 | /* |
367 | * | 368 | * |
368 | */ | 369 | */ |
369 | // qWarning("Old size was width = %d height = %d", res->oldSize().width(), res->oldSize().height() ); | 370 | // owarn << "Old size was width = " << res->oldSize().width() << " height = " << res->oldSize().height() << "" << oendl; |
370 | bool mode = true; | 371 | bool mode = true; |
371 | qWarning("New size is width = %d height = %d %s", res->size().width(), res->size().height(), name() ); | 372 | owarn << "New size is width = " << res->size().width() << " height = " << res->size().height() << " " << name() << "" << oendl; |
372 | if ( res->size().width() > m_size_policy && | 373 | if ( res->size().width() > m_size_policy && |
373 | m_orient == Horizontal ) | 374 | m_orient == Horizontal ) |
374 | { | 375 | { |
375 | changeHBox(); | 376 | changeHBox(); |
376 | mode = false; | 377 | mode = false; |
377 | } | 378 | } |
378 | else if ( (res->size().width() <= m_size_policy && | 379 | else if ( (res->size().width() <= m_size_policy && |
379 | m_orient == Horizontal ) || | 380 | m_orient == Horizontal ) || |
380 | (res->size().height() <= m_size_policy && | 381 | (res->size().height() <= m_size_policy && |
381 | m_orient == Vertical ) ) | 382 | m_orient == Vertical ) ) |
382 | { | 383 | { |
383 | changeTab(); | 384 | changeTab(); |
384 | } | 385 | } |
385 | else if ( res->size().height() > m_size_policy && | 386 | else if ( res->size().height() > m_size_policy && |
386 | m_orient == Vertical ) | 387 | m_orient == Vertical ) |
387 | { | 388 | { |
388 | qWarning("Changng to vbox %s", name() ); | 389 | owarn << "Changng to vbox " << name() << "" << oendl; |
389 | changeVBox(); | 390 | changeVBox(); |
390 | mode = false; | 391 | mode = false; |
391 | } | 392 | } |
392 | 393 | ||
393 | emit sizeChanged(mode, m_orient ); | 394 | emit sizeChanged(mode, m_orient ); |
394 | } | 395 | } |
395 | 396 | ||
396 | /* | 397 | /* |
397 | * Adds a container to a tab either the parent tab | 398 | * Adds a container to a tab either the parent tab |
398 | * or our own | 399 | * or our own |
399 | */ | 400 | */ |
400 | void OSplitter::addToTab( const Opie::Ui::Internal::OSplitterContainer& con ) | 401 | void OSplitter::addToTab( const Opie::Ui::Internal::OSplitterContainer& con ) |
@@ -435,25 +436,25 @@ void OSplitter::removeFromTab( QWidget* wid ) | |||
435 | */ | 436 | */ |
436 | void OSplitter::changeTab() | 437 | void OSplitter::changeTab() |
437 | { | 438 | { |
438 | /* if we're the owner of the tab widget */ | 439 | /* if we're the owner of the tab widget */ |
439 | if (m_tabWidget ) | 440 | if (m_tabWidget ) |
440 | { | 441 | { |
441 | raise(); | 442 | raise(); |
442 | show(); | 443 | show(); |
443 | m_tabWidget->setGeometry( frameRect() ); | 444 | m_tabWidget->setGeometry( frameRect() ); |
444 | return; | 445 | return; |
445 | } | 446 | } |
446 | 447 | ||
447 | qWarning(" New Tab Widget %s", name() ); | 448 | owarn << " New Tab Widget " << name() << "" << oendl; |
448 | /* | 449 | /* |
449 | * and add all widgets this will reparent them | 450 | * and add all widgets this will reparent them |
450 | * delete m_hbox set it to 0 | 451 | * delete m_hbox set it to 0 |
451 | * | 452 | * |
452 | */ | 453 | */ |
453 | OTabWidget *tab; | 454 | OTabWidget *tab; |
454 | if ( m_parentTab ) | 455 | if ( m_parentTab ) |
455 | { | 456 | { |
456 | hide(); | 457 | hide(); |
457 | tab = m_parentTab; | 458 | tab = m_parentTab; |
458 | /* expensive but needed cause we're called from setTabWidget and resizeEvent*/ | 459 | /* expensive but needed cause we're called from setTabWidget and resizeEvent*/ |
459 | if (!m_container.isEmpty() ) | 460 | if (!m_container.isEmpty() ) |
@@ -462,25 +463,25 @@ void OSplitter::changeTab() | |||
462 | for (; it != m_container.end(); ++it ) | 463 | for (; it != m_container.end(); ++it ) |
463 | m_parentTab->removePage( (*it).widget ); | 464 | m_parentTab->removePage( (*it).widget ); |
464 | } | 465 | } |
465 | } | 466 | } |
466 | else | 467 | else |
467 | tab = m_tabWidget = new OTabWidget( this ); | 468 | tab = m_tabWidget = new OTabWidget( this ); |
468 | 469 | ||
469 | connect(tab, SIGNAL(currentChanged(QWidget*) ), | 470 | connect(tab, SIGNAL(currentChanged(QWidget*) ), |
470 | this, SIGNAL(currentChanged(QWidget*) ) ); | 471 | this, SIGNAL(currentChanged(QWidget*) ) ); |
471 | 472 | ||
472 | for ( ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it ) | 473 | for ( ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it ) |
473 | { | 474 | { |
474 | qWarning("Widget is %s", (*it).name.latin1() ); | 475 | owarn << "Widget is " << (*it).name << "" << oendl; |
475 | addToTab( (*it) ); | 476 | addToTab( (*it) ); |
476 | } | 477 | } |
477 | 478 | ||
478 | for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() ) | 479 | for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() ) |
479 | { | 480 | { |
480 | split->reparent(this, 0, QPoint(0, 0) ); | 481 | split->reparent(this, 0, QPoint(0, 0) ); |
481 | split->setTabWidget( tab ); | 482 | split->setTabWidget( tab ); |
482 | } | 483 | } |
483 | 484 | ||
484 | 485 | ||
485 | delete m_hbox; | 486 | delete m_hbox; |
486 | m_hbox = 0; | 487 | m_hbox = 0; |
@@ -495,80 +496,80 @@ void OSplitter::changeTab() | |||
495 | /* | 496 | /* |
496 | * changes over to a box | 497 | * changes over to a box |
497 | * this is recursive as well | 498 | * this is recursive as well |
498 | */ | 499 | */ |
499 | void OSplitter::changeHBox() | 500 | void OSplitter::changeHBox() |
500 | { | 501 | { |
501 | if (m_hbox ) | 502 | if (m_hbox ) |
502 | { | 503 | { |
503 | m_hbox->setGeometry( frameRect() ); | 504 | m_hbox->setGeometry( frameRect() ); |
504 | return; | 505 | return; |
505 | } | 506 | } |
506 | 507 | ||
507 | qWarning("new HBox %s", name() ); | 508 | owarn << "new HBox " << name() << "" << oendl; |
508 | m_hbox = new QHBox( this ); | 509 | m_hbox = new QHBox( this ); |
509 | commonChangeBox(); | 510 | commonChangeBox(); |
510 | } | 511 | } |
511 | 512 | ||
512 | void OSplitter::changeVBox() | 513 | void OSplitter::changeVBox() |
513 | { | 514 | { |
514 | if (m_hbox ) | 515 | if (m_hbox ) |
515 | { | 516 | { |
516 | m_hbox->setGeometry( frameRect() ); | 517 | m_hbox->setGeometry( frameRect() ); |
517 | return; | 518 | return; |
518 | } | 519 | } |
519 | 520 | ||
520 | qWarning("New VBOX %s", name() ); | 521 | owarn << "New VBOX " << name() << "" << oendl; |
521 | m_hbox = new QVBox( this ); | 522 | m_hbox = new QVBox( this ); |
522 | 523 | ||
523 | commonChangeBox(); | 524 | commonChangeBox(); |
524 | 525 | ||
525 | } | 526 | } |
526 | 527 | ||
527 | /* | 528 | /* |
528 | * common box code | 529 | * common box code |
529 | * first remove and add children | 530 | * first remove and add children |
530 | * the other splitters | 531 | * the other splitters |
531 | * it is recursive as well due the call to setTabWidget | 532 | * it is recursive as well due the call to setTabWidget |
532 | */ | 533 | */ |
533 | void OSplitter::commonChangeBox() | 534 | void OSplitter::commonChangeBox() |
534 | { | 535 | { |
535 | qWarning(" Name of Splitters is %s", name() ); | 536 | owarn << " Name of Splitters is " << name() << "" << oendl; |
536 | 537 | ||
537 | for (ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it ) | 538 | for (ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it ) |
538 | { | 539 | { |
539 | /* only if parent tab.. m_tabWidgets gets deleted and would do that as well */ | 540 | /* only if parent tab.. m_tabWidgets gets deleted and would do that as well */ |
540 | if (m_parentTab ) | 541 | if (m_parentTab ) |
541 | removeFromTab( (*it).widget ); | 542 | removeFromTab( (*it).widget ); |
542 | qWarning("Adding to box %s", (*it).name.latin1() ); | 543 | owarn << "Adding to box " << (*it).name << "" << oendl; |
543 | addToBox( (*it) ); | 544 | addToBox( (*it) ); |
544 | } | 545 | } |
545 | for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() ) | 546 | for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() ) |
546 | { | 547 | { |
547 | /* tell them the world had changed */ | 548 | /* tell them the world had changed */ |
548 | split->setTabWidget( 0 ); | 549 | split->setTabWidget( 0 ); |
549 | OSplitterContainer con; | 550 | OSplitterContainer con; |
550 | con.widget = split; | 551 | con.widget = split; |
551 | // con.widget = split->m_tabWidget ? static_cast<QWidget*>(split->m_tabWidget) | 552 | // con.widget = split->m_tabWidget ? static_cast<QWidget*>(split->m_tabWidget) |
552 | // : static_cast<QWidget*>(split->m_hbox); | 553 | // : static_cast<QWidget*>(split->m_hbox); |
553 | addToBox( con ); | 554 | addToBox( con ); |
554 | } | 555 | } |
555 | 556 | ||
556 | 557 | ||
557 | 558 | ||
558 | if (m_parentTab ) | 559 | if (m_parentTab ) |
559 | m_parentTab->addTab(m_hbox, iconName(), label() ); | 560 | m_parentTab->addTab(m_hbox, iconName(), label() ); |
560 | else | 561 | else |
561 | { | 562 | { |
562 | qWarning(" setting Box geometry for %s", name() ); | 563 | owarn << " setting Box geometry for " << name() << "" << oendl; |
563 | m_hbox->setGeometry( frameRect() ); | 564 | m_hbox->setGeometry( frameRect() ); |
564 | m_hbox->show(); | 565 | m_hbox->show(); |
565 | delete m_tabWidget; | 566 | delete m_tabWidget; |
566 | m_tabWidget = 0; | 567 | m_tabWidget = 0; |
567 | show(); // also show this widget | 568 | show(); // also show this widget |
568 | } | 569 | } |
569 | } | 570 | } |
570 | 571 | ||
571 | /* | 572 | /* |
572 | * sets the tabwidget, removes tabs, and relayouts the widget | 573 | * sets the tabwidget, removes tabs, and relayouts the widget |
573 | */ | 574 | */ |
574 | void OSplitter::setTabWidget( OTabWidget* wid) | 575 | void OSplitter::setTabWidget( OTabWidget* wid) |