Flexible models
This commit is contained in:
parent
50cb21b6f9
commit
8b7bbec807
24 changed files with 333 additions and 51 deletions
35
pglab/PropertyProxyModel.h
Normal file
35
pglab/PropertyProxyModel.h
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#ifndef HORIZONTALPROXYMODEL_H
|
||||
#define HORIZONTALPROXYMODEL_H
|
||||
|
||||
#include <QIdentityProxyModel>
|
||||
|
||||
class PropertyProxyModel : public QIdentityProxyModel {
|
||||
Q_OBJECT
|
||||
public:
|
||||
PropertyProxyModel(QObject * parent = nullptr);
|
||||
QModelIndex mapToSource(const QModelIndex &proxyIndex) const;
|
||||
QModelIndex mapFromSource(const QModelIndex &sourceIndex) const;
|
||||
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
|
||||
QModelIndex parent(const QModelIndex &child) const;
|
||||
int rowCount(const QModelIndex &parent) const;
|
||||
int columnCount(const QModelIndex &parent) const;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
||||
QVariant data(const QModelIndex &proxyIndex, int role) const;
|
||||
|
||||
public Q_SLOTS:
|
||||
/** Updates the model (and view) to show the values for row
|
||||
*
|
||||
* The column part of the index is not used QModelIndex is used to make is eacy to connect to
|
||||
* QItemSelectionModel::currentRowChanged
|
||||
*/
|
||||
void setActiveRow(const QModelIndex &row);
|
||||
|
||||
private:
|
||||
enum Columns {
|
||||
propertyColumn = 0,
|
||||
valueColumn
|
||||
};
|
||||
int activeRow = -1;
|
||||
};
|
||||
|
||||
#endif // HORIZONTALPROXYMODEL_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue