- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# qtableview.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 QTABLEVIEW_H
    00043 #define QTABLEVIEW_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_TABLEVIEW
    00054
    00055 class QHeaderView;
    00056 class QTableViewPrivate;
    00057
    00058 class Q_GUI_EXPORT QTableView : public QAbstractItemView
    00059 {
    00060     Q_OBJECT
    00061     Q_PROPERTY(bool showGrid READ showGrid WRITE setShowGrid)
    00062     Q_PROPERTY(Qt::PenStyle gridStyle READ gridStyle WRITE setGridStyle)
    00063     Q_PROPERTY(bool sortingEnabled READ isSortingEnabled WRITE setSortingEnabled)
    00064     Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap)
    00065     Q_PROPERTY(bool cornerButtonEnabled READ isCornerButtonEnabled WRITE setCornerButtonEnabled)
    00066
    00067 public:
    00068     explicit QTableView(QWidget *parent = 0);
    00069     ~QTableView();
    00070
    00071     void setModel(QAbstractItemModel *model);
    00072     void setRootIndex(const QModelIndex &index);
    00073     void setSelectionModel(QItemSelectionModel *selectionModel);
    00074
    00075     QHeaderView *horizontalHeader() const;
    00076     QHeaderView *verticalHeader() const;
    00077     void setHorizontalHeader(QHeaderView *header);
    00078     void setVerticalHeader(QHeaderView *header);
    00079
    00080     int rowViewportPosition(int row) const;
    00081     int rowAt(int y) const;
    00082
    00083     void setRowHeight(int row, int height);
    00084     int rowHeight(int row) const;
    00085
    00086     int columnViewportPosition(int column) const;
    00087     int columnAt(int x) const;
    00088
    00089     void setColumnWidth(int column, int width);
    00090     int columnWidth(int column) const;
    00091
    00092     bool isRowHidden(int row) const;
    00093     void setRowHidden(int row, bool hide);
    00094
    00095     bool isColumnHidden(int column) const;
    00096     void setColumnHidden(int column, bool hide);
    00097
    00098     void setSortingEnabled(bool enable);
    00099     bool isSortingEnabled() const;
    00100
    00101     bool showGrid() const;
    00102
    00103     Qt::PenStyle gridStyle() const;
    00104     void setGridStyle(Qt::PenStyle style);
    00105
    00106     void setWordWrap(bool on);
    00107     bool wordWrap() const;
    00108
    00109     void setCornerButtonEnabled(bool enable);
    00110     bool isCornerButtonEnabled() const;
    00111
    00112     QRect visualRect(const QModelIndex &index) const;
    00113     void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible);
    00114     QModelIndex indexAt(const QPoint &p) const;
    00115
    00116     void setSpan(int row, int column, int rowSpan, int columnSpan);
    00117     int rowSpan(int row, int column) const;
    00118     int columnSpan(int row, int column) const;
    00119     void clearSpans();
    00120
    00121     void sortByColumn(int column, Qt::SortOrder order);
    00122
    00123 public Q_SLOTS:
    00124     void selectRow(int row);
    00125     void selectColumn(int column);
    00126     void hideRow(int row);
    00127     void hideColumn(int column);
    00128     void showRow(int row);
    00129     void showColumn(int column);
    00130     void resizeRowToContents(int row);
    00131     void resizeRowsToContents();
    00132     void resizeColumnToContents(int column);
    00133     void resizeColumnsToContents();
    00134     void sortByColumn(int column);
    00135     void setShowGrid(bool show);
    00136
    00137 protected Q_SLOTS:
    00138     void rowMoved(int row, int oldIndex, int newIndex);
    00139     void columnMoved(int column, int oldIndex, int newIndex);
    00140     void rowResized(int row, int oldHeight, int newHeight);
    00141     void columnResized(int column, int oldWidth, int newWidth);
    00142     void rowCountChanged(int oldCount, int newCount);
    00143     void columnCountChanged(int oldCount, int newCount);
    00144
    00145 protected:
    00146     QTableView(QTableViewPrivate &, QWidget *parent);
    00147     void scrollContentsBy(int dx, int dy);
    00148
    00149     QStyleOptionViewItem viewOptions() const;
    00150     void paintEvent(QPaintEvent *e);
    00151
    00152     void timerEvent(QTimerEvent *event);
    00153
    00154     int horizontalOffset() const;
    00155     int verticalOffset() const;
    00156     QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
    00157
    00158     void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command);
    00159     QRegion visualRegionForSelection(const QItemSelection &selection) const;
    00160     QModelIndexList selectedIndexes() const;
    00161
    00162     void updateGeometries();
    00163
    00164     int sizeHintForRow(int row) const;
    00165     int sizeHintForColumn(int column) const;
    00166
    00167     void verticalScrollbarAction(int action);
    00168     void horizontalScrollbarAction(int action);
    00169
    00170     bool isIndexHidden(const QModelIndex &index) const;
    00171
    00172     void selectionChanged(const QItemSelection &selected,
    00173                           const QItemSelection &deselected);
    00174     void currentChanged(const QModelIndex &current,
    00175                           const QModelIndex &previous);
    00176
    00177 private:
    00178     friend class QAccessibleItemView;
    00179     int visualIndex(const QModelIndex &index) const;
    00180
    00181     Q_DECLARE_PRIVATE(QTableView)
    00182     Q_DISABLE_COPY(QTableView)
    00183     Q_PRIVATE_SLOT(d_func(), void _q_selectRow(int))
    00184     Q_PRIVATE_SLOT(d_func(), void _q_selectColumn(int))
    00185     Q_PRIVATE_SLOT(d_func(), void _q_updateSpanInsertedRows(QModelIndex,int,int))
    00186     Q_PRIVATE_SLOT(d_func(), void _q_updateSpanInsertedColumns(QModelIndex,int,int))
    00187     Q_PRIVATE_SLOT(d_func(), void _q_updateSpanRemovedRows(QModelIndex,int,int))
    00188     Q_PRIVATE_SLOT(d_func(), void _q_updateSpanRemovedColumns(QModelIndex,int,int))
    00189 };
    00190
    00191 #endif // QT_NO_TABLEVIEW
    00192
    00193 QT_END_NAMESPACE
    00194
    00195 QT_END_HEADER
    00196
    00197 #endif // QTABLEVIEW_H