QGIS API Documentation  2.6.0-Brighton
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
30 class CORE_EXPORT QgsComposerAttributeTableColumnModelV2: public QAbstractTableModel
31 {
32  Q_OBJECT
33 
34  public:
35 
39  {
41  ShiftDown
42  };
43 
48  QgsComposerAttributeTableColumnModelV2( QgsComposerAttributeTableV2 *composerTable, QObject *parent = 0 );
50 
51  virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const;
52  int columnCount( const QModelIndex &parent = QModelIndex() ) const;
53  virtual QVariant data( const QModelIndex &index, int role ) const;
54  QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
55  virtual bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole );
56  Qt::ItemFlags flags( const QModelIndex &index ) const;
57  bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() );
58  bool insertRows( int row, int count, const QModelIndex &parent = QModelIndex() );
59  QModelIndex index( int row, int column, const QModelIndex &parent ) const;
60  QModelIndex parent( const QModelIndex &child ) const;
61 
69  bool moveRow( int row, ShiftDirection direction );
70 
75  void resetToLayer();
76 
83  QgsComposerTableColumn* columnFromIndex( const QModelIndex & index ) const;
84 
91  QModelIndex indexFromColumn( QgsComposerTableColumn *column );
92 
101  void setColumnAsSorted( QgsComposerTableColumn *column, Qt::SortOrder order );
102 
109  void setColumnAsUnsorted( QgsComposerTableColumn * column );
110 
117  bool moveColumnInSortRank( QgsComposerTableColumn * column, ShiftDirection direction );
118 
119  private:
120  QgsComposerAttributeTableV2 * mComposerTable;
121 
122 };
123 
124 
125 //QgsComposerTableSortColumnsProxyModelV2
126 
128 class CORE_EXPORT QgsComposerTableSortColumnsProxyModelV2: public QSortFilterProxyModel
129 {
130  Q_OBJECT
131 
132  public:
133 
137  {
139  ShowUnsortedColumns
140  };
141 
147  QgsComposerTableSortColumnsProxyModelV2( QgsComposerAttributeTableV2 *composerTable, ColumnFilterType filterType, QObject *parent = 0 );
148 
150 
151  bool lessThan( const QModelIndex &left, const QModelIndex &right ) const;
152  int columnCount( const QModelIndex &parent = QModelIndex() ) const;
153  virtual QVariant data( const QModelIndex &index, int role ) const;
154  QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
155  Qt::ItemFlags flags( const QModelIndex &index ) const;
156  virtual bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole );
157 
164  QgsComposerTableColumn* columnFromRow( int row );
165 
173  QgsComposerTableColumn* columnFromIndex( const QModelIndex & index ) const;
174 
183  QgsComposerTableColumn* columnFromSourceIndex( const QModelIndex& sourceIndex ) const;
184 
188  void resetFilter();
189 
190  protected:
191  bool filterAcceptsRow( int source_row, const QModelIndex & source_parent ) const;
192 
193  private:
194  QgsComposerAttributeTableV2 * mComposerTable;
195  ColumnFilterType mFilterType;
196 
201  QList<QgsComposerTableColumn*> columnsWithoutSortRank() const;
202 
203 };
204 #endif // QGSCOMPOSERATTRIBUTETABLEMODELV2_H