16 #include <QHeaderView>
37 , mCurrentEditSelectionModel( NULL )
38 , mFeatureSelectionModel( NULL )
39 , mItemDelegate( NULL )
40 , mEditSelectionDrag( false )
42 setSelectionMode( QAbstractItemView::ExtendedSelection );
52 QListView::setModel( featureListModel );
118 QPoint pos =
event->pos();
120 QModelIndex
index = indexAt( pos );
137 if ( isVisible() && updatesEnabled() )
141 viewport()->update( visualRegionForSelection( localDeselected ) | visualRegionForSelection( localSelected ) );
145 if ( currentSelection.size() == 1 )
147 QModelIndexList indexList = currentSelection.indexes();
148 if ( !indexList.isEmpty() )
160 QItemSelection selection;
168 QItemSelection selection;
193 foreach (
const QModelIndex
index, indexes )
201 setDirtyRegion( viewport()->rect() );
212 QPoint pos =
event->pos();
214 QModelIndex
index = indexAt( pos );
249 if ( Qt::Key_Up == event->key() || Qt::Key_Down ==
event->key() )
255 currentRow = localIndex.row();
258 QModelIndex newLocalIndex;
259 QModelIndex newIndex;
261 switch ( event->key() )
264 newLocalIndex =
mModel->
index( currentRow - 1, 0 );
266 if ( newIndex.isValid() )
269 scrollTo( newLocalIndex );
274 newLocalIndex =
mModel->
index( currentRow + 1, 0 );
276 if ( newIndex.isValid() )
279 scrollTo( newLocalIndex );
289 QListView::keyPressEvent( event );
295 QItemSelectionModel::SelectionFlags command = selectionCommand( index );
296 int row = index.row();
301 if ( selectionMode() != QListView::SingleSelection
302 && command.testFlag( QItemSelectionModel::Toggle ) )
306 ? QItemSelectionModel::Deselect : QItemSelectionModel::Select;
307 command &= ~QItemSelectionModel::Toggle;
310 command |= QItemSelectionModel::Current;
313 QModelIndex tl = model()->index( qMin(
mRowAnchor, row ), 0 );
314 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.
void setCurrentFeatureEdited(bool state)
Sets if the currently shown form has received any edit events so far.
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
void aboutToChangeEditSelection(bool &ok)
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.
void setCurrentFeatureEdited(bool state)
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.