Skip to content

Commit 5009aad

Browse files
committed
[Fix #7806] Be more verbose in "invalid layer" dialog
1 parent df19fe5 commit 5009aad

File tree

2 files changed

+24
-18
lines changed

2 files changed

+24
-18
lines changed

src/app/qgisapp.cpp

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -624,8 +624,8 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
624624
QString myPaths = settings.value( "plugins/searchPathsForPlugins", "" ).toString();
625625
if ( !myPaths.isEmpty() )
626626
{
627-
QStringList myPathList = myPaths.split( "|" );
628-
QgsPluginRegistry::instance()->restoreSessionPlugins( myPathList );
627+
QStringList myPathList = myPaths.split( "|" );
628+
QgsPluginRegistry::instance()->restoreSessionPlugins( myPathList );
629629
}
630630
}
631631

@@ -981,7 +981,7 @@ void QgisApp::createActions()
981981
connect( mActionAddWmsLayer, SIGNAL( triggered() ), this, SLOT( addWmsLayer() ) );
982982
connect( mActionAddWcsLayer, SIGNAL( triggered() ), this, SLOT( addWcsLayer() ) );
983983
connect( mActionAddWfsLayer, SIGNAL( triggered() ), this, SLOT( addWfsLayer() ) );
984-
connect( mActionAddDelimitedText, SIGNAL( triggered()), this, SLOT(addDelimitedTextLayer()));
984+
connect( mActionAddDelimitedText, SIGNAL( triggered() ), this, SLOT( addDelimitedTextLayer() ) );
985985
connect( mActionOpenTable, SIGNAL( triggered() ), this, SLOT( attributeTable() ) );
986986
connect( mActionOpenFieldCalc, SIGNAL( triggered() ), this, SLOT( fieldCalculator() ) );
987987
connect( mActionToggleEditing, SIGNAL( triggered() ), this, SLOT( toggleEditing() ) );
@@ -2934,7 +2934,11 @@ void QgisApp::addDatabaseLayers( QStringList const & layerPathList, QString cons
29342934
else
29352935
{
29362936
QgsMessageLog::logMessage( tr( "%1 is an invalid layer - not loaded" ).arg( layerPath ) );
2937-
QMessageBox::critical( this, tr( "Invalid Layer" ), tr( "%1 is an invalid layer and cannot be loaded." ).arg( layerPath ) );
2937+
QLabel* msgLabel = new QLabel( tr( "%1 is an invalid layer and cannot be loaded. Please check the <a href=\"#messageLog\">message log</a> for further info." ).arg( layerPath ), messageBar() );
2938+
msgLabel->setWordWrap( true );
2939+
connect( msgLabel, SIGNAL( linkActivated( QString ) ), mLogDock, SLOT( show() ) );
2940+
messageBar()->pushWidget( msgLabel,
2941+
QgsMessageBar::WARNING );
29382942
delete layer;
29392943
}
29402944
//qWarning("incrementing iterator");
@@ -4275,22 +4279,22 @@ void QgisApp::labeling()
42754279

42764280
void QgisApp::fieldCalculator()
42774281
{
4278-
if ( mMapCanvas && mMapCanvas->isDrawing() )
4279-
{
4280-
return;
4281-
}
4282+
if ( mMapCanvas && mMapCanvas->isDrawing() )
4283+
{
4284+
return;
4285+
}
42824286

4283-
QgsVectorLayer *myLayer = qobject_cast<QgsVectorLayer *>( activeLayer() );
4284-
if ( !myLayer )
4285-
{
4286-
return;
4287-
}
4287+
QgsVectorLayer *myLayer = qobject_cast<QgsVectorLayer *>( activeLayer() );
4288+
if ( !myLayer )
4289+
{
4290+
return;
4291+
}
42884292

4289-
QgsFieldCalculator calc( myLayer );
4290-
if ( calc.exec() )
4291-
{
4292-
mMapCanvas->refresh();
4293-
}
4293+
QgsFieldCalculator calc( myLayer );
4294+
if ( calc.exec() )
4295+
{
4296+
mMapCanvas->refresh();
4297+
}
42944298
}
42954299

42964300
void QgisApp::attributeTable()

src/providers/postgres/qgspostgresprovider.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ QgsPostgresProvider::QgsPostgresProvider( QString const & uri )
142142
// set the primary key
143143
if ( !determinePrimaryKey() )
144144
{
145+
QgsMessageLog::logMessage( tr( "PostgreSQL layer has no primary key." ), tr( "PostGIS" ) );
145146
mValid = false;
146147
disconnectDb();
147148
return;
@@ -200,6 +201,7 @@ QgsPostgresProvider::QgsPostgresProvider( QString const & uri )
200201
}
201202
break;
202203
case pktUnknown:
204+
QgsMessageLog::logMessage( tr( "PostgreSQL layer has unknown primary key type." ), tr( "PostGIS" ) );
203205
mValid = false;
204206
break;
205207
}

0 commit comments

Comments
 (0)