QGIS API Documentation  2.99.0-Master (23ddace)
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 
36 class GUI_EXPORT QgsDetailedItemDelegate : public QAbstractItemDelegate
37 {
38  Q_OBJECT
39  public:
40  QgsDetailedItemDelegate( QObject *parent SIP_TRANSFERTHIS = 0 );
43  void paint( QPainter *painter,
44  const QStyleOptionViewItem &option,
45  const QModelIndex &index ) const override;
47  QSize sizeHint( const QStyleOptionViewItem &option,
48  const QModelIndex &index ) const override;
49 
50  void setVerticalSpacing( int value );
51 
52  int verticalSpacing() const;
53 
54  void setHorizontalSpacing( int value );
55 
56  int horizontalSpacing() const;
57 
58  private:
59  QFont detailFont( const QStyleOptionViewItem &option ) const;
60  QFont categoryFont( const QStyleOptionViewItem &option ) const;
61  QFont titleFont( const QStyleOptionViewItem &option ) const;
62  void drawHighlight( const QStyleOptionViewItem &option,
63  QPainter *thepPainter,
64  int height ) const;
65 
66  QStringList wordWrap( const QString &string,
67  const QFontMetrics &metrics,
68  int width ) const;
69  void paintManually( QPainter *painter,
70  const QStyleOptionViewItem &option,
71  const QgsDetailedItemData &data ) const;
72  void paintAsWidget( QPainter *painter,
73  const QStyleOptionViewItem &option,
74  const QgsDetailedItemData &data ) const;
75  int height( const QStyleOptionViewItem &option,
76  const QgsDetailedItemData &data ) const;
77  QgsDetailedItemWidget *mpWidget = nullptr;
78  QCheckBox *mpCheckBox = nullptr;
79  int mVerticalSpacing;
80  int mHorizontalSpacing;
81 };
82 
83 #endif //QGSDETAILEDITEMDELEGATE_H
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:34
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.