Skip to content
Permalink
Browse files

Show provider errors more prominently

  • Loading branch information
m-kuhn committed Feb 20, 2016
1 parent fef9c93 commit 4c63c85cca6b33150c2af67895a2083dc69a7c5d
@@ -352,6 +352,10 @@ class QgsVectorDataProvider : QgsDataProvider
*/
virtual QSet<QString> layerDependencies() const;

signals:
/** Signals an error in this provider */
void raiseError( const QString& msg );

protected:
void clearMinMaxCache();
void fillMinMaxCache();
@@ -1786,6 +1786,10 @@ class QgsVectorLayer : QgsMapLayer
*/
void writeCustomSymbology( QDomElement& element, QDomDocument& doc, QString& errorMessage ) const;

/**
* Signals an error related to this vector layer.
*/
void raiseError( const QString& msg );

protected:
/** Set the extent */
@@ -9574,6 +9574,8 @@ void QgisApp::layersWereAdded( const QList<QgsMapLayer *>& theLayers )
}
}

connect( vlayer, SIGNAL( raiseError( QString ) ), this, SLOT( onLayerError( QString ) ) );

provider = vProvider;
}

@@ -11225,6 +11227,15 @@ void QgisApp::showStatisticsDockWidget()
mStatisticalSummaryDockWidget->raise();
}

void QgisApp::onLayerError( const QString& msg )
{
QgsVectorLayer* layer = qobject_cast<QgsVectorLayer*>( sender() );

Q_ASSERT( layer );

mInfoBar->pushCritical( tr( "Layer %1" ).arg( layer->name() ), msg );
}


#ifdef HAVE_TOUCH
bool QgisApp::gestureEvent( QGestureEvent *event )
@@ -1278,6 +1278,9 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
*/
void showStatisticsDockWidget();

/** Pushes a layer error to the message bar */
void onLayerError( const QString& msg );

signals:
/** Emitted when a key is pressed and we want non widget sublasses to be able
to pick up on this (e.g. maplayer) */
@@ -559,6 +559,7 @@ void QgsVectorDataProvider::pushError( const QString& msg )
{
QgsDebugMsg( msg );
mErrors << msg;
emit raiseError( msg );
}

QSet<QString> QgsVectorDataProvider::layerDependencies() const
@@ -404,6 +404,10 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
*/
virtual QSet<QString> layerDependencies() const;

signals:
/** Signals an error in this provider */
void raiseError( const QString& msg );

protected:
void clearMinMaxCache();
void fillMinMaxCache();
@@ -1524,6 +1524,7 @@ bool QgsVectorLayer::setDataProvider( QString const & provider )
// version big-time with an abnormal termination error
delete mDataProvider;
mDataProvider = ( QgsVectorDataProvider* )( QgsProviderRegistry::instance()->provider( provider, mDataSource ) );
connect( mDataProvider, SIGNAL( raiseError( QString ) ), this, SIGNAL( raiseError( QString ) ) );

if ( !mDataProvider )
{
@@ -1831,6 +1831,10 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
* This can be due to manually adding attributes or due to a join.
*/
void updatedFields();

/**
* TODO QGIS3: remove in favor of QObject::destroyed
*/
void layerDeleted();

void attributeValueChanged( QgsFeatureId fid, int idx, const QVariant & );
@@ -1898,6 +1902,11 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
*/
void writeCustomSymbology( QDomElement& element, QDomDocument& doc, QString& errorMessage ) const;

/**
* Signals an error related to this vector layer.
*/
void raiseError( const QString& msg );

private slots:
void onJoinedFieldsChanged();
void onFeatureDeleted( QgsFeatureId fid );

0 comments on commit 4c63c85

Please sign in to comment.
You can’t perform that action at this time.