CHierarchicalHeaderView.h
Go to the documentation of this file.
1 #ifndef iwidgets_CHierarchicalHeaderView_included
2 #define iwidgets_CHierarchicalHeaderView_included
3 
4 
5 // Qt includes
6 #include <QtCore/QtGlobal>
7 #if QT_VERSION >= 0x050000
8 #include <QtWidgets/QHeaderView>
9 #else
10 #include <QtGui/QHeaderView>
11 #endif
12 
13 
14 namespace iwidgets
15 {
16 
17 
21 class CHierarchicalHeaderView: public QHeaderView
22 {
23  Q_OBJECT
24 public:
25  typedef QHeaderView BaseClass;
26 
28  {
30  VerticalHeaderDataRole=Qt::UserRole+1
31  };
32 
33  CHierarchicalHeaderView(Qt::Orientation orientation, QWidget* parent = 0);
34 
35  // reimplemented (QHeaderView)
36  virtual void setModel(QAbstractItemModel* model);
37 
38 protected:
39  // reimplemented (QHeaderView)
40  virtual void paintSection(
41  QPainter* painter,
42  const QRect& rect,
43  int logicalIndex) const;
44  virtual QSize sectionSizeFromContents(int logicalIndex) const;
45 
46 private Q_SLOTS:
47  void on_sectionResized(int logicalIndex);
48 
49 private:
50  QStyleOptionHeader GetStyleOptionForCell(int logicalIndex) const;
51  QModelIndex GetChildIndex(int sectionIndex) const;
52  QSize GetCellSize(
53  const QModelIndex& childIndex,
54  const QHeaderView* headerViewPtr,
55  QStyleOptionHeader styleOptions) const;
56  void PaintHorizontalSection(
57  QPainter *painter,
58  const QRect& sectionRect,
59  int logicalChildIndex,
60  const QHeaderView* headerViewPtr,
61  const QStyleOptionHeader& styleOptions,
62  const QModelIndex& childIndex) const;
63  void PaintVerticalSection(
64  QPainter *painter,
65  const QRect& sectionRect,
66  int logicalChildIndex,
67  const QHeaderView* headerViewPtr,
68  const QStyleOptionHeader& styleOptions,
69  const QModelIndex& childIndex) const;
70  QModelIndexList GetChilds(const QModelIndex& searchedIndex) const;
71  QModelIndexList SearchChilds(const QModelIndex& curentIndex) const;
72  QModelIndex FindRootIndex(QModelIndex index) const;
73  QModelIndexList GetParentIndexes(QModelIndex index) const;
74  QModelIndex FindChild(const QModelIndex& curentIndex, int sectionIndex, int& curentChildIndex) const;
75  void SetForegroundBrush(QStyleOptionHeader& opt, const QModelIndex& index) const;
76  void SetBackgroundBrush(QStyleOptionHeader& opt, const QModelIndex& index) const;
77  int GetCurrentCellWidth(
78  const QModelIndex& searchedIndex,
79  const QModelIndex& childIndex,
80  int sectionIndex,
81  const QHeaderView* headerViewPtr) const;
82  int GetCurrentCellLeft(
83  const QModelIndex& searchedIndex,
84  const QModelIndex& childIndex,
85  int sectionIndex,
86  int left,
87  const QHeaderView* headerViewPtr) const;
88  int PaintHorizontalCell(
89  QPainter *painter,
90  const QHeaderView* headerViewPtr,
91  const QModelIndex& cellIndex,
92  const QModelIndex& childIndex,
93  int logicalChildIndex,
94  const QStyleOptionHeader& styleOptions,
95  const QRect& sectionRect,
96  int top) const;
97  int PaintVerticalCell(
98  QPainter *painter,
99  const QHeaderView* headerViewPtr,
100  const QModelIndex& cellIndex,
101  const QModelIndex& childIndex,
102  int logicalChildIndex,
103  const QStyleOptionHeader& styleOptions,
104  const QRect& sectionRect,
105  int left) const;
106 };
107 
108 
109 } // namespace iwidgets
110 
111 
112 #endif // !iwidgets_CHierarchicalHeaderView_included
113 
Hierarchical header view for QTableView.
CHierarchicalHeaderView(Qt::Orientation orientation, QWidget *parent=0)
virtual void setModel(QAbstractItemModel *model)
virtual void paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const
virtual QSize sectionSizeFromContents(int logicalIndex) const

© 2007-2017 Witold Gantzke and Kirill Lepskiy