src/gui/itemviews/qtableview.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 QTABLEVIEW_H
       
    43 #define QTABLEVIEW_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_TABLEVIEW
       
    54 
       
    55 class QHeaderView;
       
    56 class QTableViewPrivate;
       
    57 
       
    58 class Q_GUI_EXPORT QTableView : public QAbstractItemView
       
    59 {
       
    60     Q_OBJECT
       
    61     Q_PROPERTY(bool showGrid READ showGrid WRITE setShowGrid)
       
    62     Q_PROPERTY(Qt::PenStyle gridStyle READ gridStyle WRITE setGridStyle)
       
    63     Q_PROPERTY(bool sortingEnabled READ isSortingEnabled WRITE setSortingEnabled)
       
    64     Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap)
       
    65     Q_PROPERTY(bool cornerButtonEnabled READ isCornerButtonEnabled WRITE setCornerButtonEnabled)
       
    66 
       
    67 public:
       
    68     explicit QTableView(QWidget *parent = 0);
       
    69     ~QTableView();
       
    70 
       
    71     void setModel(QAbstractItemModel *model);
       
    72     void setRootIndex(const QModelIndex &index);
       
    73     void setSelectionModel(QItemSelectionModel *selectionModel);
       
    74 
       
    75     QHeaderView *horizontalHeader() const;
       
    76     QHeaderView *verticalHeader() const;
       
    77     void setHorizontalHeader(QHeaderView *header);
       
    78     void setVerticalHeader(QHeaderView *header);
       
    79 
       
    80     int rowViewportPosition(int row) const;
       
    81     int rowAt(int y) const;
       
    82 
       
    83     void setRowHeight(int row, int height);
       
    84     int rowHeight(int row) const;
       
    85 
       
    86     int columnViewportPosition(int column) const;
       
    87     int columnAt(int x) const;
       
    88 
       
    89     void setColumnWidth(int column, int width);
       
    90     int columnWidth(int column) const;
       
    91 
       
    92     bool isRowHidden(int row) const;
       
    93     void setRowHidden(int row, bool hide);
       
    94 
       
    95     bool isColumnHidden(int column) const;
       
    96     void setColumnHidden(int column, bool hide);
       
    97 
       
    98     void setSortingEnabled(bool enable);
       
    99     bool isSortingEnabled() const;
       
   100 
       
   101     bool showGrid() const;
       
   102 
       
   103     Qt::PenStyle gridStyle() const;
       
   104     void setGridStyle(Qt::PenStyle style);
       
   105 
       
   106     void setWordWrap(bool on);
       
   107     bool wordWrap() const;
       
   108 
       
   109     void setCornerButtonEnabled(bool enable);
       
   110     bool isCornerButtonEnabled() const;
       
   111 
       
   112     QRect visualRect(const QModelIndex &index) const;
       
   113     void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible);
       
   114     QModelIndex indexAt(const QPoint &p) const;
       
   115 
       
   116     void setSpan(int row, int column, int rowSpan, int columnSpan);
       
   117     int rowSpan(int row, int column) const;
       
   118     int columnSpan(int row, int column) const;
       
   119     void clearSpans();
       
   120 
       
   121     void sortByColumn(int column, Qt::SortOrder order);
       
   122 
       
   123 public Q_SLOTS:
       
   124     void selectRow(int row);
       
   125     void selectColumn(int column);
       
   126     void hideRow(int row);
       
   127     void hideColumn(int column);
       
   128     void showRow(int row);
       
   129     void showColumn(int column);
       
   130     void resizeRowToContents(int row);
       
   131     void resizeRowsToContents();
       
   132     void resizeColumnToContents(int column);
       
   133     void resizeColumnsToContents();
       
   134     void sortByColumn(int column);
       
   135     void setShowGrid(bool show);
       
   136 
       
   137 protected Q_SLOTS:
       
   138     void rowMoved(int row, int oldIndex, int newIndex);
       
   139     void columnMoved(int column, int oldIndex, int newIndex);
       
   140     void rowResized(int row, int oldHeight, int newHeight);
       
   141     void columnResized(int column, int oldWidth, int newWidth);
       
   142     void rowCountChanged(int oldCount, int newCount);
       
   143     void columnCountChanged(int oldCount, int newCount);
       
   144 
       
   145 protected:
       
   146     QTableView(QTableViewPrivate &, QWidget *parent);
       
   147     void scrollContentsBy(int dx, int dy);
       
   148 
       
   149     QStyleOptionViewItem viewOptions() const;
       
   150     void paintEvent(QPaintEvent *e);
       
   151 
       
   152     void timerEvent(QTimerEvent *event);
       
   153 
       
   154     int horizontalOffset() const;
       
   155     int verticalOffset() const;
       
   156     QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
       
   157 
       
   158     void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command);
       
   159     QRegion visualRegionForSelection(const QItemSelection &selection) const;
       
   160     QModelIndexList selectedIndexes() const;
       
   161 
       
   162     void updateGeometries();
       
   163 
       
   164     int sizeHintForRow(int row) const;
       
   165     int sizeHintForColumn(int column) const;
       
   166 
       
   167     void verticalScrollbarAction(int action);
       
   168     void horizontalScrollbarAction(int action);
       
   169 
       
   170     bool isIndexHidden(const QModelIndex &index) const;
       
   171 
       
   172     void selectionChanged(const QItemSelection &selected,
       
   173                           const QItemSelection &deselected);
       
   174     void currentChanged(const QModelIndex &current,
       
   175                           const QModelIndex &previous);
       
   176 
       
   177 private:
       
   178     friend class QAccessibleItemView;
       
   179     int visualIndex(const QModelIndex &index) const;
       
   180 
       
   181     Q_DECLARE_PRIVATE(QTableView)
       
   182     Q_DISABLE_COPY(QTableView)
       
   183     Q_PRIVATE_SLOT(d_func(), void _q_selectRow(int))
       
   184     Q_PRIVATE_SLOT(d_func(), void _q_selectColumn(int))
       
   185     Q_PRIVATE_SLOT(d_func(), void _q_updateSpanInsertedRows(QModelIndex,int,int))
       
   186     Q_PRIVATE_SLOT(d_func(), void _q_updateSpanInsertedColumns(QModelIndex,int,int))
       
   187     Q_PRIVATE_SLOT(d_func(), void _q_updateSpanRemovedRows(QModelIndex,int,int))
       
   188     Q_PRIVATE_SLOT(d_func(), void _q_updateSpanRemovedColumns(QModelIndex,int,int))
       
   189 };
       
   190 
       
   191 #endif // QT_NO_TABLEVIEW
       
   192 
       
   193 QT_END_NAMESPACE
       
   194 
       
   195 QT_END_HEADER
       
   196 
       
   197 #endif // QTABLEVIEW_H