QGIS API Documentation  2.99.0-Master (ae4d26a)
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.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  QgsDetailedItemDelegate( QObject *parent SIP_TRANSFERTHIS = 0 );
44  void paint( QPainter *painter,
45  const QStyleOptionViewItem &option,
46  const QModelIndex &index ) const override;
48  QSize sizeHint( const QStyleOptionViewItem &option,
49  const QModelIndex &index ) const override;
50 
51  void setVerticalSpacing( int value );
52 
53  int verticalSpacing() const;
54 
55  void setHorizontalSpacing( int value );
56 
57  int horizontalSpacing() const;
58 
59  private:
60  QFont detailFont( const QStyleOptionViewItem &option ) const;
61  QFont categoryFont( const QStyleOptionViewItem &option ) const;
62  QFont titleFont( const QStyleOptionViewItem &option ) const;
63  void drawHighlight( const QStyleOptionViewItem &option,
64  QPainter *thepPainter,
65  int height ) const;
66 
67  QStringList wordWrap( const QString &string,
68  const QFontMetrics &metrics,
69  int width ) const;
70  void paintManually( QPainter *painter,
71  const QStyleOptionViewItem &option,
72  const QgsDetailedItemData &data ) const;
73  void paintAsWidget( QPainter *painter,
74  const QStyleOptionViewItem &option,
75  const QgsDetailedItemData &data ) const;
76  int height( const QStyleOptionViewItem &option,
77  const QgsDetailedItemData &data ) const;
78  QgsDetailedItemWidget *mpWidget = nullptr;
79  QCheckBox *mpCheckBox = nullptr;
80  int mVerticalSpacing;
81  int mHorizontalSpacing;
82 };
83 
84 #endif //QGSDETAILEDITEMDELEGATE_H
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
This class is the data only representation of a QgsDetailedItemWidget, designed to be used in custom ...
A widget renderer for detailed item views.
A custom model/view delegate that can display an icon, heading and detail sections.