18 #include <QHeaderView>
36 , mCurrentEditSelectionModel( NULL )
37 , mFeatureSelectionModel( NULL )
38 , mItemDelegate( NULL )
39 , mEditSelectionDrag( false )
41 setSelectionMode( QAbstractItemView::ExtendedSelection );
51 QListView::setModel( featureListModel );
101 QPoint pos =
event->pos();
103 QModelIndex index = indexAt( pos );
120 if ( isVisible() && updatesEnabled() )
124 viewport()->update( visualRegionForSelection( localDeselected ) | visualRegionForSelection( localSelected ) );
128 if ( currentSelection.size() == 1 )
139 QItemSelection selection;
147 QItemSelection selection;
159 foreach (
const QModelIndex index, indexes )
167 setDirtyRegion( viewport()->rect() );
178 QPoint pos =
event->pos();
180 QModelIndex index = indexAt( pos );
215 if ( Qt::Key_Up == event->key() || Qt::Key_Down ==
event->key() )
221 currentRow = localIndex.row();
224 QModelIndex newLocalIndex;
225 QModelIndex newIndex;
227 switch ( event->key() )
230 newLocalIndex =
mModel->
index( currentRow - 1, 0 );
232 if ( newIndex.isValid() )
235 scrollTo( newLocalIndex );
240 newLocalIndex =
mModel->
index( currentRow + 1, 0 );
242 if ( newIndex.isValid() )
245 scrollTo( newLocalIndex );
255 QListView::keyPressEvent( event );
261 QItemSelectionModel::SelectionFlags command = selectionCommand( index );
262 int row = index.row();
267 if ( selectionMode() != QListView::SingleSelection
268 && command.testFlag( QItemSelectionModel::Toggle ) )
272 ? QItemSelectionModel::Deselect : QItemSelectionModel::Select;
273 command &= ~QItemSelectionModel::Toggle;
276 command |= QItemSelectionModel::Current;
279 QModelIndex tl = model()->index( qMin(
mRowAnchor, row ), 0 );
280 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.
const QString & displayExpression() const
Returns the expression which is currently used to render the features.
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)
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.
QItemSelectionModel::SelectionFlags mCtrlDragSelectionFlag
QgsAttributeTableModel * masterModel()
const QString & displayExpression() const
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.
QgsVectorLayerCache * layerCache()
Returns the layer cache.