QGIS API Documentation  2.6.0-Brighton
 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  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