-rw-r--r-- | microkde/kdeui/klistbox.cpp | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/microkde/kdeui/klistbox.cpp b/microkde/kdeui/klistbox.cpp index c65b892..71020b3 100644 --- a/microkde/kdeui/klistbox.cpp +++ b/microkde/kdeui/klistbox.cpp | |||
@@ -15,8 +15,13 @@ | |||
15 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 15 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
16 | Boston, MA 02111-1307, USA. | 16 | Boston, MA 02111-1307, USA. |
17 | */ | 17 | */ |
18 | #include <qtimer.h> | 18 | #include <qtimer.h> |
19 | //Added by qt3to4: | ||
20 | #include <QEvent> | ||
21 | #include <QMouseEvent> | ||
22 | #include <QKeyEvent> | ||
23 | #include <QFocusEvent> | ||
19 | 24 | ||
20 | #include <kglobalsettings.h> | 25 | #include <kglobalsettings.h> |
21 | //US#include <kcursor.h> | 26 | //US#include <kcursor.h> |
22 | #include <kapplication.h> | 27 | #include <kapplication.h> |
@@ -25,24 +30,25 @@ | |||
25 | 30 | ||
26 | #include "klistbox.h" | 31 | #include "klistbox.h" |
27 | 32 | ||
28 | #ifdef Q_WS_X11 | 33 | #ifdef Q_WS_X11 |
34 | #include <QX11Info> | ||
29 | #include <X11/Xlib.h> | 35 | #include <X11/Xlib.h> |
30 | #endif | 36 | #endif |
31 | #ifdef _WIN32_ | 37 | #ifdef _WIN32_ |
32 | #define Q_WS_QWS | 38 | #define Q_WS_QWS |
33 | #endif | 39 | #endif |
34 | KListBox::KListBox( QWidget *parent, const char *name, WFlags f ) | 40 | KListBox::KListBox( QWidget *parent, const char *name, Qt::WFlags f ) |
35 | : QListBox( parent, name, f ) | 41 | : Q3ListBox( parent, name, f ) |
36 | { | 42 | { |
37 | connect( this, SIGNAL( onViewport() ), | 43 | connect( this, SIGNAL( onViewport() ), |
38 | this, SLOT( slotOnViewport() ) ); | 44 | this, SLOT( slotOnViewport() ) ); |
39 | connect( this, SIGNAL( onItem( QListBoxItem * ) ), | 45 | connect( this, SIGNAL( onItem( Q3ListBoxItem * ) ), |
40 | this, SLOT( slotOnItem( QListBoxItem * ) ) ); | 46 | this, SLOT( slotOnItem( Q3ListBoxItem * ) ) ); |
41 | 47 | ||
42 | connect( this, SIGNAL( mouseButtonClicked( int, QListBoxItem *, | 48 | connect( this, SIGNAL( mouseButtonClicked( int, Q3ListBoxItem *, |
43 | const QPoint & ) ), | 49 | const QPoint & ) ), |
44 | this, SLOT( slotMouseButtonClicked( int, QListBoxItem *, | 50 | this, SLOT( slotMouseButtonClicked( int, Q3ListBoxItem *, |
45 | const QPoint & ) ) ); | 51 | const QPoint & ) ) ); |
46 | /*US | 52 | /*US |
47 | 53 | ||
48 | slotSettingsChanged(KApplication::SETTINGS_MOUSE); | 54 | slotSettingsChanged(KApplication::SETTINGS_MOUSE); |
@@ -59,9 +65,9 @@ KListBox::KListBox( QWidget *parent, const char *name, WFlags f ) | |||
59 | connect( m_pAutoSelect, SIGNAL( timeout() ), | 65 | connect( m_pAutoSelect, SIGNAL( timeout() ), |
60 | this, SLOT( slotAutoSelect() ) ); | 66 | this, SLOT( slotAutoSelect() ) ); |
61 | } | 67 | } |
62 | 68 | ||
63 | void KListBox::slotOnItem( QListBoxItem *item ) | 69 | void KListBox::slotOnItem( Q3ListBoxItem *item ) |
64 | { | 70 | { |
65 | /*US | 71 | /*US |
66 | if ( item && m_bChangeCursorOverItem && m_bUseSingle ) | 72 | if ( item && m_bChangeCursorOverItem && m_bUseSingle ) |
67 | viewport()->setCursor( KCursor().handCursor() ); | 73 | viewport()->setCursor( KCursor().handCursor() ); |
@@ -138,13 +144,13 @@ void KListBox::slotAutoSelect() | |||
138 | Window root; | 144 | Window root; |
139 | Window child; | 145 | Window child; |
140 | int root_x, root_y, win_x, win_y; | 146 | int root_x, root_y, win_x, win_y; |
141 | uint keybstate; | 147 | uint keybstate; |
142 | XQueryPointer( qt_xdisplay(), qt_xrootwin(), &root, &child, | 148 | XQueryPointer( x11Info().display(), x11Info().appRootWindow(), &root, &child, |
143 | &root_x, &root_y, &win_x, &win_y, &keybstate ); | 149 | &root_x, &root_y, &win_x, &win_y, &keybstate ); |
144 | #endif | 150 | #endif |
145 | 151 | ||
146 | QListBoxItem* previousItem = item( currentItem() ); | 152 | Q3ListBoxItem* previousItem = item( currentItem() ); |
147 | setCurrentItem( m_pCurrentItem ); | 153 | setCurrentItem( m_pCurrentItem ); |
148 | 154 | ||
149 | if( m_pCurrentItem ) { | 155 | if( m_pCurrentItem ) { |
150 | #ifndef Q_WS_QWS //FIXME | 156 | #ifndef Q_WS_QWS //FIXME |
@@ -166,9 +172,9 @@ void KListBox::slotAutoSelect() | |||
166 | bool update = viewport()->isUpdatesEnabled(); | 172 | bool update = viewport()->isUpdatesEnabled(); |
167 | viewport()->setUpdatesEnabled( false ); | 173 | viewport()->setUpdatesEnabled( false ); |
168 | 174 | ||
169 | bool down = index( previousItem ) < index( m_pCurrentItem ); | 175 | bool down = index( previousItem ) < index( m_pCurrentItem ); |
170 | QListBoxItem* it = down ? previousItem : m_pCurrentItem; | 176 | Q3ListBoxItem* it = down ? previousItem : m_pCurrentItem; |
171 | for (;it ; it = it->next() ) { | 177 | for (;it ; it = it->next() ) { |
172 | if ( down && it == m_pCurrentItem ) { | 178 | if ( down && it == m_pCurrentItem ) { |
173 | setSelected( m_pCurrentItem, select ); | 179 | setSelected( m_pCurrentItem, select ); |
174 | break; | 180 | break; |
@@ -185,9 +191,9 @@ void KListBox::slotAutoSelect() | |||
185 | triggerUpdate( false ); | 191 | triggerUpdate( false ); |
186 | 192 | ||
187 | emit selectionChanged(); | 193 | emit selectionChanged(); |
188 | 194 | ||
189 | if( selectionMode() == QListBox::Single ) | 195 | if( selectionMode() == Q3ListBox::Single ) |
190 | emit selectionChanged( m_pCurrentItem ); | 196 | emit selectionChanged( m_pCurrentItem ); |
191 | } | 197 | } |
192 | #ifndef Q_WS_QWS //FIXME | 198 | #ifndef Q_WS_QWS //FIXME |
193 | else if( (keybstate & ControlMask) ) | 199 | else if( (keybstate & ControlMask) ) |
@@ -212,16 +218,16 @@ void KListBox::slotAutoSelect() | |||
212 | kdDebug() << "Thats not supposed to happen!!!!" << endl; | 218 | kdDebug() << "Thats not supposed to happen!!!!" << endl; |
213 | #endif | 219 | #endif |
214 | } | 220 | } |
215 | 221 | ||
216 | void KListBox::emitExecute( QListBoxItem *item, const QPoint &pos ) | 222 | void KListBox::emitExecute( Q3ListBoxItem *item, const QPoint &pos ) |
217 | { | 223 | { |
218 | #ifdef Q_WS_X11 //FIXME | 224 | #ifdef Q_WS_X11 //FIXME |
219 | Window root; | 225 | Window root; |
220 | Window child; | 226 | Window child; |
221 | int root_x, root_y, win_x, win_y; | 227 | int root_x, root_y, win_x, win_y; |
222 | uint keybstate; | 228 | uint keybstate; |
223 | XQueryPointer( qt_xdisplay(), qt_xrootwin(), &root, &child, | 229 | XQueryPointer( x11Info().display(), x11Info().appRootWindow(), &root, &child, |
224 | &root_x, &root_y, &win_x, &win_y, &keybstate ); | 230 | &root_x, &root_y, &win_x, &win_y, &keybstate ); |
225 | #endif | 231 | #endif |
226 | 232 | ||
227 | m_pAutoSelect->stop(); | 233 | m_pAutoSelect->stop(); |
@@ -245,67 +251,67 @@ void KListBox::emitExecute( QListBoxItem *item, const QPoint &pos ) | |||
245 | // should be done in QListView but it is not (at least now) | 251 | // should be done in QListView but it is not (at least now) |
246 | // | 252 | // |
247 | void KListBox::keyPressEvent(QKeyEvent *e) | 253 | void KListBox::keyPressEvent(QKeyEvent *e) |
248 | { | 254 | { |
249 | if( e->key() == Key_Escape ) | 255 | if( e->key() == Qt::Key_Escape ) |
250 | { | 256 | { |
251 | e->ignore(); | 257 | e->ignore(); |
252 | } | 258 | } |
253 | else if( e->key() == Key_F1 ) | 259 | else if( e->key() == Qt::Key_F1 ) |
254 | { | 260 | { |
255 | e->ignore(); | 261 | e->ignore(); |
256 | } | 262 | } |
257 | else | 263 | else |
258 | { | 264 | { |
259 | QListBox::keyPressEvent(e); | 265 | Q3ListBox::keyPressEvent(e); |
260 | } | 266 | } |
261 | } | 267 | } |
262 | 268 | ||
263 | void KListBox::focusOutEvent( QFocusEvent *fe ) | 269 | void KListBox::focusOutEvent( QFocusEvent *fe ) |
264 | { | 270 | { |
265 | m_pAutoSelect->stop(); | 271 | m_pAutoSelect->stop(); |
266 | 272 | ||
267 | QListBox::focusOutEvent( fe ); | 273 | Q3ListBox::focusOutEvent( fe ); |
268 | } | 274 | } |
269 | 275 | ||
270 | void KListBox::leaveEvent( QEvent *e ) | 276 | void KListBox::leaveEvent( QEvent *e ) |
271 | { | 277 | { |
272 | m_pAutoSelect->stop(); | 278 | m_pAutoSelect->stop(); |
273 | 279 | ||
274 | QListBox::leaveEvent( e ); | 280 | Q3ListBox::leaveEvent( e ); |
275 | } | 281 | } |
276 | 282 | ||
277 | void KListBox::contentsMousePressEvent( QMouseEvent *e ) | 283 | void KListBox::contentsMousePressEvent( QMouseEvent *e ) |
278 | { | 284 | { |
279 | if( (selectionMode() == Extended) && (e->state() & ShiftButton) && !(e->state() & ControlButton) ) { | 285 | if( (selectionMode() == Extended) && (e->state() & Qt::ShiftButton) && !(e->state() & Qt::ControlButton) ) { |
280 | bool block = signalsBlocked(); | 286 | bool block = signalsBlocked(); |
281 | blockSignals( true ); | 287 | blockSignals( true ); |
282 | 288 | ||
283 | clearSelection(); | 289 | clearSelection(); |
284 | 290 | ||
285 | blockSignals( block ); | 291 | blockSignals( block ); |
286 | } | 292 | } |
287 | 293 | ||
288 | QListBox::contentsMousePressEvent( e ); | 294 | Q3ListBox::contentsMousePressEvent( e ); |
289 | } | 295 | } |
290 | 296 | ||
291 | void KListBox::contentsMouseDoubleClickEvent ( QMouseEvent * e ) | 297 | void KListBox::contentsMouseDoubleClickEvent ( QMouseEvent * e ) |
292 | { | 298 | { |
293 | QListBox::contentsMouseDoubleClickEvent( e ); | 299 | Q3ListBox::contentsMouseDoubleClickEvent( e ); |
294 | 300 | ||
295 | QListBoxItem* item = itemAt( e->pos() ); | 301 | Q3ListBoxItem* item = itemAt( e->pos() ); |
296 | 302 | ||
297 | if( item ) { | 303 | if( item ) { |
298 | emit doubleClicked( item, e->globalPos() ); | 304 | emit doubleClicked( item, e->globalPos() ); |
299 | 305 | ||
300 | if( (e->button() == LeftButton) && !m_bUseSingle ) | 306 | if( (e->button() == Qt::LeftButton) && !m_bUseSingle ) |
301 | emitExecute( item, e->globalPos() ); | 307 | emitExecute( item, e->globalPos() ); |
302 | } | 308 | } |
303 | } | 309 | } |
304 | 310 | ||
305 | void KListBox::slotMouseButtonClicked( int btn, QListBoxItem *item, const QPoint &pos ) | 311 | void KListBox::slotMouseButtonClicked( int btn, Q3ListBoxItem *item, const QPoint &pos ) |
306 | { | 312 | { |
307 | if( (btn == LeftButton) && item ) | 313 | if( (btn == Qt::LeftButton) && item ) |
308 | emitExecute( item, pos ); | 314 | emitExecute( item, pos ); |
309 | } | 315 | } |
310 | 316 | ||
311 | void KListBox::virtual_hook( int, void* ) | 317 | void KListBox::virtual_hook( int, void* ) |