QGIS API Documentation  3.22.4-Białowieża (ce8e65e95e)
qgsdetaileditemdelegate.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsdetaileditemdelegate.h - A rich QItemDelegate subclass
3  -------------------
4  begin : Sat May 17 2008
5  copyright : (C) 2008 Tim Sutton
6  email : [email protected]
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 #ifndef QGSDETAILEDITEMDELEGATE_H
18 #define QGSDETAILEDITEMDELEGATE_H
19 
20 #include <QAbstractItemDelegate>
21 #include "qgis_sip.h"
22 #include <QString>
23 #include "qgis_gui.h"
24 
25 class QCheckBox;
28 class QFontMetrics;
29 class QFont;
30 
37 class GUI_EXPORT QgsDetailedItemDelegate : public QAbstractItemDelegate
38 {
39  Q_OBJECT
40  public:
41 
43  QgsDetailedItemDelegate( QObject *parent SIP_TRANSFERTHIS = nullptr );
44  ~QgsDetailedItemDelegate() override;
46  void paint( QPainter *painter,
47  const QStyleOptionViewItem &option,
48  const QModelIndex &index ) const override;
50  QSize sizeHint( const QStyleOptionViewItem &option,
51  const QModelIndex &index ) const override;
52 
53  void setVerticalSpacing( int value );
54 
55  int verticalSpacing() const;
56 
57  void setHorizontalSpacing( int value );
58 
59  int horizontalSpacing() const;
60 
61  private:
62  QFont detailFont( const QStyleOptionViewItem &option ) const;
63  QFont categoryFont( const QStyleOptionViewItem &option ) const;
64  QFont titleFont( const QStyleOptionViewItem &option ) const;
65  void drawHighlight( const QStyleOptionViewItem &option,
66  QPainter *thepPainter,
67  int height ) const;
68 
69  QStringList wordWrap( const QString &string,
70  const QFontMetrics &metrics,
71  int width ) const;
72  void paintManually( QPainter *painter,
73  const QStyleOptionViewItem &option,
74  const QgsDetailedItemData &data ) const;
75  void paintAsWidget( QPainter *painter,
76  const QStyleOptionViewItem &option,
77  const QgsDetailedItemData &data ) const;
78  int height( const QStyleOptionViewItem &option,
79  const QgsDetailedItemData &data ) const;
80  QgsDetailedItemWidget *mpWidget = nullptr;
81  QCheckBox *mpCheckBox = nullptr;
82  int mVerticalSpacing;
83  int mHorizontalSpacing;
84 };
85 
86 #endif //QGSDETAILEDITEMDELEGATE_H
This class is the data only representation of a QgsDetailedItemWidget, designed to be used in custom ...
A custom model/view delegate that can display an icon, heading and detail sections.
A widget renderer for detailed item views.
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53