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

« back to all changes in this revision

Viewing changes to src/gui/itemviews/qabstractitemview.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 QABSTRACTITEMVIEW_H
 
30
#define QABSTRACTITEMVIEW_H
 
31
 
 
32
#include <QtGui/qabstractscrollarea.h>
 
33
#include <QtCore/qabstractitemmodel.h>
 
34
#include <QtGui/qitemselectionmodel.h>
 
35
#include <QtGui/qabstractitemdelegate.h>
 
36
 
 
37
class QMenu;
 
38
class QDrag;
 
39
class QEvent;
 
40
class QAbstractItemViewPrivate;
 
41
 
 
42
class Q_GUI_EXPORT QAbstractItemView : public QAbstractScrollArea
 
43
{
 
44
    Q_OBJECT
 
45
    Q_ENUMS(SelectionMode SelectionBehavior ScrollHint)
 
46
    Q_FLAGS(EditTriggers)
 
47
    Q_PROPERTY(bool autoScroll READ hasAutoScroll WRITE setAutoScroll)
 
48
    Q_PROPERTY(EditTriggers editTriggers READ editTriggers WRITE setEditTriggers)
 
49
    Q_PROPERTY(bool tabKeyNavigation READ tabKeyNavigation WRITE setTabKeyNavigation)
 
50
    Q_PROPERTY(bool showDropIndicator READ showDropIndicator WRITE setDropIndicatorShown)
 
51
    Q_PROPERTY(bool dragEnabled READ dragEnabled WRITE setDragEnabled)
 
52
    Q_PROPERTY(bool alternatingRowColors READ alternatingRowColors WRITE setAlternatingRowColors)
 
53
    Q_PROPERTY(SelectionMode selectionMode READ selectionMode WRITE setSelectionMode)
 
54
    Q_PROPERTY(SelectionBehavior selectionBehavior READ selectionBehavior WRITE setSelectionBehavior)
 
55
    Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
 
56
    Q_PROPERTY(Qt::TextElideMode textElideMode READ textElideMode WRITE setTextElideMode)
 
57
 
 
58
public:
 
59
    enum SelectionMode {
 
60
        NoSelection,
 
61
        SingleSelection,
 
62
        MultiSelection,
 
63
        ExtendedSelection
 
64
    };
 
65
 
 
66
    enum SelectionBehavior {
 
67
        SelectItems,
 
68
        SelectRows,
 
69
        SelectColumns
 
70
    };
 
71
 
 
72
    enum ScrollHint {
 
73
        EnsureVisible,
 
74
        PositionAtTop,
 
75
        PositionAtBottom
 
76
    };
 
77
 
 
78
    enum EditTrigger {
 
79
        NoEditTriggers = 0,
 
80
        CurrentChanged = 1,
 
81
        DoubleClicked = 2,
 
82
        SelectedClicked = 4,
 
83
        EditKeyPressed = 8,
 
84
        AnyKeyPressed = 16,
 
85
        AllEditTriggers = 31
 
86
    };
 
87
 
 
88
    Q_DECLARE_FLAGS(EditTriggers, EditTrigger)
 
89
 
 
90
    explicit QAbstractItemView(QWidget *parent = 0);
 
91
    ~QAbstractItemView();
 
92
 
 
93
    virtual void setModel(QAbstractItemModel *model);
 
94
    QAbstractItemModel *model() const;
 
95
 
 
96
    virtual void setSelectionModel(QItemSelectionModel *selectionModel);
 
97
    QItemSelectionModel *selectionModel() const;
 
98
 
 
99
    void setItemDelegate(QAbstractItemDelegate *delegate);
 
100
    QAbstractItemDelegate *itemDelegate() const;
 
101
 
 
102
    void setSelectionMode(QAbstractItemView::SelectionMode mode);
 
103
    QAbstractItemView::SelectionMode selectionMode() const;
 
104
 
 
105
    void setSelectionBehavior(QAbstractItemView::SelectionBehavior behavior);
 
106
    QAbstractItemView::SelectionBehavior selectionBehavior() const;
 
107
 
 
108
    QModelIndex currentIndex() const;
 
109
    QModelIndex rootIndex() const;
 
110
 
 
111
    void setEditTriggers(EditTriggers triggers);
 
112
    EditTriggers editTriggers() const;
 
113
 
 
114
    void setAutoScroll(bool enable);
 
115
    bool hasAutoScroll() const;
 
116
 
 
117
    void setTabKeyNavigation(bool enable);
 
118
    bool tabKeyNavigation() const;
 
119
 
 
120
    void setDropIndicatorShown(bool enable);
 
121
    bool showDropIndicator() const;
 
122
 
 
123
    void setDragEnabled(bool enable);
 
124
    bool dragEnabled() const;
 
125
 
 
126
    void setAlternatingRowColors(bool enable);
 
127
    bool alternatingRowColors() const;
 
128
    
 
129
    void setIconSize(const QSize &size);
 
130
    QSize iconSize() const;
 
131
 
 
132
    void setTextElideMode(Qt::TextElideMode mode);
 
133
    Qt::TextElideMode textElideMode() const;
 
134
 
 
135
    virtual void keyboardSearch(const QString &search);
 
136
 
 
137
    virtual QRect visualRect(const QModelIndex &index) const = 0;
 
138
    virtual void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) = 0;
 
139
    virtual QModelIndex indexAt(const QPoint &p) const = 0;
 
140
 
 
141
    QSize sizeHintForIndex(const QModelIndex &index) const;
 
142
    virtual int sizeHintForRow(int row) const;
 
143
    virtual int sizeHintForColumn(int column) const;
 
144
 
 
145
    void openPersistentEditor(const QModelIndex &index);
 
146
    void closePersistentEditor(const QModelIndex &index);
 
147
 
 
148
public slots:
 
149
    virtual void reset();
 
150
    virtual void setRootIndex(const QModelIndex &index);
 
151
    virtual void doItemsLayout();
 
152
    virtual void selectAll();
 
153
    void edit(const QModelIndex &index);
 
154
    void clearSelection();
 
155
    void setCurrentIndex(const QModelIndex &index);
 
156
 
 
157
protected slots:
 
158
    virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
 
159
    virtual void rowsInserted(const QModelIndex &parent, int start, int end);
 
160
    virtual void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
 
161
    virtual void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
 
162
    virtual void currentChanged(const QModelIndex &current, const QModelIndex &previous);
 
163
    virtual void updateEditorData();
 
164
    virtual void updateEditorGeometries();
 
165
    virtual void updateGeometries();
 
166
    virtual void verticalScrollbarAction(int action);
 
167
    virtual void horizontalScrollbarAction(int action);
 
168
    virtual void verticalScrollbarValueChanged(int value);
 
169
    virtual void horizontalScrollbarValueChanged(int value);
 
170
    virtual void closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint);
 
171
    virtual void commitData(QWidget *editor);
 
172
    virtual void editorDestroyed(QObject *editor);
 
173
 
 
174
signals:
 
175
    void pressed(const QModelIndex &index);
 
176
    void clicked(const QModelIndex &index);
 
177
    void doubleClicked(const QModelIndex &index);
 
178
    
 
179
    void activated(const QModelIndex &index);
 
180
    void entered(const QModelIndex &index);
 
181
    void viewportEntered();
 
182
 
 
183
protected:
 
184
    QAbstractItemView(QAbstractItemViewPrivate &, QWidget *parent = 0);
 
185
 
 
186
    void setHorizontalStepsPerItem(int steps);
 
187
    int horizontalStepsPerItem() const;
 
188
    void setVerticalStepsPerItem(int steps);
 
189
    int verticalStepsPerItem() const;
 
190
 
 
191
    enum CursorAction { MoveUp, MoveDown, MoveLeft, MoveRight,
 
192
                        MoveHome, MoveEnd, MovePageUp, MovePageDown,
 
193
                        MoveNext, MovePrevious };
 
194
    virtual QModelIndex moveCursor(CursorAction cursorAction,
 
195
                                   Qt::KeyboardModifiers modifiers) = 0;
 
196
 
 
197
    virtual int horizontalOffset() const = 0;
 
198
    virtual int verticalOffset() const = 0;
 
199
 
 
200
    virtual bool isIndexHidden(const QModelIndex &index) const = 0;
 
201
 
 
202
    virtual void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) = 0;
 
203
    virtual QRegion visualRegionForSelection(const QItemSelection &selection) const = 0;
 
204
    virtual QModelIndexList selectedIndexes() const;
 
205
 
 
206
    virtual bool edit(const QModelIndex &index, EditTrigger trigger, QEvent *event);
 
207
 
 
208
    virtual QItemSelectionModel::SelectionFlags selectionCommand(const QModelIndex &index,
 
209
                                                                 const QEvent *event = 0) const;
 
210
 
 
211
    virtual void startDrag(Qt::DropActions supportedActions);
 
212
 
 
213
    virtual QStyleOptionViewItem viewOptions() const;
 
214
 
 
215
    enum State {
 
216
        NoState,
 
217
        DraggingState,
 
218
        DragSelectingState,
 
219
        EditingState,
 
220
        ExpandingState,
 
221
        CollapsingState
 
222
    };
 
223
 
 
224
    State state() const;
 
225
    void setState(State state);
 
226
 
 
227
    void scheduleDelayedItemsLayout();
 
228
    void executeDelayedItemsLayout();
 
229
 
 
230
    void scrollDirtyRegion(int dx, int dy);
 
231
    QPoint dirtyRegionOffset() const;
 
232
    
 
233
    void startAutoScroll();
 
234
    void stopAutoScroll();
 
235
    void doAutoScroll();
 
236
 
 
237
    bool viewportEvent(QEvent *e);
 
238
    void mousePressEvent(QMouseEvent *e);
 
239
    void mouseMoveEvent(QMouseEvent *e);
 
240
    void mouseReleaseEvent(QMouseEvent *e);
 
241
    void mouseDoubleClickEvent(QMouseEvent *e);
 
242
    void dragEnterEvent(QDragEnterEvent *e);
 
243
    void dragMoveEvent(QDragMoveEvent *e);
 
244
    void dragLeaveEvent(QDragLeaveEvent *e);
 
245
    void dropEvent(QDropEvent *e);
 
246
    void focusInEvent(QFocusEvent *e);
 
247
    void focusOutEvent(QFocusEvent *e);
 
248
    void keyPressEvent(QKeyEvent *e);
 
249
    void resizeEvent(QResizeEvent *e);
 
250
    void timerEvent(QTimerEvent *e);
 
251
 
 
252
private:
 
253
    Q_DECLARE_PRIVATE(QAbstractItemView)
 
254
    Q_DISABLE_COPY(QAbstractItemView)
 
255
};
 
256
Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractItemView::EditTriggers)
 
257
 
 
258
#endif // QABSTRACTITEMVIEW_H