QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
qgscomposerattributetablemodel.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscomposerattributetablemodel.h
3  --------------------
4  begin : April 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 QGSCOMPOSERATTRIBUTETABLEMODEL_H
19 #define QGSCOMPOSERATTRIBUTETABLEMODEL_H
20 
21 #include <QAbstractTableModel>
22 #include <QSortFilterProxyModel>
23 
26 
27 //QgsComposerAttributeTableColumnModel
28 
30 class CORE_EXPORT QgsComposerAttributeTableColumnModel: public QAbstractTableModel
31 {
32  Q_OBJECT
33 
34  public:
35 
39  {
41  ShiftDown
42  };
43 
48  QgsComposerAttributeTableColumnModel( QgsComposerAttributeTable *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:
121 
122 };
123 
124 
125 //QgsComposerTableSortColumnsProxyModel
126 
128 class CORE_EXPORT QgsComposerTableSortColumnsProxyModel: public QSortFilterProxyModel
129 {
130  Q_OBJECT
131 
132  public:
133 
137  {
139  ShowUnsortedColumns
140  };
141 
147  QgsComposerTableSortColumnsProxyModel( QgsComposerAttributeTable *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 
175 
184  QgsComposerTableColumn* columnFromSourceIndex( const QModelIndex& sourceIndex ) const;
185 
189  void resetFilter();
190 
191  protected:
192  bool filterAcceptsRow( int source_row, const QModelIndex & source_parent ) const;
193 
194  private:
197 
202  QList<QgsComposerTableColumn*> columnsWithoutSortRank() const;
203 
204 };
205 #endif // QGSCOMPOSERATTRIBUTETABLEMODEL_H
static unsigned index
A model for displaying columns shown in a QgsComposerAttributeTable.
Stores properties of a column in a QgsComposerTable.
A table class that displays a vector attribute table.
Allows for filtering QgsComposerAttributeTable columns by columns which are sorted or unsorted...