File indexing completed on 2024-05-19 12:55:40
0001 /* This file is part of the KDE project 0002 Copyright (C) 2016 Jarosław Staniek <staniek@kde.org> 0003 0004 Forked from kwidgetsaddons/src/kpageview_p.h: 0005 Copyright (C) 2006 Tobias Koenig (tokoe@kde.org) 0006 Copyright (C) 2007 Rafael Fernández López (ereslibre@kde.org) 0007 0008 This library is free software; you can redistribute it and/or 0009 modify it under the terms of the GNU Library General Public 0010 License as published by the Free Software Foundation; either 0011 version 2 of the License, or (at your option) any later version. 0012 0013 This library is distributed in the hope that it will be useful, 0014 but WITHOUT ANY WARRANTY; without even the implied warranty of 0015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0016 Library General Public License for more details. 0017 0018 You should have received a copy of the GNU Library General Public License 0019 along with this library; see the file COPYING.LIB. If not, write to 0020 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0021 * Boston, MA 02110-1301, USA. 0022 */ 0023 0024 #ifndef KEXILISTVIEW_H 0025 #define KEXILISTVIEW_H 0026 0027 #include <QListView> 0028 0029 #include "kexiextwidgets_export.h" 0030 0031 //! Default delegate for KexiListView 0032 class KEXIEXTWIDGETS_EXPORT KexiListViewDelegate : public QAbstractItemDelegate 0033 { 0034 Q_OBJECT 0035 0036 public: 0037 explicit KexiListViewDelegate(QObject *parent = 0); 0038 0039 void paint(QPainter *painter, const QStyleOptionViewItem &option, 0040 const QModelIndex &index) const override; 0041 QSize sizeHint(const QStyleOptionViewItem &option, 0042 const QModelIndex &index) const override; 0043 0044 private: 0045 void drawFocus(QPainter *, const QStyleOptionViewItem &, const QRect &) const; 0046 void paint(QPainter *painter, const QStyle &style, QStyleOptionViewItem *option, 0047 const QModelIndex &index) const; 0048 }; 0049 0050 class KEXIEXTWIDGETS_EXPORT KexiListView : public QListView 0051 { 0052 Q_OBJECT 0053 0054 public: 0055 explicit KexiListView(QWidget *parent = 0); 0056 0057 virtual ~KexiListView(); 0058 0059 void setModel(QAbstractItemModel *model) override; 0060 0061 protected: 0062 //! Used in KexiListView(UseDelegate, QWidget*) 0063 enum UseDelegate 0064 { 0065 UseDefaultDelegate, 0066 DontUseDelegate 0067 }; 0068 0069 //! Alternative constructor, the same as the default but if @a useDelegate is DontUseDelegate, 0070 //! delegate is not set. This allows to replace delegate. 0071 KexiListView(UseDelegate useDelegate, QWidget *parent); 0072 0073 private Q_SLOTS: 0074 void updateWidth(); 0075 }; 0076 0077 #endif