QGIS API Documentation  2.4.0-Chugiak
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsfeaturelistview.h
Go to the documentation of this file.
1 /***************************************************************************
2  QgsAttributeListView.h
3  --------------------------------------
4  Date : Jan 2012
5  Copyright : (C) 2013 Matthias Kuhn
6  Email : matthias dot kuhn at gmx dot ch
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSATTRIBUTELISTVIEW_H
17 #define QGSATTRIBUTELISTVIEW_H
18 
19 #include <QListView>
20 #include <qdebug.h>
21 
22 #include "qgsfeature.h" // For QgsFeatureIds
23 
28 class QgsVectorLayer;
31 class QRect;
32 
41 class GUI_EXPORT QgsFeatureListView : public QListView
42 {
43  Q_OBJECT
44 
45  public:
51  explicit QgsFeatureListView( QWidget* parent = 0 );
52 
56  virtual ~QgsFeatureListView() {}
57 
62  QgsVectorLayerCache* layerCache();
63 
69  virtual void setModel( QgsFeatureListModel* featureListModel );
75  QgsFeatureListModel* featureListModel() { return mModel; }
76 
85  bool setDisplayExpression( const QString displayExpression );
86 
94  const QString displayExpression() const;
95 
101  QString parserErrorString();
102 
108  QgsFeatureIds currentEditSelection();
109 
115  void setCurrentFeatureEdited( bool state );
116 
117  protected:
118  virtual void mouseMoveEvent( QMouseEvent *event );
119  virtual void mousePressEvent( QMouseEvent *event );
120  virtual void mouseReleaseEvent( QMouseEvent *event );
121  virtual void keyPressEvent( QKeyEvent *event );
122 
123  signals:
129  void currentEditSelectionChanged( QgsFeature &feat );
130 
135  void displayExpressionChanged( const QString expression );
136 
137  void aboutToChangeEditSelection( bool& ok );
138 
139  public slots:
145  void setEditSelection( const QgsFeatureIds &fids );
146 
153  void setEditSelection( const QModelIndex& index, QItemSelectionModel::SelectionFlags command );
154 
158  virtual void selectAll();
159 
160  void repaintRequested( QModelIndexList indexes );
161  void repaintRequested();
162 
163  private slots:
164  void editSelectionChanged( QItemSelection deselected, QItemSelection selected );
165 
166  private:
167  void selectRow( const QModelIndex &index, bool anchor );
168 
170  QItemSelectionModel* mCurrentEditSelectionModel;
173  bool mEditSelectionDrag; // Is set to true when the user initiated a left button click over an edit button and still keeps pressing /**< TODO */
175  QItemSelectionModel::SelectionFlags mCtrlDragSelectionFlag;
176 };
177 
178 #endif
QgsFeatureListViewDelegate * mItemDelegate
static unsigned index
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeature.h:325
QgsFeatureListModel * mModel
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:113
A model backed by a QgsVectorLayerCache which is able to provide feature/attribute information to a Q...
Shows a list of features and renders a edit button next to each feature.
QgsFeatureListModel * featureListModel()
Get the featureListModel used by this view.
QItemSelectionModel * mCurrentEditSelectionModel
virtual ~QgsFeatureListView()
Destructor.
QItemSelectionModel::SelectionFlags mCtrlDragSelectionFlag
This class caches features of a given QgsVectorLayer.
QgsFeatureSelectionModel * mFeatureSelectionModel
Represents a vector layer which manages a vector based data sets.