1
/****************************************************************************
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
5
** This file is part of the Qt 3 compatibility classes 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/qicon.h"
33
#include "QtGui/qwidget.h"
34
#include "QtCore/qstring.h"
43
class Q_COMPAT_EXPORT Q3Header : public QWidget
46
friend class Q3TableHeader;
47
friend class Q3ListView;
50
Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
51
Q_PROPERTY(bool tracking READ tracking WRITE setTracking)
52
Q_PROPERTY(int count READ count)
53
Q_PROPERTY(int offset READ offset WRITE setOffset)
54
Q_PROPERTY(bool moving READ isMovingEnabled WRITE setMovingEnabled)
55
Q_PROPERTY(bool stretching READ isStretchEnabled WRITE setStretchEnabled)
58
Q3Header(QWidget* parent=0, const char* name=0);
59
Q3Header(int, QWidget* parent=0, const char* name=0);
62
int addLabel(const QString &, int size = -1);
63
int addLabel(const QIcon&, const QString &, int size = -1);
64
void removeLabel(int section);
65
virtual void setLabel(int, const QString &, int size = -1);
66
virtual void setLabel(int, const QIcon&, const QString &, int size = -1);
67
QString label(int section) const;
68
QIcon* iconSet(int section) const;
70
virtual void setOrientation(Qt::Orientation);
71
Qt::Orientation orientation() const;
72
virtual void setTracking(bool enable);
73
bool tracking() const;
75
virtual void setClickEnabled(bool, int section = -1);
76
virtual void setResizeEnabled(bool, int section = -1);
77
virtual void setMovingEnabled(bool);
78
virtual void setStretchEnabled(bool b, int section);
79
void setStretchEnabled(bool b) { setStretchEnabled(b, -1); }
80
bool isClickEnabled(int section = -1) const;
81
bool isResizeEnabled(int section = -1) const;
82
bool isMovingEnabled() const;
83
bool isStretchEnabled() const;
84
bool isStretchEnabled(int section) const;
86
void resizeSection(int section, int s);
87
int sectionSize(int section) const;
88
int sectionPos(int section) const;
89
int sectionAt(int pos) const;
91
int headerWidth() const;
92
QRect sectionRect(int section) const;
94
virtual void setCellSize(int , int); // obsolete, do not use
95
int cellSize(int i) const { return sectionSize(mapToSection(i)); } // obsolete, do not use
96
int cellPos(int) const; // obsolete, do not use
97
int cellAt(int pos) const { return mapToIndex(sectionAt(pos + offset())); } // obsolete, do not use
101
QSize sizeHint() const;
103
int mapToSection(int index) const;
104
int mapToIndex(int section) const;
105
int mapToLogical(int) const; // obsolete, do not use
106
int mapToActual(int) const; // obsolete, do not use
108
void moveSection(int section, int toIndex);
109
virtual void moveCell(int, int); // obsolete, do not use
111
void setSortIndicator(int section, bool ascending = true); // obsolete, do not use
112
inline void setSortIndicator(int section, Qt::SortOrder order)
113
{ setSortIndicator(section, (order == Qt::AscendingOrder)); }
114
int sortIndicatorSection() const;
115
Qt::SortOrder sortIndicatorOrder() const;
117
void adjustHeaderSize() { adjustHeaderSize(-1); }
120
void setUpdatesEnabled(bool enable);
121
virtual void setOffset(int pos);
124
void clicked(int section);
125
void pressed(int section);
126
void released(int section);
127
void sizeChange(int section, int oldSize, int newSize);
128
void indexChange(int section, int fromIndex, int toIndex);
129
void sectionClicked(int); // obsolete, do not use
130
void moved(int, int); // obsolete, do not use
131
void sectionHandleDoubleClicked(int section);
134
void paintEvent(QPaintEvent *);
135
void showEvent(QShowEvent *e);
136
void resizeEvent(QResizeEvent *e);
137
QRect sRect(int index);
139
virtual void paintSection(QPainter *p, int index, const QRect& fr);
140
virtual void paintSectionLabel(QPainter* p, int index, const QRect& fr);
142
void changeEvent(QEvent *);
143
void mousePressEvent(QMouseEvent *);
144
void mouseReleaseEvent(QMouseEvent *);
145
void mouseMoveEvent(QMouseEvent *);
146
void mouseDoubleClickEvent(QMouseEvent *);
148
void keyPressEvent(QKeyEvent *);
149
void keyReleaseEvent(QKeyEvent *);
152
void handleColumnMove(int fromIdx, int toIdx);
153
void adjustHeaderSize(int diff);
156
void paintRect(int p, int s);
157
void markLine(int idx);
158
void unMarkLine(int idx);
159
int pPos(int i) const;
160
int pSize(int i) const;
163
bool reverse() const;
164
void calculatePositions(bool onlyVisible = false, int start = 0);
165
void handleColumnResize(int, int, bool, bool = true);
166
QSize sectionSizeHint(int section, const QFontMetrics& fm) const;
167
void setSectionSizeAndHeight(int section, int size);
169
void resizeArrays(int size);
170
void setIsATableHeader(bool b);
175
enum State { Idle, Sliding, Pressed, Moving, Blocked };
180
int cachedPos; // not used
181
Qt::Orientation orient;
186
Q_DISABLE_COPY(Q3Header)
190
inline Qt::Orientation Q3Header::orientation() const
195
inline void Q3Header::setTracking(bool enable) { trackingIsOn = enable; }
196
inline bool Q3Header::tracking() const { return trackingIsOn; }
198
extern Q_COMPAT_EXPORT bool qt_qheader_label_return_null_strings; // needed for professional edition
200
#endif // QT_NO_HEADER