Diffstat (limited to 'libopie2/opieui/opopupmenu.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opieui/opopupmenu.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/libopie2/opieui/opopupmenu.cpp b/libopie2/opieui/opopupmenu.cpp index 3ab8490..50c613f 100644 --- a/libopie2/opieui/opopupmenu.cpp +++ b/libopie2/opieui/opopupmenu.cpp | |||
@@ -8,33 +8,33 @@ | |||
8 | 8 | ||
9 | This library is distributed in the hope that it will be useful, | 9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. | 12 | Library General Public License for more details. |
13 | 13 | ||
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
17 | Boston, MA 02111-1307, USA. | 17 | Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | /* QT */ | 20 | /* OPIE */ |
21 | #include <opie2/opopupmenu.h> | ||
22 | #include <opie2/oconfig.h> | ||
23 | #include <opie2/odebug.h> | ||
21 | 24 | ||
25 | /* QT */ | ||
22 | #include <qdrawutil.h> | 26 | #include <qdrawutil.h> |
23 | #include <qtimer.h> | 27 | #include <qtimer.h> |
24 | 28 | ||
25 | /* OPIE */ | ||
26 | |||
27 | #include <opie2/opopupmenu.h> | ||
28 | #include <opie2/oconfig.h> | ||
29 | 29 | ||
30 | using namespace Opie::Core; | 30 | using namespace Opie::Core; |
31 | using namespace Opie::Ui; | 31 | using namespace Opie::Ui; |
32 | 32 | ||
33 | OPopupTitle::OPopupTitle(QWidget *parent, const char *name) | 33 | OPopupTitle::OPopupTitle(QWidget *parent, const char *name) |
34 | : QWidget(parent, name) | 34 | : QWidget(parent, name) |
35 | { | 35 | { |
36 | setMinimumSize(16, fontMetrics().height()+8); | 36 | setMinimumSize(16, fontMetrics().height()+8); |
37 | } | 37 | } |
38 | 38 | ||
39 | OPopupTitle::OPopupTitle(OPixmapEffect::GradientType /* gradient */, | 39 | OPopupTitle::OPopupTitle(OPixmapEffect::GradientType /* gradient */, |
40 | const QColor &/* color */, const QColor &/* textColor */, | 40 | const QColor &/* color */, const QColor &/* textColor */, |
@@ -123,25 +123,25 @@ QSize OPopupTitle::sizeHint() const | |||
123 | } | 123 | } |
124 | 124 | ||
125 | class OPopupMenu::OPopupMenuPrivate | 125 | class OPopupMenu::OPopupMenuPrivate |
126 | { | 126 | { |
127 | public: | 127 | public: |
128 | OPopupMenuPrivate () | 128 | OPopupMenuPrivate () |
129 | : noMatches(false) | 129 | : noMatches(false) |
130 | , shortcuts(false) | 130 | , shortcuts(false) |
131 | , autoExec(false) | 131 | , autoExec(false) |
132 | , lastHitIndex(-1) | 132 | , lastHitIndex(-1) |
133 | , m_ctxMenu(0) | 133 | , m_ctxMenu(0) |
134 | {} | 134 | {} |
135 | 135 | ||
136 | ~OPopupMenuPrivate () | 136 | ~OPopupMenuPrivate () |
137 | { | 137 | { |
138 | delete m_ctxMenu; | 138 | delete m_ctxMenu; |
139 | } | 139 | } |
140 | 140 | ||
141 | QString m_lastTitle; | 141 | QString m_lastTitle; |
142 | 142 | ||
143 | // variables for keyboard navigation | 143 | // variables for keyboard navigation |
144 | QTimer clearTimer; | 144 | QTimer clearTimer; |
145 | 145 | ||
146 | bool noMatches : 1; | 146 | bool noMatches : 1; |
147 | bool shortcuts : 1; | 147 | bool shortcuts : 1; |
@@ -169,25 +169,25 @@ OPopupMenu::OPopupMenu(QWidget *parent, const char *name) | |||
169 | d = new OPopupMenuPrivate; | 169 | d = new OPopupMenuPrivate; |
170 | resetKeyboardVars(); | 170 | resetKeyboardVars(); |
171 | connect(&(d->clearTimer), SIGNAL(timeout()), SLOT(resetKeyboardVars())); | 171 | connect(&(d->clearTimer), SIGNAL(timeout()), SLOT(resetKeyboardVars())); |
172 | } | 172 | } |
173 | 173 | ||
174 | OPopupMenu::~OPopupMenu() | 174 | OPopupMenu::~OPopupMenu() |
175 | { | 175 | { |
176 | if (OPopupMenuPrivate::s_contextedMenu == this) | 176 | if (OPopupMenuPrivate::s_contextedMenu == this) |
177 | { | 177 | { |
178 | OPopupMenuPrivate::s_contextedMenu = 0; | 178 | OPopupMenuPrivate::s_contextedMenu = 0; |
179 | OPopupMenuPrivate::s_highlightedItem = -1; | 179 | OPopupMenuPrivate::s_highlightedItem = -1; |
180 | } | 180 | } |
181 | 181 | ||
182 | delete d; | 182 | delete d; |
183 | } | 183 | } |
184 | 184 | ||
185 | int OPopupMenu::insertTitle(const QString &text, int id, int index) | 185 | int OPopupMenu::insertTitle(const QString &text, int id, int index) |
186 | { | 186 | { |
187 | OPopupTitle *titleItem = new OPopupTitle(); | 187 | OPopupTitle *titleItem = new OPopupTitle(); |
188 | titleItem->setTitle(text); | 188 | titleItem->setTitle(text); |
189 | int ret = insertItem(titleItem, id, index); | 189 | int ret = insertItem(titleItem, id, index); |
190 | setItemEnabled(id, false); | 190 | setItemEnabled(id, false); |
191 | return ret; | 191 | return ret; |
192 | } | 192 | } |
193 | 193 | ||
@@ -200,77 +200,77 @@ int OPopupMenu::insertTitle(const QPixmap &icon, const QString &text, int id, | |||
200 | setItemEnabled(id, false); | 200 | setItemEnabled(id, false); |
201 | return ret; | 201 | return ret; |
202 | } | 202 | } |
203 | 203 | ||
204 | void OPopupMenu::changeTitle(int id, const QString &text) | 204 | void OPopupMenu::changeTitle(int id, const QString &text) |
205 | { | 205 | { |
206 | QMenuItem *item = findItem(id); | 206 | QMenuItem *item = findItem(id); |
207 | if(item){ | 207 | if(item){ |
208 | if(item->widget()) | 208 | if(item->widget()) |
209 | ((OPopupTitle *)item->widget())->setTitle(text); | 209 | ((OPopupTitle *)item->widget())->setTitle(text); |
210 | #ifndef NDEBUG | 210 | #ifndef NDEBUG |
211 | else | 211 | else |
212 | qWarning( "KPopupMenu: changeTitle() called with non-title id %d", id ); | 212 | owarn << "KPopupMenu: changeTitle() called with non-title id " << id << "" << oendl; |
213 | #endif | 213 | #endif |
214 | } | 214 | } |
215 | #ifndef NDEBUG | 215 | #ifndef NDEBUG |
216 | else | 216 | else |
217 | qWarning( "KPopupMenu: changeTitle() called with invalid id %d", id ); | 217 | owarn << "KPopupMenu: changeTitle() called with invalid id " << id << "" << oendl; |
218 | #endif | 218 | #endif |
219 | } | 219 | } |
220 | 220 | ||
221 | void OPopupMenu::changeTitle(int id, const QPixmap &icon, const QString &text) | 221 | void OPopupMenu::changeTitle(int id, const QPixmap &icon, const QString &text) |
222 | { | 222 | { |
223 | QMenuItem *item = findItem(id); | 223 | QMenuItem *item = findItem(id); |
224 | if(item){ | 224 | if(item){ |
225 | if(item->widget()) | 225 | if(item->widget()) |
226 | ((OPopupTitle *)item->widget())->setTitle(text, &icon); | 226 | ((OPopupTitle *)item->widget())->setTitle(text, &icon); |
227 | #ifndef NDEBUG | 227 | #ifndef NDEBUG |
228 | else | 228 | else |
229 | qWarning( "KPopupMenu: changeTitle() called with non-title id %d", id ); | 229 | owarn << "KPopupMenu: changeTitle() called with non-title id " << id << "" << oendl; |
230 | #endif | 230 | #endif |
231 | } | 231 | } |
232 | #ifndef NDEBUG | 232 | #ifndef NDEBUG |
233 | else | 233 | else |
234 | qWarning( "KPopupMenu: changeTitle() called with invalid id %d", id ); | 234 | owarn << "KPopupMenu: changeTitle() called with invalid id " << id << "" << oendl; |
235 | #endif | 235 | #endif |
236 | } | 236 | } |
237 | 237 | ||
238 | QString OPopupMenu::title(int id) const | 238 | QString OPopupMenu::title(int id) const |
239 | { | 239 | { |
240 | if(id == -1) // obsolete | 240 | if(id == -1) // obsolete |
241 | return(d->m_lastTitle); | 241 | return(d->m_lastTitle); |
242 | QMenuItem *item = findItem(id); | 242 | QMenuItem *item = findItem(id); |
243 | if(item){ | 243 | if(item){ |
244 | if(item->widget()) | 244 | if(item->widget()) |
245 | return(((OPopupTitle *)item->widget())->title()); | 245 | return(((OPopupTitle *)item->widget())->title()); |
246 | else | 246 | else |
247 | qWarning("OPopupMenu: title() called with non-title id %d.", id); | 247 | owarn << "OPopupMenu: title() called with non-title id " << id << "." << oendl; |
248 | } | 248 | } |
249 | else | 249 | else |
250 | qWarning("OPopupMenu: title() called with invalid id %d.", id); | 250 | owarn << "OPopupMenu: title() called with invalid id " << id << "." << oendl; |
251 | return(QString::null); | 251 | return(QString::null); |
252 | } | 252 | } |
253 | 253 | ||
254 | QPixmap OPopupMenu::titlePixmap(int id) const | 254 | QPixmap OPopupMenu::titlePixmap(int id) const |
255 | { | 255 | { |
256 | QMenuItem *item = findItem(id); | 256 | QMenuItem *item = findItem(id); |
257 | if(item){ | 257 | if(item){ |
258 | if(item->widget()) | 258 | if(item->widget()) |
259 | return(((OPopupTitle *)item->widget())->icon()); | 259 | return(((OPopupTitle *)item->widget())->icon()); |
260 | else | 260 | else |
261 | qWarning("KPopupMenu: titlePixmap() called with non-title id %d.", id); | 261 | owarn << "KPopupMenu: titlePixmap() called with non-title id " << id << "." << oendl; |
262 | } | 262 | } |
263 | else | 263 | else |
264 | qWarning("KPopupMenu: titlePixmap() called with invalid id %d.", id); | 264 | owarn << "KPopupMenu: titlePixmap() called with invalid id " << id << "." << oendl; |
265 | QPixmap tmp; | 265 | QPixmap tmp; |
266 | return(tmp); | 266 | return(tmp); |
267 | } | 267 | } |
268 | 268 | ||
269 | /** | 269 | /** |
270 | * This is re-implemented for keyboard navigation. | 270 | * This is re-implemented for keyboard navigation. |
271 | */ | 271 | */ |
272 | void OPopupMenu::closeEvent(QCloseEvent*e) | 272 | void OPopupMenu::closeEvent(QCloseEvent*e) |
273 | { | 273 | { |
274 | if (d->shortcuts) | 274 | if (d->shortcuts) |
275 | resetKeyboardVars(); | 275 | resetKeyboardVars(); |
276 | QPopupMenu::closeEvent(e); | 276 | QPopupMenu::closeEvent(e); |