QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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  virtual void contextMenuEvent( QContextMenuEvent *event );
123 
124  signals:
130  void currentEditSelectionChanged( QgsFeature &feat );
131 
136  void displayExpressionChanged( const QString expression );
137 
138  void aboutToChangeEditSelection( bool& ok );
139 
140  public slots:
146  void setEditSelection( const QgsFeatureIds &fids );
147 
154  void setEditSelection( const QModelIndex& index, QItemSelectionModel::SelectionFlags command );
155 
159  virtual void selectAll();
160 
161  void repaintRequested( QModelIndexList indexes );
162  void repaintRequested();
163 
164  private slots:
165  void editSelectionChanged( QItemSelection deselected, QItemSelection selected );
166 
167  private:
168  void selectRow( const QModelIndex &index, bool anchor );
169 
170  QgsFeatureListModel *mModel;
171  QItemSelectionModel* mCurrentEditSelectionModel;
172  QgsFeatureSelectionModel* mFeatureSelectionModel;
173  QgsFeatureListViewDelegate* mItemDelegate;
174  bool mEditSelectionDrag; // Is set to true when the user initiated a left button click over an edit button and still keeps pressing /**< TODO */
175  int mRowAnchor;
176  QItemSelectionModel::SelectionFlags mCtrlDragSelectionFlag;
177 };
178 
179 #endif
static unsigned index
Definition: mersenne-twister.cpp:36
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeature.h:325
Definition: qgsattributetablefiltermodel.h:31
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...
Definition: qgsattributetablemodel.h:45
Definition: qgsfeatureselectionmodel.h:12
Definition: qgsfeaturelistviewdelegate.h:14
Shows a list of features and renders a edit button next to each feature.
Definition: qgsfeaturelistview.h:41
QgsFeatureListModel * featureListModel()
Get the featureListModel used by this view.
Definition: qgsfeaturelistview.h:75
Definition: qgsfeaturelistmodel.h:17
virtual ~QgsFeatureListView()
Destructor.
Definition: qgsfeaturelistview.h:56
This class caches features of a given QgsVectorLayer.
Definition: qgsvectorlayercache.h:38
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:470