16 #include <QHeaderView>
37 , mCurrentEditSelectionModel( NULL )
38 , mFeatureSelectionModel( NULL )
39 , mItemDelegate( NULL )
40 , mEditSelectionDrag( false )
42 setSelectionMode( QAbstractItemView::ExtendedSelection );
52 QListView::setModel( featureListModel );
112 QPoint pos =
event->pos();
114 QModelIndex
index = indexAt( pos );
131 if ( isVisible() && updatesEnabled() )
135 viewport()->update( visualRegionForSelection( localDeselected ) | visualRegionForSelection( localSelected ) );
139 if ( currentSelection.size() == 1 )
150 QItemSelection selection;
158 QItemSelection selection;
170 foreach (
const QModelIndex
index, indexes )
178 setDirtyRegion( viewport()->rect() );
189 QPoint pos =
event->pos();
191 QModelIndex
index = indexAt( pos );
226 if ( Qt::Key_Up == event->key() || Qt::Key_Down ==
event->key() )
232 currentRow = localIndex.row();
235 QModelIndex newLocalIndex;
236 QModelIndex newIndex;
238 switch ( event->key() )
241 newLocalIndex =
mModel->
index( currentRow - 1, 0 );
243 if ( newIndex.isValid() )
246 scrollTo( newLocalIndex );
251 newLocalIndex =
mModel->
index( currentRow + 1, 0 );
253 if ( newIndex.isValid() )
256 scrollTo( newLocalIndex );
266 QListView::keyPressEvent( event );
272 QItemSelectionModel::SelectionFlags command = selectionCommand( index );
273 int row = index.row();
278 if ( selectionMode() != QListView::SingleSelection
279 && command.testFlag( QItemSelectionModel::Toggle ) )
283 ? QItemSelectionModel::Deselect : QItemSelectionModel::Select;
284 command &= ~QItemSelectionModel::Toggle;
287 command |= QItemSelectionModel::Current;
290 QModelIndex tl = model()->index( qMin(
mRowAnchor, row ), 0 );
291 QModelIndex br = model()->index( qMax(
mRowAnchor, row ), model()->columnCount() - 1 );
QgsFeatureListViewDelegate * mItemDelegate
virtual bool isSelected(QgsFeatureId fid)
Returns the selection status of a given feature id.
virtual void mouseReleaseEvent(QMouseEvent *event)
QSet< QgsFeatureId > QgsFeatureIds
virtual QModelIndex mapToMaster(const QModelIndex &proxyIndex) const
QgsFeatureListModel * mModel
bool featureByIndex(const QModelIndex &index, QgsFeature &feat)
virtual QModelIndex mapFromMaster(const QModelIndex &sourceIndex) const
QgsVectorLayer * layer()
Returns the layer to which this cache belongs.
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
virtual void mousePressEvent(QMouseEvent *event)
const QString displayExpression() const
Returns the expression which is currently used to render the features.
void enableSync(bool enable)
Enables or disables synchronisation to the QgsVectorLayer When synchronisation is disabled...
QString parserErrorString()
Returns a detailed message about errors while parsing a QgsExpression.
Element positionToElement(const QPoint &pos)
QgsFeatureListView(QWidget *parent=0)
Creates a feature list view.
QgsFeatureListModel * featureListModel()
Get the featureListModel used by this view.
void setFeatureSelectionModel(QgsFeatureSelectionModel *featureSelectionModel)
bool setDisplayExpression(const QString expression)
virtual void mouseMoveEvent(QMouseEvent *event)
QItemSelectionModel * mCurrentEditSelectionModel
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
virtual void selectFeatures(const QItemSelection &selection, SelectionFlags command)
Select features on this table.
QString parserErrorString()
Returns a detailed message about errors while parsing a QgsExpression.
QgsFeatureIds currentEditSelection()
Get the currentEditSelection.
QItemSelectionModel::SelectionFlags mCtrlDragSelectionFlag
QgsAttributeTableModel * masterModel()
void displayExpressionChanged(const QString expression)
Is emitted, whenever the display expression is successfully changed.
This class caches features of a given QgsVectorLayer.
void setEditSelection(const QgsFeatureIds &fids)
Set the feature(s) to be edited.
bool setDisplayExpression(const QString displayExpression)
The display expression is an expression used to render the fields into a single string which is displ...
virtual void keyPressEvent(QKeyEvent *event)
QgsFeatureSelectionModel * mFeatureSelectionModel
virtual void selectAll()
Select all currently visible features.
void selectRow(const QModelIndex &index, bool anchor)
void editSelectionChanged(QItemSelection deselected, QItemSelection selected)
QgsVectorLayerCache * layerCache()
QModelIndex fidToIdx(const QgsFeatureId fid) const
void setEditSelectionModel(QItemSelectionModel *editSelectionModel)
void currentEditSelectionChanged(QgsFeature &feat)
Is emitted, whenever the current edit selection has been changed.
virtual QItemSelection mapSelectionFromMaster(const QItemSelection &selection) const
virtual void setModel(QgsFeatureListModel *featureListModel)
Set the QgsFeatureListModel which is used to retrieve information.
QString displayExpression() const
QgsVectorLayerCache * layerCache()
Returns the layer cache.