summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2003-02-23 03:35:32 (UTC)
committer llornkcor <llornkcor>2003-02-23 03:35:32 (UTC)
commit98ed23c5281a57d08c6c18b464fc50b4638385f8 (patch) (unidiff)
tree79e3ad38c6e96ce3d0bbabb00e601a45f41d7210
parent47fc358e914aecd13c4cb3d9cb4b3f2ca1a93b6c (diff)
downloadopie-98ed23c5281a57d08c6c18b464fc50b4638385f8.zip
opie-98ed23c5281a57d08c6c18b464fc50b4638385f8.tar.gz
opie-98ed23c5281a57d08c6c18b464fc50b4638385f8.tar.bz2
added a couple public methods- remove(int) count() text(int) and setUseLabel. see header for notes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/menubutton.cpp71
-rw-r--r--library/menubutton.h6
2 files changed, 60 insertions, 17 deletions
diff --git a/library/menubutton.cpp b/library/menubutton.cpp
index 007761f..4357460 100644
--- a/library/menubutton.cpp
+++ b/library/menubutton.cpp
@@ -69,2 +69,3 @@ MenuButton::MenuButton( const QStringList& items, QWidget* parent, const char* n
69{ 69{
70 useLabel = true;
70 init(); 71 init();
@@ -100,4 +101,4 @@ void MenuButton::clear()
100{ 101{
101 delete pop; 102 delete pop;
102 init(); 103 init();
103} 104}
@@ -113,6 +114,6 @@ void MenuButton::insertItems( const QStringList& items )
113 for (; it!=items.end(); ++it) { 114 for (; it!=items.end(); ++it) {
114 if ( (*it) == "--" ) 115 if ( (*it) == "--" )
115 insertSeparator(); 116 insertSeparator();
116 else 117 else
117 insertItem(*it); 118 insertItem(*it);
118 } 119 }
@@ -129,3 +130,3 @@ void MenuButton::insertItem( const QIconSet& icon, const QString& text )
129 pop->insertItem(icon, text, nitems++); 130 pop->insertItem(icon, text, nitems++);
130 if ( nitems==1 ) select(0); 131// if ( nitems==1 ) select(0);
131} 132}
@@ -141,3 +142,3 @@ void MenuButton::insertItem( const QString& text )
141 pop->insertItem(text, nitems++); 142 pop->insertItem(text, nitems++);
142 if ( nitems==1 ) select(0); 143// if ( nitems==1 ) select(0);
143} 144}
@@ -160,6 +161,6 @@ void MenuButton::select(const QString& s)
160 for (int i=0; i<nitems; i++) { 161 for (int i=0; i<nitems; i++) {
161 if ( pop->text(i) == s ) { 162 if ( pop->text(i) == s ) {
162 select(i); 163 select(i);
163 break; 164 break;
164 } 165 }
165 } 166 }
@@ -176,3 +177,3 @@ void MenuButton::select(int s)
176 if ( pop->iconSet(cur) ) 177 if ( pop->iconSet(cur) )
177 setIconSet(*pop->iconSet(cur)); 178 setIconSet(*pop->iconSet(cur));
178 emit selected(cur); 179 emit selected(cur);
@@ -210,7 +211,43 @@ void MenuButton::updateLabel()
210{ 211{
211 QString t = pop->text(cur); 212 if(useLabel)
212 if ( !lab.isEmpty() ) 213 {
213 t = lab.arg(t); 214 QString t = pop->text(cur);
214 setText(t); 215 if ( !lab.isEmpty() )
216 t = lab.arg(t);
217 setText(t);
218 }
215} 219}
216 220
221
222/*!
223 remove item at id
224 */
225void MenuButton::remove(int id)
226{
227 pop->removeItem(id);
228 nitems--;
229}
230
231/*!
232 return count of items in menu
233 */
234int MenuButton::count()
235{
236 return nitems;
237}
238
239/*!
240 returns text of item id
241 */
242QString MenuButton::text(int id)
243{
244 return pop->text(id);
245}
246
247/*!
248 sets true or false the use of label
249 */
250void MenuButton::setUseLabel(bool b)
251{
252 useLabel = b;
253}
diff --git a/library/menubutton.h b/library/menubutton.h
index 6582b1e..ee5dcf1 100644
--- a/library/menubutton.h
+++ b/library/menubutton.h
@@ -33,2 +33,3 @@ public:
33 33
34
34 int currentItem() const; 35 int currentItem() const;
@@ -42,2 +43,6 @@ public:
42 void setLabel(const QString& label); 43 void setLabel(const QString& label);
44 int count();
45 void remove(int id);
46 QString text(int id);
47 void setUseLabel(bool b);
43 48
@@ -52,2 +57,3 @@ public slots:
52private: 57private:
58 bool useLabel;
53 void init(); 59 void init();