Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stac gui fixes #60493

Merged
merged 7 commits into from
Feb 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/gui/stac/qgsstacitemlistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ QVariant QgsStacItemListModel::data( const QModelIndex &index, int role ) const
{
return QVariant::fromValue( mItems.at( index.row() )->geometry() );
}
case Role::Extent:
{
return QVariant::fromValue( mItems.at( index.row() )->boundingBox() );
}
}

return QVariant();
Expand Down
27 changes: 15 additions & 12 deletions src/gui/stac/qgsstacsourceselect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ void QgsStacSourceSelect::btnConnect_clicked()
mStac->fetchStacObjectAsync( connection.url );
mFiltersLabel->clear();
mFiltersButton->setEnabled( false );
emit enableButtons( false );
}

void QgsStacSourceSelect::btnNew_clicked()
Expand Down Expand Up @@ -364,7 +365,7 @@ void QgsStacSourceSelect::onItemCollectionRequestFinished( int requestId, QStrin
#ifndef __clang_analyzer__
// Let the results appear, then fetch more if there's no scrollbar
QTimer::singleShot( 100, this, [=] {
if ( !mItemsView->verticalScrollBar()->isVisible() )
if ( isVisible() && !mItemsView->verticalScrollBar()->isVisible() )
{
fetchNextResultPage();
}
Expand Down Expand Up @@ -493,7 +494,7 @@ void QgsStacSourceSelect::showItemsContextMenu( QPoint point )
if ( QgsDataSourceManagerDialog *dsm = qobject_cast<QgsDataSourceManagerDialog *>( window() ) )
bar = dsm->messageBar();

QMenu *assetsMenu = menu->addMenu( tr( "Add Layer" ) );
QMenu *assetsMenu = new QMenu( tr( "Add Layer" ), menu );
if ( const QgsStacItem *item = dynamic_cast<QgsStacItem *>( index.data( QgsStacItemListModel::Role::StacObject ).value<QgsStacObject *>() ) )
{
const QMap<QString, QgsStacAsset> assets = item->assets();
Expand All @@ -512,28 +513,27 @@ void QgsStacSourceSelect::showItemsContextMenu( QPoint point )
}

QAction *zoomToAction = new QAction( tr( "Zoom to Item" ), menu );
connect( zoomToAction, &QAction::triggered, this, [index, this] {
QgsGeometry geom = index.data( QgsStacItemListModel::Role::Geometry ).value<QgsGeometry>();
const QgsRectangle bbox = index.data( QgsStacItemListModel::Role::Extent ).value<QgsBox3D>().toRectangle();
connect( zoomToAction, &QAction::triggered, this, [bbox, this] {
if ( QgsMapCanvas *map = mapCanvas() )
{
const QgsRectangle bbox = geom.boundingBox();
const QgsCoordinateTransform ct( QgsCoordinateReferenceSystem::fromEpsgId( 4324 ), map->mapSettings().destinationCrs(), QgsProject::instance() );
const QgsCoordinateTransform ct( QgsCoordinateReferenceSystem::fromEpsgId( 4326 ), map->mapSettings().destinationCrs(), QgsProject::instance() );
QgsRectangle extent = ct.transformBoundingBox( bbox );
map->zoomToFeatureExtent( extent );
}
} );
zoomToAction->setEnabled( !bbox.isNull() );

QAction *panToAction = new QAction( tr( "Pan to Item" ), menu );
connect( panToAction, &QAction::triggered, this, [index, this] {
QgsGeometry geom = index.data( QgsStacItemListModel::Role::Geometry ).value<QgsGeometry>();
connect( panToAction, &QAction::triggered, this, [bbox, this] {
if ( QgsMapCanvas *map = mapCanvas() )
{
const QgsRectangle bbox = geom.boundingBox();
const QgsCoordinateTransform ct( QgsCoordinateReferenceSystem::fromEpsgId( 4324 ), map->mapSettings().destinationCrs(), QgsProject::instance() );
const QgsCoordinateTransform ct( QgsCoordinateReferenceSystem::fromEpsgId( 4326 ), map->mapSettings().destinationCrs(), QgsProject::instance() );
const QgsRectangle extent = ct.transformBoundingBox( bbox );
map->setCenter( extent.center() );
}
} );
panToAction->setEnabled( !bbox.isNull() );

QAction *downloadAction = new QAction( tr( "Download Assets…" ), menu );
connect( downloadAction, &QAction::triggered, this, [index, bar, authCfg = mStac->authCfg()] {
Expand All @@ -553,8 +553,11 @@ void QgsStacSourceSelect::showItemsContextMenu( QPoint point )
} );


menu->addAction( zoomToAction );
menu->addAction( panToAction );
if ( mapCanvas() )
{
menu->addAction( zoomToAction );
menu->addAction( panToAction );
}
if ( !assetsMenu->isEmpty() )
menu->addMenu( assetsMenu );
menu->addAction( downloadAction );
Expand Down
31 changes: 9 additions & 22 deletions src/ui/stac/qgsstacsearchparametersdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<item row="0" column="1">
<widget class="QgsDateTimeEdit" name="mFromDateTimeEdit">
<property name="currentSection">
<enum>QDateTimeEdit::YearSection</enum>
<enum>QDateTimeEdit::Section::YearSection</enum>
</property>
<property name="displayFormat">
<string>yyyy-MM-dd HH:mm:ss</string>
Expand All @@ -63,7 +63,7 @@
<bool>true</bool>
</property>
<property name="timeSpec">
<enum>Qt::UTC</enum>
<enum>Qt::TimeSpec::UTC</enum>
</property>
</widget>
</item>
Expand All @@ -77,7 +77,7 @@
<item row="1" column="1">
<widget class="QgsDateTimeEdit" name="mToDateTimeEdit">
<property name="currentSection">
<enum>QDateTimeEdit::YearSection</enum>
<enum>QDateTimeEdit::Section::YearSection</enum>
</property>
<property name="displayFormat">
<string>yyyy-MM-dd HH:mm:ss</string>
Expand All @@ -86,7 +86,7 @@
<bool>true</bool>
</property>
<property name="timeSpec">
<enum>Qt::UTC</enum>
<enum>Qt::TimeSpec::UTC</enum>
</property>
</widget>
</item>
Expand All @@ -95,7 +95,7 @@
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down Expand Up @@ -135,7 +135,7 @@
<item>
<widget class="QListView" name="mCollectionsListView">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
<set>QAbstractItemView::EditTrigger::NoEditTriggers</set>
</property>
<property name="showDropIndicator" stdset="0">
<bool>false</bool>
Expand All @@ -161,7 +161,7 @@
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand All @@ -176,26 +176,13 @@
</layout>
</widget>
</item>
<item>
<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>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
</property>
</widget>
</item>
Expand Down
Loading