summaryrefslogtreecommitdiff
path: root/library
authorzecke <zecke>2002-10-06 09:53:54 (UTC)
committer zecke <zecke>2002-10-06 09:53:54 (UTC)
commit4209ade719759f4b079bdd40baa4d255ce1e9d3a (patch) (unidiff)
tree34ba8c99dd79f6b6f6c5b396e288f7de9493dda9 /library
parent93432da5b2a73874b359d4a4468cdaffeaab960c (diff)
downloadopie-4209ade719759f4b079bdd40baa4d255ce1e9d3a.zip
opie-4209ade719759f4b079bdd40baa4d255ce1e9d3a.tar.gz
opie-4209ade719759f4b079bdd40baa4d255ce1e9d3a.tar.bz2
As spotted on the MailinList
no default arguments in the implementation!
Diffstat (limited to 'library') (more/less context) (ignore whitespace changes)
-rw-r--r--library/menubutton.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/library/menubutton.cpp b/library/menubutton.cpp
index f5c832c..007761f 100644
--- a/library/menubutton.cpp
+++ b/library/menubutton.cpp
@@ -31,186 +31,186 @@
31 31
32 The index of the item that the user's input device (e.g. stylus) is 32 The index of the item that the user's input device (e.g. stylus) is
33 pointing at is the currentItem(), whose text is available using 33 pointing at is the currentItem(), whose text is available using
34 currentText(). 34 currentText().
35 35
36 Menu items are inserted with the \link MenuButton::MenuButton() 36 Menu items are inserted with the \link MenuButton::MenuButton()
37 constructor\endlink, insertItem() or insertItems(). Separators are 37 constructor\endlink, insertItem() or insertItems(). Separators are
38 inserted with insertSeparator(). All the items in the menu can be 38 inserted with insertSeparator(). All the items in the menu can be
39 removed by calling clear(). 39 removed by calling clear().
40 40
41 Items can be selected programmatically using select(). When a menu 41 Items can be selected programmatically using select(). When a menu
42 item is selected (programmatically or by the user), the selected() 42 item is selected (programmatically or by the user), the selected()
43 signal is emitted. 43 signal is emitted.
44 44
45 \ingroup qtopiaemb 45 \ingroup qtopiaemb
46*/ 46*/
47 47
48/*! 48/*!
49 \overload void MenuButton::selected(int index) 49 \overload void MenuButton::selected(int index)
50 50
51 This signal is emitted when the item at position \a index is selected. 51 This signal is emitted when the item at position \a index is selected.
52*/ 52*/
53 53
54/*! 54/*!
55 \fn void MenuButton::selected(const QString& text) 55 \fn void MenuButton::selected(const QString& text)
56 56
57 This signal is emitted when the item with the label \a text is selected. 57 This signal is emitted when the item with the label \a text is selected.
58*/ 58*/
59 59
60 60
61/*! 61/*!
62 Constructs a MenuButton. A menu item is created (see insertItem() 62 Constructs a MenuButton. A menu item is created (see insertItem()
63 and insertItems()) for each string in the \a items string list. The 63 and insertItems()) for each string in the \a items string list. The
64 standard \a parent an \a name arguments are passed to the base 64 standard \a parent an \a name arguments are passed to the base
65 class. 65 class.
66*/ 66*/
67MenuButton::MenuButton( const QStringList& items, QWidget* parent, const char* name) : 67MenuButton::MenuButton( const QStringList& items, QWidget* parent, const char* name) :
68 QPushButton(parent,name) 68 QPushButton(parent,name)
69{ 69{
70 init(); 70 init();
71 insertItems(items); 71 insertItems(items);
72} 72}
73 73
74/*! 74/*!
75 Constructs an empty MenuButton. 75 Constructs an empty MenuButton.
76 The standard \a parent an \a name arguments are passed to the base class. 76 The standard \a parent an \a name arguments are passed to the base class.
77 77
78 \sa insertItem() insertItems() 78 \sa insertItem() insertItems()
79*/ 79*/
80MenuButton::MenuButton( QWidget* parent, const char* name) : 80MenuButton::MenuButton( QWidget* parent, const char* name) :
81 QPushButton(parent,name) 81 QPushButton(parent,name)
82{ 82{
83 init(); 83 init();
84} 84}
85 85
86void MenuButton::init() 86void MenuButton::init()
87{ 87{
88 setAutoDefault(FALSE); 88 setAutoDefault(FALSE);
89 pop = new QPopupMenu(this); 89 pop = new QPopupMenu(this);
90 nitems=0; 90 nitems=0;
91 connect(pop, SIGNAL(activated(int)), this, SLOT(select(int))); 91 connect(pop, SIGNAL(activated(int)), this, SLOT(select(int)));
92 setPopup(pop); 92 setPopup(pop);
93 //setPopupDelay(0); 93 //setPopupDelay(0);
94} 94}
95 95
96/*! 96/*!
97 Removes all the menu items from the button and menu. 97 Removes all the menu items from the button and menu.
98*/ 98*/
99void MenuButton::clear() 99void MenuButton::clear()
100{ 100{
101 delete pop; 101 delete pop;
102 init(); 102 init();
103} 103}
104 104
105/*! 105/*!
106 A menu item is created (see insertItem()) for each string in the \a 106 A menu item is created (see insertItem()) for each string in the \a
107 items string list. If any string is "--" a separator (see 107 items string list. If any string is "--" a separator (see
108 insertSeparator()) is inserted in its place. 108 insertSeparator()) is inserted in its place.
109*/ 109*/
110void MenuButton::insertItems( const QStringList& items ) 110void MenuButton::insertItems( const QStringList& items )
111{ 111{
112 QStringList::ConstIterator it=items.begin(); 112 QStringList::ConstIterator it=items.begin();
113 for (; it!=items.end(); ++it) { 113 for (; it!=items.end(); ++it) {
114 if ( (*it) == "--" ) 114 if ( (*it) == "--" )
115 insertSeparator(); 115 insertSeparator();
116 else 116 else
117 insertItem(*it); 117 insertItem(*it);
118 } 118 }
119} 119}
120 120
121/*! 121/*!
122 Inserts a menu item with the icon \a icon and label \a text into 122 Inserts a menu item with the icon \a icon and label \a text into
123 the menu. 123 the menu.
124 124
125 \sa insertItems() 125 \sa insertItems()
126*/ 126*/
127void MenuButton::insertItem( const QIconSet& icon, const QString& text=QString::null ) 127void MenuButton::insertItem( const QIconSet& icon, const QString& text )
128{ 128{
129 pop->insertItem(icon, text, nitems++); 129 pop->insertItem(icon, text, nitems++);
130 if ( nitems==1 ) select(0); 130 if ( nitems==1 ) select(0);
131} 131}
132 132
133/*! 133/*!
134 \overload 134 \overload
135 Inserts a menu item with the label \a text into the menu. 135 Inserts a menu item with the label \a text into the menu.
136 136
137 \sa insertItems() 137 \sa insertItems()
138*/ 138*/
139void MenuButton::insertItem( const QString& text ) 139void MenuButton::insertItem( const QString& text )
140{ 140{
141 pop->insertItem(text, nitems++); 141 pop->insertItem(text, nitems++);
142 if ( nitems==1 ) select(0); 142 if ( nitems==1 ) select(0);
143} 143}
144 144
145/*! 145/*!
146 Inserts a separator into the menu. 146 Inserts a separator into the menu.
147 147
148 \sa insertItems() 148 \sa insertItems()
149*/ 149*/
150void MenuButton::insertSeparator() 150void MenuButton::insertSeparator()
151{ 151{
152 pop->insertSeparator(); 152 pop->insertSeparator();
153} 153}
154 154
155/*! 155/*!
156 Selects the items with label text \a s. 156 Selects the items with label text \a s.
157*/ 157*/
158void MenuButton::select(const QString& s) 158void MenuButton::select(const QString& s)
159{ 159{
160 for (int i=0; i<nitems; i++) { 160 for (int i=0; i<nitems; i++) {
161 if ( pop->text(i) == s ) { 161 if ( pop->text(i) == s ) {
162 select(i); 162 select(i);
163 break; 163 break;
164 } 164 }
165 } 165 }
166} 166}
167 167
168/*! 168/*!
169 \overload 169 \overload
170 Selects the item at index position \a s. 170 Selects the item at index position \a s.
171*/ 171*/
172void MenuButton::select(int s) 172void MenuButton::select(int s)
173{ 173{
174 cur = s; 174 cur = s;
175 updateLabel(); 175 updateLabel();
176 if ( pop->iconSet(cur) ) 176 if ( pop->iconSet(cur) )
177 setIconSet(*pop->iconSet(cur)); 177 setIconSet(*pop->iconSet(cur));
178 emit selected(cur); 178 emit selected(cur);
179 emit selected(currentText()); 179 emit selected(currentText());
180} 180}
181 181
182/*! 182/*!
183 Returns the index position of the current item. 183 Returns the index position of the current item.
184*/ 184*/
185int MenuButton::currentItem() const 185int MenuButton::currentItem() const
186{ 186{
187 return cur; 187 return cur;
188} 188}
189 189
190/*! 190/*!
191 Returns the label text of the current item. 191 Returns the label text of the current item.
192*/ 192*/
193QString MenuButton::currentText() const 193QString MenuButton::currentText() const
194{ 194{
195 return pop->text(cur); 195 return pop->text(cur);
196} 196}
197 197
198/*! 198/*!
199 Sets the menubutton's label. If \a label is empty, the 199 Sets the menubutton's label. If \a label is empty, the
200 current item text is displayed, otherwise \a label should contain 200 current item text is displayed, otherwise \a label should contain
201 "%1", which will be replaced by the current item text. 201 "%1", which will be replaced by the current item text.
202*/ 202*/
203void MenuButton::setLabel(const QString& label) 203void MenuButton::setLabel(const QString& label)
204{ 204{
205 lab = label; 205 lab = label;
206 updateLabel(); 206 updateLabel();
207} 207}
208 208
209void MenuButton::updateLabel() 209void MenuButton::updateLabel()
210{ 210{
211 QString t = pop->text(cur); 211 QString t = pop->text(cur);
212 if ( !lab.isEmpty() ) 212 if ( !lab.isEmpty() )
213 t = lab.arg(t); 213 t = lab.arg(t);
214 setText(t); 214 setText(t);
215} 215}
216 216