QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
19 #include <QDragEnterEvent>
26 setModel( mProxyModel );
32 setSizeAdjustPolicy( QComboBox::AdjustToMinimumContentsLengthWithIcon );
34 setAcceptDrops(
true );
84 setCurrentIndex( -1 );
92 QModelIndex proxyIdx = mProxyModel->mapFromSource( idx );
93 if ( proxyIdx.isValid() )
95 setCurrentIndex( proxyIdx.row() );
100 setCurrentIndex( -1 );
106 return layer( currentIndex() );
111 const QModelIndex proxyIndex = mProxyModel->index( layerIndex, 0 );
112 if ( !proxyIndex.isValid() )
117 const QModelIndex index = mProxyModel->mapToSource( proxyIndex );
118 if ( !index.isValid() )
145 else if ( count() == 0 )
151 QgsMapLayer *QgsMapLayerComboBox::compatibleMapLayerFromMimeData(
const QMimeData *data )
const
168 if ( !( event->possibleActions() & Qt::CopyAction ) )
174 if ( compatibleMapLayerFromMimeData( event->mimeData() ) )
177 event->setDropAction( Qt::CopyAction );
204 if ( !( event->possibleActions() & Qt::CopyAction ) )
210 if (
QgsMapLayer *
layer = compatibleMapLayerFromMimeData( event->mimeData() ) )
213 setFocus( Qt::MouseFocusReason );
214 event->setDropAction( Qt::CopyAction );
229 QComboBox::paintEvent( e );
230 if ( mDragActive || mHighlight )
234 p.setPen( QPen( palette().highlight(), width ) );
235 QRect r = rect().adjusted( width, width, -width, -width );
QStringList additionalItems() const
Returns the list of additional (non map layer) items included at the end of the combo box.
void dropEvent(QDropEvent *event) override
void setAdditionalItems(const QStringList &items)
Sets a list of additional (non map layer) items to include at the end of the model.
void dragEnterEvent(QDragEnterEvent *event) override
void setExcludedProviders(const QStringList &providers)
Sets a blocklist of data providers which should be excluded from the model.
QList< QgsMimeDataUtils::Uri > UriList
void dragLeaveEvent(QDragLeaveEvent *event) override
void setShowCrs(bool showCrs)
Sets whether the CRS of layers is also included in the combo box text.
void setAdditionalItems(const QStringList &items)
Sets a list of additional (non map layer) items to include at the end of the combobox.
bool acceptsLayer(QgsMapLayer *layer) const
Returns true if the proxy model accepts the specified map layer.
QgsMapLayerModel * sourceLayerModel() const
layerModel returns the QgsMapLayerModel used in this QSortFilterProxyModel
QgsMapLayer * currentLayer() const
Returns the current layer selected in the combo box.
QgsMapLayerComboBox(QWidget *parent=nullptr)
QgsMapLayerComboBox creates a combo box to display the list of layers (currently in the registry).
QStringList excludedProviders() const
Returns the blocklist of data providers which are excluded from the model.
QModelIndex indexFromLayer(QgsMapLayer *layer) const
indexFromLayer returns the model index for a given layer
The QgsMapLayerProxyModel class provides an easy to use model to display the list of layers in widget...
QStringList additionalItems
QgsMapLayer * layer(int layerIndex) const
Returns the layer currently shown at the specified index within the combo box.
static UriList decodeUriList(const QMimeData *data)
void setExcludedProviders(const QStringList &providers)
Sets a list of data providers which should be excluded from the combobox.
Base class for all map layer types.
void setAllowEmptyLayer(bool allowEmpty)
Sets whether an optional empty layer ("not set") option is shown in the combo box.
void setShowCrs(bool showCrs)
Sets whether the CRS of layers is also included in the model's display role.
void paintEvent(QPaintEvent *e) override
void setAllowEmptyLayer(bool allowEmpty)
Sets whether an optional empty layer ("not set") option is present in the model.
void setLayer(QgsMapLayer *layer)
setLayer set the current layer selected in the combo
void layerChanged(QgsMapLayer *layer)
Emitted whenever the currently selected layer changes.
QStringList excludedProviders