QAdvanced Item View
0.4
The QAIV (Qt Advanced Item Views) library provides GUI and utility classes extending the capabilities of the Qt item views.
|
The QAdvancedTableView class provides an advanced model/view implementation of a table view. More...
#include <qadvancedtableview.h>
Public Slots | |
void | addFilterGroup () |
void | clearSelection () |
void | edit (const QModelIndex &index) |
void | hideColumn (int column) |
void | hideColumns (const QStringList &names) |
void | hideFilterView () |
void | hideRow (int row) |
void | resizeColumnToContents (int column) |
void | resizeColumnsToContents () |
void | resizeRowToContents (int row) |
void | resizeRowsToContents () |
virtual void | reset () |
void | scrollToBottom () |
void | scrollToTop () |
virtual void | selectAll () |
void | selectColumn (int colum) |
void | selectRow (int row) |
void | setCurrentIndex (const QModelIndex &index) |
void | setFilterEnabled (int row, int column, bool enable) |
void | setShowFilter (bool show) |
void | setShowFixedRows (bool show) |
void | setShowGrid (bool show) |
void | showColumn (int column) |
void | showRow (int row) |
void | splitView (bool split) |
void | update (const QModelIndex &index) |
Signals | |
void | activated (const QModelIndex &index) |
void | clicked (const QModelIndex &index) |
void | doubleClicked (const QModelIndex &index) |
void | entered (const QModelIndex &index) |
void | pressed (const QModelIndex &index) |
void | viewportEntered () |
Public Member Functions | |
QAdvancedTableView (QWidget *parent=0) | |
~QAdvancedTableView () | |
bool | alternatingRowColors () const |
int | columnAt (int x) const |
QVariantList | columnsFilterTypes (int column) const |
int | columnWidth (int column) const |
QMenu * | createStandardContextMenu (const QModelIndex &index) |
QModelIndex | currentIndex () const |
int | defaultFilterType (int column) const |
bool | dragEnabled () const |
QAbstractItemView::EditTriggers | editTriggers () const |
QAbstractFilter * | filterAt (int row, int column) const |
QIcon | filterDisabledIcon () const |
QIcon | filterEnabledIcon () const |
QAbstractFilterModel * | filterModel () const |
QAbstractFilterProxyModel * | filterProxyModel () const |
QModelIndexList | fixedRows (int column=0) const |
bool | hasAutoScroll () const |
QHeaderView * | horizontalHeader () const |
Qt::PenStyle | gridStyle () const |
QSize | iconSize () const |
virtual QModelIndex | indexAt (const QPoint &point) const |
bool | isColumnHidden (int column) const |
bool | showFixedRows () const |
bool | isRowHidden (int row) const |
bool | isSortIndicatorShown () const |
bool | isSortingEnabled () const |
QAbstractItemDelegate * | itemDelegate () const |
QAbstractItemDelegate * | itemDelegateForColumn (int column) const |
QAbstractItemDelegate * | itemDelegateForRow (int row) const |
QSize | minimumSizeHint () const |
QAbstractItemModel * | model () const |
bool | restoreFilter (const QByteArray &data) |
bool | restoreState (const QByteArray &data) |
QModelIndex | rootIndex () const |
int | rowAt (int y) const |
int | rowHeight (int row) const |
QByteArray | saveFilter () const |
QByteArray | saveState () |
QAbstractItemView::SelectionBehavior | selectionBehavior () const |
QAbstractItemView::SelectionMode | selectionMode () const |
QItemSelectionModel * | selectionModel () const |
void | setAlternatingRowColors (bool enable) |
void | setAutoScroll (bool enable) |
void | setColumnWidth (int column, int width) |
void | setContextMenuPolicy (Qt::ContextMenuPolicy policy) |
void | setDefaultFilterType (int column, int type) |
void | setDefaultFilterType (const QString &name, int type) |
void | setDragEnabled (bool enable) |
void | setEditTriggers (QAbstractItemView::EditTriggers triggers) |
void | setColumnFilterTypes (int column, const QVariantList &types) |
void | setFilterDisabledIcon (const QIcon &icon) |
void | setFilterEnabledIcon (const QIcon &icon) |
void | setFilterModel (QAbstractFilterModel *model) |
void | setFilterProxyModel (QAbstractFilterProxyModel *proxy) |
bool | setFilterType (int type, int column, int row=0) |
void | setGridStyle (Qt::PenStyle style) |
void | setIconSize (const QSize &size) |
void | setItemDelegate (QAbstractItemDelegate *delegate) |
void | setItemDelegateForColumn (int column, QAbstractItemDelegate *delegate) |
void | setItemDelegateForRow (int row, QAbstractItemDelegate *delegate) |
void | setModel (QAbstractItemModel *model) |
virtual void | setRootIndex (const QModelIndex &index) |
void | setRowHeight (int row, int height) |
void | setSelectionMode (QAbstractItemView::SelectionMode mode) |
void | setSortIndicatorShown (bool show) |
void | setSortingEnabled (bool enable) |
void | setTextElideMode (Qt::TextElideMode mode) |
void | setWordWrap (bool wrap) |
bool | showFilter () const |
bool | showGrid () const |
QSize | sizeHint () const |
void | sortByColumn (int column, Qt::SortOrder order) |
Qt::TextElideMode | textElideMode () const |
QHeaderView * | verticalHeader () const |
bool | viewSplitted () const |
QWidget * | viewport () const |
bool | wordWrap () const |
Protected Member Functions | |
virtual void | contextMenuEvent (QContextMenuEvent *event) |
bool | eventFilter (QObject *obj, QEvent *event) |
void | showEvent (QShowEvent *event) |
Properties | |
bool | alternatingRowColors |
bool | autoScroll |
bool | dragEnabled |
QAbstractItemView::EditTriggers | editTriggers |
QIcon | filterDisabledIcon |
QIcon | filterEnabledIcon |
Qt::PenStyle | gridStyle |
QSize | iconSize |
QAbstractItemView::SelectionBehavior | selectionBehavior |
QAbstractItemView::SelectionMode | selectionMode |
bool | showFilter |
bool | showFixedRows |
bool | showGrid |
bool | showSortIndicator |
bool | splitView |
bool | sortingEnabled |
Qt::TextElideMode | textElideMode |
bool | wordWrap |
The QAdvancedTableView class provides an advanced model/view implementation of a table view.
QAdvancedTableView is not deribed from QAbstractItemView, but the current implementation provides maximum compatibility with QAbstractItemView.
QAdvancedTableView provides the following features.
With all features disabled, the QAbvancedTableView provides with same look and feel as Qt's QTableView class.
The visibility of the filter is controlled with setShowFilter().
A list
|
explicit |
Constructs a filter table view with a parent
to represent the data.
QAdvancedTableView::~QAdvancedTableView | ( | ) |
Destroys the filter table view.
|
signal |
This signal is emitted when the item specified by index is activated by the user. How to activate items depends on the platform; e.g., by single- or double-clicking the item, or by pressing the Return or Enter key when the item is current.
|
slot |
Adds the an empty filter group.
bool QAdvancedTableView::alternatingRowColors | ( | ) | const |
Returns true if alternating row colors are displayed. Otherwise false.
|
slot |
Deselects all selected items. The current index will not be changed.
|
signal |
This signal is emitted when a mouse button is clicked. The item the mouse was clicked on is specified by index. The signal is only emitted when the index is valid.
int QAdvancedTableView::columnAt | ( | int | x | ) | const |
Returns the column in which the given x-coordinate, x
, in contents coordinates is located.
QVariantList QAdvancedTableView::columnsFilterTypes | ( | int | column | ) | const |
Returns a list filter types allowed for the specfied column
. The list is empty if the specified column
does not exists or all types are allowed.
int QAdvancedTableView::columnWidth | ( | int | column | ) | const |
Returns the width of the given column
.
|
protectedvirtual |
QWidget::contextMenuEvent().
QModelIndex QAdvancedTableView::currentIndex | ( | ) | const |
Returns the model index of the current item.
int QAdvancedTableView::defaultFilterType | ( | int | column | ) | const |
Returns the default filter type set for the given column
. Returns -1 if no default filter type is set or the given column
does not exists.
|
signal |
This signal is emitted when a mouse button is double-clicked. The item the mouse was double-clicked on is specified by index. The signal is only emitted when the index is valid.
bool QAdvancedTableView::dragEnabled | ( | ) | const |
Returns true if drag is enabled. Otherwise false.
|
slot |
Starts editing the item corresponding to the given qp index if it is editable.
QAbstractItemView::EditTriggers QAdvancedTableView::editTriggers | ( | ) | const |
Returns the current edit trigger settings.
|
signal |
This signal is emitted when the mouse cursor enters the item specified by index. Mouse tracking needs to be enabled for this feature to work.
|
protected |
QWidget::contextMenuEvent().
QAbstractFilter * QAdvancedTableView::filterAt | ( | int | row, |
int | column | ||
) | const |
Returns the filter at the specified row
and column
, or 0 if no filter exists at row
and column
.
QAbstractFilterModel * QAdvancedTableView::filterModel | ( | ) | const |
Returns the filter model that this view is using for filtering.
QAbstractFilterProxyModel * QAdvancedTableView::filterProxyModel | ( | ) | const |
Retunr the filter proxy model that this view is using.
QModelIndexList QAdvancedTableView::fixedRows | ( | int | column = 0 | ) | const |
Returns the indexes in the given column
for the rows where all columns are fixed.
Qt::PenStyle QAdvancedTableView::gridStyle | ( | ) | const |
Returns the style used when drawing the grid.
bool QAdvancedTableView::hasAutoScroll | ( | ) | const |
Returns true if autoscrolling in drag move events is enabled.
|
slot |
Hide the given column
.
|
slot |
Hide the columns specified by the list of column names
.
|
slot |
Hides the filter view.
|
slot |
Hide the given row
.
QHeaderView * QAdvancedTableView::horizontalHeader | ( | ) | const |
Returns the table view's horizontal header.
|
virtual |
Returns the model index of the item at the viewport coordinates point
.
bool QAdvancedTableView::isColumnHidden | ( | int | column | ) | const |
Returns true if the given column
is hidden; otherwise returns false.
bool QAdvancedTableView::isRowHidden | ( | int | row | ) | const |
Returns true if the given row
is hidden; otherwise returns false.
bool QAdvancedTableView::isSortIndicatorShown | ( | ) | const |
Returns true if the sort indicator is shown. Otherwise false.
bool QAdvancedTableView::isSortingEnabled | ( | ) | const |
Returns true if sorting is enabled. Otherwise false.
QAbstractItemDelegate * QAdvancedTableView::itemDelegate | ( | ) | const |
Returns the item delegate used by this view and model. This is either one set with setItemDelegate(), or the default one.
QAbstractItemDelegate * QAdvancedTableView::itemDelegateForColumn | ( | int | column | ) | const |
Returns the item delegate used by this view and model for the given column
. You can call itemDelegate() to get a pointer to the current delegate for a given index.
QAbstractItemDelegate * QAdvancedTableView::itemDelegateForRow | ( | int | row | ) | const |
Returns the item delegate used by this view and model for the given row
, or 0 if no delegate has been assigned. You can call itemDelegate() to get a pointer to the current delegate for a given index.
QSize QAdvancedTableView::minimumSizeHint | ( | ) | const |
QWidget::minimumSizeHint()
QAbstractItemModel * QAdvancedTableView::model | ( | ) | const |
Returns the model used by this view.
|
signal |
This signal is emitted when a mouse button is pressed. The item the mouse was pressed on is specified by index
. The signal is only emitted when the index
is valid. Use the QApplication::mouseButtons() function to get the state of the mouse buttons.
|
virtualslot |
Reset the internal state of the view.
|
slot |
Resizes all columns based on the size hints of the delegate used to render each item in the columns.
|
slot |
Resizes the given column
based on the size hints of the delegate used to render each item in the column.
|
slot |
Resizes all rows based on the size hints of the delegate used to render each item in the rows.
|
slot |
Resizes the given row
based on the size hints of the delegate used to render each item in the row.
bool QAdvancedTableView::restoreFilter | ( | const QByteArray & | data | ) |
Restores the filter definition of this table view. This function returns true if the filter definition was restored; otherwise returns false.
bool QAdvancedTableView::restoreState | ( | const QByteArray & | data | ) |
Restores the state of this advanced table view. This function returns true if the state was restored; otherwise returns false.
QModelIndex QAdvancedTableView::rootIndex | ( | ) | const |
Returns the model index of the model's root item. The root item is the parent item to the view's toplevel items. The root can be invalid.
int QAdvancedTableView::rowAt | ( | int | y | ) | const |
Returns the row in which the given y-coordinate, y
, in contents coordinates is located.
int QAdvancedTableView::rowHeight | ( | int | row | ) | const |
Returns the height of the given row
.
QByteArray QAdvancedTableView::saveFilter | ( | ) | const |
Saves the current filter definition of this table view.
QByteArray QAdvancedTableView::saveState | ( | ) |
Saves the current state of this advanced table view.
|
slot |
Scrolls the view to the bottom.
|
slot |
Scrolls the view to the top.
|
virtualslot |
Selects all items in the view. This function will use the selection behavior set on the view when selecting.
|
slot |
Selects the given column
in the table view if the current SelectionMode and SelectionBehavior allows columns to be selected.
QAbstractItemView::SelectionMode QAdvancedTableView::selectionMode | ( | ) | const |
Returns the current selection mode
QItemSelectionModel * QAdvancedTableView::selectionModel | ( | ) | const |
Returns the current selection model.
|
slot |
Selects the given row
in the table view if the current SelectionMode and SelectionBehavior allows rows to be selected.
void QAdvancedTableView::setAlternatingRowColors | ( | bool | enable | ) |
If enable
is true, the item background will be drawn using QPalette::Base and QPalette::AlternateBase; otherwise the background will be drawn using the QPalette::Base color.
void QAdvancedTableView::setAutoScroll | ( | bool | enable | ) |
If enable
is true auto scroll is enabled.
void QAdvancedTableView::setColumnFilterTypes | ( | int | column, |
const QVariantList & | types | ||
) |
Sets the list of available filter types
for the given column
.
void QAdvancedTableView::setColumnWidth | ( | int | column, |
int | width | ||
) |
Sets the width of the given column
to be width
.
void QAdvancedTableView::setContextMenuPolicy | ( | Qt::ContextMenuPolicy | policy | ) |
Sets the custom context menu policy to policy
.
|
slot |
Sets the current item to be the item at index
.
void QAdvancedTableView::setDefaultFilterType | ( | int | column, |
int | type | ||
) |
Sets the default filter type
for the specified column
.
void QAdvancedTableView::setDefaultFilterType | ( | const QString & | name, |
int | type | ||
) |
Sets the default filter type
for the specified column
.
void QAdvancedTableView::setDragEnabled | ( | bool | enable | ) |
If is
true drag is enabled.
void QAdvancedTableView::setEditTriggers | ( | QAbstractItemView::EditTriggers | triggers | ) |
Sets the current item to be the item at index
.
|
slot |
If is
true the filter specified by the given row
and column
is enabled.
row
and column
specify a cell in the view's filter view. bool QAdvancedTableView::setFilterType | ( | int | type, |
int | column, | ||
int | row = 0 |
||
) |
Sets the filter type
for the specified column
.
void QAdvancedTableView::setGridStyle | ( | Qt::PenStyle | style | ) |
This property holds the pen style
used to draw the grid.
void QAdvancedTableView::setItemDelegate | ( | QAbstractItemDelegate * | delegate | ) |
Sets the item delegate for this view and its model to delegate
. This is useful if you want complete control over the editing and display of items.
void QAdvancedTableView::setItemDelegateForColumn | ( | int | column, |
QAbstractItemDelegate * | delegate | ||
) |
Sets the given item delegate used by this view and model for the given column. All items on column will be drawn and managed by delegate instead of using the default delegate (i.e., itemDelegate()).
void QAdvancedTableView::setItemDelegateForRow | ( | int | row, |
QAbstractItemDelegate * | delegate | ||
) |
Sets the given item delegate used by this view and model for the given row. All items on row will be drawn and managed by delegate instead of using the default delegate (i.e., itemDelegate()).
void QAdvancedTableView::setModel | ( | QAbstractItemModel * | model | ) |
Sets the model
for the view to present.
|
virtual |
Sets the model's root index
.
void QAdvancedTableView::setRowHeight | ( | int | row, |
int | height | ||
) |
Sets the height of the given row
to be height
.
void QAdvancedTableView::setSelectionMode | ( | QAbstractItemView::SelectionMode | mode | ) |
Sets the selection mode
.
|
slot |
If visible
is true the filter is shown. Otherwise the filter is hidden.
|
slot |
Enables the fixed rows mode if on
is true.
|
slot |
If show
is true a grid is drawn for the table. Otherwise no grid is drawn.
void QAdvancedTableView::setSortIndicatorShown | ( | bool | show | ) |
If show
is true a sort indicator is shown.
void QAdvancedTableView::setSortingEnabled | ( | bool | enable | ) |
If enable
is true sorting i::s enabled. Otherwise sorting is disabled.
void QAdvancedTableView::setTextElideMode | ( | Qt::TextElideMode | mode | ) |
Set the text elide mode to mode
.
void QAdvancedTableView::setWordWrap | ( | bool | wrap | ) |
If wrap
is true word wrapping is enabled.
|
slot |
Show the given column
.
|
protected |
QWidget::contextMenuEvent().
bool QAdvancedTableView::showFilter | ( | ) | const |
Returns true if the filter are shown. Otherwise false.
bool QAdvancedTableView::showFixedRows | ( | ) | const |
Returns true if the fixed rows are show. Otherwise false.
bool QAdvancedTableView::showGrid | ( | ) | const |
Returns true if the show is shwon. Otherwise false.
|
slot |
Show the given row
.
QSize QAdvancedTableView::sizeHint | ( | ) | const |
Returns true if the filter are shown. Otherwise false.
void QAdvancedTableView::sortByColumn | ( | int | column, |
Qt::SortOrder | order | ||
) |
Sorts the model by the values in the given column
in the given order
.
|
slot |
Splits view if split
is true.
Qt::TextElideMode QAdvancedTableView::textElideMode | ( | ) | const |
Return the vies's text elide mode.
|
slot |
Updates the area occupied by the given index
.
QHeaderView * QAdvancedTableView::verticalHeader | ( | ) | const |
Returns the table view's vertical header.
QWidget * QAdvancedTableView::viewport | ( | ) | const |
Returns the viewport widget.
|
signal |
This function is used to handle tool tips, and What's This? mode, if the given event is a QEvent::ToolTip,or a QEvent::WhatsThis. It passes all other events on to its base class viewportEvent() handler.
bool QAdvancedTableView::viewSplitted | ( | ) | const |
Returns true if the view is splitted. Otherwise false.
bool QAdvancedTableView::wordWrap | ( | ) | const |
Returns true if word wrap is enabled. Otherwise false.
|
readwrite |
This property holds whether to draw the background using alternating colors.
By default this property is false.
|
readwrite |
This property holds whether autoscrolling in drag move events is enabled.
If this property is set to true (the default), the QAbstractItemView automatically scrolls the contents of the view if the user drags within 16 pixels of the viewport edge. If the current item changes, then the view will scroll automatically to ensure that the current item is fully visible.
This property only works if the viewport accepts drops. Autoscroll is switched off by setting this property to false.
|
readwrite |
This property holds whether the view supports dragging of its own items.
|
readwrite |
This property holds which actions will initiate item editing.
This property is a selection of flags defined by EditTrigger, combined using the OR operator. The view will only initiate the editing of an item if the action performed is set in this property.
|
readwrite |
This property holds the icon shown if a filter is disabled.
|
readwrite |
This property holds the icon shown if a filter is enabled.
|
readwrite |
This property holds the pen style used to draw the grid.
|
readwrite |
This property holds the size of items' icons.
Setting this property when the view is visible will cause the items to be laid out again.
|
readwrite |
This property holds which selection behavior the view uses. This property holds whether selections are done in terms of single items, rows or columns.
|
readwrite |
This property holds which selection mode the view operates in.
|
readwrite |
This property holds whether the filter are shown. If this property is true the filter are visible; if the property is false, no filter are shown. The default value is true.
|
readwrite |
This property holds whether fixed rows are shown. If this property is true fixed rows are show as a seperate table view above the main view; if the property is false, no fixed rows are shown. The default value is false.
|
readwrite |
This property holds whether the grid is shown. If this property is true a grid is drawn for the table; if the property is false, no grid is drawn. The default value is true.
|
readwrite |
This property holds whether sorting is enabled.
If this property is true, sorting is enabled for the table. If this property is false, sorting is not enabled. The default value is false.
|
readwrite |
This property holds whether the view is splitted If this property is true is splitted into two table view; if the property is false, a single view is shown. The default value is false.
|
readwrite |
This property holds the position of the "..." in elided text.
The default value for all item views is Qt::ElideRight.
|
readwrite |
This property holds the item text word-wrapping policy.
If this property is true then the item text is wrapped where necessary at word-breaks; otherwise it is not wrapped at all. This property is true by default.
Note that even of wrapping is enabled, the cell will not be expanded to fit all text. Ellipsis will be inserted according to the current textElideMode.