mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-15 00:07:25 -05:00
Add mechanism for QgsMapLayerConfigWidgetFactory to create sub widgets
which are embedded into the raster layer temporal properties widget
This commit is contained in:
parent
4faceaf0d7
commit
207be1dd66
@ -1,6 +1,6 @@
|
||||
# The following has been generated automatically from src/gui/qgsmaplayerconfigwidgetfactory.h
|
||||
# monkey patching scoped based enum
|
||||
QgsMapLayerConfigWidgetFactory.ParentPage.None.__doc__ = "Factory creates pages itself, not sub-components"
|
||||
QgsMapLayerConfigWidgetFactory.ParentPage.NoParent.__doc__ = "Factory creates pages itself, not sub-components"
|
||||
QgsMapLayerConfigWidgetFactory.ParentPage.Temporal.__doc__ = "Factory creates sub-components of the temporal properties page"
|
||||
QgsMapLayerConfigWidgetFactory.ParentPage.__doc__ = 'Available parent pages, for factories which create a widget which is a sub-component\nof a standard page.\n\n.. versionadded:: 3.20\n\n' + '* ``None``: ' + QgsMapLayerConfigWidgetFactory.ParentPage.None.__doc__ + '\n' + '* ``Temporal``: ' + QgsMapLayerConfigWidgetFactory.ParentPage.Temporal.__doc__
|
||||
QgsMapLayerConfigWidgetFactory.ParentPage.__doc__ = 'Available parent pages, for factories which create a widget which is a sub-component\nof a standard page.\n\n.. versionadded:: 3.20\n\n' + '* ``NoParent``: ' + QgsMapLayerConfigWidgetFactory.ParentPage.NoParent.__doc__ + '\n' + '* ``Temporal``: ' + QgsMapLayerConfigWidgetFactory.ParentPage.Temporal.__doc__
|
||||
# --
|
||||
|
||||
@ -24,7 +24,7 @@ Factory class for creating custom map layer property pages
|
||||
|
||||
enum class ParentPage
|
||||
{
|
||||
None,
|
||||
NoParent,
|
||||
Temporal,
|
||||
};
|
||||
|
||||
@ -132,7 +132,7 @@ Check if the layer is supported for this widget.
|
||||
%Docstring
|
||||
Returns the associated parent page, for factories which create sub-components of a standard page.
|
||||
|
||||
The default implementation returns QgsMapLayerConfigWidgetFactory.ParentPage.None, indicating that the
|
||||
The default implementation returns QgsMapLayerConfigWidgetFactory.ParentPage.NoParent, indicating that the
|
||||
factory creates top-level pages which are not subcomponents.
|
||||
|
||||
.. versionadded:: 3.20
|
||||
|
||||
@ -37,6 +37,13 @@ Save widget temporal properties inputs.
|
||||
void syncToLayer();
|
||||
%Docstring
|
||||
Updates the widget state to match the current layer state.
|
||||
%End
|
||||
|
||||
void addWidget( QgsMapLayerConfigWidget *widget /Transfer/ );
|
||||
%Docstring
|
||||
Adds a child ``widget`` to the properties widget.
|
||||
|
||||
.. versionadded:: 3.20
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
@ -34,5 +34,5 @@ bool QgsMapLayerConfigWidgetFactory::supportsLayer( QgsMapLayer *layer ) const
|
||||
|
||||
QgsMapLayerConfigWidgetFactory::ParentPage QgsMapLayerConfigWidgetFactory::parentPage() const
|
||||
{
|
||||
return ParentPage::None;
|
||||
return ParentPage::NoParent;
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ class GUI_EXPORT QgsMapLayerConfigWidgetFactory
|
||||
*/
|
||||
enum class ParentPage : int
|
||||
{
|
||||
None, //!< Factory creates pages itself, not sub-components
|
||||
NoParent, //!< Factory creates pages itself, not sub-components
|
||||
Temporal, //!< Factory creates sub-components of the temporal properties page
|
||||
};
|
||||
|
||||
@ -130,7 +130,7 @@ class GUI_EXPORT QgsMapLayerConfigWidgetFactory
|
||||
/**
|
||||
* Returns the associated parent page, for factories which create sub-components of a standard page.
|
||||
*
|
||||
* The default implementation returns QgsMapLayerConfigWidgetFactory::ParentPage::None, indicating that the
|
||||
* The default implementation returns QgsMapLayerConfigWidgetFactory::ParentPage::NoParent, indicating that the
|
||||
* factory creates top-level pages which are not subcomponents.
|
||||
*
|
||||
* \since QGIS 3.20
|
||||
|
||||
@ -550,13 +550,24 @@ void QgsRasterLayerProperties::addPropertiesPageFactory( const QgsMapLayerConfig
|
||||
}
|
||||
|
||||
QgsMapLayerConfigWidget *page = factory->createWidget( mRasterLayer, nullptr, false, this );
|
||||
mLayerPropertiesPages << page;
|
||||
switch ( factory->parentPage() )
|
||||
{
|
||||
case QgsMapLayerConfigWidgetFactory::ParentPage::NoParent:
|
||||
{
|
||||
mLayerPropertiesPages << page;
|
||||
|
||||
const QString beforePage = factory->layerPropertiesPagePositionHint();
|
||||
if ( beforePage.isEmpty() )
|
||||
addPage( factory->title(), factory->title(), factory->icon(), page );
|
||||
else
|
||||
insertPage( factory->title(), factory->title(), factory->icon(), page, beforePage );
|
||||
const QString beforePage = factory->layerPropertiesPagePositionHint();
|
||||
if ( beforePage.isEmpty() )
|
||||
addPage( factory->title(), factory->title(), factory->icon(), page );
|
||||
else
|
||||
insertPage( factory->title(), factory->title(), factory->icon(), page, beforePage );
|
||||
break;
|
||||
}
|
||||
|
||||
case QgsMapLayerConfigWidgetFactory::ParentPage::Temporal:
|
||||
mTemporalWidget->addWidget( page );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void QgsRasterLayerProperties::setupTransparencyTable( int nBands )
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
#include "qgsrasterdataprovidertemporalcapabilities.h"
|
||||
#include "qgsrasterlayer.h"
|
||||
#include "qgsrasterlayertemporalproperties.h"
|
||||
#include "qgsmaplayerconfigwidget.h"
|
||||
|
||||
QgsRasterLayerTemporalPropertiesWidget::QgsRasterLayerTemporalPropertiesWidget( QWidget *parent, QgsRasterLayer *layer )
|
||||
: QWidget( parent )
|
||||
@ -30,10 +31,12 @@ QgsRasterLayerTemporalPropertiesWidget::QgsRasterLayerTemporalPropertiesWidget(
|
||||
Q_ASSERT( mLayer );
|
||||
setupUi( this );
|
||||
|
||||
mExtraWidgetContainer->setLayout( new QVBoxLayout() );
|
||||
|
||||
connect( mModeFixedRangeRadio, &QRadioButton::toggled, mFixedTimeRangeFrame, &QWidget::setEnabled );
|
||||
|
||||
mStartTemporalDateTimeEdit->setDisplayFormat( "yyyy-MM-dd HH:mm:ss" );
|
||||
mEndTemporalDateTimeEdit->setDisplayFormat( "yyyy-MM-dd HH:mm:ss" );
|
||||
mStartTemporalDateTimeEdit->setDisplayFormat( QStringLiteral( "yyyy-MM-dd HH:mm:ss" ) );
|
||||
mEndTemporalDateTimeEdit->setDisplayFormat( QStringLiteral( "yyyy-MM-dd HH:mm:ss" ) );
|
||||
|
||||
if ( !mLayer->dataProvider() || !mLayer->dataProvider()->temporalCapabilities()->hasTemporalCapabilities() )
|
||||
{
|
||||
@ -59,6 +62,11 @@ void QgsRasterLayerTemporalPropertiesWidget::saveTemporalProperties()
|
||||
else if ( mModeFixedRangeRadio->isChecked() )
|
||||
temporalProperties->setMode( QgsRasterLayerTemporalProperties::ModeFixedTemporalRange );
|
||||
temporalProperties->setFixedTemporalRange( normalRange );
|
||||
|
||||
for ( QgsMapLayerConfigWidget *widget : std::as_const( mExtraWidgets ) )
|
||||
{
|
||||
widget->apply();
|
||||
}
|
||||
}
|
||||
|
||||
void QgsRasterLayerTemporalPropertiesWidget::syncToLayer()
|
||||
@ -78,4 +86,15 @@ void QgsRasterLayerTemporalPropertiesWidget::syncToLayer()
|
||||
mEndTemporalDateTimeEdit->setDateTime( temporalProperties->fixedTemporalRange().end() );
|
||||
|
||||
mTemporalGroupBox->setChecked( temporalProperties->isActive() );
|
||||
|
||||
for ( QgsMapLayerConfigWidget *widget : std::as_const( mExtraWidgets ) )
|
||||
{
|
||||
widget->syncToLayer( mLayer );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsRasterLayerTemporalPropertiesWidget::addWidget( QgsMapLayerConfigWidget *widget )
|
||||
{
|
||||
mExtraWidgets << widget;
|
||||
mExtraWidgetContainer->layout()->addWidget( widget );
|
||||
}
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
#include "qgis_gui.h"
|
||||
|
||||
class QgsRasterLayer;
|
||||
class QgsMapLayerConfigWidget;
|
||||
|
||||
/**
|
||||
* \ingroup gui
|
||||
@ -51,6 +52,13 @@ class GUI_EXPORT QgsRasterLayerTemporalPropertiesWidget : public QWidget, privat
|
||||
*/
|
||||
void syncToLayer();
|
||||
|
||||
/**
|
||||
* Adds a child \a widget to the properties widget.
|
||||
*
|
||||
* \since QGIS 3.20
|
||||
*/
|
||||
void addWidget( QgsMapLayerConfigWidget *widget SIP_TRANSFER );
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
@ -58,5 +66,7 @@ class GUI_EXPORT QgsRasterLayerTemporalPropertiesWidget : public QWidget, privat
|
||||
*/
|
||||
QgsRasterLayer *mLayer = nullptr;
|
||||
|
||||
QList< QgsMapLayerConfigWidget * > mExtraWidgets;
|
||||
|
||||
};
|
||||
#endif // QGSRASTERLAYERTEMPORALPROPERTIESWIDGET_H
|
||||
|
||||
@ -52,7 +52,7 @@
|
||||
<height>413</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<layout class="QGridLayout" name="gridLayout" rowstretch="0,1">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
@ -65,6 +65,9 @@
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<widget class="QWidget" name="mExtraWidgetContainer" native="true"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="mTemporalGroupBox">
|
||||
<property name="enabled">
|
||||
@ -94,6 +97,19 @@ background: white;QgsCollapsibleGroupBoxBasic::title, QgsCollapsibleGroupBox::ti
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QRadioButton" name="mModeAutomaticRadio">
|
||||
<property name="toolTip">
|
||||
<string>Delegates temporal handling to the data provider</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Automatic</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QFrame" name="mFixedTimeRangeFrame">
|
||||
<property name="enabled">
|
||||
@ -108,7 +124,7 @@ background: white;QgsCollapsibleGroupBoxBasic::title, QgsCollapsibleGroupBox::ti
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2" columnstretch="0,2,0,2">
|
||||
<layout class="QGridLayout" name="gridLayout_2" columnstretch="0,0,0,0">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
@ -132,6 +148,19 @@ background: white;QgsCollapsibleGroupBoxBasic::title, QgsCollapsibleGroupBox::ti
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QgsDateTimeEdit" name="mStartTemporalDateTimeEdit">
|
||||
<property name="displayFormat">
|
||||
@ -149,48 +178,9 @@ background: white;QgsCollapsibleGroupBoxBasic::title, QgsCollapsibleGroupBox::ti
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QRadioButton" name="mModeAutomaticRadio">
|
||||
<property name="toolTip">
|
||||
<string>Delegates temporal handling to the data provider</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Automatic</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user