File indexing completed on 2024-04-28 11:36:30

0001 /* This file is part of the KDE libraries
0002    Copyright (C) 2000 Reginald Stadlbauer <reggie@kde.org>
0003 
0004    This library is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU Library General Public
0006    License version 2 as published by the Free Software Foundation.
0007 
0008    This library is distributed in the hope that it will be useful,
0009    but WITHOUT ANY WARRANTY; without even the implied warranty of
0010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0011    Library General Public License for more details.
0012 
0013    You should have received a copy of the GNU Library General Public License
0014    along with this library; see the file COPYING.LIB.  If not, write to
0015    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0016    Boston, MA 02110-1301, USA.
0017 */
0018 #ifndef KLISTWIDGET_H
0019 #define KLISTWIDGET_H
0020 
0021 #include <kdelibs4support_export.h>
0022 
0023 #include <QListWidget>
0024 
0025 /**
0026  * @deprecated since 5.0, use QListWidget instead
0027  * @short A variant of QListWidget that honors KDE's system-wide settings.
0028  *
0029  * Extends the functionality of QListWidget to honor the system
0030  * wide settings for Single Click/Double Click mode, Auto Selection and
0031  * Change Cursor over Link.
0032  *
0033  * There is a new signal executed(). It gets connected to either
0034  * QListWidget::itemClicked() or QListWidget::itemDoubleClicked()
0035  * depending on the KDE wide Single Click/Double Click settings. It is
0036  * strongly recommended that you use this signal instead of the above
0037  * mentioned. This way you don't need to care about the current
0038  * settings.  If you want to get informed when the user selects
0039  * something connect to the QListWidget::itemSelectionChanged() signal.
0040  **/
0041 class KDELIBS4SUPPORT_DEPRECATED_EXPORT KListWidget : public QListWidget
0042 {
0043     Q_OBJECT
0044 
0045 public:
0046     KDELIBS4SUPPORT_DEPRECATED explicit KListWidget(QWidget *parent = nullptr);
0047 
0048     ~KListWidget() override;
0049 
0050 Q_SIGNALS:
0051 
0052     /**
0053      * Emitted whenever the user executes an listbox item.
0054      *
0055      * That means depending on the KDE wide Single Click/Double Click
0056      * setting the user clicked or double clicked on that item.
0057      * @param item is the pointer to the executed listbox item.
0058      *
0059      * Note that you may not delete any QListWidgetItem objects in slots
0060      * connected to this signal.
0061      */
0062     void executed(QListWidgetItem *item);
0063 
0064     /**
0065      * Emitted whenever the user executes an listbox item.
0066      *
0067      * That means depending on the KDE wide Single Click/Double Click
0068      * setting the user clicked or double clicked on that item.
0069      * @param item is the pointer to the executed listbox item.
0070      * @param pos is the position where the user has clicked
0071      *
0072      * Note that you may not delete any QListWidgetItem objects in slots
0073      * connected to this signal.
0074      */
0075     void executed(QListWidgetItem *item, const QPoint &pos);
0076 
0077     /**
0078      * This signal gets emitted whenever the user double clicks into the
0079      * listbox.
0080      *
0081      * @param item The pointer to the clicked listbox item.
0082      * @param pos The position where the user has clicked.
0083      *
0084      * Note that you may not delete any QListWidgetItem objects in slots
0085      * connected to this signal.
0086      *
0087      * This signal is more or less here for the sake of completeness.
0088      * You should normally not need to use this. In most cases it's better
0089      * to use executed() instead.
0090      */
0091     void doubleClicked(QListWidgetItem *item, const QPoint &pos);
0092 
0093 protected:
0094     void keyPressEvent(QKeyEvent *e) override;
0095     void focusOutEvent(QFocusEvent *e) override;
0096     void leaveEvent(QEvent *e) override;
0097     void mousePressEvent(QMouseEvent *e) override;
0098     void mouseDoubleClickEvent(QMouseEvent *e) override;
0099     void mouseReleaseEvent(QMouseEvent *e) override;
0100 
0101 private:
0102     class KListWidgetPrivate;
0103     KListWidgetPrivate *const d;
0104 
0105     Q_PRIVATE_SLOT(d, void _k_slotItemEntered(QListWidgetItem *))
0106     Q_PRIVATE_SLOT(d, void _k_slotOnViewport())
0107     Q_PRIVATE_SLOT(d, void _k_slotSettingsChanged(int))
0108     Q_PRIVATE_SLOT(d, void _k_slotAutoSelect())
0109     Q_PRIVATE_SLOT(d, void _k_slotEmitExecute(QListWidgetItem *))
0110 };
0111 
0112 #endif // KLISTWIDGET_H