Skip to content

Commit

Permalink
Merge pull request #9381 from elpaso/gpkg-project-storage
Browse files Browse the repository at this point in the history
Gpkg project storage
  • Loading branch information
elpaso committed Mar 7, 2019
2 parents 12ba417 + e217693 commit 41cc02f
Show file tree
Hide file tree
Showing 11 changed files with 781 additions and 11 deletions.
8 changes: 6 additions & 2 deletions src/app/qgisapp.cpp
Expand Up @@ -5643,7 +5643,11 @@ void QgisApp::fileOpenAfterLaunch()
return;
}

if ( !projPath.endsWith( QLatin1String( ".qgs" ), Qt::CaseInsensitive ) &&
// Is this a storage based project?
const bool projectIsFromStorage { QgsApplication::instance()->projectStorageRegistry()->projectStorageFromUri( projPath ) };

if ( !projectIsFromStorage &&
!projPath.endsWith( QLatin1String( ".qgs" ), Qt::CaseInsensitive ) &&
!projPath.endsWith( QLatin1String( ".qgz" ), Qt::CaseInsensitive ) )
{
visibleMessageBar()->pushMessage( autoOpenMsgTitle,
Expand All @@ -5652,7 +5656,7 @@ void QgisApp::fileOpenAfterLaunch()
return;
}

if ( QFile::exists( projPath ) )
if ( projectIsFromStorage || QFile::exists( projPath ) )
{
// set flag to check on next app launch if the following project opened OK
settings.setValue( QStringLiteral( "qgis/projOpenedOKAtLaunch" ), QVariant( false ) );
Expand Down
3 changes: 3 additions & 0 deletions src/providers/ogr/CMakeLists.txt
Expand Up @@ -7,6 +7,7 @@ SET (OGR_SRCS
qgsgeopackagedataitems.cpp
qgsgeopackagerasterwriter.cpp
qgsgeopackagerasterwritertask.cpp
qgsgeopackageprojectstorage.cpp
qgsogrdbconnection.cpp
qgsogrdbtablemodel.cpp
qgsogrtransaction.cpp
Expand All @@ -27,10 +28,12 @@ IF (WITH_GUI)
SET(OGR_SRCS ${OGR_SRCS}
qgsogrdbsourceselect.cpp
qgsogrsourceselect.cpp
qgsgeopackageprojectstoragedialog.cpp
)
SET(OGR_MOC_HDRS ${OGR_MOC_HDRS}
qgsogrsourceselect.h
qgsogrdbsourceselect.h
qgsgeopackageprojectstoragedialog.h
)
ENDIF ()

Expand Down
13 changes: 12 additions & 1 deletion src/providers/ogr/qgsgeopackagedataitems.cpp
Expand Up @@ -42,7 +42,8 @@
#include "qgsproviderregistry.h"
#include "qgsproxyprogresstask.h"
#include "qgssqliteutils.h"

#include "qgsprojectstorageregistry.h"
#include "qgsgeopackageprojectstorage.h"

QGISEXTERN bool deleteLayer( const QString &uri, const QString &errCause );

Expand Down Expand Up @@ -144,6 +145,16 @@ QVector<QgsDataItem *> QgsGeoPackageCollectionItem::createChildren()
}
}
qDeleteAll( layers );
QgsProjectStorage *storage = QgsApplication::projectStorageRegistry()->projectStorageFromType( "geopackage" );
if ( storage )
{
const QStringList projectNames = storage->listProjects( mPath );
for ( const QString &projectName : projectNames )
{
QgsGeoPackageProjectUri projectUri { true, mPath, projectName };
children.append( new QgsProjectItem( this, projectName, QgsGeoPackageProjectStorage::encodeUri( projectUri ) ) );
}
}
return children;
}

Expand Down

0 comments on commit 41cc02f

Please sign in to comment.