~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/gui/itemviews/qheaderview.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
 
4
**
 
5
** This file is part of the item views module of the Qt Toolkit.
 
6
**
 
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.
 
10
**
 
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.
 
15
**
 
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.
 
20
**
 
21
** Contact info@trolltech.com if any conditions of this licensing are
 
22
** not clear to you.
 
23
**
 
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.
 
26
**
 
27
****************************************************************************/
 
28
 
 
29
#ifndef QHEADERVIEW_H
 
30
#define QHEADERVIEW_H
 
31
 
 
32
#include <QtGui/qabstractitemview.h>
 
33
 
 
34
class QHeaderViewPrivate;
 
35
 
 
36
class Q_GUI_EXPORT QHeaderView : public QAbstractItemView
 
37
{
 
38
    Q_OBJECT
 
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)
 
42
    Q_ENUMS(ResizeMode)
 
43
 
 
44
public:
 
45
 
 
46
    enum ResizeMode
 
47
    {
 
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
 
51
    };
 
52
 
 
53
    explicit QHeaderView(Qt::Orientation orientation, QWidget *parent = 0);
 
54
    virtual ~QHeaderView();
 
55
 
 
56
    void setModel(QAbstractItemModel *model);
 
57
 
 
58
    Qt::Orientation orientation() const;
 
59
    int offset() const;
 
60
    int length() const;
 
61
    QSize sizeHint() const;
 
62
    int sectionSizeHint(int logicalIndex) const;
 
63
 
 
64
    int visualIndexAt(int position) const;
 
65
    int logicalIndexAt(int position) const;
 
66
 
 
67
    inline int logicalIndexAt(int x, int y) const;
 
68
    inline int logicalIndexAt(const QPoint &pos) const;
 
69
 
 
70
    int sectionSize(int logicalIndex) const;
 
71
    int sectionPosition(int logicalIndex) const;
 
72
    int sectionViewportPosition(int logicalIndex) const;
 
73
 
 
74
    void moveSection(int from, int to);
 
75
    void resizeSection(int logicalIndex, int size);
 
76
 
 
77
    bool isSectionHidden(int logicalIndex) const;
 
78
    void setSectionHidden(int logicalIndex, bool hide);
 
79
 
 
80
    inline void hideSection(int logicalIndex);
 
81
    inline void showSection(int logicalIndex);
 
82
 
 
83
    int count() const;
 
84
    int visualIndex(int logicalIndex) const;
 
85
    int logicalIndex(int visualIndex) const;
 
86
 
 
87
    void setMovable(bool movable);
 
88
    bool isMovable() const;
 
89
 
 
90
    void setClickable(bool clickable);
 
91
    bool isClickable() const;
 
92
 
 
93
    void setHighlightSections(bool highlight);
 
94
    bool highlightSections() const;
 
95
 
 
96
    void setResizeMode(ResizeMode mode);
 
97
    void setResizeMode(int logicalIndex, ResizeMode mode);
 
98
    ResizeMode resizeMode(int logicalIndex) const;
 
99
    int stretchSectionCount() const;
 
100
 
 
101
    void setSortIndicatorShown(bool show);
 
102
    bool isSortIndicatorShown() const;
 
103
 
 
104
    void setSortIndicator(int logicalIndex, Qt::SortOrder order);
 
105
    int sortIndicatorSection() const;
 
106
    Qt::SortOrder sortIndicatorOrder() const;
 
107
 
 
108
    bool stretchLastSection() const;
 
109
    void setStretchLastSection(bool stretch);
 
110
 
 
111
    void doItemsLayout();
 
112
    bool sectionsMoved() const;
 
113
 
 
114
public slots:
 
115
    void setOffset(int offset);
 
116
    void headerDataChanged(Qt::Orientation orientation, int logicalFirst, int logicalLast);
 
117
 
 
118
signals:
 
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);
 
127
 
 
128
protected slots:
 
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);
 
133
 
 
134
protected:
 
135
    QHeaderView(QHeaderViewPrivate &dd, Qt::Orientation orientation, QWidget *parent = 0);
 
136
    void initialize();
 
137
 
 
138
    void initializeSections();
 
139
    void initializeSections(int start, int end);
 
140
    void currentChanged(const QModelIndex &old, const QModelIndex &current);
 
141
 
 
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);
 
148
 
 
149
    virtual void paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const;
 
150
    virtual QSize sectionSizeFromContents(int logicalIndex) const;
 
151
 
 
152
    int horizontalOffset() const;
 
153
    int verticalOffset() const;
 
154
    void updateGeometries();
 
155
    void scrollContentsBy(int dx, int dy);
 
156
 
 
157
    void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
 
158
    void rowsInserted(const QModelIndex &parent, int start, int end);
 
159
 
 
160
    QRect visualRect(const QModelIndex &index) const;
 
161
    void scrollTo(const QModelIndex &index, ScrollHint hint);
 
162
 
 
163
    QModelIndex indexAt(const QPoint &p) const;
 
164
    bool isIndexHidden(const QModelIndex &index) const;
 
165
 
 
166
    QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers);
 
167
    void setSelection(const QRect&, QItemSelectionModel::SelectionFlags);
 
168
    QRegion visualRegionForSelection(const QItemSelection &selection) const;
 
169
 
 
170
private:
 
171
    Q_DECLARE_PRIVATE(QHeaderView)
 
172
    Q_DISABLE_COPY(QHeaderView)
 
173
};
 
174
 
 
175
inline int QHeaderView::logicalIndexAt(int ax, int ay) const
 
176
{ return orientation() == Qt::Horizontal ? logicalIndexAt(ax) : logicalIndexAt(ay); }
 
177
 
 
178
inline int QHeaderView::logicalIndexAt(const QPoint &apos) const
 
179
{ return logicalIndexAt(apos.x(), apos.y()); }
 
180
 
 
181
inline void QHeaderView::hideSection(int alogicalIndex)
 
182
{ setSectionHidden(alogicalIndex, true); }
 
183
inline void QHeaderView::showSection(int alogicalIndex)
 
184
{ setSectionHidden(alogicalIndex, false); }
 
185
 
 
186
#endif // QHEADERVIEW_H