Page size can be changed from source properties

This commit is contained in:
Nyall Dawson 2023-12-13 12:33:24 +10:00
parent e568db4ec2
commit ed54031c2d
2 changed files with 46 additions and 2 deletions

View File

@ -31,6 +31,8 @@ QgsSensorThingsSourceWidget::QgsSensorThingsSourceWidget( QWidget *parent )
{ {
setupUi( this ); setupUi( this );
mSpinPageSize->setClearValue( 0, tr( "Default" ) );
for ( Qgis::SensorThingsEntity type : for ( Qgis::SensorThingsEntity type :
{ {
Qgis::SensorThingsEntity::Thing, Qgis::SensorThingsEntity::Thing,
@ -50,6 +52,7 @@ QgsSensorThingsSourceWidget::QgsSensorThingsSourceWidget( QWidget *parent )
connect( mComboEntityType, qOverload< int >( &QComboBox::currentIndexChanged ), this, &QgsSensorThingsSourceWidget::entityTypeChanged ); connect( mComboEntityType, qOverload< int >( &QComboBox::currentIndexChanged ), this, &QgsSensorThingsSourceWidget::entityTypeChanged );
connect( mComboGeometryType, qOverload< int >( &QComboBox::currentIndexChanged ), this, &QgsSensorThingsSourceWidget::validate ); connect( mComboGeometryType, qOverload< int >( &QComboBox::currentIndexChanged ), this, &QgsSensorThingsSourceWidget::validate );
connect( mSpinPageSize, qOverload< int >( &QSpinBox::valueChanged ), this, &QgsSensorThingsSourceWidget::validate );
} }
void QgsSensorThingsSourceWidget::setSourceUri( const QString &uri ) void QgsSensorThingsSourceWidget::setSourceUri( const QString &uri )
@ -64,6 +67,17 @@ void QgsSensorThingsSourceWidget::setSourceUri( const QString &uri )
rebuildGeometryTypes( type ); rebuildGeometryTypes( type );
setCurrentGeometryTypeFromString( mSourceParts.value( QStringLiteral( "geometryType" ) ).toString() ); setCurrentGeometryTypeFromString( mSourceParts.value( QStringLiteral( "geometryType" ) ).toString() );
bool ok = false;
const int maxPageSizeParam = mSourceParts.value( QStringLiteral( "pageSize" ) ).toInt( &ok );
if ( ok )
{
mSpinPageSize->setValue( maxPageSizeParam );
}
else
{
mSpinPageSize->clear();
}
mIsValid = true; mIsValid = true;
} }
@ -99,6 +113,15 @@ QString QgsSensorThingsSourceWidget::sourceUri() const
} }
} }
if ( mSpinPageSize->value() > 0 )
{
parts.insert( QStringLiteral( "pageSize" ), QString::number( mSpinPageSize->value() ) );
}
else
{
parts.remove( QStringLiteral( "pageSize" ) );
}
return QgsProviderRegistry::instance()->encodeUri( return QgsProviderRegistry::instance()->encodeUri(
QgsSensorThingsProvider::SENSORTHINGS_PROVIDER_KEY, QgsSensorThingsProvider::SENSORTHINGS_PROVIDER_KEY,
parts parts

View File

@ -24,6 +24,9 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1">
<widget class="QComboBox" name="mComboGeometryType"/>
</item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
@ -31,11 +34,29 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="2" column="0">
<widget class="QComboBox" name="mComboGeometryType"/> <widget class="QLabel" name="label_3">
<property name="text">
<string>Page size</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QgsSpinBox" name="mSpinPageSize">
<property name="maximum">
<number>9999999</number>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets>
<customwidget>
<class>QgsSpinBox</class>
<extends>QSpinBox</extends>
<header>qgsspinbox.h</header>
</customwidget>
</customwidgets>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>