1/* This file is part of the KDE libraries
2 Copyright (C) 2000 Reginald Stadlbauer <reggie@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
7
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
12
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
17*/
18#ifndef K3LISTBOX_H
19#define K3LISTBOX_H
20
21#include <kde3support_export.h>
22#include <Qt3Support/Q3ListBox>
23
24/**
25 * @short A variant of QListBox that honors KDE's system-wide settings.
26 *
27 * Extends the functionality of QListBox to honor the system
28 * wide settings for Single Click/Double Click mode, Auto Selection and
29 * Change Cursor over Link.
30 *
31 * There is a new signal executed(). It gets connected to either
32 * QListBox::clicked() or QListBox::doubleClicked()
33 * depending on the KDE wide Single Click/Double Click settings. It is
34 * strongly recommended that you use this signal instead of the above
35 * mentioned. This way you don't need to care about the current
36 * settings. If you want to get informed when the user selects
37 * something connect to the QListBox::selectionChanged() signal.
38 **/
39class KDE3SUPPORT_EXPORT K3ListBox : public Q3ListBox
40{
41 Q_OBJECT
42
43public:
44 explicit K3ListBox( QWidget *parent = 0, const char *name = 0, Qt::WindowFlags f = 0 );
45
46Q_SIGNALS:
47
48 /**
49 * Emitted whenever the user executes an listbox item.
50 *
51 * That means depending on the KDE wide Single Click/Double Click
52 * setting the user clicked or double clicked on that item.
53 * @param item is the pointer to the executed listbox item.
54 *
55 * Note that you may not delete any QListBoxItem objects in slots
56 * connected to this signal.
57 */
58 void executed( Q3ListBoxItem *item );
59
60 /**
61 * Emitted whenever the user executes an listbox item.
62 *
63 * That means depending on the KDE wide Single Click/Double Click
64 * setting the user clicked or double clicked on that item.
65 * @param item is the pointer to the executed listbox item.
66 * @param pos is the position where the user has clicked
67 *
68 * Note that you may not delete any QListBoxItem objects in slots
69 * connected to this signal.
70 */
71 void executed( Q3ListBoxItem *item, const QPoint &pos );
72
73 /**
74 * This signal gets emitted whenever the user double clicks into the
75 * listbox.
76 *
77 * @param item The pointer to the clicked listbox item.
78 * @param pos The position where the user has clicked.
79 *
80 * Note that you may not delete any QListBoxItem objects in slots
81 * connected to this signal.
82 *
83 * This signal is more or less here for the sake of completeness.
84 * You should normally not need to use this. In most cases it's better
85 * to use executed() instead.
86 */
87 void doubleClicked( Q3ListBoxItem *item, const QPoint &pos );
88
89protected Q_SLOTS:
90 void slotOnItem( Q3ListBoxItem *item );
91 void slotOnViewport();
92
93 void slotSettingsChanged(int);
94
95 /**
96 * Auto selection happend.
97 */
98 void slotAutoSelect();
99
100protected:
101 void emitExecute( Q3ListBoxItem *item, const QPoint &pos );
102
103 virtual void keyPressEvent(QKeyEvent *e);
104 virtual void focusOutEvent( QFocusEvent *fe );
105 virtual void leaveEvent( QEvent *e );
106 virtual void contentsMousePressEvent( QMouseEvent *e );
107 virtual void contentsMouseDoubleClickEvent ( QMouseEvent *e );
108
109 bool m_bUseSingle;
110 bool m_bChangeCursorOverItem;
111
112 Q3ListBoxItem* m_pCurrentItem;
113
114 QTimer* m_pAutoSelect;
115 int m_autoSelectDelay;
116
117private Q_SLOTS:
118 void slotMouseButtonClicked( int btn, Q3ListBoxItem *item, const QPoint &pos );
119
120private:
121 class K3ListBoxPrivate;
122 K3ListBoxPrivate* const d;
123};
124
125#endif
126