summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/otabinfo.h16
-rw-r--r--libopie/otabwidget.cpp48
-rw-r--r--libopie/otabwidget.h10
3 files changed, 68 insertions, 6 deletions
diff --git a/libopie/otabinfo.h b/libopie/otabinfo.h
index 8dbbcc2..6589638 100644
--- a/libopie/otabinfo.h
+++ b/libopie/otabinfo.h
@@ -84,27 +84,43 @@ public:
84 84
85/** 85/**
86 * @fn label() 86 * @fn label()
87 * @brief Returns text label for widget. 87 * @brief Returns text label for widget.
88 */ 88 */
89 const QString &label() const { return l; } 89 const QString &label() const { return l; }
90 90
91/** 91/**
92 * @fn setLabel( const QString &label )
93 * @brief Set label for tab.
94 *
95 * @param label QString text label for OTabWidget selection control.
96 */
97 void setLabel( const QString &label ) { l = label; }
98
99/**
92 * @fn control() 100 * @fn control()
93 * @brief Returns pointer to widget. 101 * @brief Returns pointer to widget.
94 */ 102 */
95 QWidget *control() const { return c; } 103 QWidget *control() const { return c; }
96 104
97/** 105/**
98 * @fn icon() 106 * @fn icon()
99 * @brief Returns name of icon file. 107 * @brief Returns name of icon file.
100 */ 108 */
101 const QString &icon() const { return p; } 109 const QString &icon() const { return p; }
102 110
111/**
112 * @fn setIcon( const QString &icon )
113 * @brief Set icon for tab.
114 *
115 * @param icon QString name of icon file.
116 */
117 void setIcon( const QString &icon ) { p = icon; }
118
103private: 119private:
104 int i; 120 int i;
105 QWidget *c; 121 QWidget *c;
106 QString p; 122 QString p;
107 QString l; 123 QString l;
108}; 124};
109 125
110/** 126/**
diff --git a/libopie/otabwidget.cpp b/libopie/otabwidget.cpp
index bee3f35..99bf067 100644
--- a/libopie/otabwidget.cpp
+++ b/libopie/otabwidget.cpp
@@ -93,17 +93,17 @@ void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &lab
93 if ( tabBarStyle == IconTab ) 93 if ( tabBarStyle == IconTab )
94 { 94 {
95 tab->label = QString::null; 95 tab->label = QString::null;
96 } 96 }
97 else 97 else
98 { 98 {
99 tab->label = label; 99 tab->label = label;
100 } 100 }
101 if ( tabBarStyle == IconTab || tabBarStyle == IconList) 101 if ( tabBarStyle == IconTab || tabBarStyle == IconList )
102 { 102 {
103 tab->iconset = new QIconSet( iconset ); 103 tab->iconset = new QIconSet( iconset );
104 } 104 }
105 int tabid = tabBar->addTab( tab ); 105 int tabid = tabBar->addTab( tab );
106 106
107 if ( tabBarStyle == IconTab || tabBarStyle == IconList ) 107 if ( tabBarStyle == IconTab || tabBarStyle == IconList )
108 { 108 {
109 tabList->insertItem( iconset, label, -1 ); 109 tabList->insertItem( iconset, label, -1 );
@@ -153,26 +153,62 @@ void OTabWidget::removePage( QWidget *childwidget )
153 widgetStack->setFrameStyle( QFrame::NoFrame ); 153 widgetStack->setFrameStyle( QFrame::NoFrame );
154 } 154 }
155 155
156 setUpLayout(); 156 setUpLayout();
157 } 157 }
158 } 158 }
159} 159}
160 160
161void OTabWidget::changeTab( QWidget *widget, const QString &iconset, const QString &label)
162{
163 OTabInfo *currtab = tabs.first();
164 while ( currtab && currtab->control() != widget )
165 {
166 currtab = tabs.next();
167 }
168 if ( currtab && currtab->control() == widget )
169 {
170 QTab *tab = tabBar->tab( currtab->id() );
171 QPixmap icon( loadSmooth( iconset ) );
172 tab->setText( label );
173 if ( tabBarStyle == IconTab )
174 tab->setIconSet( icon );
175 int i = 0;
176 while ( i < tabList->count() && tabList->text( i ) != currtab->label() )
177 {
178 i++;
179 }
180 if ( i < tabList->count() && tabList->text( i ) == currtab->label() )
181 {
182 if ( tabBarStyle == IconTab || tabBarStyle == IconList )
183 {
184 tabList->changeItem( icon, label, i );
185 }
186 else
187 {
188 tabList->changeItem( label, i );
189 }
190 }
191 currtab->setLabel( label );
192 currtab->setIcon( iconset );
193 }
194 setUpLayout();
195}
196
161void OTabWidget::setCurrentTab( QWidget *childwidget ) 197void OTabWidget::setCurrentTab( QWidget *childwidget )
162{ 198{
163 OTabInfo *newtab = tabs.first(); 199 OTabInfo *currtab = tabs.first();
164 while ( newtab && newtab->control() != childwidget ) 200 while ( currtab && currtab->control() != childwidget )
165 { 201 {
166 newtab = tabs.next(); 202 currtab = tabs.next();
167 } 203 }
168 if ( newtab && newtab->control() == childwidget ) 204 if ( currtab && currtab->control() == childwidget )
169 { 205 {
170 selectTab( newtab ); 206 selectTab( currtab );
171 } 207 }
172} 208}
173 209
174void OTabWidget::setCurrentTab( const QString &tabname ) 210void OTabWidget::setCurrentTab( const QString &tabname )
175{ 211{
176 OTabInfo *newtab = tabs.first(); 212 OTabInfo *newtab = tabs.first();
177 while ( newtab && newtab->label() != tabname ) 213 while ( newtab && newtab->label() != tabname )
178 { 214 {
diff --git a/libopie/otabwidget.h b/libopie/otabwidget.h
index 74d683b..0aa9bb8 100644
--- a/libopie/otabwidget.h
+++ b/libopie/otabwidget.h
@@ -121,16 +121,26 @@ public:
121 * @fn removePage( QWidget *widget ) 121 * @fn removePage( QWidget *widget )
122 * @brief Remove widget from control. Does not delete widget. 122 * @brief Remove widget from control. Does not delete widget.
123 * 123 *
124 * @param widget Widget control to be removed. 124 * @param widget Widget control to be removed.
125 */ 125 */
126 void removePage( QWidget * ); 126 void removePage( QWidget * );
127 127
128/** 128/**
129 * @fn changeTab( QWidget *widget, const QIconSet &icon, const QString &label )
130 * @brief Change text and/or icon for existing tab
131 *
132 * @param child Widget control.
133 * @param icon Path to icon.
134 * @param label Text label.
135 */
136 void changeTab( QWidget *, const QString &, const QString & );
137
138/**
129 * @fn tabStyle() 139 * @fn tabStyle()
130 * @brief Returns current widget selection control style. 140 * @brief Returns current widget selection control style.
131 */ 141 */
132 TabStyle tabStyle() const; 142 TabStyle tabStyle() const;
133 143
134/** 144/**
135 * @fn setTabStyle( TabStyle s ) 145 * @fn setTabStyle( TabStyle s )
136 * @brief Set the current widget selection control style. 146 * @brief Set the current widget selection control style.