Skip to content

Commit

Permalink
Review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
uclaros committed Nov 22, 2024
1 parent 8edbd82 commit 6bb127e
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 28 deletions.
10 changes: 4 additions & 6 deletions src/core/stac/qgsstacasset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,10 @@ QStringList QgsStacAsset::roles() const

bool QgsStacAsset::isCloudOptimized() const
{
if ( mMediaType == QLatin1String( "image/tiff; application=geotiff; profile=cloud-optimized" ) ||
mMediaType == QLatin1String( "image/vnd.stac.geotiff; cloud-optimized=true" ) ||
mMediaType == QLatin1String( "application/vnd.laszip+copc" ) ||
mHref.endsWith( QLatin1String( "/ept.json" ) ) )
return true;
return false;
const QString format = formatName();
return format == QLatin1String( "COG" ) ||
format == QLatin1String( "COPC" ) ||
format == QLatin1String( "EPT" );
}

QString QgsStacAsset::formatName() const
Expand Down
7 changes: 3 additions & 4 deletions src/core/stac/qgsstacitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,7 @@ QgsMimeDataUtils::UriList QgsStacItem::uris() const
{
uri.uri = it->href();
}
else if ( it->mediaType() == QLatin1String( "image/tiff; application=geotiff; profile=cloud-optimized" ) ||
it->mediaType() == QLatin1String( "image/vnd.stac.geotiff; cloud-optimized=true" ) )
else if ( it->formatName() == QLatin1String( "COG" ) )
{
uri.layerType = QStringLiteral( "raster" );
uri.providerKey = QStringLiteral( "gdal" );
Expand All @@ -218,13 +217,13 @@ QgsMimeDataUtils::UriList QgsStacItem::uris() const
uri.uri = it->href();
}
}
else if ( it->mediaType() == QLatin1String( "application/vnd.laszip+copc" ) )
else if ( it->formatName() == QLatin1String( "COPC" ) )
{
uri.layerType = QStringLiteral( "pointcloud" );
uri.providerKey = QStringLiteral( "copc" );
uri.uri = it->href();
}
else if ( it->href().endsWith( QStringLiteral( "/ept.json" ) ) )
else if ( it->formatName() == QLatin1String( "EPT" ) )
{
uri.layerType = QStringLiteral( "pointcloud" );
uri.providerKey = QStringLiteral( "ept" );
Expand Down
2 changes: 1 addition & 1 deletion src/core/stac/qgsstacitemcollection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include "qgsstacitemcollection.h"

QgsStacItemCollection::QgsStacItemCollection( const QVector< QgsStacItem * > items, const QVector< QgsStacLink > links, int numberMatched )
QgsStacItemCollection::QgsStacItemCollection( const QVector< QgsStacItem * > &items, const QVector< QgsStacLink > &links, int numberMatched )
: mItems( items )
, mLinks( links )
, mNumberMatched( numberMatched )
Expand Down
2 changes: 1 addition & 1 deletion src/core/stac/qgsstacitemcollection.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class CORE_EXPORT QgsStacItemCollection
* \param numberMatched The total number of items in the parent catalog, collection or total matching results from a STAC API endpoint
* \note ownership of \a items is transferred. Items will be deleted when object is destroyed.
*/
QgsStacItemCollection( const QVector< QgsStacItem * > items, const QVector< QgsStacLink > links, int numberMatched = -1 );
QgsStacItemCollection( const QVector< QgsStacItem * > &items, const QVector< QgsStacLink > &links, int numberMatched = -1 );

//! Destructor
~QgsStacItemCollection();
Expand Down
20 changes: 14 additions & 6 deletions src/gui/stac/qgsstacitemlistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
***************************************************************************/

#include "qgsstacitemlistmodel.h"
#include "moc_qgsstacitemlistmodel.cpp"
#include "qgsstacitem.h"
#include "qgsstaccollection.h"
#include "qgsnetworkcontentfetcher.h"
Expand Down Expand Up @@ -119,7 +120,7 @@ void QgsStacItemListModel::clear()
endResetModel();
}

void QgsStacItemListModel::setCollections( const QVector<QgsStacCollection *> collections )
void QgsStacItemListModel::setCollections( const QVector<QgsStacCollection *> &collections )
{
for ( QgsStacCollection *col : collections )
{
Expand All @@ -128,7 +129,7 @@ void QgsStacItemListModel::setCollections( const QVector<QgsStacCollection *> co
}
}

void QgsStacItemListModel::addItems( const QVector<QgsStacItem *> items )
void QgsStacItemListModel::addItems( const QVector<QgsStacItem *> &items )
{
int nextItemIndex = mItems.count();
beginInsertRows( QModelIndex(), mItems.size(), mItems.size() + items.size() - 1 );
Expand Down Expand Up @@ -156,7 +157,10 @@ void QgsStacItemListModel::addItems( const QVector<QgsStacItem *> items )
previewPainter.setRenderHint( QPainter::Antialiasing, true );
previewPainter.setPen( Qt::NoPen );
previewPainter.setBrush( Qt::black );
previewPainter.drawRoundedRect( 0, 0, previewImage.width(), previewImage.height(), previewImage.width() / 10, previewImage.width() / 10 );
previewPainter.drawRoundedRect( 0, 0,
previewImage.width(), previewImage.height(),
static_cast<double>( previewImage.width() ) / 10.,
static_cast<double>( previewImage.width() ) / 10. );
previewPainter.setCompositionMode( QPainter::CompositionMode_SourceIn );
previewPainter.drawImage( 0, 0, img );
previewPainter.end();
Expand Down Expand Up @@ -222,8 +226,11 @@ void QgsStacItemDelegate::paint( QPainter *painter, const QStyleOptionViewItem &
painter->setRenderHint( QPainter::SmoothPixmapTransform, true );
painter->setPen( QColor( 0, 0, 0, 0 ) );
painter->setBrush( QBrush( color ) );
painter->drawRoundedRect( option.rect.left() + 0.625 * mRoundedRectSizePixels, option.rect.top() + 0.625 * mRoundedRectSizePixels,
option.rect.width() - 2 * 0.625 * mRoundedRectSizePixels, option.rect.height() - 2 * 0.625 * mRoundedRectSizePixels, mRoundedRectSizePixels, mRoundedRectSizePixels );
painter->drawRoundedRect( option.rect.left() + static_cast<int>( 0.625 * mRoundedRectSizePixels ),
option.rect.top() + static_cast<int>( 0.625 * mRoundedRectSizePixels ),
option.rect.width() - static_cast<int>( 2 * 0.625 * mRoundedRectSizePixels ),
option.rect.height() - static_cast<int>( 2 * 0.625 * mRoundedRectSizePixels ),
mRoundedRectSizePixels, mRoundedRectSizePixels );

const QFontMetrics fm( option.font );
const int textSize = static_cast<int>( fm.height() * 0.85 );
Expand All @@ -244,7 +251,8 @@ void QgsStacItemDelegate::paint( QPainter *painter, const QStyleOptionViewItem &

if ( !icon.isNull() )
{
painter->drawPixmap( option.rect.left() + 1.25 * mRoundedRectSizePixels, option.rect.top() + 1.25 * mRoundedRectSizePixels,
painter->drawPixmap( option.rect.left() + static_cast<int>( 1.25 * mRoundedRectSizePixels ),
option.rect.top() + static_cast<int>( 1.25 * mRoundedRectSizePixels ),
iconSize.width(), iconSize.height(), icon );
}

Expand Down
4 changes: 2 additions & 2 deletions src/gui/stac/qgsstacitemlistmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ class QgsStacItemListModel : public QAbstractListModel
void clear();

//! Builds collection dictionary. Does not take ownership
void setCollections( const QVector< QgsStacCollection * > collections );
void setCollections( const QVector< QgsStacCollection * > &collections );
//! Add items to the model. Takes ownership
void addItems( const QVector< QgsStacItem * > items );
void addItems( const QVector< QgsStacItem * > &items );

private:
QVector< QgsStacItem * > mItems;
Expand Down
3 changes: 2 additions & 1 deletion src/gui/stac/qgsstacsearchparametersdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
***************************************************************************/

#include "qgsstacsearchparametersdialog.h"
#include "moc_qgsstacsearchparametersdialog.cpp"
#include "qgsgui.h"
#include "qgsmapcanvas.h"
#include "qgsprojecttimesettings.h"
Expand Down Expand Up @@ -53,7 +54,7 @@ QgsStacSearchParametersDialog::QgsStacSearchParametersDialog( QgsMapCanvas *canv
mCollectionsFilterLineEdit->setShowSearchIcon( true );

mMenu = new QMenu( this );
mTemporalExtentFromProjectAction = new QAction( tr( "Use project's temporal extent" ), this );
mTemporalExtentFromProjectAction = new QAction( tr( "Use Project's Temporal Extent" ), this );
connect( mTemporalExtentFromProjectAction, &QAction::triggered, this, &QgsStacSearchParametersDialog::readTemporalExtentsFromProject );

mMenu->addAction( mTemporalExtentFromProjectAction );
Expand Down
3 changes: 2 additions & 1 deletion src/gui/stac/qgsstacsourceselect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
***************************************************************************/

#include "qgsstacsourceselect.h"
#include "moc_qgsstacsourceselect.cpp"
#include "qgsgui.h"
#include "qgsmapcanvas.h"
#include "qgsstaccontroller.h"
Expand Down Expand Up @@ -47,7 +48,7 @@ QgsStacSourceSelect::QgsStacSourceSelect( QWidget *parent, Qt::WindowFlags fl, Q
setupUi( this );
QgsGui::enableAutoGeometryRestore( this );

setWindowTitle( tr( "Add Layer from STAC catalog" ) );
setWindowTitle( tr( "Add Layer from STAC Catalog" ) );

connect( btnConnect, &QToolButton::clicked, this, &QgsStacSourceSelect::btnConnect_clicked );
connect( btnNew, &QToolButton::clicked, this, &QgsStacSourceSelect::btnNew_clicked );
Expand Down
2 changes: 1 addition & 1 deletion src/gui/stac/qgsstacsourceselectprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ QString QgsStacSourceSelectProvider::text() const

QString QgsStacSourceSelectProvider::toolTip() const
{
return QObject::tr( "Spatio-Temporal Asset Catalog " );
return QObject::tr( "Spatio-Temporal Asset Catalog" );
}

QIcon QgsStacSourceSelectProvider::icon() const
Expand Down
2 changes: 1 addition & 1 deletion src/ui/qgisapp.ui
Original file line number Diff line number Diff line change
Expand Up @@ -3353,7 +3353,7 @@ Shows placeholders for labels which could not be placed, e.g. due to overlaps wi
<normaloff>:/images/themes/default/mIconStac.svg</normaloff>:/images/themes/default/mIconStac.svg</iconset>
</property>
<property name="text">
<string>Add layer from STAC catalog…</string>
<string>Add Layer from STAC Catalog…</string>
</property>
</action>
</widget>
Expand Down
5 changes: 1 addition & 4 deletions src/ui/qgsstacsourceselectbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
<height>594</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="GroupBox1">
Expand Down Expand Up @@ -123,7 +120,7 @@
<bool>false</bool>
</property>
<property name="text">
<string>Filters...</string>
<string>Filters</string>
</property>
</widget>
</item>
Expand Down

0 comments on commit 6bb127e

Please sign in to comment.