summaryrefslogtreecommitdiff
path: root/library/menubutton.cpp
authorzecke <zecke>2002-10-06 09:53:54 (UTC)
committer zecke <zecke>2002-10-06 09:53:54 (UTC)
commit4209ade719759f4b079bdd40baa4d255ce1e9d3a (patch) (unidiff)
tree34ba8c99dd79f6b6f6c5b396e288f7de9493dda9 /library/menubutton.cpp
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/menubutton.cpp') (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
@@ -63,129 +63,129 @@
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.