-rw-r--r-- | libopie/otabwidget.cpp | 24 | ||||
-rw-r--r-- | libopie/otabwidget.h | 15 |
2 files changed, 38 insertions, 1 deletions
diff --git a/libopie/otabwidget.cpp b/libopie/otabwidget.cpp index aaf14ce..bed7ef1 100644 --- a/libopie/otabwidget.cpp +++ b/libopie/otabwidget.cpp @@ -142,5 +142,5 @@ void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &lab void OTabWidget::removePage( QWidget *childwidget ) { - if ( childwidget ) + if ( childwidget ) { OTabInfo *tab = tabs.first(); @@ -202,4 +202,17 @@ void OTabWidget::setCurrentTab( const QString &tabname ) } +void OTabWidget::setCurrentTab(int tabindex) { + OTabInfo *newtab = tabs.first(); + while ( newtab && newtab->id() != tabindex ) + { + newtab = tabs.next(); + } + if ( newtab && newtab->id() == tabindex ) + { + selectTab( newtab ); + } +} + + OTabWidget::TabStyle OTabWidget::tabStyle() const { @@ -306,2 +319,11 @@ void OTabWidget::resizeEvent( QResizeEvent * ) setUpLayout(); } + +int OTabWidget::getCurrentTab() { + if ( currentTab ) + { + return currentTab->id(); + } + return -1; +} + diff --git a/libopie/otabwidget.h b/libopie/otabwidget.h index d61fe9e..74d683b 100644 --- a/libopie/otabwidget.h +++ b/libopie/otabwidget.h @@ -171,4 +171,12 @@ public: /** + * @fn setCurrentTab( int ) + * @brief Selects and brings to top the desired widget, by using id. + * + * @param tab id for widget to select. + */ + void setCurrentTab(int); + +/** * @fn sizeHint() * @brief Reimplemented for internal purposes. @@ -176,4 +184,10 @@ public: QSize sizeHint() const; +/** + * @fn getCurrentTab( ) + * @brief returns current tab id. + */ + int getCurrentTab(); + protected: @@ -220,4 +234,5 @@ private: void setUpLayout(); + signals: /** |