qlistview.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
00004 ** All rights reserved.
00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
00006 **
00007 ** This file is part of the QtGui module of the Qt Toolkit.
00008 **
00009 ** $QT_BEGIN_LICENSE:LGPL$
00010 ** Commercial Usage
00011 ** Licensees holding valid Qt Commercial licenses may use this file in
00012 ** accordance with the Qt Commercial License Agreement provided with the
00013 ** Software or, alternatively, in accordance with the terms contained in
00014 ** a written agreement between you and Nokia.
00015 **
00016 ** GNU Lesser General Public License Usage
00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
00018 ** General Public License version 2.1 as published by the Free Software
00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
00020 ** packaging of this file.  Please review the following information to
00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
00023 **
00024 ** In addition, as a special exception, Nokia gives you certain additional
00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
00027 **
00028 ** GNU General Public License Usage
00029 ** Alternatively, this file may be used under the terms of the GNU
00030 ** General Public License version 3.0 as published by the Free Software
00031 ** Foundation and appearing in the file LICENSE.GPL included in the
00032 ** packaging of this file.  Please review the following information to
00033 ** ensure the GNU General Public License version 3.0 requirements will be
00034 ** met: http://www.gnu.org/copyleft/gpl.html.
00035 **
00036 ** If you have questions regarding the use of this file, please contact
00037 ** Nokia at qt-info@nokia.com.
00038 ** $QT_END_LICENSE$
00039 **
00040 ****************************************************************************/
00041 
00042 #ifndef QLISTVIEW_H
00043 #define QLISTVIEW_H
00044 
00045 #include <QtGui/qabstractitemview.h>
00046 
00047 QT_BEGIN_HEADER
00048 
00049 QT_BEGIN_NAMESPACE
00050 
00051 QT_MODULE(Gui)
00052 
00053 #ifndef QT_NO_LISTVIEW
00054 
00055 class QListViewPrivate;
00056 
00057 class Q_GUI_EXPORT QListView : public QAbstractItemView
00058 {
00059     Q_OBJECT
00060     Q_ENUMS(Movement Flow ResizeMode LayoutMode ViewMode)
00061     Q_PROPERTY(Movement movement READ movement WRITE setMovement)
00062     Q_PROPERTY(Flow flow READ flow WRITE setFlow)
00063     Q_PROPERTY(bool isWrapping READ isWrapping WRITE setWrapping)
00064     Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode)
00065     Q_PROPERTY(LayoutMode layoutMode READ layoutMode WRITE setLayoutMode)
00066     Q_PROPERTY(int spacing READ spacing WRITE setSpacing)
00067     Q_PROPERTY(QSize gridSize READ gridSize WRITE setGridSize)
00068     Q_PROPERTY(ViewMode viewMode READ viewMode WRITE setViewMode)
00069     Q_PROPERTY(int modelColumn READ modelColumn WRITE setModelColumn)
00070     Q_PROPERTY(bool uniformItemSizes READ uniformItemSizes WRITE setUniformItemSizes)
00071     Q_PROPERTY(int batchSize READ batchSize WRITE setBatchSize)
00072     Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap)
00073     Q_PROPERTY(bool selectionRectVisible READ isSelectionRectVisible WRITE setSelectionRectVisible)
00074 
00075 public:
00076     enum Movement { Static, Free, Snap };
00077     enum Flow { LeftToRight, TopToBottom };
00078     enum ResizeMode { Fixed, Adjust };
00079     enum LayoutMode { SinglePass, Batched };
00080     enum ViewMode { ListMode, IconMode };
00081 
00082     explicit QListView(QWidget *parent = 0);
00083     ~QListView();
00084 
00085     void setMovement(Movement movement);
00086     Movement movement() const;
00087 
00088     void setFlow(Flow flow);
00089     Flow flow() const;
00090 
00091     void setWrapping(bool enable);
00092     bool isWrapping() const;
00093 
00094     void setResizeMode(ResizeMode mode);
00095     ResizeMode resizeMode() const;
00096 
00097     void setLayoutMode(LayoutMode mode);
00098     LayoutMode layoutMode() const;
00099 
00100     void setSpacing(int space);
00101     int spacing() const;
00102 
00103     void setBatchSize(int batchSize);
00104     int batchSize() const;
00105 
00106     void setGridSize(const QSize &size);
00107     QSize gridSize() const;
00108 
00109     void setViewMode(ViewMode mode);
00110     ViewMode viewMode() const;
00111 
00112     void clearPropertyFlags();
00113 
00114     bool isRowHidden(int row) const;
00115     void setRowHidden(int row, bool hide);
00116 
00117     void setModelColumn(int column);
00118     int modelColumn() const;
00119 
00120     void setUniformItemSizes(bool enable);
00121     bool uniformItemSizes() const;
00122 
00123     void setWordWrap(bool on);
00124     bool wordWrap() const;
00125 
00126     void setSelectionRectVisible(bool show);
00127     bool isSelectionRectVisible() const;
00128 
00129     QRect visualRect(const QModelIndex &index) const;
00130     void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible);
00131     QModelIndex indexAt(const QPoint &p) const;
00132 
00133     void doItemsLayout();
00134     void reset();
00135     void setRootIndex(const QModelIndex &index);
00136 
00137 Q_SIGNALS:
00138     void indexesMoved(const QModelIndexList &indexes);
00139 
00140 protected:
00141     QListView(QListViewPrivate &, QWidget *parent = 0);
00142 
00143     bool event(QEvent *e);
00144 
00145     void scrollContentsBy(int dx, int dy);
00146 
00147     void resizeContents(int width, int height);
00148     QSize contentsSize() const;
00149 
00150     void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
00151     void rowsInserted(const QModelIndex &parent, int start, int end);
00152     void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
00153 
00154     void mouseMoveEvent(QMouseEvent *e);
00155     void mouseReleaseEvent(QMouseEvent *e);
00156 
00157     void timerEvent(QTimerEvent *e);
00158     void resizeEvent(QResizeEvent *e);
00159 #ifndef QT_NO_DRAGANDDROP
00160     void dragMoveEvent(QDragMoveEvent *e);
00161     void dragLeaveEvent(QDragLeaveEvent *e);
00162     void dropEvent(QDropEvent *e);
00163     void startDrag(Qt::DropActions supportedActions);
00164 
00165     void internalDrop(QDropEvent *e);
00166     void internalDrag(Qt::DropActions supportedActions);
00167 #endif // QT_NO_DRAGANDDROP
00168 
00169     QStyleOptionViewItem viewOptions() const;
00170     void paintEvent(QPaintEvent *e);
00171 
00172     int horizontalOffset() const;
00173     int verticalOffset() const;
00174     QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
00175     QRect rectForIndex(const QModelIndex &index) const;
00176     void setPositionForIndex(const QPoint &position, const QModelIndex &index);
00177 
00178     void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command);
00179     QRegion visualRegionForSelection(const QItemSelection &selection) const;
00180     QModelIndexList selectedIndexes() const;
00181 
00182     void updateGeometries();
00183 
00184     bool isIndexHidden(const QModelIndex &index) const;
00185 
00186     void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
00187     void currentChanged(const QModelIndex &current, const QModelIndex &previous);
00188 
00189 private:
00190     friend class QAccessibleItemView;
00191     int visualIndex(const QModelIndex &index) const;
00192 
00193     Q_DECLARE_PRIVATE(QListView)
00194     Q_DISABLE_COPY(QListView)
00195 };
00196 
00197 #endif // QT_NO_LISTVIEW
00198 
00199 QT_END_NAMESPACE
00200 
00201 QT_END_HEADER
00202 
00203 #endif // QLISTVIEW_H