File indexing completed on 2024-05-12 13:42:31

0001 /*
0002  *   SPDX-FileCopyrightText: 2009 Rafael Fernández López <ereslibre@kde.org>
0003  *
0004  *   SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef CATEGORIZEDVIEW_H
0008 #define CATEGORIZEDVIEW_H
0009 
0010 #include <QProxyStyle>
0011 
0012 #include <KCategorizedView>
0013 
0014 class CategorizedView : public KCategorizedView
0015 {
0016 public:
0017     explicit CategorizedView(QWidget *parent = nullptr);
0018 
0019     void setModel(QAbstractItemModel *model) override;
0020 
0021 protected:
0022     void wheelEvent(QWheelEvent *) override;
0023 };
0024 
0025 class ActivateItemOnSingleClickStyle : public QProxyStyle
0026 {
0027 public:
0028     explicit ActivateItemOnSingleClickStyle(QStyle *style)
0029         : QProxyStyle(style)
0030     {
0031     }
0032 
0033     int styleHint(QStyle::StyleHint hint,
0034                   const QStyleOption *option = nullptr,
0035                   const QWidget *widget = nullptr,
0036                   QStyleHintReturn *returnData = nullptr) const override
0037     {
0038         if (hint == QStyle::SH_ItemView_ActivateItemOnSingleClick) {
0039             return 1;
0040         }
0041 
0042         return QProxyStyle::styleHint(hint, option, widget, returnData);
0043     }
0044 };
0045 
0046 #endif