mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-15 00:07:25 -05:00
rename QgsFeatureChooser to QgsFeaturePicker
This commit is contained in:
parent
3cd237eca7
commit
82da0fd962
@ -1,14 +1,14 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/qgsfeaturechoosermodel.h *
|
||||
* src/core/qgsfeaturepickermodel.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
|
||||
class QgsFeatureChooserModel : QAbstractItemModel
|
||||
class QgsFeaturePickerModel : QAbstractItemModel
|
||||
{
|
||||
%Docstring
|
||||
Provides a list of features based on filter conditions.
|
||||
@ -18,7 +18,7 @@ Features are fetched asynchronously.
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgsfeaturechoosermodel.h"
|
||||
#include "qgsfeaturepickermodel.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
@ -29,11 +29,11 @@ Features are fetched asynchronously.
|
||||
FeatureIdRole
|
||||
};
|
||||
|
||||
explicit QgsFeatureChooserModel( QObject *parent = 0 );
|
||||
explicit QgsFeaturePickerModel( QObject *parent = 0 );
|
||||
%Docstring
|
||||
Create a new QgsFeatureChooserModel, optionally specifying a ``parent``.
|
||||
Create a new QgsFeaturePickerModel, optionally specifying a ``parent``.
|
||||
%End
|
||||
~QgsFeatureChooserModel();
|
||||
~QgsFeaturePickerModel();
|
||||
|
||||
QgsVectorLayer *sourceLayer() const;
|
||||
%Docstring
|
||||
@ -193,7 +193,7 @@ Add a NULL entry to the list.
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/qgsfeaturechoosermodel.h *
|
||||
* src/core/qgsfeaturepickermodel.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
@ -61,7 +61,7 @@
|
||||
%Include auto_generated/qgsexpressioncontextscopegenerator.sip
|
||||
%Include auto_generated/qgsexpressionfieldbuffer.sip
|
||||
%Include auto_generated/qgsfeature.sip
|
||||
%Include auto_generated/qgsfeaturechoosermodel.sip
|
||||
%Include auto_generated/qgsfeaturepickermodel.sip
|
||||
%Include auto_generated/qgsfeaturefiltermodel.sip
|
||||
%Include auto_generated/qgsfeaturefilterprovider.sip
|
||||
%Include auto_generated/qgsfeatureid.sip
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/gui/qgsfeaturechooserwidget.h *
|
||||
* src/gui/qgsfeaturepickerwidget.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
@ -10,7 +10,7 @@
|
||||
|
||||
|
||||
|
||||
class QgsFeatureChooserWidget : QWidget
|
||||
class QgsFeaturePickerWidget : QWidget
|
||||
{
|
||||
%Docstring
|
||||
This offers a combobox with autocompleter that allows selecting features from a layer.
|
||||
@ -22,13 +22,13 @@ and whenever text is typed into the combobox, the completer and popup will adjus
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgsfeaturechooserwidget.h"
|
||||
#include "qgsfeaturepickerwidget.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
QgsFeatureChooserWidget( QWidget *parent = 0 );
|
||||
QgsFeaturePickerWidget( QWidget *parent = 0 );
|
||||
%Docstring
|
||||
Create a new QgsFeatureChooserWidget, optionally specifying a ``parent``.
|
||||
Create a new QgsFeaturePickerWidget, optionally specifying a ``parent``.
|
||||
%End
|
||||
|
||||
QgsVectorLayer *layer() const;
|
||||
@ -41,7 +41,7 @@ The layer from which features should be listed.
|
||||
The layer from which features should be listed.
|
||||
%End
|
||||
|
||||
void setCurrentFeature( const QgsFeature &feature );
|
||||
void setCurrentFeature( QgsFeatureId featureId );
|
||||
%Docstring
|
||||
Sets the current index by using the given feature
|
||||
%End
|
||||
@ -144,7 +144,7 @@ Sends the feature as soon as it is chosen
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/gui/qgsfeaturechooserwidget.h *
|
||||
* src/gui/qgsfeaturepickerwidget.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
@ -80,7 +80,7 @@
|
||||
%Include auto_generated/qgsextentgroupbox.sip
|
||||
%Include auto_generated/qgsextentwidget.sip
|
||||
%Include auto_generated/qgsexternalresourcewidget.sip
|
||||
%Include auto_generated/qgsfeaturechooserwidget.sip
|
||||
%Include auto_generated/qgsfeaturepickerwidget.sip
|
||||
%Include auto_generated/qgsfeaturelistcombobox.sip
|
||||
%Include auto_generated/qgsfeatureselectiondlg.sip
|
||||
%Include auto_generated/qgsfieldcombobox.sip
|
||||
|
||||
@ -257,7 +257,7 @@ SET(QGIS_CORE_SRCS
|
||||
qgsexpressioncontext.cpp
|
||||
qgsexpressionfieldbuffer.cpp
|
||||
qgsfeature.cpp
|
||||
qgsfeaturechoosermodel.cpp
|
||||
qgsfeaturepickermodel.cpp
|
||||
qgsfeatureiterator.cpp
|
||||
qgsfeaturerequest.cpp
|
||||
qgsfeaturesink.cpp
|
||||
@ -797,7 +797,7 @@ SET(QGIS_CORE_HDRS
|
||||
qgsexpressioncontextscopegenerator.h
|
||||
qgsexpressionfieldbuffer.h
|
||||
qgsfeature.h
|
||||
qgsfeaturechoosermodel.h
|
||||
qgsfeaturepickermodel.h
|
||||
qgsfeatureexpressionvaluesgatherer.h
|
||||
qgsfeaturefiltermodel.h
|
||||
qgsfeaturefilterprovider.h
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/***************************************************************************
|
||||
qgsfeaturechoosermodel.cpp - QgsFeatureChooserModel
|
||||
qgsfeaturepickermodel.cpp - QgsFeaturePickerModel
|
||||
---------------------
|
||||
begin : 03.04.2020
|
||||
copyright : (C) 2020 by Denis Rouzaud
|
||||
@ -12,7 +12,7 @@
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
#include "qgsfeaturechoosermodel.h"
|
||||
#include "qgsfeaturepickermodel.h"
|
||||
#include "qgsfeatureexpressionvaluesgatherer.h"
|
||||
|
||||
#include "qgsvectorlayer.h"
|
||||
@ -21,27 +21,27 @@
|
||||
#include "qgssettings.h"
|
||||
|
||||
|
||||
QgsFeatureChooserModel::QgsFeatureChooserModel( QObject *parent )
|
||||
QgsFeaturePickerModel::QgsFeaturePickerModel( QObject *parent )
|
||||
: QAbstractItemModel( parent )
|
||||
{
|
||||
mReloadTimer.setInterval( 100 );
|
||||
mReloadTimer.setSingleShot( true );
|
||||
connect( &mReloadTimer, &QTimer::timeout, this, &QgsFeatureChooserModel::scheduledReload );
|
||||
connect( &mReloadTimer, &QTimer::timeout, this, &QgsFeaturePickerModel::scheduledReload );
|
||||
setCurrentFeatureUnguarded( FID_NULL );
|
||||
}
|
||||
|
||||
QgsFeatureChooserModel::~QgsFeatureChooserModel()
|
||||
QgsFeaturePickerModel::~QgsFeaturePickerModel()
|
||||
{
|
||||
if ( mGatherer )
|
||||
connect( mGatherer, &QgsFeatureExpressionValuesGatherer::finished, mGatherer, &QgsFeatureExpressionValuesGatherer::deleteLater );
|
||||
}
|
||||
|
||||
QgsVectorLayer *QgsFeatureChooserModel::sourceLayer() const
|
||||
QgsVectorLayer *QgsFeaturePickerModel::sourceLayer() const
|
||||
{
|
||||
return mSourceLayer;
|
||||
}
|
||||
|
||||
void QgsFeatureChooserModel::setSourceLayer( QgsVectorLayer *sourceLayer )
|
||||
void QgsFeaturePickerModel::setSourceLayer( QgsVectorLayer *sourceLayer )
|
||||
{
|
||||
if ( mSourceLayer == sourceLayer )
|
||||
return;
|
||||
@ -54,12 +54,12 @@ void QgsFeatureChooserModel::setSourceLayer( QgsVectorLayer *sourceLayer )
|
||||
setDisplayExpression( sourceLayer->displayExpression() );
|
||||
}
|
||||
|
||||
QString QgsFeatureChooserModel::displayExpression() const
|
||||
QString QgsFeaturePickerModel::displayExpression() const
|
||||
{
|
||||
return mDisplayExpression.expression();
|
||||
}
|
||||
|
||||
void QgsFeatureChooserModel::setDisplayExpression( const QString &displayExpression )
|
||||
void QgsFeaturePickerModel::setDisplayExpression( const QString &displayExpression )
|
||||
{
|
||||
if ( mDisplayExpression.expression() == displayExpression )
|
||||
return;
|
||||
@ -69,12 +69,12 @@ void QgsFeatureChooserModel::setDisplayExpression( const QString &displayExpress
|
||||
emit displayExpressionChanged();
|
||||
}
|
||||
|
||||
QString QgsFeatureChooserModel::filterValue() const
|
||||
QString QgsFeaturePickerModel::filterValue() const
|
||||
{
|
||||
return mFilterValue;
|
||||
}
|
||||
|
||||
void QgsFeatureChooserModel::setFilterValue( const QString &filterValue )
|
||||
void QgsFeaturePickerModel::setFilterValue( const QString &filterValue )
|
||||
{
|
||||
if ( mFilterValue == filterValue )
|
||||
return;
|
||||
@ -84,12 +84,12 @@ void QgsFeatureChooserModel::setFilterValue( const QString &filterValue )
|
||||
emit filterValueChanged();
|
||||
}
|
||||
|
||||
QString QgsFeatureChooserModel::filterExpression() const
|
||||
QString QgsFeaturePickerModel::filterExpression() const
|
||||
{
|
||||
return mFilterExpression;
|
||||
}
|
||||
|
||||
void QgsFeatureChooserModel::setFilterExpression( const QString &filterExpression )
|
||||
void QgsFeaturePickerModel::setFilterExpression( const QString &filterExpression )
|
||||
{
|
||||
if ( mFilterExpression == filterExpression )
|
||||
return;
|
||||
@ -99,37 +99,37 @@ void QgsFeatureChooserModel::setFilterExpression( const QString &filterExpressio
|
||||
emit filterExpressionChanged();
|
||||
}
|
||||
|
||||
bool QgsFeatureChooserModel::isLoading() const
|
||||
bool QgsFeaturePickerModel::isLoading() const
|
||||
{
|
||||
return mGatherer;
|
||||
}
|
||||
|
||||
QModelIndex QgsFeatureChooserModel::index( int row, int column, const QModelIndex &parent ) const
|
||||
QModelIndex QgsFeaturePickerModel::index( int row, int column, const QModelIndex &parent ) const
|
||||
{
|
||||
Q_UNUSED( parent )
|
||||
return createIndex( row, column, nullptr );
|
||||
}
|
||||
|
||||
QModelIndex QgsFeatureChooserModel::parent( const QModelIndex &child ) const
|
||||
QModelIndex QgsFeaturePickerModel::parent( const QModelIndex &child ) const
|
||||
{
|
||||
Q_UNUSED( child )
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
int QgsFeatureChooserModel::rowCount( const QModelIndex &parent ) const
|
||||
int QgsFeaturePickerModel::rowCount( const QModelIndex &parent ) const
|
||||
{
|
||||
Q_UNUSED( parent )
|
||||
|
||||
return mEntries.size();
|
||||
}
|
||||
|
||||
int QgsFeatureChooserModel::columnCount( const QModelIndex &parent ) const
|
||||
int QgsFeaturePickerModel::columnCount( const QModelIndex &parent ) const
|
||||
{
|
||||
Q_UNUSED( parent )
|
||||
return 1;
|
||||
}
|
||||
|
||||
QVariant QgsFeatureChooserModel::data( const QModelIndex &index, int role ) const
|
||||
QVariant QgsFeaturePickerModel::data( const QModelIndex &index, int role ) const
|
||||
{
|
||||
if ( !index.isValid() )
|
||||
return QVariant();
|
||||
@ -194,7 +194,7 @@ QVariant QgsFeatureChooserModel::data( const QModelIndex &index, int role ) cons
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void QgsFeatureChooserModel::updateCompleter()
|
||||
void QgsFeaturePickerModel::updateCompleter()
|
||||
{
|
||||
emit beginUpdate();
|
||||
|
||||
@ -313,7 +313,7 @@ void QgsFeatureChooserModel::updateCompleter()
|
||||
emit isLoadingChanged();
|
||||
}
|
||||
|
||||
void QgsFeatureChooserModel::scheduledReload()
|
||||
void QgsFeaturePickerModel::scheduledReload()
|
||||
{
|
||||
if ( !mSourceLayer )
|
||||
return;
|
||||
@ -342,14 +342,14 @@ void QgsFeatureChooserModel::scheduledReload()
|
||||
request.setLimit( QgsSettings().value( QStringLiteral( "maxEntriesRelationWidget" ), 100, QgsSettings::Gui ).toInt() );
|
||||
|
||||
mGatherer = new QgsFeatureExpressionValuesGatherer( mSourceLayer, mDisplayExpression, request );
|
||||
connect( mGatherer, &QgsFeatureExpressionValuesGatherer::finished, this, &QgsFeatureChooserModel::updateCompleter );
|
||||
connect( mGatherer, &QgsFeatureExpressionValuesGatherer::finished, this, &QgsFeaturePickerModel::updateCompleter );
|
||||
|
||||
mGatherer->start();
|
||||
if ( !wasLoading )
|
||||
emit isLoadingChanged();
|
||||
}
|
||||
|
||||
void QgsFeatureChooserModel::setCurrentIndex( int index, bool force )
|
||||
void QgsFeaturePickerModel::setCurrentIndex( int index, bool force )
|
||||
{
|
||||
if ( mCurrentIndex == index && !force )
|
||||
return;
|
||||
@ -359,7 +359,7 @@ void QgsFeatureChooserModel::setCurrentIndex( int index, bool force )
|
||||
emit currentFeatureChanged( currentFeature() );
|
||||
}
|
||||
|
||||
void QgsFeatureChooserModel::setCurrentFeature( const QgsFeatureId &featureId )
|
||||
void QgsFeaturePickerModel::setCurrentFeature( const QgsFeatureId &featureId )
|
||||
{
|
||||
if ( featureId == 0 || featureId == currentFeature().id() )
|
||||
return;
|
||||
@ -374,7 +374,7 @@ void QgsFeatureChooserModel::setCurrentFeature( const QgsFeatureId &featureId )
|
||||
mIsSettingCurrentFeature = false;
|
||||
}
|
||||
|
||||
void QgsFeatureChooserModel::setCurrentFeatureUnguarded( const QgsFeatureId &featureId )
|
||||
void QgsFeaturePickerModel::setCurrentFeatureUnguarded( const QgsFeatureId &featureId )
|
||||
{
|
||||
const QVector<QgsFeatureExpressionValuesGatherer::Entry> entries = mEntries;
|
||||
|
||||
@ -399,7 +399,7 @@ void QgsFeatureChooserModel::setCurrentFeatureUnguarded( const QgsFeatureId &fea
|
||||
}
|
||||
}
|
||||
|
||||
QgsConditionalStyle QgsFeatureChooserModel::featureStyle( const QgsFeature &feature ) const
|
||||
QgsConditionalStyle QgsFeaturePickerModel::featureStyle( const QgsFeature &feature ) const
|
||||
{
|
||||
if ( !mSourceLayer )
|
||||
return QgsConditionalStyle();
|
||||
@ -427,12 +427,12 @@ QgsConditionalStyle QgsFeatureChooserModel::featureStyle( const QgsFeature &feat
|
||||
return style;
|
||||
}
|
||||
|
||||
bool QgsFeatureChooserModel::allowNull() const
|
||||
bool QgsFeaturePickerModel::allowNull() const
|
||||
{
|
||||
return mAllowNull;
|
||||
}
|
||||
|
||||
void QgsFeatureChooserModel::setAllowNull( bool allowNull )
|
||||
void QgsFeaturePickerModel::setAllowNull( bool allowNull )
|
||||
{
|
||||
if ( mAllowNull == allowNull )
|
||||
return;
|
||||
@ -443,7 +443,7 @@ void QgsFeatureChooserModel::setAllowNull( bool allowNull )
|
||||
reload();
|
||||
}
|
||||
|
||||
QgsFeature QgsFeatureChooserModel::currentFeature() const
|
||||
QgsFeature QgsFeaturePickerModel::currentFeature() const
|
||||
{
|
||||
if ( mCurrentIndex < mEntries.count() )
|
||||
return mEntries.at( mCurrentIndex ).feature;
|
||||
@ -451,7 +451,7 @@ QgsFeature QgsFeatureChooserModel::currentFeature() const
|
||||
return QgsFeature();
|
||||
}
|
||||
|
||||
void QgsFeatureChooserModel::reload()
|
||||
void QgsFeaturePickerModel::reload()
|
||||
{
|
||||
mReloadTimer.start();
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
/***************************************************************************
|
||||
qgsfeaturechoosermodel.h - QgsFeatureChooserModel
|
||||
qgsfeaturepickermodel.h - QgsFeaturePickerModel
|
||||
---------------------
|
||||
begin : 03.04.2020
|
||||
copyright : (C) 2020 by Denis Rouzaud
|
||||
@ -12,8 +12,8 @@
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
#ifndef QGSFEATURECHOOSERMODEL_H
|
||||
#define QGSFEATURECHOOSERMODEL_H
|
||||
#ifndef QGSFEATUREPICKERMODEL_H
|
||||
#define QGSFEATUREPICKERMODEL_H
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
*
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
class CORE_EXPORT QgsFeatureChooserModel : public QAbstractItemModel
|
||||
class CORE_EXPORT QgsFeaturePickerModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -51,10 +51,10 @@ class CORE_EXPORT QgsFeatureChooserModel : public QAbstractItemModel
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a new QgsFeatureChooserModel, optionally specifying a \a parent.
|
||||
* Create a new QgsFeaturePickerModel, optionally specifying a \a parent.
|
||||
*/
|
||||
explicit QgsFeatureChooserModel( QObject *parent = nullptr );
|
||||
~QgsFeatureChooserModel() override;
|
||||
explicit QgsFeaturePickerModel( QObject *parent = nullptr );
|
||||
~QgsFeaturePickerModel() override;
|
||||
|
||||
/**
|
||||
* The source layer from which features will be fetched.
|
||||
@ -231,4 +231,4 @@ class CORE_EXPORT QgsFeatureChooserModel : public QAbstractItemModel
|
||||
|
||||
};
|
||||
|
||||
#endif // QGSFEATURECHOOSERMODEL_H
|
||||
#endif // QGSFEATUREPICKERMODEL_H
|
||||
@ -403,7 +403,7 @@ SET(QGIS_GUI_SRCS
|
||||
qgsfeatureselectiondlg.cpp
|
||||
qgsfieldcombobox.cpp
|
||||
qgsfieldexpressionwidget.cpp
|
||||
qgsfeaturechooserwidget.cpp
|
||||
qgsfeaturepickerwidget.cpp
|
||||
qgsfieldmappingwidget.cpp
|
||||
qgsfieldmappingmodel.cpp
|
||||
qgsfeaturelistcombobox.cpp
|
||||
@ -628,7 +628,7 @@ SET(QGIS_GUI_HDRS
|
||||
qgsextentgroupbox.h
|
||||
qgsextentwidget.h
|
||||
qgsexternalresourcewidget.h
|
||||
qgsfeaturechooserwidget.h
|
||||
qgsfeaturepickerwidget.h
|
||||
qgsfeaturelistcombobox.h
|
||||
qgsfeatureselectiondlg.h
|
||||
qgsfieldcombobox.h
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
#include "qgsexpressionpreviewwidget.h"
|
||||
#include "qgsmessageviewer.h"
|
||||
#include "qgsvectorlayer.h"
|
||||
#include "qgsfeaturechooserwidget.h"
|
||||
#include "qgsfeaturepickerwidget.h"
|
||||
|
||||
|
||||
|
||||
@ -28,7 +28,7 @@ QgsExpressionPreviewWidget::QgsExpressionPreviewWidget( QWidget *parent )
|
||||
setupUi( this );
|
||||
mPreviewLabel->clear();
|
||||
|
||||
connect( mFeatureChooserWidget, &QgsFeatureChooserWidget::currentFeatureChanged, this, &QgsExpressionPreviewWidget::setCurrentFeature );
|
||||
connect( mFeatureChooserWidget, &QgsFeaturePickerWidget::currentFeatureChanged, this, &QgsExpressionPreviewWidget::setCurrentFeature );
|
||||
connect( mPreviewLabel, &QLabel::linkActivated, this, &QgsExpressionPreviewWidget::linkActivated );
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/***************************************************************************
|
||||
qgsfeaturechooserwidget.cpp - QgsFeatureChooserWidget
|
||||
qgsfeaturepickerwidget.cpp - QgsFeaturePickerWidget
|
||||
---------------------
|
||||
begin : 03.04.2020
|
||||
copyright : (C) 2020 by Denis Rouzaud
|
||||
@ -16,13 +16,13 @@
|
||||
#include <QHBoxLayout>
|
||||
#include <QKeyEvent>
|
||||
|
||||
#include "qgsfeaturechooserwidget.h"
|
||||
#include "qgsfeaturepickerwidget.h"
|
||||
#include "qgsfilterlineedit.h"
|
||||
#include "qgsfeaturechoosermodel.h"
|
||||
#include "qgsfeaturepickermodel.h"
|
||||
|
||||
QgsFeatureChooserWidget::QgsFeatureChooserWidget( QWidget *parent )
|
||||
QgsFeaturePickerWidget::QgsFeaturePickerWidget( QWidget *parent )
|
||||
: QWidget( parent )
|
||||
, mModel( new QgsFeatureChooserModel( this ) )
|
||||
, mModel( new QgsFeaturePickerModel( this ) )
|
||||
, mCompleter( new QCompleter( mModel ) )
|
||||
{
|
||||
QHBoxLayout *layout = new QHBoxLayout();
|
||||
@ -35,22 +35,22 @@ QgsFeatureChooserWidget::QgsFeatureChooserWidget( QWidget *parent )
|
||||
mCompleter->setFilterMode( Qt::MatchContains );
|
||||
mComboBox->setCompleter( mCompleter );
|
||||
mCompleter->setWidget( mComboBox );
|
||||
connect( mModel, &QgsFeatureChooserModel::sourceLayerChanged, this, &QgsFeatureChooserWidget::layerChanged );
|
||||
connect( mModel, &QgsFeatureChooserModel::displayExpressionChanged, this, &QgsFeatureChooserWidget::displayExpressionChanged );
|
||||
connect( mModel, &QgsFeatureChooserModel::filterExpressionChanged, this, &QgsFeatureChooserWidget::filterExpressionChanged );
|
||||
connect( mModel, &QgsFeatureChooserModel::isLoadingChanged, this, &QgsFeatureChooserWidget::onLoadingChanged );
|
||||
connect( mModel, &QgsFeatureChooserModel::filterJobCompleted, this, &QgsFeatureChooserWidget::onFilterUpdateCompleted );
|
||||
connect( mModel, &QgsFeatureChooserModel::allowNullChanged, this, &QgsFeatureChooserWidget::allowNullChanged );
|
||||
connect( mModel, &QgsFeatureChooserModel::currentIndexChanged, mComboBox, &QComboBox::setCurrentIndex );
|
||||
connect( mModel, &QgsFeatureChooserModel::currentFeatureChanged, this, &QgsFeatureChooserWidget::currentFeatureChanged );
|
||||
connect( mCompleter, static_cast<void( QCompleter::* )( const QModelIndex & )>( &QCompleter::highlighted ), this, &QgsFeatureChooserWidget::onItemSelected );
|
||||
connect( mCompleter, static_cast<void( QCompleter::* )( const QModelIndex & )>( &QCompleter::activated ), this, &QgsFeatureChooserWidget::onActivated );
|
||||
connect( mModel, &QgsFeatureChooserModel::beginUpdate, this, &QgsFeatureChooserWidget::storeLineEditState );
|
||||
connect( mModel, &QgsFeatureChooserModel::endUpdate, this, &QgsFeatureChooserWidget::restoreLineEditState );
|
||||
connect( mModel, &QgsFeatureChooserModel::endUpdate, this, &QgsFeatureChooserWidget::modelUpdated );
|
||||
connect( mModel, &QgsFeatureChooserModel::dataChanged, this, &QgsFeatureChooserWidget::onDataChanged );
|
||||
connect( mModel, &QgsFeaturePickerModel::sourceLayerChanged, this, &QgsFeaturePickerWidget::layerChanged );
|
||||
connect( mModel, &QgsFeaturePickerModel::displayExpressionChanged, this, &QgsFeaturePickerWidget::displayExpressionChanged );
|
||||
connect( mModel, &QgsFeaturePickerModel::filterExpressionChanged, this, &QgsFeaturePickerWidget::filterExpressionChanged );
|
||||
connect( mModel, &QgsFeaturePickerModel::isLoadingChanged, this, &QgsFeaturePickerWidget::onLoadingChanged );
|
||||
connect( mModel, &QgsFeaturePickerModel::filterJobCompleted, this, &QgsFeaturePickerWidget::onFilterUpdateCompleted );
|
||||
connect( mModel, &QgsFeaturePickerModel::allowNullChanged, this, &QgsFeaturePickerWidget::allowNullChanged );
|
||||
connect( mModel, &QgsFeaturePickerModel::currentIndexChanged, mComboBox, &QComboBox::setCurrentIndex );
|
||||
connect( mModel, &QgsFeaturePickerModel::currentFeatureChanged, this, &QgsFeaturePickerWidget::currentFeatureChanged );
|
||||
connect( mCompleter, static_cast<void( QCompleter::* )( const QModelIndex & )>( &QCompleter::highlighted ), this, &QgsFeaturePickerWidget::onItemSelected );
|
||||
connect( mCompleter, static_cast<void( QCompleter::* )( const QModelIndex & )>( &QCompleter::activated ), this, &QgsFeaturePickerWidget::onActivated );
|
||||
connect( mModel, &QgsFeaturePickerModel::beginUpdate, this, &QgsFeaturePickerWidget::storeLineEditState );
|
||||
connect( mModel, &QgsFeaturePickerModel::endUpdate, this, &QgsFeaturePickerWidget::restoreLineEditState );
|
||||
connect( mModel, &QgsFeaturePickerModel::endUpdate, this, &QgsFeaturePickerWidget::modelUpdated );
|
||||
connect( mModel, &QgsFeaturePickerModel::dataChanged, this, &QgsFeaturePickerWidget::onDataChanged );
|
||||
|
||||
connect( mComboBox, static_cast<void( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFeatureChooserWidget::onCurrentIndexChanged );
|
||||
connect( mComboBox, static_cast<void( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFeaturePickerWidget::onCurrentIndexChanged );
|
||||
|
||||
mLineEdit = new QgsFilterLineEdit( nullptr, QgsApplication::nullRepresentation() );
|
||||
mLineEdit->setSelectOnFocus( true );
|
||||
@ -60,44 +60,44 @@ QgsFeatureChooserWidget::QgsFeatureChooserWidget( QWidget *parent )
|
||||
mComboBox->setLineEdit( mLineEdit );
|
||||
mComboBox->setModel( mModel );
|
||||
|
||||
connect( mLineEdit, &QgsFilterLineEdit::textEdited, this, &QgsFeatureChooserWidget::onCurrentTextChanged );
|
||||
connect( mLineEdit, &QgsFilterLineEdit::textEdited, this, &QgsFeaturePickerWidget::onCurrentTextChanged );
|
||||
|
||||
setToolTip( tr( "Just start typing what you are looking for." ) );
|
||||
}
|
||||
|
||||
QgsVectorLayer *QgsFeatureChooserWidget::layer() const
|
||||
QgsVectorLayer *QgsFeaturePickerWidget::layer() const
|
||||
{
|
||||
return mModel->sourceLayer();
|
||||
}
|
||||
|
||||
void QgsFeatureChooserWidget::setLayer( QgsVectorLayer *sourceLayer )
|
||||
void QgsFeaturePickerWidget::setLayer( QgsVectorLayer *sourceLayer )
|
||||
{
|
||||
mModel->setSourceLayer( sourceLayer );
|
||||
}
|
||||
|
||||
void QgsFeatureChooserWidget::setCurrentFeature(QgsFeatureId featureId )
|
||||
void QgsFeaturePickerWidget::setCurrentFeature(QgsFeatureId featureId )
|
||||
{
|
||||
mModel->setCurrentFeature( featureId );
|
||||
}
|
||||
|
||||
QString QgsFeatureChooserWidget::displayExpression() const
|
||||
QString QgsFeaturePickerWidget::displayExpression() const
|
||||
{
|
||||
return mModel->displayExpression();
|
||||
}
|
||||
|
||||
void QgsFeatureChooserWidget::setDisplayExpression( const QString &expression )
|
||||
void QgsFeaturePickerWidget::setDisplayExpression( const QString &expression )
|
||||
{
|
||||
mModel->setDisplayExpression( expression );
|
||||
}
|
||||
|
||||
void QgsFeatureChooserWidget::onCurrentTextChanged( const QString &text )
|
||||
void QgsFeaturePickerWidget::onCurrentTextChanged( const QString &text )
|
||||
{
|
||||
mIsCurrentlyEdited = true;
|
||||
mPopupRequested = true;
|
||||
mModel->setFilterValue( text );
|
||||
}
|
||||
|
||||
void QgsFeatureChooserWidget::onFilterUpdateCompleted()
|
||||
void QgsFeaturePickerWidget::onFilterUpdateCompleted()
|
||||
{
|
||||
if ( mPopupRequested )
|
||||
mCompleter->complete();
|
||||
@ -105,36 +105,36 @@ void QgsFeatureChooserWidget::onFilterUpdateCompleted()
|
||||
mPopupRequested = false;
|
||||
}
|
||||
|
||||
void QgsFeatureChooserWidget::onLoadingChanged()
|
||||
void QgsFeaturePickerWidget::onLoadingChanged()
|
||||
{
|
||||
mLineEdit->setShowSpinner( mModel->isLoading() );
|
||||
}
|
||||
|
||||
void QgsFeatureChooserWidget::onItemSelected( const QModelIndex &index )
|
||||
void QgsFeaturePickerWidget::onItemSelected( const QModelIndex &index )
|
||||
{
|
||||
mComboBox->setCurrentIndex( index.row() );
|
||||
}
|
||||
|
||||
void QgsFeatureChooserWidget::onCurrentIndexChanged( int i )
|
||||
void QgsFeaturePickerWidget::onCurrentIndexChanged( int i )
|
||||
{
|
||||
if ( !mHasStoredEditState )
|
||||
mIsCurrentlyEdited = false;
|
||||
QModelIndex modelIndex = mModel->index( i, 0, QModelIndex() );
|
||||
mModel->setCurrentFeature( mModel->data( modelIndex, QgsFeatureChooserModel::FeatureIdRole ).value<QgsFeatureId>() );
|
||||
mLineEdit->setText( mModel->data( modelIndex, QgsFeatureChooserModel::ValueRole ).toString() );
|
||||
mModel->setCurrentFeature( mModel->data( modelIndex, QgsFeaturePickerModel::FeatureIdRole ).value<QgsFeatureId>() );
|
||||
mLineEdit->setText( mModel->data( modelIndex, QgsFeaturePickerModel::ValueRole ).toString() );
|
||||
mLineEdit->setFont( mModel->data( modelIndex, Qt::FontRole ).value<QFont>() );
|
||||
QPalette palette = mLineEdit->palette();
|
||||
palette.setBrush( mLineEdit->foregroundRole(), mModel->data( modelIndex, Qt::ForegroundRole ).value<QBrush>() );
|
||||
mLineEdit->setPalette( palette );
|
||||
}
|
||||
|
||||
void QgsFeatureChooserWidget::onActivated( QModelIndex modelIndex )
|
||||
void QgsFeaturePickerWidget::onActivated( QModelIndex modelIndex )
|
||||
{
|
||||
setCurrentFeature( mModel->data( modelIndex, QgsFeatureChooserModel::FeatureIdRole ).value<QgsFeatureId>() );
|
||||
mLineEdit->setText( mModel->data( modelIndex, QgsFeatureChooserModel::ValueRole ).toString() );
|
||||
setCurrentFeature( mModel->data( modelIndex, QgsFeaturePickerModel::FeatureIdRole ).value<QgsFeatureId>() );
|
||||
mLineEdit->setText( mModel->data( modelIndex, QgsFeaturePickerModel::ValueRole ).toString() );
|
||||
}
|
||||
|
||||
void QgsFeatureChooserWidget::storeLineEditState()
|
||||
void QgsFeaturePickerWidget::storeLineEditState()
|
||||
{
|
||||
if ( mIsCurrentlyEdited )
|
||||
{
|
||||
@ -143,7 +143,7 @@ void QgsFeatureChooserWidget::storeLineEditState()
|
||||
}
|
||||
}
|
||||
|
||||
void QgsFeatureChooserWidget::restoreLineEditState()
|
||||
void QgsFeaturePickerWidget::restoreLineEditState()
|
||||
{
|
||||
if ( mIsCurrentlyEdited )
|
||||
{
|
||||
@ -152,7 +152,7 @@ void QgsFeatureChooserWidget::restoreLineEditState()
|
||||
}
|
||||
}
|
||||
|
||||
int QgsFeatureChooserWidget::nullIndex() const
|
||||
int QgsFeaturePickerWidget::nullIndex() const
|
||||
{
|
||||
int index = -1;
|
||||
|
||||
@ -164,7 +164,7 @@ int QgsFeatureChooserWidget::nullIndex() const
|
||||
return index;
|
||||
}
|
||||
|
||||
void QgsFeatureChooserWidget::onDataChanged( const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles )
|
||||
void QgsFeaturePickerWidget::onDataChanged( const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles )
|
||||
{
|
||||
Q_UNUSED( roles )
|
||||
if ( !mIsCurrentlyEdited )
|
||||
@ -173,54 +173,54 @@ void QgsFeatureChooserWidget::onDataChanged( const QModelIndex &topLeft, const Q
|
||||
if ( currentIndex >= topLeft.row() && currentIndex <= bottomRight.row() )
|
||||
{
|
||||
QModelIndex modelIndex = mModel->index( currentIndex, 0, QModelIndex() );
|
||||
mLineEdit->setText( mModel->data( modelIndex, QgsFeatureChooserModel::ValueRole ).toString() );
|
||||
mLineEdit->setText( mModel->data( modelIndex, QgsFeaturePickerModel::ValueRole ).toString() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QModelIndex QgsFeatureChooserWidget::currentModelIndex() const
|
||||
QModelIndex QgsFeaturePickerWidget::currentModelIndex() const
|
||||
{
|
||||
return mModel->index( mModel->currentIndex(), 0, QModelIndex() );
|
||||
}
|
||||
|
||||
void QgsFeatureChooserWidget::focusOutEvent( QFocusEvent *event )
|
||||
void QgsFeaturePickerWidget::focusOutEvent( QFocusEvent *event )
|
||||
{
|
||||
Q_UNUSED( event )
|
||||
QWidget::focusOutEvent( event );
|
||||
mLineEdit->setText( mModel->data( currentModelIndex(), QgsFeatureChooserModel::ValueRole ).toString() );
|
||||
mLineEdit->setText( mModel->data( currentModelIndex(), QgsFeaturePickerModel::ValueRole ).toString() );
|
||||
}
|
||||
|
||||
void QgsFeatureChooserWidget::keyPressEvent( QKeyEvent *event )
|
||||
void QgsFeaturePickerWidget::keyPressEvent( QKeyEvent *event )
|
||||
{
|
||||
if ( event->key() == Qt::Key_Escape )
|
||||
{
|
||||
mLineEdit->setText( mModel->data( currentModelIndex(), QgsFeatureChooserModel::ValueRole ).toString() );
|
||||
mLineEdit->setText( mModel->data( currentModelIndex(), QgsFeaturePickerModel::ValueRole ).toString() );
|
||||
}
|
||||
QWidget::keyReleaseEvent( event );
|
||||
}
|
||||
|
||||
bool QgsFeatureChooserWidget::allowNull() const
|
||||
bool QgsFeaturePickerWidget::allowNull() const
|
||||
{
|
||||
return mModel->allowNull();
|
||||
}
|
||||
|
||||
void QgsFeatureChooserWidget::setAllowNull( bool allowNull )
|
||||
void QgsFeaturePickerWidget::setAllowNull( bool allowNull )
|
||||
{
|
||||
mModel->setAllowNull( allowNull );
|
||||
mLineEdit->setClearMode( allowNull ? QgsFilterLineEdit::ClearToNull : QgsFilterLineEdit::ClearToDefault );
|
||||
}
|
||||
|
||||
QString QgsFeatureChooserWidget::filterExpression() const
|
||||
QString QgsFeaturePickerWidget::filterExpression() const
|
||||
{
|
||||
return mModel->filterExpression();
|
||||
}
|
||||
|
||||
void QgsFeatureChooserWidget::setFilterExpression( const QString &filterExpression )
|
||||
void QgsFeaturePickerWidget::setFilterExpression( const QString &filterExpression )
|
||||
{
|
||||
mModel->setFilterExpression( filterExpression );
|
||||
}
|
||||
|
||||
void QgsFeatureChooserWidget::LineEditState::store( QLineEdit *lineEdit )
|
||||
void QgsFeaturePickerWidget::LineEditState::store( QLineEdit *lineEdit )
|
||||
{
|
||||
text = lineEdit->text();
|
||||
selectionStart = lineEdit->selectionStart();
|
||||
@ -229,7 +229,7 @@ void QgsFeatureChooserWidget::LineEditState::store( QLineEdit *lineEdit )
|
||||
|
||||
}
|
||||
|
||||
void QgsFeatureChooserWidget::LineEditState::restore( QLineEdit *lineEdit ) const
|
||||
void QgsFeaturePickerWidget::LineEditState::restore( QLineEdit *lineEdit ) const
|
||||
{
|
||||
lineEdit->setText( text );
|
||||
lineEdit->setCursorPosition( cursorPosition );
|
||||
@ -1,5 +1,5 @@
|
||||
/***************************************************************************
|
||||
qgsfeaturechooserwidget.h - QgsFeatureChooserWidget
|
||||
qgsfeaturepickerwidget.h - QgsFeaturePickerWidget
|
||||
---------------------
|
||||
begin : 03.04.2020
|
||||
copyright : (C) 2020 by Denis Rouzaud
|
||||
@ -25,7 +25,7 @@
|
||||
#include "qgis_gui.h"
|
||||
|
||||
class QgsVectorLayer;
|
||||
class QgsFeatureChooserModel;
|
||||
class QgsFeaturePickerModel;
|
||||
class QgsAnimatedIcon;
|
||||
class QgsFilterLineEdit;
|
||||
|
||||
@ -39,7 +39,7 @@ class QgsFilterLineEdit;
|
||||
*
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
class GUI_EXPORT QgsFeatureChooserWidget : public QWidget
|
||||
class GUI_EXPORT QgsFeaturePickerWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -51,9 +51,9 @@ class GUI_EXPORT QgsFeatureChooserWidget : public QWidget
|
||||
public:
|
||||
|
||||
/**
|
||||
* Create a new QgsFeatureChooserWidget, optionally specifying a \a parent.
|
||||
* Create a new QgsFeaturePickerWidget, optionally specifying a \a parent.
|
||||
*/
|
||||
QgsFeatureChooserWidget( QWidget *parent = nullptr );
|
||||
QgsFeaturePickerWidget( QWidget *parent = nullptr );
|
||||
|
||||
/**
|
||||
* The layer from which features should be listed.
|
||||
@ -181,7 +181,7 @@ class GUI_EXPORT QgsFeatureChooserWidget : public QWidget
|
||||
};
|
||||
|
||||
QComboBox *mComboBox;
|
||||
QgsFeatureChooserModel *mModel = nullptr;
|
||||
QgsFeaturePickerModel *mModel = nullptr;
|
||||
QCompleter *mCompleter = nullptr;
|
||||
QgsFilterLineEdit *mLineEdit;
|
||||
bool mPopupRequested = false;
|
||||
@ -189,7 +189,7 @@ class GUI_EXPORT QgsFeatureChooserWidget : public QWidget
|
||||
bool mHasStoredEditState = false;
|
||||
LineEditState mLineEditState;
|
||||
|
||||
friend class TestQgsFeatureChooserWidget;
|
||||
friend class TestQgsFeaturePickerWidget;
|
||||
};
|
||||
|
||||
|
||||
@ -68,7 +68,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QgsFeatureChooserWidget" name="mFeatureChooserWidget"/>
|
||||
<widget class="QgsFeaturePickerWidget" name="mFeatureChooserWidget"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
@ -76,9 +76,9 @@
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>QgsFeatureChooserWidget</class>
|
||||
<class>QgsFeaturePickerWidget</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>qgsfeaturechooserwidget.h</header>
|
||||
<header>qgsfeaturepickerwidget.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user