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