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

« back to all changes in this revision

Viewing changes to src/qt3support/widgets/q3header.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 Qt 3 compatibility classes 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 Q3HEADER_H
 
30
#define Q3HEADER_H
 
31
 
 
32
#include "QtGui/qicon.h"
 
33
#include "QtGui/qwidget.h"
 
34
#include "QtCore/qstring.h"
 
35
 
 
36
#ifndef QT_NO_HEADER
 
37
 
 
38
class QShowEvent;
 
39
class Q3HeaderData;
 
40
class Q3Table;
 
41
class Q3ListView;
 
42
 
 
43
class Q_COMPAT_EXPORT Q3Header : public QWidget
 
44
{
 
45
    friend class Q3Table;
 
46
    friend class Q3TableHeader;
 
47
    friend class Q3ListView;
 
48
 
 
49
    Q_OBJECT
 
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)
 
56
 
 
57
public:
 
58
    Q3Header(QWidget* parent=0, const char* name=0);
 
59
    Q3Header(int, QWidget* parent=0, const char* name=0);
 
60
    ~Q3Header();
 
61
 
 
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;
 
69
 
 
70
    virtual void setOrientation(Qt::Orientation);
 
71
    Qt::Orientation orientation() const;
 
72
    virtual void setTracking(bool enable);
 
73
    bool        tracking() const;
 
74
 
 
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;
 
85
 
 
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;
 
90
    int                count() const;
 
91
    int         headerWidth() const;
 
92
    QRect        sectionRect(int section) const;
 
93
 
 
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
 
98
 
 
99
    int         offset() const;
 
100
 
 
101
    QSize        sizeHint() const;
 
102
 
 
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
 
107
 
 
108
    void         moveSection(int section, int toIndex);
 
109
    virtual void moveCell(int, int); // obsolete, do not use
 
110
 
 
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;
 
116
 
 
117
    void        adjustHeaderSize() { adjustHeaderSize(-1); }
 
118
 
 
119
public slots:
 
120
    void         setUpdatesEnabled(bool enable);
 
121
    virtual void setOffset(int pos);
 
122
 
 
123
signals:
 
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);
 
132
 
 
133
protected:
 
134
    void        paintEvent(QPaintEvent *);
 
135
    void        showEvent(QShowEvent *e);
 
136
    void         resizeEvent(QResizeEvent *e);
 
137
    QRect        sRect(int index);
 
138
 
 
139
    virtual void paintSection(QPainter *p, int index, const QRect& fr);
 
140
    virtual void paintSectionLabel(QPainter* p, int index, const QRect& fr);
 
141
 
 
142
    void        changeEvent(QEvent *);
 
143
    void        mousePressEvent(QMouseEvent *);
 
144
    void        mouseReleaseEvent(QMouseEvent *);
 
145
    void        mouseMoveEvent(QMouseEvent *);
 
146
    void        mouseDoubleClickEvent(QMouseEvent *);
 
147
 
 
148
    void        keyPressEvent(QKeyEvent *);
 
149
    void        keyReleaseEvent(QKeyEvent *);
 
150
 
 
151
private:
 
152
    void        handleColumnMove(int fromIdx, int toIdx);
 
153
    void         adjustHeaderSize(int diff);
 
154
    void        init(int);
 
155
 
 
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;
 
161
    int         findLine(int);
 
162
    int                handleAt(int p);
 
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);
 
168
 
 
169
    void         resizeArrays(int size);
 
170
    void         setIsATableHeader(bool b);
 
171
    int                offs;
 
172
    int                handleIdx;
 
173
    int                oldHIdxSize;
 
174
    int                moveToIdx;
 
175
    enum State { Idle, Sliding, Pressed, Moving, Blocked };
 
176
    State        state;
 
177
    int        clickPos;
 
178
    bool        trackingIsOn;
 
179
    int oldHandleIdx;
 
180
    int        cachedPos; // not used
 
181
    Qt::Orientation orient;
 
182
 
 
183
    Q3HeaderData *d;
 
184
 
 
185
private:
 
186
    Q_DISABLE_COPY(Q3Header)
 
187
};
 
188
 
 
189
 
 
190
inline Qt::Orientation Q3Header::orientation() const
 
191
{
 
192
    return orient;
 
193
}
 
194
 
 
195
inline void Q3Header::setTracking(bool enable) { trackingIsOn = enable; }
 
196
inline bool Q3Header::tracking() const { return trackingIsOn; }
 
197
 
 
198
extern Q_COMPAT_EXPORT bool qt_qheader_label_return_null_strings; // needed for professional edition
 
199
 
 
200
#endif // QT_NO_HEADER
 
201
 
 
202
#endif // Q3HEADER_H