src/gui/itemviews/qlistview.h
changeset 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the QtGui module of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    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 **
       
    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.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #ifndef QLISTVIEW_H
       
    43 #define QLISTVIEW_H
       
    44 
       
    45 #include <QtGui/qabstractitemview.h>
       
    46 
       
    47 QT_BEGIN_HEADER
       
    48 
       
    49 QT_BEGIN_NAMESPACE
       
    50 
       
    51 QT_MODULE(Gui)
       
    52 
       
    53 #ifndef QT_NO_LISTVIEW
       
    54 
       
    55 class QListViewPrivate;
       
    56 
       
    57 class Q_GUI_EXPORT QListView : public QAbstractItemView
       
    58 {
       
    59     Q_OBJECT
       
    60     Q_ENUMS(Movement Flow ResizeMode LayoutMode ViewMode)
       
    61     Q_PROPERTY(Movement movement READ movement WRITE setMovement)
       
    62     Q_PROPERTY(Flow flow READ flow WRITE setFlow)
       
    63     Q_PROPERTY(bool isWrapping READ isWrapping WRITE setWrapping)
       
    64     Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode)
       
    65     Q_PROPERTY(LayoutMode layoutMode READ layoutMode WRITE setLayoutMode)
       
    66     Q_PROPERTY(int spacing READ spacing WRITE setSpacing)
       
    67     Q_PROPERTY(QSize gridSize READ gridSize WRITE setGridSize)
       
    68     Q_PROPERTY(ViewMode viewMode READ viewMode WRITE setViewMode)
       
    69     Q_PROPERTY(int modelColumn READ modelColumn WRITE setModelColumn)
       
    70     Q_PROPERTY(bool uniformItemSizes READ uniformItemSizes WRITE setUniformItemSizes)
       
    71     Q_PROPERTY(int batchSize READ batchSize WRITE setBatchSize)
       
    72     Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap)
       
    73     Q_PROPERTY(bool selectionRectVisible READ isSelectionRectVisible WRITE setSelectionRectVisible)
       
    74 
       
    75 public:
       
    76     enum Movement { Static, Free, Snap };
       
    77     enum Flow { LeftToRight, TopToBottom };
       
    78     enum ResizeMode { Fixed, Adjust };
       
    79     enum LayoutMode { SinglePass, Batched };
       
    80     enum ViewMode { ListMode, IconMode };
       
    81 
       
    82     explicit QListView(QWidget *parent = 0);
       
    83     ~QListView();
       
    84 
       
    85     void setMovement(Movement movement);
       
    86     Movement movement() const;
       
    87 
       
    88     void setFlow(Flow flow);
       
    89     Flow flow() const;
       
    90 
       
    91     void setWrapping(bool enable);
       
    92     bool isWrapping() const;
       
    93 
       
    94     void setResizeMode(ResizeMode mode);
       
    95     ResizeMode resizeMode() const;
       
    96 
       
    97     void setLayoutMode(LayoutMode mode);
       
    98     LayoutMode layoutMode() const;
       
    99 
       
   100     void setSpacing(int space);
       
   101     int spacing() const;
       
   102 
       
   103     void setBatchSize(int batchSize);
       
   104     int batchSize() const;
       
   105 
       
   106     void setGridSize(const QSize &size);
       
   107     QSize gridSize() const;
       
   108 
       
   109     void setViewMode(ViewMode mode);
       
   110     ViewMode viewMode() const;
       
   111 
       
   112     void clearPropertyFlags();
       
   113 
       
   114     bool isRowHidden(int row) const;
       
   115     void setRowHidden(int row, bool hide);
       
   116 
       
   117     void setModelColumn(int column);
       
   118     int modelColumn() const;
       
   119 
       
   120     void setUniformItemSizes(bool enable);
       
   121     bool uniformItemSizes() const;
       
   122 
       
   123     void setWordWrap(bool on);
       
   124     bool wordWrap() const;
       
   125 
       
   126     void setSelectionRectVisible(bool show);
       
   127     bool isSelectionRectVisible() const;
       
   128 
       
   129     QRect visualRect(const QModelIndex &index) const;
       
   130     void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible);
       
   131     QModelIndex indexAt(const QPoint &p) const;
       
   132 
       
   133     void doItemsLayout();
       
   134     void reset();
       
   135     void setRootIndex(const QModelIndex &index);
       
   136 
       
   137 Q_SIGNALS:
       
   138     void indexesMoved(const QModelIndexList &indexes);
       
   139 
       
   140 protected:
       
   141     QListView(QListViewPrivate &, QWidget *parent = 0);
       
   142 
       
   143     bool event(QEvent *e);
       
   144 
       
   145     void scrollContentsBy(int dx, int dy);
       
   146 
       
   147     void resizeContents(int width, int height);
       
   148     QSize contentsSize() const;
       
   149 
       
   150     void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
       
   151     void rowsInserted(const QModelIndex &parent, int start, int end);
       
   152     void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
       
   153 
       
   154     void mouseMoveEvent(QMouseEvent *e);
       
   155     void mouseReleaseEvent(QMouseEvent *e);
       
   156 
       
   157     void timerEvent(QTimerEvent *e);
       
   158     void resizeEvent(QResizeEvent *e);
       
   159 #ifndef QT_NO_DRAGANDDROP
       
   160     void dragMoveEvent(QDragMoveEvent *e);
       
   161     void dragLeaveEvent(QDragLeaveEvent *e);
       
   162     void dropEvent(QDropEvent *e);
       
   163     void startDrag(Qt::DropActions supportedActions);
       
   164 
       
   165     void internalDrop(QDropEvent *e);
       
   166     void internalDrag(Qt::DropActions supportedActions);
       
   167 #endif // QT_NO_DRAGANDDROP
       
   168 
       
   169     QStyleOptionViewItem viewOptions() const;
       
   170     void paintEvent(QPaintEvent *e);
       
   171 
       
   172     int horizontalOffset() const;
       
   173     int verticalOffset() const;
       
   174     QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
       
   175     QRect rectForIndex(const QModelIndex &index) const;
       
   176     void setPositionForIndex(const QPoint &position, const QModelIndex &index);
       
   177 
       
   178     void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command);
       
   179     QRegion visualRegionForSelection(const QItemSelection &selection) const;
       
   180     QModelIndexList selectedIndexes() const;
       
   181 
       
   182     void updateGeometries();
       
   183 
       
   184     bool isIndexHidden(const QModelIndex &index) const;
       
   185 
       
   186     void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
       
   187     void currentChanged(const QModelIndex &current, const QModelIndex &previous);
       
   188 
       
   189 private:
       
   190     friend class QAccessibleItemView;
       
   191     int visualIndex(const QModelIndex &index) const;
       
   192 
       
   193     Q_DECLARE_PRIVATE(QListView)
       
   194     Q_DISABLE_COPY(QListView)
       
   195 };
       
   196 
       
   197 #endif // QT_NO_LISTVIEW
       
   198 
       
   199 QT_END_NAMESPACE
       
   200 
       
   201 QT_END_HEADER
       
   202 
       
   203 #endif // QLISTVIEW_H