-rw-r--r-- | libopie/otabinfo.h | 16 | ||||
-rw-r--r-- | libopie/otabwidget.cpp | 48 | ||||
-rw-r--r-- | libopie/otabwidget.h | 10 |
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 | |||
@@ -89,6 +89,14 @@ public: | |||
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 | */ |
@@ -100,6 +108,14 @@ public: | |||
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 | |||
103 | private: | 119 | private: |
104 | int i; | 120 | int i; |
105 | QWidget *c; | 121 | QWidget *c; |
diff --git a/libopie/otabwidget.cpp b/libopie/otabwidget.cpp index bee3f35..99bf067 100644 --- a/libopie/otabwidget.cpp +++ b/libopie/otabwidget.cpp | |||
@@ -98,7 +98,7 @@ void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &lab | |||
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 | } |
@@ -158,16 +158,52 @@ void OTabWidget::removePage( QWidget *childwidget ) | |||
158 | } | 158 | } |
159 | } | 159 | } |
160 | 160 | ||
161 | void 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 | |||
161 | void OTabWidget::setCurrentTab( QWidget *childwidget ) | 197 | void 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 | ||
diff --git a/libopie/otabwidget.h b/libopie/otabwidget.h index 74d683b..0aa9bb8 100644 --- a/libopie/otabwidget.h +++ b/libopie/otabwidget.h | |||
@@ -126,6 +126,16 @@ public: | |||
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 | */ |