QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 <QString>
22 
23 class QCheckBox;
26 class QFontMetrics;
27 class QFont;
28 
35 {
36  Q_OBJECT
37  public:
38  QgsDetailedItemDelegate( QObject * parent = nullptr );
41  void paint( QPainter * thePainter,
42  const QStyleOptionViewItem & theOption,
43  const QModelIndex & theIndex ) const override;
45  QSize sizeHint( const QStyleOptionViewItem & theOption,
46  const QModelIndex & theIndex ) const override;
47 
48  void setVerticalSpacing( int theValue );
49 
50  int verticalSpacing() const;
51 
52  void setHorizontalSpacing( int theValue );
53 
54  int horizontalSpacing() const;
55 
56  private:
57  QFont detailFont( const QStyleOptionViewItem &theOption ) const;
58  QFont categoryFont( const QStyleOptionViewItem &theOption ) const;
59  QFont titleFont( const QStyleOptionViewItem &theOption ) const;
60  void drawHighlight( const QStyleOptionViewItem &theOption,
61  QPainter * thepPainter,
62  int theHeight ) const;
63 
64  QStringList wordWrap( const QString& theString,
65  const QFontMetrics& theMetrics,
66  int theWidth ) const;
67  void paintManually( QPainter *thePainter,
68  const QStyleOptionViewItem &theOption,
69  const QgsDetailedItemData &theData ) const;
70  void paintAsWidget( QPainter *thePainter,
71  const QStyleOptionViewItem &theOption,
72  const QgsDetailedItemData &theData ) const;
73  int height( const QStyleOptionViewItem &theOption,
74  const QgsDetailedItemData &theData ) const;
75  QgsDetailedItemWidget * mpWidget;
76  QCheckBox * mpCheckBox;
77  int mVerticalSpacing;
78  int mHorizontalSpacing;
79 };
80 
81 #endif //QGSDETAILEDITEMDELEGATE_H
This class is the data only representation of a QgsDetailedItemWidget, designed to be used in custom ...
A widget renderer for detailed item views.
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const=0
virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const=0
A custom model/view delegate that can display an icon, heading and detail sections.