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
qfixedrowstableview.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 QFIXEDROWSTABLEVIEW_H
22 #define QFIXEDROWSTABLEVIEW_H
23 
24 #include <QHeaderView>
25 #include <QIdentityProxyModel>
26 #include <QPointer>
27 #include <QSortFilterProxyModel>
28 #include <QTableView>
29 
30 #include <qaivlib_global.h>
31 
34 class QFixedRowsDecorationProxyModelPrivate;
35 class QFixedRowsFilterProxyModelPrivate;
36 class QFixedRowsTableViewPrivate;
37 
39 
42 class QAIVLIBSHARED_EXPORT QFixedRowsTableView : public QTableView
43 {
44  Q_OBJECT
46 
51  Q_PROPERTY(bool fixedRowsMode READ fixedRowsMode WRITE setFixedRowsMode)
52 public:
56  QFixedRowsTableView(QWidget* parent = 0);
64  QFixedRowsDecorationProxyModel* decorationProxy() const;
69  bool fixedRowsMode() const;
73  QFixedRowsFilterProxyModel* filterProxy() const;
77  void setModel(QAbstractItemModel* model);
78 public slots:
82  void setFixedRowsMode(bool on);
83 signals:
87  void focusReceived();
88 protected:
92  void closeEditor(QWidget* editor, QAbstractItemDelegate::EndEditHint hint);
96  void focusInEvent(QFocusEvent* event);
97 private slots:
98  void updateHeight();
99 
100  void verticalHeaderSectionClicked(int section);
101 private:
102  QFixedRowsTableViewPrivate* d;
103 };
104 
106 
109 class QAIVLIBSHARED_EXPORT QFixedRowsFilterProxyModel : public QSortFilterProxyModel
110 {
111  Q_OBJECT
112 public:
116  QFixedRowsFilterProxyModel(QObject *parent = 0);
124  void clear();
128  bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
132  QVariant headerData(int section, Qt::Orientation orientation, int role) const;
136  bool isEnabled() const;
140  bool isRowPinned(int row) const;
141 public slots:
145  void setEnabled(bool on);
149  void sourceModelReset();
153  void toggleRow(const QModelIndex & index);
157  void setRowFixed(const QModelIndex & index, bool fixed);
158 private:
159  QFixedRowsFilterProxyModelPrivate* d;
160 };
161 
163 class QAIVLIBSHARED_EXPORT QFixedRowsDecorationProxyModel : public QIdentityProxyModel
164 {
165  Q_OBJECT
166 public:
170  QFixedRowsDecorationProxyModel(QFixedRowsFilterProxyModel* filterProxy, QObject* parent = 0);
178  QVariant headerData(int section, Qt::Orientation orientation, int role) const;
179 
180  QSize iconSize() const;
184  bool isEnabled() const;
185 signals:
190  void modelToggled(bool on);
191 public slots:
195  void setEnabled(bool on);
196  void toggleRow(const QModelIndex & index);
197 private:
198  QFixedRowsDecorationProxyModelPrivate* d;
199 };
200 
201 #endif // QFIXEDROWSTABLEVIEW_H
The class QFixedRowsTableView implements a table view with fixed (pinned) rows.
Definition: qfixedrowstableview.h:42
The QFixedRowsDecorationProxyModel class implements a decoration proxy model.
Definition: qfixedrowstableview.h:163
The QFixedRowsFilterProxyModel class implements a proxy model supporting fixed (pinned) rows...
Definition: qfixedrowstableview.h:109