1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the Qt3Support module of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
15 | **
|
---|
16 | ** GNU Lesser General Public License Usage
|
---|
17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
18 | ** General Public License version 2.1 as published by the Free Software
|
---|
19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
20 | ** packaging of this file. Please review the following information to
|
---|
21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
23 | **
|
---|
24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #ifndef Q3HEADER_H
|
---|
43 | #define Q3HEADER_H
|
---|
44 |
|
---|
45 | #include <QtGui/qicon.h>
|
---|
46 | #include <QtGui/qwidget.h>
|
---|
47 | #include <QtCore/qstring.h>
|
---|
48 |
|
---|
49 | QT_BEGIN_HEADER
|
---|
50 |
|
---|
51 | QT_BEGIN_NAMESPACE
|
---|
52 |
|
---|
53 | QT_MODULE(Qt3SupportLight)
|
---|
54 |
|
---|
55 | #ifndef QT_NO_HEADER
|
---|
56 |
|
---|
57 | class QShowEvent;
|
---|
58 | class Q3HeaderData;
|
---|
59 | class Q3Table;
|
---|
60 | class Q3ListView;
|
---|
61 |
|
---|
62 | class Q_COMPAT_EXPORT Q3Header : public QWidget
|
---|
63 | {
|
---|
64 | friend class Q3Table;
|
---|
65 | friend class Q3TableHeader;
|
---|
66 | friend class Q3ListView;
|
---|
67 |
|
---|
68 | Q_OBJECT
|
---|
69 | Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
|
---|
70 | Q_PROPERTY(bool tracking READ tracking WRITE setTracking)
|
---|
71 | Q_PROPERTY(int count READ count)
|
---|
72 | Q_PROPERTY(int offset READ offset WRITE setOffset)
|
---|
73 | Q_PROPERTY(bool moving READ isMovingEnabled WRITE setMovingEnabled)
|
---|
74 | Q_PROPERTY(bool stretching READ isStretchEnabled WRITE setStretchEnabled)
|
---|
75 |
|
---|
76 | public:
|
---|
77 | Q3Header(QWidget* parent=0, const char* name=0);
|
---|
78 | Q3Header(int, QWidget* parent=0, const char* name=0);
|
---|
79 | ~Q3Header();
|
---|
80 |
|
---|
81 | int addLabel(const QString &, int size = -1);
|
---|
82 | int addLabel(const QIcon&, const QString &, int size = -1);
|
---|
83 | void removeLabel(int section);
|
---|
84 | virtual void setLabel(int, const QString &, int size = -1);
|
---|
85 | virtual void setLabel(int, const QIcon&, const QString &, int size = -1);
|
---|
86 | QString label(int section) const;
|
---|
87 | QIcon* iconSet(int section) const;
|
---|
88 |
|
---|
89 | virtual void setOrientation(Qt::Orientation);
|
---|
90 | Qt::Orientation orientation() const;
|
---|
91 | virtual void setTracking(bool enable);
|
---|
92 | bool tracking() const;
|
---|
93 |
|
---|
94 | virtual void setClickEnabled(bool, int section = -1);
|
---|
95 | virtual void setResizeEnabled(bool, int section = -1);
|
---|
96 | virtual void setMovingEnabled(bool);
|
---|
97 | virtual void setStretchEnabled(bool b, int section);
|
---|
98 | void setStretchEnabled(bool b) { setStretchEnabled(b, -1); }
|
---|
99 | bool isClickEnabled(int section = -1) const;
|
---|
100 | bool isResizeEnabled(int section = -1) const;
|
---|
101 | bool isMovingEnabled() const;
|
---|
102 | bool isStretchEnabled() const;
|
---|
103 | bool isStretchEnabled(int section) const;
|
---|
104 |
|
---|
105 | void resizeSection(int section, int s);
|
---|
106 | int sectionSize(int section) const;
|
---|
107 | int sectionPos(int section) const;
|
---|
108 | int sectionAt(int pos) const;
|
---|
109 | int count() const;
|
---|
110 | int headerWidth() const;
|
---|
111 | QRect sectionRect(int section) const;
|
---|
112 |
|
---|
113 | virtual void setCellSize(int , int); // obsolete, do not use
|
---|
114 | int cellSize(int i) const { return sectionSize(mapToSection(i)); } // obsolete, do not use
|
---|
115 | int cellPos(int) const; // obsolete, do not use
|
---|
116 | int cellAt(int pos) const { return mapToIndex(sectionAt(pos + offset())); } // obsolete, do not use
|
---|
117 |
|
---|
118 | int offset() const;
|
---|
119 |
|
---|
120 | QSize sizeHint() const;
|
---|
121 |
|
---|
122 | int mapToSection(int index) const;
|
---|
123 | int mapToIndex(int section) const;
|
---|
124 | int mapToLogical(int) const; // obsolete, do not use
|
---|
125 | int mapToActual(int) const; // obsolete, do not use
|
---|
126 |
|
---|
127 | void moveSection(int section, int toIndex);
|
---|
128 | virtual void moveCell(int, int); // obsolete, do not use
|
---|
129 |
|
---|
130 | void setSortIndicator(int section, bool ascending = true); // obsolete, do not use
|
---|
131 | inline void setSortIndicator(int section, Qt::SortOrder order)
|
---|
132 | { setSortIndicator(section, (order == Qt::AscendingOrder)); }
|
---|
133 | int sortIndicatorSection() const;
|
---|
134 | Qt::SortOrder sortIndicatorOrder() const;
|
---|
135 |
|
---|
136 | void adjustHeaderSize() { adjustHeaderSize(-1); }
|
---|
137 |
|
---|
138 | public Q_SLOTS:
|
---|
139 | void setUpdatesEnabled(bool enable);
|
---|
140 | virtual void setOffset(int pos);
|
---|
141 |
|
---|
142 | Q_SIGNALS:
|
---|
143 | void clicked(int section);
|
---|
144 | void pressed(int section);
|
---|
145 | void released(int section);
|
---|
146 | void sizeChange(int section, int oldSize, int newSize);
|
---|
147 | void indexChange(int section, int fromIndex, int toIndex);
|
---|
148 | void sectionClicked(int); // obsolete, do not use
|
---|
149 | void moved(int, int); // obsolete, do not use
|
---|
150 | void sectionHandleDoubleClicked(int section);
|
---|
151 |
|
---|
152 | protected:
|
---|
153 | void paintEvent(QPaintEvent *);
|
---|
154 | void showEvent(QShowEvent *e);
|
---|
155 | void resizeEvent(QResizeEvent *e);
|
---|
156 | QRect sRect(int index);
|
---|
157 |
|
---|
158 | virtual void paintSection(QPainter *p, int index, const QRect& fr);
|
---|
159 | virtual void paintSectionLabel(QPainter* p, int index, const QRect& fr);
|
---|
160 |
|
---|
161 | void changeEvent(QEvent *);
|
---|
162 | void mousePressEvent(QMouseEvent *);
|
---|
163 | void mouseReleaseEvent(QMouseEvent *);
|
---|
164 | void mouseMoveEvent(QMouseEvent *);
|
---|
165 | void mouseDoubleClickEvent(QMouseEvent *);
|
---|
166 |
|
---|
167 | void keyPressEvent(QKeyEvent *);
|
---|
168 | void keyReleaseEvent(QKeyEvent *);
|
---|
169 |
|
---|
170 | private:
|
---|
171 | void handleColumnMove(int fromIdx, int toIdx);
|
---|
172 | void adjustHeaderSize(int diff);
|
---|
173 | void init(int);
|
---|
174 |
|
---|
175 | void paintRect(int p, int s);
|
---|
176 | void markLine(int idx);
|
---|
177 | void unMarkLine(int idx);
|
---|
178 | int pPos(int i) const;
|
---|
179 | int pSize(int i) const;
|
---|
180 | int findLine(int);
|
---|
181 | int handleAt(int p);
|
---|
182 | bool reverse() const;
|
---|
183 | void calculatePositions(bool onlyVisible = false, int start = 0);
|
---|
184 | void handleColumnResize(int, int, bool, bool = true);
|
---|
185 | QSize sectionSizeHint(int section, const QFontMetrics& fm) const;
|
---|
186 | void setSectionSizeAndHeight(int section, int size);
|
---|
187 |
|
---|
188 | void resizeArrays(int size);
|
---|
189 | void setIsATableHeader(bool b);
|
---|
190 | int offs;
|
---|
191 | int handleIdx;
|
---|
192 | int oldHIdxSize;
|
---|
193 | int moveToIdx;
|
---|
194 | enum State { Idle, Sliding, Pressed, Moving, Blocked };
|
---|
195 | State state;
|
---|
196 | int clickPos;
|
---|
197 | bool trackingIsOn;
|
---|
198 | int oldHandleIdx;
|
---|
199 | int cachedPos; // not used
|
---|
200 | Qt::Orientation orient;
|
---|
201 |
|
---|
202 | Q3HeaderData *d;
|
---|
203 |
|
---|
204 | private:
|
---|
205 | Q_DISABLE_COPY(Q3Header)
|
---|
206 | };
|
---|
207 |
|
---|
208 |
|
---|
209 | inline Qt::Orientation Q3Header::orientation() const
|
---|
210 | {
|
---|
211 | return orient;
|
---|
212 | }
|
---|
213 |
|
---|
214 | inline void Q3Header::setTracking(bool enable) { trackingIsOn = enable; }
|
---|
215 | inline bool Q3Header::tracking() const { return trackingIsOn; }
|
---|
216 |
|
---|
217 | extern Q_COMPAT_EXPORT bool qt_qheader_label_return_null_strings; // needed for professional edition
|
---|
218 |
|
---|
219 | #endif // QT_NO_HEADER
|
---|
220 |
|
---|
221 | QT_END_NAMESPACE
|
---|
222 |
|
---|
223 | QT_END_HEADER
|
---|
224 |
|
---|
225 | #endif // Q3HEADER_H
|
---|