QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
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
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
25class QCheckBox;
28class QFontMetrics;
29class QFont;
30
37class GUI_EXPORT QgsDetailedItemDelegate : public QAbstractItemDelegate
38{
39 Q_OBJECT
40 public:
42 QgsDetailedItemDelegate( QObject *parent SIP_TRANSFERTHIS = nullptr );
43 ~QgsDetailedItemDelegate() override;
45 void paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const override;
47 QSize sizeHint( const QStyleOptionViewItem &option, 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, QPainter *thepPainter, int height ) const;
62
63 QStringList wordWrap( const QString &string, const QFontMetrics &metrics, int width ) const;
64 void paintManually( QPainter *painter, const QStyleOptionViewItem &option, const QgsDetailedItemData &data ) const;
65 void paintAsWidget( QPainter *painter, const QStyleOptionViewItem &option, const QgsDetailedItemData &data ) const;
66 int height( const QStyleOptionViewItem &option, const QgsDetailedItemData &data ) const;
67 QgsDetailedItemWidget *mpWidget = nullptr;
68 QCheckBox *mpCheckBox = nullptr;
69 int mVerticalSpacing;
70 int mHorizontalSpacing;
71};
72
73#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