[2] | 1 | /****************************************************************************
|
---|
| 2 | **
|
---|
[846] | 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
[561] | 4 | ** All rights reserved.
|
---|
| 5 | ** Contact: Nokia Corporation (qt-info@nokia.com)
|
---|
[2] | 6 | **
|
---|
| 7 | ** This file is part of the QtGui 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 | **
|
---|
[561] | 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.
|
---|
[2] | 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 | **
|
---|
[561] | 36 | ** If you have questions regarding the use of this file, please contact
|
---|
| 37 | ** Nokia at qt-info@nokia.com.
|
---|
[2] | 38 | ** $QT_END_LICENSE$
|
---|
| 39 | **
|
---|
| 40 | ****************************************************************************/
|
---|
| 41 |
|
---|
| 42 | #ifndef QABSTRACTITEMVIEW_H
|
---|
| 43 | #define QABSTRACTITEMVIEW_H
|
---|
| 44 |
|
---|
| 45 | #include <QtGui/qabstractscrollarea.h>
|
---|
| 46 | #include <QtCore/qabstractitemmodel.h>
|
---|
| 47 | #include <QtGui/qitemselectionmodel.h>
|
---|
| 48 | #include <QtGui/qabstractitemdelegate.h>
|
---|
| 49 |
|
---|
| 50 | QT_BEGIN_HEADER
|
---|
| 51 |
|
---|
| 52 | QT_BEGIN_NAMESPACE
|
---|
| 53 |
|
---|
| 54 | QT_MODULE(Gui)
|
---|
| 55 |
|
---|
| 56 | #ifndef QT_NO_ITEMVIEWS
|
---|
| 57 |
|
---|
| 58 | class QMenu;
|
---|
| 59 | class QDrag;
|
---|
| 60 | class QEvent;
|
---|
| 61 | class QAbstractItemViewPrivate;
|
---|
| 62 |
|
---|
| 63 | class Q_GUI_EXPORT QAbstractItemView : public QAbstractScrollArea
|
---|
| 64 | {
|
---|
| 65 | Q_OBJECT
|
---|
| 66 | Q_ENUMS(SelectionMode SelectionBehavior ScrollHint ScrollMode DragDropMode)
|
---|
| 67 | Q_FLAGS(EditTriggers)
|
---|
| 68 | Q_PROPERTY(bool autoScroll READ hasAutoScroll WRITE setAutoScroll)
|
---|
| 69 | Q_PROPERTY(int autoScrollMargin READ autoScrollMargin WRITE setAutoScrollMargin)
|
---|
| 70 | Q_PROPERTY(EditTriggers editTriggers READ editTriggers WRITE setEditTriggers)
|
---|
| 71 | Q_PROPERTY(bool tabKeyNavigation READ tabKeyNavigation WRITE setTabKeyNavigation)
|
---|
| 72 | #ifndef QT_NO_DRAGANDDROP
|
---|
| 73 | Q_PROPERTY(bool showDropIndicator READ showDropIndicator WRITE setDropIndicatorShown)
|
---|
| 74 | Q_PROPERTY(bool dragEnabled READ dragEnabled WRITE setDragEnabled)
|
---|
| 75 | Q_PROPERTY(bool dragDropOverwriteMode READ dragDropOverwriteMode WRITE setDragDropOverwriteMode)
|
---|
| 76 | Q_PROPERTY(DragDropMode dragDropMode READ dragDropMode WRITE setDragDropMode)
|
---|
[561] | 77 | Q_PROPERTY(Qt::DropAction defaultDropAction READ defaultDropAction WRITE setDefaultDropAction)
|
---|
[2] | 78 | #endif
|
---|
| 79 | Q_PROPERTY(bool alternatingRowColors READ alternatingRowColors WRITE setAlternatingRowColors)
|
---|
| 80 | Q_PROPERTY(SelectionMode selectionMode READ selectionMode WRITE setSelectionMode)
|
---|
| 81 | Q_PROPERTY(SelectionBehavior selectionBehavior READ selectionBehavior WRITE setSelectionBehavior)
|
---|
| 82 | Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
|
---|
| 83 | Q_PROPERTY(Qt::TextElideMode textElideMode READ textElideMode WRITE setTextElideMode)
|
---|
| 84 | Q_PROPERTY(ScrollMode verticalScrollMode READ verticalScrollMode WRITE setVerticalScrollMode)
|
---|
| 85 | Q_PROPERTY(ScrollMode horizontalScrollMode READ horizontalScrollMode WRITE setHorizontalScrollMode)
|
---|
| 86 |
|
---|
| 87 | public:
|
---|
| 88 | enum SelectionMode {
|
---|
| 89 | NoSelection,
|
---|
| 90 | SingleSelection,
|
---|
| 91 | MultiSelection,
|
---|
| 92 | ExtendedSelection,
|
---|
| 93 | ContiguousSelection
|
---|
| 94 | };
|
---|
| 95 |
|
---|
| 96 | enum SelectionBehavior {
|
---|
| 97 | SelectItems,
|
---|
| 98 | SelectRows,
|
---|
| 99 | SelectColumns
|
---|
| 100 | };
|
---|
| 101 |
|
---|
| 102 | enum ScrollHint {
|
---|
| 103 | EnsureVisible,
|
---|
| 104 | PositionAtTop,
|
---|
| 105 | PositionAtBottom,
|
---|
| 106 | PositionAtCenter
|
---|
| 107 | };
|
---|
| 108 |
|
---|
| 109 | enum EditTrigger {
|
---|
| 110 | NoEditTriggers = 0,
|
---|
| 111 | CurrentChanged = 1,
|
---|
| 112 | DoubleClicked = 2,
|
---|
| 113 | SelectedClicked = 4,
|
---|
| 114 | EditKeyPressed = 8,
|
---|
| 115 | AnyKeyPressed = 16,
|
---|
| 116 | AllEditTriggers = 31
|
---|
| 117 | };
|
---|
| 118 |
|
---|
| 119 | Q_DECLARE_FLAGS(EditTriggers, EditTrigger)
|
---|
| 120 |
|
---|
| 121 | enum ScrollMode {
|
---|
| 122 | ScrollPerItem,
|
---|
| 123 | ScrollPerPixel
|
---|
| 124 | };
|
---|
| 125 |
|
---|
| 126 | explicit QAbstractItemView(QWidget *parent = 0);
|
---|
| 127 | ~QAbstractItemView();
|
---|
| 128 |
|
---|
| 129 | virtual void setModel(QAbstractItemModel *model);
|
---|
| 130 | QAbstractItemModel *model() const;
|
---|
| 131 |
|
---|
| 132 | virtual void setSelectionModel(QItemSelectionModel *selectionModel);
|
---|
| 133 | QItemSelectionModel *selectionModel() const;
|
---|
| 134 |
|
---|
| 135 | void setItemDelegate(QAbstractItemDelegate *delegate);
|
---|
| 136 | QAbstractItemDelegate *itemDelegate() const;
|
---|
| 137 |
|
---|
| 138 | void setSelectionMode(QAbstractItemView::SelectionMode mode);
|
---|
| 139 | QAbstractItemView::SelectionMode selectionMode() const;
|
---|
| 140 |
|
---|
| 141 | void setSelectionBehavior(QAbstractItemView::SelectionBehavior behavior);
|
---|
| 142 | QAbstractItemView::SelectionBehavior selectionBehavior() const;
|
---|
| 143 |
|
---|
| 144 | QModelIndex currentIndex() const;
|
---|
| 145 | QModelIndex rootIndex() const;
|
---|
| 146 |
|
---|
| 147 | void setEditTriggers(EditTriggers triggers);
|
---|
| 148 | EditTriggers editTriggers() const;
|
---|
| 149 |
|
---|
| 150 | void setVerticalScrollMode(ScrollMode mode);
|
---|
| 151 | ScrollMode verticalScrollMode() const;
|
---|
| 152 |
|
---|
| 153 | void setHorizontalScrollMode(ScrollMode mode);
|
---|
| 154 | ScrollMode horizontalScrollMode() const;
|
---|
| 155 |
|
---|
| 156 | void setAutoScroll(bool enable);
|
---|
| 157 | bool hasAutoScroll() const;
|
---|
| 158 |
|
---|
| 159 | void setAutoScrollMargin(int margin);
|
---|
| 160 | int autoScrollMargin() const;
|
---|
| 161 |
|
---|
| 162 | void setTabKeyNavigation(bool enable);
|
---|
| 163 | bool tabKeyNavigation() const;
|
---|
| 164 |
|
---|
| 165 | #ifndef QT_NO_DRAGANDDROP
|
---|
| 166 | void setDropIndicatorShown(bool enable);
|
---|
| 167 | bool showDropIndicator() const;
|
---|
| 168 |
|
---|
| 169 | void setDragEnabled(bool enable);
|
---|
| 170 | bool dragEnabled() const;
|
---|
| 171 |
|
---|
| 172 | void setDragDropOverwriteMode(bool overwrite);
|
---|
| 173 | bool dragDropOverwriteMode() const;
|
---|
| 174 |
|
---|
| 175 | enum DragDropMode {
|
---|
| 176 | NoDragDrop,
|
---|
| 177 | DragOnly,
|
---|
| 178 | DropOnly,
|
---|
| 179 | DragDrop,
|
---|
| 180 | InternalMove
|
---|
| 181 | };
|
---|
| 182 |
|
---|
| 183 | void setDragDropMode(DragDropMode behavior);
|
---|
| 184 | DragDropMode dragDropMode() const;
|
---|
[561] | 185 |
|
---|
| 186 | void setDefaultDropAction(Qt::DropAction dropAction);
|
---|
| 187 | Qt::DropAction defaultDropAction() const;
|
---|
[2] | 188 | #endif
|
---|
[561] | 189 |
|
---|
[2] | 190 | void setAlternatingRowColors(bool enable);
|
---|
| 191 | bool alternatingRowColors() const;
|
---|
| 192 |
|
---|
| 193 | void setIconSize(const QSize &size);
|
---|
| 194 | QSize iconSize() const;
|
---|
| 195 |
|
---|
| 196 | void setTextElideMode(Qt::TextElideMode mode);
|
---|
| 197 | Qt::TextElideMode textElideMode() const;
|
---|
| 198 |
|
---|
| 199 | virtual void keyboardSearch(const QString &search);
|
---|
| 200 |
|
---|
| 201 | virtual QRect visualRect(const QModelIndex &index) const = 0;
|
---|
| 202 | virtual void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) = 0;
|
---|
| 203 | virtual QModelIndex indexAt(const QPoint &point) const = 0;
|
---|
| 204 |
|
---|
| 205 | QSize sizeHintForIndex(const QModelIndex &index) const;
|
---|
| 206 | virtual int sizeHintForRow(int row) const;
|
---|
| 207 | virtual int sizeHintForColumn(int column) const;
|
---|
| 208 |
|
---|
| 209 | void openPersistentEditor(const QModelIndex &index);
|
---|
| 210 | void closePersistentEditor(const QModelIndex &index);
|
---|
| 211 |
|
---|
| 212 | void setIndexWidget(const QModelIndex &index, QWidget *widget);
|
---|
| 213 | QWidget *indexWidget(const QModelIndex &index) const;
|
---|
| 214 |
|
---|
| 215 | void setItemDelegateForRow(int row, QAbstractItemDelegate *delegate);
|
---|
| 216 | QAbstractItemDelegate *itemDelegateForRow(int row) const;
|
---|
| 217 |
|
---|
| 218 | void setItemDelegateForColumn(int column, QAbstractItemDelegate *delegate);
|
---|
| 219 | QAbstractItemDelegate *itemDelegateForColumn(int column) const;
|
---|
| 220 |
|
---|
| 221 | QAbstractItemDelegate *itemDelegate(const QModelIndex &index) const;
|
---|
| 222 |
|
---|
| 223 | virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
|
---|
| 224 |
|
---|
| 225 | #ifdef Q_NO_USING_KEYWORD
|
---|
| 226 | inline void update() { QAbstractScrollArea::update(); }
|
---|
| 227 | #else
|
---|
| 228 | using QAbstractScrollArea::update;
|
---|
| 229 | #endif
|
---|
| 230 |
|
---|
| 231 | public Q_SLOTS:
|
---|
| 232 | virtual void reset();
|
---|
| 233 | virtual void setRootIndex(const QModelIndex &index);
|
---|
| 234 | virtual void doItemsLayout();
|
---|
| 235 | virtual void selectAll();
|
---|
| 236 | void edit(const QModelIndex &index);
|
---|
| 237 | void clearSelection();
|
---|
| 238 | void setCurrentIndex(const QModelIndex &index);
|
---|
| 239 | void scrollToTop();
|
---|
| 240 | void scrollToBottom();
|
---|
| 241 | void update(const QModelIndex &index);
|
---|
| 242 |
|
---|
| 243 | protected Q_SLOTS:
|
---|
| 244 | virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
|
---|
| 245 | virtual void rowsInserted(const QModelIndex &parent, int start, int end);
|
---|
| 246 | virtual void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
|
---|
| 247 | virtual void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
|
---|
| 248 | virtual void currentChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
---|
| 249 | virtual void updateEditorData();
|
---|
| 250 | virtual void updateEditorGeometries();
|
---|
| 251 | virtual void updateGeometries();
|
---|
| 252 | virtual void verticalScrollbarAction(int action);
|
---|
| 253 | virtual void horizontalScrollbarAction(int action);
|
---|
| 254 | virtual void verticalScrollbarValueChanged(int value);
|
---|
| 255 | virtual void horizontalScrollbarValueChanged(int value);
|
---|
| 256 | virtual void closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint);
|
---|
| 257 | virtual void commitData(QWidget *editor);
|
---|
| 258 | virtual void editorDestroyed(QObject *editor);
|
---|
| 259 |
|
---|
| 260 | Q_SIGNALS:
|
---|
| 261 | void pressed(const QModelIndex &index);
|
---|
| 262 | void clicked(const QModelIndex &index);
|
---|
| 263 | void doubleClicked(const QModelIndex &index);
|
---|
| 264 |
|
---|
| 265 | void activated(const QModelIndex &index);
|
---|
| 266 | void entered(const QModelIndex &index);
|
---|
| 267 | void viewportEntered();
|
---|
| 268 |
|
---|
| 269 | protected:
|
---|
| 270 | QAbstractItemView(QAbstractItemViewPrivate &, QWidget *parent = 0);
|
---|
| 271 |
|
---|
| 272 | void setHorizontalStepsPerItem(int steps);
|
---|
| 273 | int horizontalStepsPerItem() const;
|
---|
| 274 | void setVerticalStepsPerItem(int steps);
|
---|
| 275 | int verticalStepsPerItem() const;
|
---|
| 276 |
|
---|
| 277 | enum CursorAction { MoveUp, MoveDown, MoveLeft, MoveRight,
|
---|
| 278 | MoveHome, MoveEnd, MovePageUp, MovePageDown,
|
---|
| 279 | MoveNext, MovePrevious };
|
---|
| 280 | virtual QModelIndex moveCursor(CursorAction cursorAction,
|
---|
| 281 | Qt::KeyboardModifiers modifiers) = 0;
|
---|
| 282 |
|
---|
| 283 | virtual int horizontalOffset() const = 0;
|
---|
| 284 | virtual int verticalOffset() const = 0;
|
---|
| 285 |
|
---|
| 286 | virtual bool isIndexHidden(const QModelIndex &index) const = 0;
|
---|
| 287 |
|
---|
| 288 | virtual void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) = 0;
|
---|
| 289 | virtual QRegion visualRegionForSelection(const QItemSelection &selection) const = 0;
|
---|
| 290 | virtual QModelIndexList selectedIndexes() const;
|
---|
| 291 |
|
---|
| 292 | virtual bool edit(const QModelIndex &index, EditTrigger trigger, QEvent *event);
|
---|
| 293 |
|
---|
| 294 | virtual QItemSelectionModel::SelectionFlags selectionCommand(const QModelIndex &index,
|
---|
| 295 | const QEvent *event = 0) const;
|
---|
| 296 |
|
---|
| 297 | #ifndef QT_NO_DRAGANDDROP
|
---|
| 298 | virtual void startDrag(Qt::DropActions supportedActions);
|
---|
| 299 | #endif
|
---|
| 300 |
|
---|
| 301 | virtual QStyleOptionViewItem viewOptions() const;
|
---|
| 302 |
|
---|
| 303 | enum State {
|
---|
| 304 | NoState,
|
---|
| 305 | DraggingState,
|
---|
| 306 | DragSelectingState,
|
---|
| 307 | EditingState,
|
---|
| 308 | ExpandingState,
|
---|
| 309 | CollapsingState,
|
---|
| 310 | AnimatingState
|
---|
| 311 | };
|
---|
| 312 |
|
---|
| 313 | State state() const;
|
---|
| 314 | void setState(State state);
|
---|
| 315 |
|
---|
| 316 | void scheduleDelayedItemsLayout();
|
---|
| 317 | void executeDelayedItemsLayout();
|
---|
| 318 |
|
---|
| 319 | void setDirtyRegion(const QRegion ®ion);
|
---|
| 320 | void scrollDirtyRegion(int dx, int dy);
|
---|
| 321 | QPoint dirtyRegionOffset() const;
|
---|
| 322 |
|
---|
| 323 | void startAutoScroll();
|
---|
| 324 | void stopAutoScroll();
|
---|
| 325 | void doAutoScroll();
|
---|
| 326 |
|
---|
| 327 | bool focusNextPrevChild(bool next);
|
---|
| 328 | bool event(QEvent *event);
|
---|
| 329 | bool viewportEvent(QEvent *event);
|
---|
| 330 | void mousePressEvent(QMouseEvent *event);
|
---|
| 331 | void mouseMoveEvent(QMouseEvent *event);
|
---|
| 332 | void mouseReleaseEvent(QMouseEvent *event);
|
---|
| 333 | void mouseDoubleClickEvent(QMouseEvent *event);
|
---|
| 334 | #ifndef QT_NO_DRAGANDDROP
|
---|
| 335 | void dragEnterEvent(QDragEnterEvent *event);
|
---|
| 336 | void dragMoveEvent(QDragMoveEvent *event);
|
---|
| 337 | void dragLeaveEvent(QDragLeaveEvent *event);
|
---|
| 338 | void dropEvent(QDropEvent *event);
|
---|
| 339 | #endif
|
---|
| 340 | void focusInEvent(QFocusEvent *event);
|
---|
| 341 | void focusOutEvent(QFocusEvent *event);
|
---|
| 342 | void keyPressEvent(QKeyEvent *event);
|
---|
| 343 | void resizeEvent(QResizeEvent *event);
|
---|
| 344 | void timerEvent(QTimerEvent *event);
|
---|
| 345 | void inputMethodEvent(QInputMethodEvent *event);
|
---|
| 346 |
|
---|
| 347 | #ifndef QT_NO_DRAGANDDROP
|
---|
| 348 | enum DropIndicatorPosition { OnItem, AboveItem, BelowItem, OnViewport };
|
---|
| 349 | DropIndicatorPosition dropIndicatorPosition() const;
|
---|
| 350 | #endif
|
---|
| 351 |
|
---|
| 352 | private:
|
---|
| 353 | Q_DECLARE_PRIVATE(QAbstractItemView)
|
---|
| 354 | Q_DISABLE_COPY(QAbstractItemView)
|
---|
| 355 | Q_PRIVATE_SLOT(d_func(), void _q_columnsAboutToBeRemoved(const QModelIndex&, int, int))
|
---|
| 356 | Q_PRIVATE_SLOT(d_func(), void _q_columnsRemoved(const QModelIndex&, int, int))
|
---|
| 357 | Q_PRIVATE_SLOT(d_func(), void _q_columnsInserted(const QModelIndex&, int, int))
|
---|
| 358 | Q_PRIVATE_SLOT(d_func(), void _q_rowsRemoved(const QModelIndex&, int, int))
|
---|
| 359 | Q_PRIVATE_SLOT(d_func(), void _q_modelDestroyed())
|
---|
| 360 | Q_PRIVATE_SLOT(d_func(), void _q_layoutChanged())
|
---|
[561] | 361 | Q_PRIVATE_SLOT(d_func(), void _q_headerDataChanged())
|
---|
[2] | 362 |
|
---|
| 363 | friend class QTreeViewPrivate; // needed to compile with MSVC
|
---|
| 364 | friend class QAccessibleItemRow;
|
---|
[561] | 365 | friend class QListModeViewBase;
|
---|
| 366 | friend class QListViewPrivate; // needed to compile for Symbian emulator
|
---|
[2] | 367 | };
|
---|
| 368 |
|
---|
| 369 | Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractItemView::EditTriggers)
|
---|
| 370 |
|
---|
| 371 | #endif // QT_NO_ITEMVIEWS
|
---|
| 372 |
|
---|
| 373 | QT_END_NAMESPACE
|
---|
| 374 |
|
---|
| 375 | QT_END_HEADER
|
---|
| 376 |
|
---|
| 377 | #endif // QABSTRACTITEMVIEW_H
|
---|