~ubuntu-branches/ubuntu/wily/qgis/wily

« back to all changes in this revision

Viewing changes to src/gui/qgsdetaileditemdelegate.h

  • Committer: Bazaar Package Importer
  • Author(s): Johan Van de Wauw
  • Date: 2010-07-11 20:23:24 UTC
  • mfrom: (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100711202324-5ktghxa7hracohmr
Tags: 1.4.0+12730-3ubuntu1
* Merge from Debian unstable (LP: #540941).
* Fix compilation issues with QT 4.7
* Add build-depends on libqt4-webkit-dev 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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;
 
25
class QgsDetailedItemWidget;
 
26
class QgsDetailedItemData;
 
27
class QFontMetrics;
 
28
class QFont;
 
29
 
 
30
/** \ingroup gui
 
31
 * A custom model/view delegate that can display an icon, heading
 
32
 * and detail sections.
 
33
 * @see also QgsDetailedItemData
 
34
 */
 
35
class GUI_EXPORT QgsDetailedItemDelegate :
 
36
    public QAbstractItemDelegate
 
37
{
 
38
    Q_OBJECT
 
39
  public:
 
40
    QgsDetailedItemDelegate( QObject * parent = 0 );
 
41
    ~QgsDetailedItemDelegate();
 
42
    /** reimplement for parent class */
 
43
    void paint( QPainter * thePainter,
 
44
                const QStyleOptionViewItem & theOption,
 
45
                const QModelIndex & theIndex ) const;
 
46
    /** reimplement for parent class */
 
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;
 
76
    QgsDetailedItemWidget * mpWidget;
 
77
    QCheckBox * mpCheckBox;
 
78
    int mVerticalSpacing;
 
79
    int mHorizontalSpacing;
 
80
};
 
81
 
 
82
#endif //QGSDETAILEDITEMDELEGATE_H