16 #include <QHeaderView> 39 , mCurrentEditSelectionModel( nullptr )
40 , mFeatureSelectionModel( nullptr )
41 , mFeatureSelectionManager( nullptr )
42 , mItemDelegate( nullptr )
43 , mEditSelectionDrag( false )
59 delete mFeatureSelectionModel;
62 if ( !mFeatureSelectionManager )
67 mFeatureSelectionModel =
new QgsFeatureSelectionModel( featureListModel, featureListModel, mFeatureSelectionManager,
this );
70 if ( mItemDelegate && mItemDelegate->
parent() == this )
80 connect( mFeatureSelectionModel, SIGNAL( requestRepaint( QModelIndexList ) ),
this, SLOT(
repaintRequested( QModelIndexList ) ) );
137 mEditSelectionDrag =
true;
143 selectRow( index,
true );
163 if ( currentSelection.
size() == 1 )
165 QModelIndexList indexList = currentSelection.
indexes();
166 if ( !indexList.isEmpty() )
181 mFeatureSelectionModel->
selectFeatures( selection, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows );
197 mCurrentEditSelectionModel->
select( selection, QItemSelectionModel::ClearAndSelect );
206 mCurrentEditSelectionModel->
select( index, command );
234 if ( mEditSelectionDrag )
240 selectRow( index,
false );
255 if ( mEditSelectionDrag )
257 mEditSelectionDrag =
false;
261 if ( mFeatureSelectionModel )
268 if ( Qt::Key_Up == event->
key() || Qt::Key_Down ==
event->key() )
274 currentRow = localIndex.
row();
280 switch ( event->
key() )
283 newLocalIndex = mModel->
index( currentRow - 1, 0 );
293 newLocalIndex = mModel->
index( currentRow + 1, 0 );
328 int row = index.
row();
334 && command.testFlag( QItemSelectionModel::Toggle ) )
337 mCtrlDragSelectionFlag = mFeatureSelectionModel->
isSelected( index )
338 ? QItemSelectionModel::Deselect : QItemSelectionModel::Select;
340 command |= mCtrlDragSelectionFlag;
342 command |= QItemSelectionModel::Current;
353 delete mFeatureSelectionManager;
355 mFeatureSelectionManager = featureSelectionManager;
357 if ( mFeatureSelectionModel )
QModelIndexList indexes() const
void setDirtyRegion(const QRegion ®ion)
virtual void setSelectionModel(QItemSelectionModel *selectionModel)
virtual bool isSelected(QgsFeatureId fid)
Returns the selection status of a given feature id.
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const=0
void setCurrentFeatureEdited(bool state)
Sets if the currently shown form has received any edit events so far.
void setSelectionMode(QAbstractItemView::SelectionMode mode)
virtual void mouseReleaseEvent(QMouseEvent *event) override
bool setDisplayExpression(const QString &expression)
bool setDisplayExpression(const QString &displayExpression)
The display expression is an expression used to render the fields into a single string which is displ...
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const override
virtual void setModel(QAbstractItemModel *model)
bool featureByIndex(const QModelIndex &index, QgsFeature &feat)
QgsVectorLayer * layer()
Returns the layer to which this cache belongs.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
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.
virtual QModelIndex mapToMaster(const QModelIndex &proxyIndex) const
Get the feature id of the feature in this row.
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
virtual QRegion visualRegionForSelection(const QItemSelection &selection) const
QgsFeatureListModel * featureListModel()
Get the featureListModel used by this view.
void append(const T &value)
void setFeatureSelectionModel(QgsFeatureSelectionModel *featureSelectionModel)
virtual QVariant data(const QModelIndex &index, int role) const override
void aboutToChangeEditSelection(bool &ok)
const QItemSelection selection() const
QString parserErrorString()
Returns a detailed message about errors while parsing a QgsExpression.
virtual void select(const QModelIndex &index, QFlags< QItemSelectionModel::SelectionFlag > command)
QModelIndexList selectedIndexes() const
void setItemDelegate(QAbstractItemDelegate *delegate)
virtual void setFeatureSelectionManager(QgsIFeatureSelectionManager *featureSelectionManager)
void displayExpressionChanged(const QString &expression)
Is emitted, whenever the display expression is successfully changed.
QString displayExpression() const
void setCurrentFeatureEdited(bool state)
QgsFeatureIds currentEditSelection()
Get the currentEditSelection.
virtual void mouseMoveEvent(QMouseEvent *event) override
QgsAttributeTableModel * masterModel()
virtual QModelIndex mapFromMaster(const QModelIndex &sourceIndex) const
This class caches features of a given QgsVectorLayer.
virtual bool event(QEvent *e)
void setEditSelection(const QgsFeatureIds &fids)
Set the feature(s) to be edited.
virtual QItemSelectionModel::SelectionFlags selectionCommand(const QModelIndex &index, const QEvent *event) const
const QString displayExpression() const
Returns the expression which is currently used to render the features.
virtual void selectFeatures(const QItemSelection &selection, const SelectionFlags &command)
Select features on this table.
virtual QModelIndex indexAt(const QPoint &p) const
virtual void selectAll() override
Select all currently visible features.
QVariant data(int role) const
virtual void mousePressEvent(QMouseEvent *event) override
QModelIndex fidToIdx(const QgsFeatureId fid) const
void setFeatureSelectionManager(QgsIFeatureSelectionManager *featureSelectionManager)
setFeatureSelectionManager
virtual void contextMenuEvent(QContextMenuEvent *event) override
virtual void keyPressEvent(QKeyEvent *event) override
virtual QItemSelection mapSelectionFromMaster(const QItemSelection &selection) const
QgsFeatureListView(QWidget *parent=nullptr)
Creates a feature list view.
QgsVectorLayerCache * layerCache()
Element positionToElement(QPoint pos)
virtual void keyPressEvent(QKeyEvent *event)
const QPoint & pos() const
QAbstractItemModel * model() const
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void setEditSelectionModel(QItemSelectionModel *editSelectionModel)
Is an interface class to abstract feature selection handling.
void currentEditSelectionChanged(QgsFeature &feat)
Is emitted, whenever the current edit selection has been changed.
virtual void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
virtual void setModel(QgsFeatureListModel *featureListModel)
Set the QgsFeatureListModel which is used to retrieve information.
QgsVectorLayerCache * layerCache()
Returns the layer cache.