Quantum GIS API Documentation  1.7.5-Wroclaw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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 : tim@linfiniti.com
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 /* $Id:$ */
18 #ifndef QGSDETAILEDITEMDELEGATE_H
19 #define QGSDETAILEDITEMDELEGATE_H
20 
21 #include <QAbstractItemDelegate>
22 #include <QString>
23 
24 class QCheckBox;
27 class QFontMetrics;
28 class QFont;
29 
35 class GUI_EXPORT QgsDetailedItemDelegate :
36  public QAbstractItemDelegate
37 {
38  Q_OBJECT
39  public:
40  QgsDetailedItemDelegate( QObject * parent = 0 );
43  void paint( QPainter * thePainter,
44  const QStyleOptionViewItem & theOption,
45  const QModelIndex & theIndex ) const;
47  QSize sizeHint( const QStyleOptionViewItem & theOption,
48  const QModelIndex & theIndex ) const;
49 
50  void setVerticalSpacing( int theValue );
51 
52  int verticalSpacing() const;
53 
54  void setHorizontalSpacing( int theValue );
55 
56  int horizontalSpacing() const;
57 
58  private:
59  QFont detailFont( 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