QGIS API Documentation  2.0.1-Dufour
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
34 class GUI_EXPORT QgsDetailedItemDelegate :
35  public QAbstractItemDelegate
36 {
37  Q_OBJECT
38  public:
39  QgsDetailedItemDelegate( QObject * parent = 0 );
42  void paint( QPainter * thePainter,
43  const QStyleOptionViewItem & theOption,
44  const QModelIndex & theIndex ) const;
46  QSize sizeHint( const QStyleOptionViewItem & theOption,
47  const QModelIndex & theIndex ) const;
48 
49  void setVerticalSpacing( int theValue );
50 
51  int verticalSpacing() const;
52 
53  void setHorizontalSpacing( int theValue );
54 
55  int horizontalSpacing() const;
56 
57  private:
58  QFont detailFont( const QStyleOptionViewItem &theOption ) const;
59  QFont categoryFont( const QStyleOptionViewItem &theOption ) const;
60  QFont titleFont( const QStyleOptionViewItem &theOption ) const;
61  void drawHighlight( const QStyleOptionViewItem &theOption,
62  QPainter * thepPainter,
63  int theHeight ) const;
64 
65  QStringList wordWrap( QString theString,
66  QFontMetrics theMetrics,
67  int theWidth ) const;
68  void paintManually( QPainter * thePainter,
69  const QStyleOptionViewItem & theOption,
70  const QgsDetailedItemData theData ) const;
71  void paintAsWidget( QPainter * thePainter,
72  const QStyleOptionViewItem & theOption,
73  const QgsDetailedItemData theData ) const;
74  int height( const QStyleOptionViewItem & theOption,
75  const QgsDetailedItemData theData ) const;
77  QCheckBox * mpCheckBox;
80 };
81 
82 #endif //QGSDETAILEDITEMDELEGATE_H