Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
better error message and fix OWS connection list
  • Loading branch information
3nids committed Jan 16, 2023
1 parent 72387f6 commit 5cdc28c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/core/qgsowsconnection.cpp
Expand Up @@ -247,17 +247,17 @@ QgsDataSourceUri &QgsOwsConnection::addWfsConnectionSettings( QgsDataSourceUri &

QStringList QgsOwsConnection::connectionList( const QString &service )
{
return QgsOwsConnection::sTtreeOwsServices->items( {service.toLower()} );
return QgsOwsConnection::sTreeOwsConnections->items( {service.toLower()} );
}

QString QgsOwsConnection::selectedConnection( const QString &service )
{
return QgsOwsConnection::sTtreeOwsServices->selectedItem( {service.toLower()} );
return QgsOwsConnection::sTreeOwsConnections->selectedItem( {service.toLower()} );
}

void QgsOwsConnection::setSelectedConnection( const QString &service, const QString &name )
{
QgsOwsConnection::sTtreeOwsServices->setSelectedItem( name, {service.toLower()} );
QgsOwsConnection::sTreeOwsConnections->setSelectedItem( name, {service.toLower()} );
}

void QgsOwsConnection::addCommonConnectionSettings( QgsDataSourceUri &uri, const QString &key )
Expand Down
22 changes: 11 additions & 11 deletions src/core/settings/qgssettingstreeelement.cpp
Expand Up @@ -155,18 +155,18 @@ QgsSettingsTreeNamedListElement::~QgsSettingsTreeNamedListElement()
}


QStringList QgsSettingsTreeNamedListElement::items( const QStringList &parentNamedItems ) const
QStringList QgsSettingsTreeNamedListElement::items( const QStringList &parentsNamedItems ) const
{
return items( Qgis::SettingsOrigin::Any, parentNamedItems );
return items( Qgis::SettingsOrigin::Any, parentsNamedItems );
}

QStringList QgsSettingsTreeNamedListElement::items( Qgis::SettingsOrigin origin, const QStringList &parentNamedItems ) const
QStringList QgsSettingsTreeNamedListElement::items( Qgis::SettingsOrigin origin, const QStringList &parentsNamedItems ) const
{
if ( namedElementsCount() - 1 != parentNamedItems.count() )
throw QgsSettingsException( QObject::tr( "The number of given parent named items (%1) doesn't match with the number of named items in the key (%2)." ).arg( parentNamedItems.count(), namedElementsCount() ) );
if ( namedElementsCount() - 1 != parentsNamedItems.count() )
throw QgsSettingsException( QObject::tr( "The number of given parent named items (%1) for the element '%2' doesn't match with the number of named items in the key (%3)." ).arg( QString::number( parentsNamedItems.count() ), mCompleteKey, QString::number( namedElementsCount() ) ) );


const QString completeKeyParam = completeKeyWithNamedItems( mItemsCompleteKey, parentNamedItems );
const QString completeKeyParam = completeKeyWithNamedItems( mItemsCompleteKey, parentsNamedItems );
QgsSettings settings;
settings.beginGroup( completeKeyParam );
return settings.childGroups( origin );
Expand All @@ -175,27 +175,27 @@ QStringList QgsSettingsTreeNamedListElement::items( Qgis::SettingsOrigin origin,
void QgsSettingsTreeNamedListElement::setSelectedItem( const QString &item, const QStringList &parentsNamedItems )
{
if ( namedElementsCount() - 1 != parentsNamedItems.count() )
throw QgsSettingsException( QObject::tr( "The number of given parent named items (%1) doesn't match with the number of named items in the key (%2)." ).arg( parentsNamedItems.count(), namedElementsCount() ) );
throw QgsSettingsException( QObject::tr( "The number of given parent named items (%1) for the element '%2' doesn't match with the number of named items in the key (%3)." ).arg( QString::number( parentsNamedItems.count() ), mCompleteKey, QString::number( namedElementsCount() ) ) );
if ( !mOptions.testFlag( Option::NamedListSelectedItemSetting ) )
throw QgsSettingsException( QObject::tr( "The named list element has no option to set the current selected entry." ) );
throw QgsSettingsException( QObject::tr( "The named list element '%1' has no option to set the current selected entry." ).arg( mCompleteKey ) );

mSelectedItemSetting->setValue( item, parentsNamedItems );
}

QString QgsSettingsTreeNamedListElement::selectedItem( const QStringList &parentsNamedItems )
{
if ( namedElementsCount() - 1 != parentsNamedItems.count() )
throw QgsSettingsException( QObject::tr( "The number of given parent named items (%1) doesn't match with the number of named items in the key (%2)." ).arg( parentsNamedItems.count(), namedElementsCount() ) );
throw QgsSettingsException( QObject::tr( "The number of given parent named items (%1) for the element '%2' doesn't match with the number of named items in the key (%3)." ).arg( QString::number( parentsNamedItems.count() ), mCompleteKey, QString::number( namedElementsCount() ) ) );
if ( !mOptions.testFlag( Option::NamedListSelectedItemSetting ) )
throw QgsSettingsException( QObject::tr( "The named list element has no option to set the current selected entry." ) );
throw QgsSettingsException( QObject::tr( "The named list element '%1' has no option to set the current selected entry." ).arg( mCompleteKey ) );

return mSelectedItemSetting->value( parentsNamedItems );
}

void QgsSettingsTreeNamedListElement::deleteItem( const QString &item, const QStringList &parentsNamedItems )
{
if ( namedElementsCount() - 1 != parentsNamedItems.count() )
throw QgsSettingsException( QObject::tr( "The number of given parent named items (%1) doesn't match with the number of named items in the key (%2)." ).arg( parentsNamedItems.count(), namedElementsCount() ) );
throw QgsSettingsException( QObject::tr( "The number of given parent named items (%1) doesn't match with the number of named items in the key (%2)." ).arg( parentsNamedItems.count(), namedElementsCount() ) );
if ( !mOptions.testFlag( Option::NamedListSelectedItemSetting ) )
throw QgsSettingsException( QObject::tr( "The named list element has no option to set the current selected entry." ) );

Expand Down

0 comments on commit 5cdc28c

Please sign in to comment.