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.
 All Classes Functions Variables Enumerations Enumerator Properties Groups Pages
qadvancedtableview.h
1 /******************************************************************************
2 ** This file is part of qadvanceditemviews.
3 **
4 ** Copyright (c) 2011-2012 Martin Hoppe martin@2x2hoppe.de
5 **
6 ** qadvanceditemviews is free software: you can redistribute it
7 ** and/or modify it under the terms of the GNU Lesser General
8 ** Public License as published by the Free Software Foundation,
9 ** either version 3 of the License, or (at your option) any
10 ** later version.
11 **
12 ** qadvanceditemviews is distributed in the hope that it will be
13 ** useful, but WITHOUT ANY WARRANTY; without even the implied
14 ** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 ** See the GNU General Public License for more details.
16 **
17 ** You should have received a copy of the GNU Lesser General Public
18 ** License along with qadvanceditemviews.
19 ** If not, see <http://www.gnu.org/licenses/>.
20 ******************************************************************************/
21 #ifndef QADVANCEDTABLEVIEW_H
22 #define QADVANCEDTABLEVIEW_H
23 
24 #include <QAbstractItemView>
25 #include <QHeaderView>
26 
27 #include <qaivlib_global.h>
28 #include <qabstractfilter.h>
29 
30 class QFilterView;
32 class QFilterModelProxy;
35 
36 class QAdvancedTableViewPrivate;
37 
38 namespace Ui {
39  class QAdvancedTableView;
40 }
41 
43 
65 class QAIVLIBSHARED_EXPORT QAdvancedTableView : public QWidget
66 {
67  Q_OBJECT
69 
76  Q_PROPERTY(bool alternatingRowColors READ alternatingRowColors WRITE setAlternatingRowColors)
78 
87  Q_PROPERTY(bool autoScroll READ hasAutoScroll WRITE setAutoScroll)
89 
92  Q_PROPERTY(bool dragEnabled READ dragEnabled WRITE setDragEnabled)
94 
99  Q_PROPERTY(QAbstractItemView::EditTriggers editTriggers READ editTriggers WRITE setEditTriggers)
101 
104  Q_PROPERTY(QIcon filterDisabledIcon READ filterDisabledIcon WRITE setFilterDisabledIcon)
106 
109  Q_PROPERTY(QIcon filterEnabledIcon READ filterEnabledIcon WRITE setFilterEnabledIcon)
111 
114  Q_PROPERTY(Qt::PenStyle gridStyle READ gridStyle WRITE setGridStyle)
116 
121  Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
123 
128  Q_PROPERTY(QAbstractItemView::SelectionBehavior selectionBehavior READ selectionBehavior WRITE setSelectionBehavior)
130 
133  Q_PROPERTY(QAbstractItemView::SelectionMode selectionMode READ selectionMode WRITE setSelectionMode)
135 
141  Q_PROPERTY(bool showFilter READ showFilter WRITE setShowFilter)
143 
149  Q_PROPERTY(bool showFixedRows READ showFixedRows WRITE setShowFixedRows)
151 
157  Q_PROPERTY(bool showGrid READ showGrid WRITE setShowGrid)
159  Q_PROPERTY(bool showSortIndicator READ isSortIndicatorShown WRITE setSortIndicatorShown)
161 
167  Q_PROPERTY(bool splitView READ viewSplitted WRITE splitView)
169 
178  Q_PROPERTY(bool sortingEnabled READ isSortingEnabled WRITE setSortingEnabled)
180 
185  Q_PROPERTY(Qt::TextElideMode textElideMode READ textElideMode WRITE setTextElideMode)
187 
194  Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap)
195 public:
199  explicit QAdvancedTableView(QWidget *parent = 0);
208  bool alternatingRowColors() const;
214  int columnAt(int x) const;
220  QVariantList columnsFilterTypes(int column) const;
225  int columnWidth(int column) const;
229  QMenu* createStandardContextMenu(const QModelIndex &index);
234  QModelIndex currentIndex() const;
240  int defaultFilterType(int column) const;
244  bool dragEnabled() const;
249  QAbstractItemView::EditTriggers editTriggers() const;
253  QAbstractFilter* filterAt(int row, int column) const;
254 
255  QIcon filterDisabledIcon() const;
256  QIcon filterEnabledIcon() const;
260  QAbstractFilterModel* filterModel() const;
264  QAbstractFilterProxyModel* filterProxyModel() const;
268  QModelIndexList fixedRows(int column = 0) const;
273  bool hasAutoScroll() const;
277  QHeaderView* horizontalHeader() const;
282  Qt::PenStyle gridStyle() const;
283 
284  QSize iconSize() const;
288  virtual QModelIndex indexAt(const QPoint & point) const;
293  bool isColumnHidden(int column) const;
298  bool showFixedRows() const;
303  bool isRowHidden(int row) const;
307  bool isSortIndicatorShown() const;
312  bool isSortingEnabled() const;
317  QAbstractItemDelegate* itemDelegate() const;
322  QAbstractItemDelegate* itemDelegateForColumn(int column) const;
327  QAbstractItemDelegate* itemDelegateForRow(int row) const;
331  QSize minimumSizeHint() const;
335  QAbstractItemModel* model() const;
340  bool restoreFilter(const QByteArray & data);
344  bool restoreState(const QByteArray & data);
348  QModelIndex rootIndex() const;
353  int rowAt(int y) const;
357  int rowHeight(int row) const;
362  QByteArray saveFilter() const;
367  QByteArray saveState();
368 
369  QAbstractItemView::SelectionBehavior selectionBehavior() const;
374  QAbstractItemView::SelectionMode selectionMode() const;
378  QItemSelectionModel* selectionModel() const;
383  void setAlternatingRowColors(bool enable);
387  void setAutoScroll(bool enable);
392  void setColumnWidth(int column, int width);
396  void setContextMenuPolicy(Qt::ContextMenuPolicy policy);
400  void setDefaultFilterType(int column, int type);
404  void setDefaultFilterType(const QString & name, int type);
408  void setDragEnabled(bool enable);
412  void setEditTriggers(QAbstractItemView::EditTriggers triggers);
417  void setColumnFilterTypes(int column, const QVariantList & types);
418  void setFilterDisabledIcon(const QIcon & icon);
419  void setFilterEnabledIcon(const QIcon & icon);
420  void setFilterModel(QAbstractFilterModel* model);
421  void setFilterProxyModel(QAbstractFilterProxyModel* proxy);
426  bool setFilterType(int type, int column, int row = 0);
431  void setGridStyle(Qt::PenStyle style);
432 
433  void setIconSize(const QSize & size);
438  void setItemDelegate(QAbstractItemDelegate* delegate);
443  void setItemDelegateForColumn(int column, QAbstractItemDelegate * delegate);
448  void setItemDelegateForRow(int row, QAbstractItemDelegate * delegate);
452  void setModel( QAbstractItemModel* model );
456  virtual void setRootIndex(const QModelIndex & index);
461  void setRowHeight(int row, int height);
463  void setSelectionBehavior(QAbstractItemView::SelectionBehavior behavior);
465 
468  void setSelectionMode(QAbstractItemView::SelectionMode mode);
472  void setSortIndicatorShown(bool show);
477  void setSortingEnabled(bool enable);
482  void setTextElideMode(Qt::TextElideMode mode);
486  void setWordWrap(bool wrap);
491  bool showFilter() const;
496  bool showGrid() const;
501  QSize sizeHint() const;
506  void sortByColumn(int column, Qt::SortOrder order);
511  Qt::TextElideMode textElideMode() const;
515  QHeaderView* verticalHeader() const;
520  bool viewSplitted() const;
524  QWidget* viewport() const;
528  bool wordWrap() const;
529 signals:
534  void activated( const QModelIndex & index );
539  void clicked( const QModelIndex & index );
543  void doubleClicked( const QModelIndex & index );
548  void entered( const QModelIndex & index );
554  void pressed( const QModelIndex & index );
558  void viewportEntered();
559 public slots:
563  void addFilterGroup();
568  void clearSelection();
572  void edit(const QModelIndex & index);
577  void hideColumn(int column);
581  void hideColumns(const QStringList & names);
585  void hideFilterView();
590  void hideRow(int row);
595  void resizeColumnToContents(int column);
599  void resizeColumnsToContents();
603  void resizeRowToContents(int row);
607  void resizeRowsToContents();
611  virtual void reset();
616  void scrollToBottom();
621  void scrollToTop();
625  virtual void selectAll();
630  void selectColumn(int colum);
635  void selectRow(int row);
639  void setCurrentIndex(const QModelIndex & index);
644  void setFilterEnabled(int row, int column, bool enable);
649  void setShowFilter(bool show);
654  void setShowFixedRows(bool show);
659  void setShowGrid( bool show );
664  void showColumn(int column);
669  void showRow(int row);
674  void splitView(bool split);
678  void update(const QModelIndex & index);
679 protected:
683  virtual void contextMenuEvent(QContextMenuEvent* event);
687  bool eventFilter(QObject *obj, QEvent *event);
691  void showEvent(QShowEvent* event);
692 private slots:
693  void dataModelLayoutChanged();
694  void dataViewHorizontalScrollBarRangeChanged(int minimum, int maximum);
695  void dataViewHorizontalScrollBarSilderMoved( int value );
696  void dataViewHorizontalScrollBarValueChanged( int value );
697  void filterAdded(const QModelIndex & parent, int start, int end);
698  void headerViewHorizontalScrollBarRangeChanged( int min, int max );
699  void headerViewHorizontalScrollBarSilderMoved( int value );
700  void headerViewHorizontalScrollBarValueChanged( int value );
701  void headerViewSectionResized( int logicalIndex, int oldSize, int newSize );
702  void horizontalHeaderViewSectionMoved( int logicalIndex, int oldVisualIndex, int newVisualIndex );
703  void horizontalHeaderSortIndicatorChanged( int logicalIndex, Qt::SortOrder order );
704  void modelReset();
705  void subviewReceivedFocus();
706  void updateHeaderViewGeometries();
707  void updateHeaderViewVerticalScrollBar( int min, int max );
708  void updateHorizontalHeaderSectionSize();
709  void verticalHeaderSectionClicked(int section);
710 
711  void verticalHeaderSectionResized(int logicalIndex, int oldSize, int newSize);
712  void viewActivated(const QModelIndex & index);
713  void viewClicked(const QModelIndex & index);
714  void viewDoubleClicked(const QModelIndex & index);
715  void viewEntered(const QModelIndex & index);
716  void viewPressed(const QModelIndex & index);
717 private:
718  QModelIndex mapToSource(const QModelIndex & index) const;
719 
720  QAdvancedTableViewPrivate* d;
721 
722  Ui::QAdvancedTableView *ui;
723 };
724 
725 #endif // QADVANCEDTABLEVIEW_H
The QFilterModelProxy provides for filtering or highlighting data passed between a model and a view...
Definition: qfiltermodelproxy.h:34
The QAbstractFilterProxyModel provides an abstract base class for filter models.
Definition: qabstractfilterproxymodel.h:32
The QAdvancedHeaderView class provides a header view to manage to appearance of the related view...
Definition: qadvancedheaderview.h:38
The QAbstractFilterModel class provides the abstract interface for filter model classes.
Definition: qabstractfiltermodel.h:41
The QAbstractFilter class provides a base class for filter definitions used with a QAdvancedTableView...
Definition: qabstractfilter.h:41
The QAdvancedTableView class provides an advanced model/view implementation of a table view...
Definition: qadvancedtableview.h:65
The QFilterView class provides a widget that is used to view and edit filter definitions.
Definition: qfilterview.h:38