QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgscomposerattributetablemodelv2.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscomposerattributetablemodelv2.h
3  --------------------
4  begin : September 2014
5  copyright : (C) 2014 by Nyall Dawson
6  email : nyall dot dawson at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGSCOMPOSERATTRIBUTETABLEMODELV2_H
19 #define QGSCOMPOSERATTRIBUTETABLEMODELV2_H
20 
21 #include <QAbstractTableModel>
22 #include <QSortFilterProxyModel>
23 
26 
27 //QgsComposerAttributeTableColumnModelV2
28 
33 {
34  Q_OBJECT
35 
36  public:
37 
41  {
43  ShiftDown
44  };
45 
52 
53  virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
54  int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
55  virtual QVariant data( const QModelIndex &index, int role ) const override;
56  QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override;
57  virtual bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ) override;
58  Qt::ItemFlags flags( const QModelIndex &index ) const override;
59  bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() ) override;
60  bool insertRows( int row, int count, const QModelIndex &parent = QModelIndex() ) override;
61  QModelIndex index( int row, int column, const QModelIndex &parent ) const override;
62  QModelIndex parent( const QModelIndex &child ) const override;
63 
71  bool moveRow( int row, ShiftDirection direction );
72 
77  void resetToLayer();
78 
85  QgsComposerTableColumn* columnFromIndex( const QModelIndex & index ) const;
86 
93  QModelIndex indexFromColumn( QgsComposerTableColumn *column );
94 
103  void setColumnAsSorted( QgsComposerTableColumn *column, Qt::SortOrder order );
104 
111  void setColumnAsUnsorted( QgsComposerTableColumn * column );
112 
119  bool moveColumnInSortRank( QgsComposerTableColumn * column, ShiftDirection direction );
120 
121  private:
122  QgsComposerAttributeTableV2 * mComposerTable;
123 
124 };
125 
126 
127 //QgsComposerTableSortColumnsProxyModelV2
128 
133 {
134  Q_OBJECT
135 
136  public:
137 
141  {
143  ShowUnsortedColumns
144  };
145 
151  QgsComposerTableSortColumnsProxyModelV2( QgsComposerAttributeTableV2 *composerTable, ColumnFilterType filterType, QObject *parent = nullptr );
152 
154 
155  bool lessThan( const QModelIndex &left, const QModelIndex &right ) const override;
156  int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
157  virtual QVariant data( const QModelIndex &index, int role ) const override;
158  QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override;
159  Qt::ItemFlags flags( const QModelIndex &index ) const override;
160  virtual bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ) override;
161 
168  QgsComposerTableColumn* columnFromRow( int row );
169 
177  QgsComposerTableColumn* columnFromIndex( const QModelIndex & index ) const;
178 
187  QgsComposerTableColumn* columnFromSourceIndex( const QModelIndex& sourceIndex ) const;
188 
192  void resetFilter();
193 
194  protected:
195  bool filterAcceptsRow( int source_row, const QModelIndex & source_parent ) const override;
196 
197  private:
198  QgsComposerAttributeTableV2 * mComposerTable;
199  ColumnFilterType mFilterType;
200 
205  QList<QgsComposerTableColumn*> columnsWithoutSortRank() const;
206 
207 };
208 #endif // QGSCOMPOSERATTRIBUTETABLEMODELV2_H
virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const
static unsigned index
virtual int rowCount(const QModelIndex &parent) const=0
ShiftDirection
Controls whether a row/column is shifted up or down.
virtual Qt::ItemFlags flags(const QModelIndex &index) const
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const
A model for displaying columns shown in a QgsComposerAttributeTableV2.
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const
virtual bool insertRows(int row, int count, const QModelIndex &parent)
A table that displays attributes from a vector layer.
Allows for filtering QgsComposerAttributeTable columns by columns which are sorted or unsorted...
virtual int columnCount(const QModelIndex &parent) const
virtual QVariant data(const QModelIndex &index, int role) const=0
Stores properties of a column in a QgsComposerTable.
virtual bool setData(const QModelIndex &index, const QVariant &value, int role)
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const
virtual bool removeRows(int row, int count, const QModelIndex &parent)
virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
ColumnFilterType
Controls whether the proxy model shows sorted or unsorted columns.
virtual int columnCount(const QModelIndex &parent) const=0
virtual bool setData(const QModelIndex &index, const QVariant &value, int role)
virtual Qt::ItemFlags flags(const QModelIndex &index) const
QObject * parent() const
virtual QVariant data(const QModelIndex &index, int role) const
typedef ItemFlags