1
/****************************************************************************
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
5
** This file is part of the item views module of the Qt Toolkit.
7
** This file may be distributed under the terms of the Q Public License
8
** as defined by Trolltech AS of Norway and appearing in the file
9
** LICENSE.QPL included in the packaging of this file.
11
** This file may be distributed and/or modified under the terms of the
12
** GNU General Public License version 2 as published by the Free Software
13
** Foundation and appearing in the file LICENSE.GPL included in the
14
** packaging of this file.
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
17
** information about Qt Commercial License Agreements.
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
21
** Contact info@trolltech.com if any conditions of this licensing are
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27
****************************************************************************/
32
#include <QtGui/qabstractitemview.h>
34
class QHeaderViewPrivate;
36
class Q_GUI_EXPORT QHeaderView : public QAbstractItemView
39
Q_PROPERTY(bool showSortIndicator READ isSortIndicatorShown WRITE setSortIndicatorShown)
40
Q_PROPERTY(bool highlightSections READ highlightSections WRITE setHighlightSections)
41
Q_PROPERTY(bool stretchLastSection READ stretchLastSection WRITE setStretchLastSection)
48
Interactive, // don't change the size (let the user decide)
49
Stretch, // fill available visible space
50
Custom // let somebody else do the resize
53
explicit QHeaderView(Qt::Orientation orientation, QWidget *parent = 0);
54
virtual ~QHeaderView();
56
void setModel(QAbstractItemModel *model);
58
Qt::Orientation orientation() const;
61
QSize sizeHint() const;
62
int sectionSizeHint(int logicalIndex) const;
64
int visualIndexAt(int position) const;
65
int logicalIndexAt(int position) const;
67
inline int logicalIndexAt(int x, int y) const;
68
inline int logicalIndexAt(const QPoint &pos) const;
70
int sectionSize(int logicalIndex) const;
71
int sectionPosition(int logicalIndex) const;
72
int sectionViewportPosition(int logicalIndex) const;
74
void moveSection(int from, int to);
75
void resizeSection(int logicalIndex, int size);
77
bool isSectionHidden(int logicalIndex) const;
78
void setSectionHidden(int logicalIndex, bool hide);
80
inline void hideSection(int logicalIndex);
81
inline void showSection(int logicalIndex);
84
int visualIndex(int logicalIndex) const;
85
int logicalIndex(int visualIndex) const;
87
void setMovable(bool movable);
88
bool isMovable() const;
90
void setClickable(bool clickable);
91
bool isClickable() const;
93
void setHighlightSections(bool highlight);
94
bool highlightSections() const;
96
void setResizeMode(ResizeMode mode);
97
void setResizeMode(int logicalIndex, ResizeMode mode);
98
ResizeMode resizeMode(int logicalIndex) const;
99
int stretchSectionCount() const;
101
void setSortIndicatorShown(bool show);
102
bool isSortIndicatorShown() const;
104
void setSortIndicator(int logicalIndex, Qt::SortOrder order);
105
int sortIndicatorSection() const;
106
Qt::SortOrder sortIndicatorOrder() const;
108
bool stretchLastSection() const;
109
void setStretchLastSection(bool stretch);
111
void doItemsLayout();
112
bool sectionsMoved() const;
115
void setOffset(int offset);
116
void headerDataChanged(Qt::Orientation orientation, int logicalFirst, int logicalLast);
119
void sectionMoved(int logicalIndex, int oldVisualIndex, int newVisualIndex);
120
void sectionResized(int logicalIndex, int oldSize, int newSize);
121
void sectionPressed(int logicalIndex);
122
void sectionClicked(int logicalIndex);
123
void sectionDoubleClicked(int logicalIndex);
124
void sectionCountChanged(int oldCount, int newCount);
125
void sectionHandleDoubleClicked(int logicalIndex);
126
void sectionAutoResize(int logicalIndex, ResizeMode mode);
129
void updateSection(int logicalIndex);
130
void resizeSections();
131
void sectionsInserted(const QModelIndex &parent, int logicalFirst, int logicalLast);
132
void sectionsAboutToBeRemoved(const QModelIndex &parent, int logicalFirst, int logicalLast);
135
QHeaderView(QHeaderViewPrivate &dd, Qt::Orientation orientation, QWidget *parent = 0);
138
void initializeSections();
139
void initializeSections(int start, int end);
140
void currentChanged(const QModelIndex &old, const QModelIndex ¤t);
142
bool event(QEvent *e);
143
void paintEvent(QPaintEvent *e);
144
void mousePressEvent(QMouseEvent *e);
145
void mouseMoveEvent(QMouseEvent *e);
146
void mouseReleaseEvent(QMouseEvent *e);
147
void mouseDoubleClickEvent(QMouseEvent *e);
149
virtual void paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const;
150
virtual QSize sectionSizeFromContents(int logicalIndex) const;
152
int horizontalOffset() const;
153
int verticalOffset() const;
154
void updateGeometries();
155
void scrollContentsBy(int dx, int dy);
157
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
158
void rowsInserted(const QModelIndex &parent, int start, int end);
160
QRect visualRect(const QModelIndex &index) const;
161
void scrollTo(const QModelIndex &index, ScrollHint hint);
163
QModelIndex indexAt(const QPoint &p) const;
164
bool isIndexHidden(const QModelIndex &index) const;
166
QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers);
167
void setSelection(const QRect&, QItemSelectionModel::SelectionFlags);
168
QRegion visualRegionForSelection(const QItemSelection &selection) const;
171
Q_DECLARE_PRIVATE(QHeaderView)
172
Q_DISABLE_COPY(QHeaderView)
175
inline int QHeaderView::logicalIndexAt(int ax, int ay) const
176
{ return orientation() == Qt::Horizontal ? logicalIndexAt(ax) : logicalIndexAt(ay); }
178
inline int QHeaderView::logicalIndexAt(const QPoint &apos) const
179
{ return logicalIndexAt(apos.x(), apos.y()); }
181
inline void QHeaderView::hideSection(int alogicalIndex)
182
{ setSectionHidden(alogicalIndex, true); }
183
inline void QHeaderView::showSection(int alogicalIndex)
184
{ setSectionHidden(alogicalIndex, false); }
186
#endif // QHEADERVIEW_H