1
/****************************************************************************
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
5
** This file is part of the item views module 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
****************************************************************************/
29
#ifndef QABSTRACTITEMVIEW_H
30
#define QABSTRACTITEMVIEW_H
32
#include <QtGui/qabstractscrollarea.h>
33
#include <QtCore/qabstractitemmodel.h>
34
#include <QtGui/qitemselectionmodel.h>
35
#include <QtGui/qabstractitemdelegate.h>
40
class QAbstractItemViewPrivate;
42
class Q_GUI_EXPORT QAbstractItemView : public QAbstractScrollArea
45
Q_ENUMS(SelectionMode SelectionBehavior ScrollHint)
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)
66
enum SelectionBehavior {
88
Q_DECLARE_FLAGS(EditTriggers, EditTrigger)
90
explicit QAbstractItemView(QWidget *parent = 0);
93
virtual void setModel(QAbstractItemModel *model);
94
QAbstractItemModel *model() const;
96
virtual void setSelectionModel(QItemSelectionModel *selectionModel);
97
QItemSelectionModel *selectionModel() const;
99
void setItemDelegate(QAbstractItemDelegate *delegate);
100
QAbstractItemDelegate *itemDelegate() const;
102
void setSelectionMode(QAbstractItemView::SelectionMode mode);
103
QAbstractItemView::SelectionMode selectionMode() const;
105
void setSelectionBehavior(QAbstractItemView::SelectionBehavior behavior);
106
QAbstractItemView::SelectionBehavior selectionBehavior() const;
108
QModelIndex currentIndex() const;
109
QModelIndex rootIndex() const;
111
void setEditTriggers(EditTriggers triggers);
112
EditTriggers editTriggers() const;
114
void setAutoScroll(bool enable);
115
bool hasAutoScroll() const;
117
void setTabKeyNavigation(bool enable);
118
bool tabKeyNavigation() const;
120
void setDropIndicatorShown(bool enable);
121
bool showDropIndicator() const;
123
void setDragEnabled(bool enable);
124
bool dragEnabled() const;
126
void setAlternatingRowColors(bool enable);
127
bool alternatingRowColors() const;
129
void setIconSize(const QSize &size);
130
QSize iconSize() const;
132
void setTextElideMode(Qt::TextElideMode mode);
133
Qt::TextElideMode textElideMode() const;
135
virtual void keyboardSearch(const QString &search);
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;
141
QSize sizeHintForIndex(const QModelIndex &index) const;
142
virtual int sizeHintForRow(int row) const;
143
virtual int sizeHintForColumn(int column) const;
145
void openPersistentEditor(const QModelIndex &index);
146
void closePersistentEditor(const QModelIndex &index);
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);
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 ¤t, 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);
175
void pressed(const QModelIndex &index);
176
void clicked(const QModelIndex &index);
177
void doubleClicked(const QModelIndex &index);
179
void activated(const QModelIndex &index);
180
void entered(const QModelIndex &index);
181
void viewportEntered();
184
QAbstractItemView(QAbstractItemViewPrivate &, QWidget *parent = 0);
186
void setHorizontalStepsPerItem(int steps);
187
int horizontalStepsPerItem() const;
188
void setVerticalStepsPerItem(int steps);
189
int verticalStepsPerItem() const;
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;
197
virtual int horizontalOffset() const = 0;
198
virtual int verticalOffset() const = 0;
200
virtual bool isIndexHidden(const QModelIndex &index) const = 0;
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;
206
virtual bool edit(const QModelIndex &index, EditTrigger trigger, QEvent *event);
208
virtual QItemSelectionModel::SelectionFlags selectionCommand(const QModelIndex &index,
209
const QEvent *event = 0) const;
211
virtual void startDrag(Qt::DropActions supportedActions);
213
virtual QStyleOptionViewItem viewOptions() const;
225
void setState(State state);
227
void scheduleDelayedItemsLayout();
228
void executeDelayedItemsLayout();
230
void scrollDirtyRegion(int dx, int dy);
231
QPoint dirtyRegionOffset() const;
233
void startAutoScroll();
234
void stopAutoScroll();
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);
253
Q_DECLARE_PRIVATE(QAbstractItemView)
254
Q_DISABLE_COPY(QAbstractItemView)
256
Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractItemView::EditTriggers)
258
#endif // QABSTRACTITEMVIEW_H