Skip to content
Permalink
Browse files

Show commit errors in transaction mode

  • Loading branch information
m-kuhn committed Oct 18, 2016
1 parent 70ae301 commit e0fc641402b7dc9d46eb740f1ad8530a23a8fe18
Showing with 43 additions and 7 deletions.
  1. +8 −1 python/core/qgsproject.sip
  2. +10 −0 src/app/qgisapp.cpp
  3. +2 −0 src/app/qgisapp.h
  4. +10 −2 src/core/qgsproject.cpp
  5. +13 −4 src/core/qgsproject.h
@@ -467,8 +467,15 @@ class QgsProject : QObject
*/
void variablesChanged();

public slots:
/**
* Emitted whenever a new transaction group has been created or a
* transaction group has been removed.
*
* @note Added in QGIS 3.0
*/
void transactionGroupsChanged();

public slots:
/**
* Flag the project as dirty (modified). If this flag is set, the user will
* be asked to save changes to the project before closing the current project.
@@ -2773,6 +2773,8 @@ void QgisApp::setupConnections()
connect( this, SIGNAL( projectRead() ),
this, SLOT( fileOpenedOKAfterLaunch() ) );

connect( QgsProject::instance(), &QgsProject::transactionGroupsChanged, this, &QgisApp::onTransactionGroupsChanged );

// connect preview modes actions
connect( mActionPreviewModeOff, SIGNAL( triggered() ), this, SLOT( disablePreviewMode() ) );
connect( mActionPreviewModeGrayscale, SIGNAL( triggered() ), this, SLOT( activateGrayscalePreview() ) );
@@ -11201,6 +11203,14 @@ void QgisApp::keyPressEvent( QKeyEvent * e )
}
}

void QgisApp::onTransactionGroupsChanged()
{
Q_FOREACH ( QgsTransactionGroup* tg, QgsProject::instance()->transactionGroups().values() )
{
connect( tg, SIGNAL( commitError( QString ) ), this, SLOT( displayMessage( QString, QString, QgsMessageBar::MessageLevel ) ), Qt::UniqueConnection );
}
}

void QgisApp::startProfile( const QString& name )
{
mProfiler->start( name );
@@ -726,6 +726,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
#endif

private slots:
void onTransactionGroupsChanged();

//! validate a SRS
void validateCrs( QgsCoordinateReferenceSystem &crs );

@@ -995,6 +995,8 @@ void QgsProject::onMapLayersAdded( const QList<QgsMapLayer*>& layers )
{
QMap<QString, QgsMapLayer*> existingMaps = QgsMapLayerRegistry::instance()->mapLayers();

bool tgChanged = false;

Q_FOREACH ( QgsMapLayer* layer, layers )
{
QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer*>( layer );
@@ -1013,15 +1015,17 @@ void QgsProject::onMapLayersAdded( const QList<QgsMapLayer*>& layers )
{
tg = new QgsTransactionGroup();
mTransactionGroups.insert( qMakePair( key, connString ), tg );

connect( tg, SIGNAL( commitError( QString ) ), this, SLOT( displayMapToolMessage( QString ) ) );
tgChanged = true;
}
tg->addLayer( vlayer );
}
}
vlayer->dataProvider()->setProviderProperty( QgsVectorDataProvider::EvaluateDefaultValues, evaluateDefaultValues() );
}

if ( tgChanged )
emit transactionGroupsChanged();

connect( layer, SIGNAL( configChanged() ), this, SLOT( setDirty() ) );

// check if we have to update connections for layers with dependencies
@@ -1039,18 +1043,22 @@ void QgsProject::onMapLayersAdded( const QList<QgsMapLayer*>& layers )

void QgsProject::cleanTransactionGroups( bool force )
{
bool changed = false;
for ( QMap< QPair< QString, QString>, QgsTransactionGroup*>::Iterator tg = mTransactionGroups.begin(); tg != mTransactionGroups.end(); )
{
if ( tg.value()->isEmpty() || force )
{
delete tg.value();
tg = mTransactionGroups.erase( tg );
changed = true;
}
else
{
++tg;
}
}
if ( changed )
emit transactionGroupsChanged();
}

bool QgsProject::read( QDomNode &layerNode )
@@ -513,9 +513,11 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera
//! emitted when an old project file is read.
void oldProjectVersionWarning( const QString& );

//! emitted when a layer from a projects was read
// @param i current layer
// @param n number of layers
/**
* Emitted when a layer from a projects was read.
* @param i current layer
* @param n number of layers
*/
void layerLoaded( int i, int n );

void loadingLayer( const QString& );
@@ -536,8 +538,15 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera
*/
void variablesChanged();

public slots:
/**
* Emitted whenever a new transaction group has been created or a
* transaction group has been removed.
*
* @note Added in QGIS 3.0
*/
void transactionGroupsChanged();

public slots:
/**
* Flag the project as dirty (modified). If this flag is set, the user will
* be asked to save changes to the project before closing the current project.

0 comments on commit e0fc641

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