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 ) ) );
136 mEditSelectionDrag =
true;
142 selectRow( index,
true );
162 if ( currentSelection.
size() == 1 )
164 QModelIndexList indexList = currentSelection.
indexes();
165 if ( !indexList.isEmpty() )
180 mFeatureSelectionModel->
selectFeatures( selection, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows );
196 mCurrentEditSelectionModel->
select( selection, QItemSelectionModel::ClearAndSelect );
205 mCurrentEditSelectionModel->
select( index, command );
233 if ( mEditSelectionDrag )
239 selectRow( index,
false );
254 if ( mEditSelectionDrag )
256 mEditSelectionDrag =
false;
266 if ( Qt::Key_Up == event->
key() || Qt::Key_Down ==
event->key() )
272 currentRow = localIndex.
row();
278 switch ( event->
key() )
281 newLocalIndex = mModel->
index( currentRow - 1, 0 );
291 newLocalIndex = mModel->
index( currentRow + 1, 0 );
326 int row = index.
row();
332 && command.testFlag( QItemSelectionModel::Toggle ) )
335 mCtrlDragSelectionFlag = mFeatureSelectionModel->
isSelected( index )
336 ? QItemSelectionModel::Deselect : QItemSelectionModel::Select;
338 command |= mCtrlDragSelectionFlag;
340 command |= QItemSelectionModel::Current;
351 delete mFeatureSelectionManager;
353 mFeatureSelectionManager = featureSelectionManager;
355 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 QModelIndex mapToMaster(const QModelIndex &proxyIndex) const
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const override
virtual void setModel(QAbstractItemModel *model)
bool featureByIndex(const QModelIndex &index, QgsFeature &feat)
virtual QModelIndex mapFromMaster(const QModelIndex &sourceIndex) const
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...
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.
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.
void setCurrentFeatureEdited(bool state)
QgsFeatureIds currentEditSelection()
Get the currentEditSelection.
virtual void mouseMoveEvent(QMouseEvent *event) override
QgsAttributeTableModel * masterModel()
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
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
void setFeatureSelectionManager(QgsIFeatureSelectionManager *featureSelectionManager)
setFeatureSelectionManager
virtual void contextMenuEvent(QContextMenuEvent *event) override
virtual void keyPressEvent(QKeyEvent *event) override
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
QModelIndex fidToIdx(const QgsFeatureId fid) 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 QItemSelection mapSelectionFromMaster(const QItemSelection &selection) const
virtual void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
virtual void setModel(QgsFeatureListModel *featureListModel)
Set the QgsFeatureListModel which is used to retrieve information.
QString displayExpression() const
QgsVectorLayerCache * layerCache()
Returns the layer cache.