-rw-r--r-- | libopie/big-screen/osplitter.cpp | 7 | ||||
-rw-r--r-- | libopie/big-screen/osplitter.h | 5 |
2 files changed, 7 insertions, 5 deletions
diff --git a/libopie/big-screen/osplitter.cpp b/libopie/big-screen/osplitter.cpp index b09bc94..0c9ed6c 100644 --- a/libopie/big-screen/osplitter.cpp +++ b/libopie/big-screen/osplitter.cpp @@ -261,121 +261,121 @@ void OSplitter::setCurrentWidget( QWidget* w) { if (m_tabWidget ) m_tabWidget->setCurrentTab( w ); // else // m_hbox->setFocus( w ); } /** * This is an overloaded member function and only differs in the * argument it takes. * Searches list of widgets for label. It'll pick the first label it finds * * @param label Label to look for. First match will be taken */ void OSplitter::setCurrentWidget( const QString& label ) { ContainerList::Iterator it; for (it = m_container.begin(); it != m_container.end(); ++it ) { if ( (*it).name == label ) { setCurrentWidget( (*it).widget ); break; } } } /** * This will only work when the TabWidget is active * If everything is visible this signal is kindly ignored * @see OTabWidget::setCurrentTab(int) * * @param tab The tab to make current */ void OSplitter::setCurrentWidget( int tab ) { if (m_tabWidget ) m_tabWidget->setCurrentTab( tab ); } /** * return the currently activated widget if in tab widget mode * or null because all widgets are visible */ QWidget* OSplitter::currentWidget() const{ if (m_tabWidget) return m_tabWidget->currentWidget(); else if (m_parentTab ) return m_parentTab->currentWidget(); return 0l; } - - +/* wrong */ +#if 0 /** * @reimplented for internal reasons * returns the sizeHint of one of its sub widgets */ QSize OSplitter::sizeHint()const { if (m_parentTab ) return QFrame::sizeHint(); if (m_hbox ) return m_hbox->sizeHint(); else return m_tabWidget->sizeHint(); } QSize OSplitter::minimumSizeHint()const { if (m_parentTab ) return QFrame::minimumSizeHint(); if (m_hbox) return m_hbox->sizeHint(); else return m_tabWidget->sizeHint(); } - +#endif /** * @reimplemented for internal reasons */ void OSplitter::resizeEvent( QResizeEvent* res ) { QFrame::resizeEvent( res ); /* * */ // qWarning("Old size was width = %d height = %d", res->oldSize().width(), res->oldSize().height() ); bool mode = true; qWarning("New size is width = %d height = %d %s", res->size().width(), res->size().height(), name() ); if ( res->size().width() > m_size_policy && m_orient == Horizontal ) { changeHBox(); mode = false; }else if ( (res->size().width() <= m_size_policy && m_orient == Horizontal ) || (res->size().height() <= m_size_policy && m_orient == Vertical ) ) { changeTab(); }else if ( res->size().height() > m_size_policy && m_orient == Vertical ) { qWarning("Changng to vbox %s", name() ); changeVBox(); mode = false; } emit sizeChanged(mode, m_orient ); } /* * Adds a container to a tab either the parent tab * or our own */ void OSplitter::addToTab( const Opie::OSplitterContainer& con ) { QWidget *wid = con.widget; // not needed widgetstack will reparent as well wid.reparent(m_tabWidget, wid->getWFlags(), QPoint(0, 0) ); if (m_parentTab ) m_parentTab->addTab( wid, con.icon, con.name ); else m_tabWidget->addTab( wid, con.icon, con.name ); } /* * adds a container to the box */ @@ -470,96 +470,97 @@ void OSplitter::changeVBox() { if (m_hbox ) { m_hbox->setGeometry( frameRect() ); return; } qWarning("New VBOX %s", name() ); m_hbox = new QVBox( this ); commonChangeBox(); } /* * common box code * first remove and add children * the other splitters * it is recursive as well due the call to setTabWidget */ void OSplitter::commonChangeBox() { qWarning(" Name of Splitters is %s", name() ); for (ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it ) { /* only if parent tab.. m_tabWidgets gets deleted and would do that as well */ if (m_parentTab ) removeFromTab( (*it).widget ); qWarning("Adding to box %s", (*it).name.latin1() ); addToBox( (*it) ); } for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() ) { /* tell them the world had changed */ split->setTabWidget( 0 ); Opie::OSplitterContainer con; con.widget = split; // con.widget = split->m_tabWidget ? static_cast<QWidget*>(split->m_tabWidget) // : static_cast<QWidget*>(split->m_hbox); addToBox( con ); } if (m_parentTab ) m_parentTab->addTab(m_hbox, iconName(), label() ); else { qWarning(" setting Box geometry for %s", name() ); m_hbox->setGeometry( frameRect() ); m_hbox->show(); delete m_tabWidget; m_tabWidget = 0; + show(); // also show this widget } } /* * sets the tabwidget, removes tabs, and relayouts the widget */ void OSplitter::setTabWidget( OTabWidget* wid) { /* clean up cause m_parentTab will not be available for us */ if ( m_parentTab ) { if (m_hbox ) m_parentTab->removePage( m_hbox ); else if (!m_container.isEmpty() ){ ContainerList::Iterator it = m_container.begin(); for ( ; it != m_container.end(); ++it ) m_parentTab->removePage( (*it).widget ); } } /* the parent Splitter changed so either make us indepent or dep */ m_parentTab = wid; QWidget *tab = m_tabWidget; QWidget *box = m_hbox; m_hbox = 0; m_tabWidget = 0; if ( layoutMode() ) changeTab(); else if (m_orient == Horizontal ) changeHBox(); else changeVBox(); /* our own crap is added and children from change* */ delete tab; delete box; } #if 0 void OSplitter::reparentAll() { if (m_container.isEmpty() ) return; ContainerList::Iterator it = m_container.begin(); for ( ; it != m_container.end(); ++it ) (*it).wid->reparent(0, 0, QPoint(0, 0) ); diff --git a/libopie/big-screen/osplitter.h b/libopie/big-screen/osplitter.h index 33a085f..61a247b 100644 --- a/libopie/big-screen/osplitter.h +++ b/libopie/big-screen/osplitter.h @@ -46,100 +46,101 @@ class QHBox; * TODO * -check API docu * -one more example * -allow inserting at a position */ /** * * If you've widgets that could be placed side by side but you think * on small resolutions is not enough place but it would really make sense * on bigger resolutions this class will help you. * You can add as many widgets you want to it. Set a poliy on which width/height it * should switch the layout. * You can either say to place widgets vertical or horizontal. * This class uses QHBox, QVBox and QTAbWidget internally. * OSplitter takes ownership of the widgets * * @since 1.2 * * @short a small dynamically changing its layout to store two or more widgets side by side * @version 0.1 * @author zecke */ class OSplitter : public QFrame{ Q_OBJECT public: typedef QValueList<Opie::OSplitterContainer> ContainerList; OSplitter( Qt::Orientation = Horizontal, QWidget *parent = 0, const char* name = 0, WFlags fl = 0 ); ~OSplitter(); void setLabel( const QString& name ); void setIconName( const QString& name ); QString label()const; QString iconName()const; void setSizeChange( int width_height ); void addWidget( OSplitter* splitter ); void addWidget( QWidget* wid, const QString& icon, const QString& label ); void removeWidget( QWidget* ); void removeWidget( OSplitter* ); void setCurrentWidget( QWidget* ); void setCurrentWidget( const QString& label ); void setCurrentWidget( int ); QWidget* currentWidget()const; + signals: /** * Emitted if in tab and comes directly from the tab widget * */ void currentChanged( QWidget* ); /** * emitted whenever a border is crossed * true if in small screen mode * false if in bigscreen * this signal is emitted after the layout switch * @param b The layout mode * @param ori The orientation */ void sizeChanged( bool b, Orientation ori); public: - QSize sizeHint()const; - QSize minimumSizeHint()const; +// QSize sizeHint()const; +// QSize minimumSizeHint()const; protected: void resizeEvent( QResizeEvent* ); private: /* true if OTabMode */ bool layoutMode()const; // void reparentAll(); void setTabWidget( OTabWidget*); void addToTab( const Opie::OSplitterContainer& ); void addToBox( const Opie::OSplitterContainer& ); void removeFromTab( QWidget* ); void changeTab(); void changeHBox(); void changeVBox(); void commonChangeBox(); QHBox *m_hbox; OTabWidget *m_tabWidget; OTabWidget *m_parentTab; Orientation m_orient; int m_size_policy; ContainerList m_container; QList<OSplitter> m_splitter; QString m_icon, m_name; struct Private; Private *d; }; #endif |