Skip to content

Commit

Permalink
add external storage display name
Browse files Browse the repository at this point in the history
  • Loading branch information
troopa81 committed Aug 11, 2021
1 parent 12268c6 commit bbd9464
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ and registered in :py:class:`QgsExternalStorageRegistry`.
virtual QString type() const = 0;
%Docstring
Unique identifier of the external storage type.
%End

virtual QString displayName() const = 0;
%Docstring
Returns the translated external storage name, which should be used for any
user-visible display of the external storage name.
%End

QgsExternalStorageStoredContent *store( const QString &filePath, const QString &url, const QString &authCfg = QString(), Qgis::ActionStart storingMode = Qgis::ActionStart::Deferred ) const /Factory/;
Expand Down
6 changes: 6 additions & 0 deletions src/core/externalstorage/qgsexternalstorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ class CORE_EXPORT QgsExternalStorage
*/
virtual QString type() const = 0;

/**
* Returns the translated external storage name, which should be used for any
* user-visible display of the external storage name.
*/
virtual QString displayName() const = 0;

/**
* Stores file \a filePath to the \a url for this project external storage.
* Storing process is run in background.
Expand Down
5 changes: 5 additions & 0 deletions src/core/externalstorage/qgssimplecopyexternalstorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ QString QgsSimpleCopyExternalStorage::type() const
return QStringLiteral( "SimpleCopy" );
};

QString QgsSimpleCopyExternalStorage::displayName() const
{
return QObject::tr( "Simple copy" );
};

QgsExternalStorageStoredContent *QgsSimpleCopyExternalStorage::doStore( const QString &filePath, const QString &url, const QString &authcfg ) const
{
return new QgsSimpleCopyExternalStorageStoredContent( filePath, url, authcfg );
Expand Down
2 changes: 2 additions & 0 deletions src/core/externalstorage/qgssimplecopyexternalstorage_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class CORE_EXPORT QgsSimpleCopyExternalStorage : public QgsExternalStorage

QString type() const override;

QString displayName() const override;

QgsExternalStorageStoredContent *doStore( const QString &filePath, const QString &url, const QString &authcfg = QString() ) const override;

QgsExternalStorageFetchedContent *doFetch( const QString &url, const QString &authConfig = QString() ) const override;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/editorwidgets/qgsexternalresourceconfigdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ QgsExternalResourceConfigDlg::QgsExternalResourceConfigDlg( QgsVectorLayer *vl,
mStorageType->addItem( tr( "Select Existing file" ), QString() );
for ( QgsExternalStorage *storage : QgsApplication::externalStorageRegistry()->externalStorages() )
{
mStorageType->addItem( tr( "Store with %1" ).arg( storage->type() ), storage->type() );
mStorageType->addItem( storage->displayName(), storage->type() );
}

mExternalStorageGroupBox->setVisible( false );
Expand Down
2 changes: 2 additions & 0 deletions tests/src/gui/testqgsexternalresourcewidgetwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ class QgsTestExternalStorage : public QgsExternalStorage

QString type() const override { return QStringLiteral( "test" ); }

QString displayName() const override { return QStringLiteral( "Test" ); }

QgsExternalStorageStoredContent *doStore( const QString &filePath, const QString &url, const QString &authcfg = QString() ) const override
{
Q_UNUSED( authcfg );
Expand Down
2 changes: 2 additions & 0 deletions tests/src/gui/testqgsexternalstoragefilewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ class QgsTestExternalStorage : public QgsExternalStorage

QString type() const override { return QStringLiteral( "test" ); }

QString displayName() const override { return QStringLiteral( "Test" ); }

static QPointer<QgsTestExternalStorageStoredContent> sCurrentStoredContent;

protected:
Expand Down

0 comments on commit bbd9464

Please sign in to comment.