Skip to content
Permalink
Browse files

Add QgsProject::transactionGroup() available & with Python bindings.

  • Loading branch information
nouanda authored and nyalldawson committed Jul 11, 2017
1 parent 590b380 commit b88c2f42ea671299a54d1a17e31167799c6f00e5
@@ -2574,6 +2574,10 @@ QMap<QString, QgsMapLayer *> QgsProject::mapLayers() const
return mLayerStore->mapLayers();
}

QgsTransactionGroup *QgsProject::transactionGroup( const QString &providerKey, const QString &connString )
{
return mTransactionGroups.value( qMakePair( providerKey, connString ) );
}

QgsCoordinateReferenceSystem QgsProject::defaultCrsForNewLayers() const
{
@@ -584,14 +584,23 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera
*/
QMap< QPair< QString, QString>, QgsTransactionGroup *> transactionGroups() SIP_SKIP;

/**
* Get a transaction group by getting provider & connection string.
* Returns null pointer if transaction group is not available.
*
* providerKey, connString -> transactionGroup
*
* \since QGIS 3.0
*/
QgsTransactionGroup *transactionGroup( const QString &providerKey, const QString &connString );

/**
* Should default values be evaluated on provider side when requested and not when committed.
*
* \since QGIS 2.16
*/
bool evaluateDefaultValues() const;


/**
* Defines if default values should be evaluated on provider side when requested and not when committed.
*
@@ -0,0 +1 @@
---
@@ -54,6 +54,11 @@ def __init__(self, methodName):
unittest.TestCase.__init__(self, methodName)
self.messageCaught = False

def setUpClass(cls):
cls.dbconn = 'dbname=\'qgis_test\''
if 'QGIS_PGTEST_DB' in os.environ:
cls.dbconn = os.environ['QGIS_PGTEST_DB']

def test_makeKeyTokens_(self):
# see http://www.w3.org/TR/REC-xml/#d0e804 for a list of valid characters

@@ -689,6 +694,17 @@ def testTakeLayer(self):
p = None
self.assertTrue(l1.isValid())

def test_transactionsGroup(self):
# No transaction group.
QgsProject.instance().setAutoTransaction(False)
noTg = QgsProject.instance().transactionGroup("provider-key", "database-connection-string")
self.assertIsNone(noTg)

# Undefined transaction group (wrong provider key).
QgsProject.instance().setAutoTransaction(True)
noTg = QgsProject.instance().transactionGroup("provider-key", "database-connection-string")
self.assertIsNone(noTg)

def test_zip_new_project(self):
tmpDir = QTemporaryDir()
tmpFile = "{}/project.qgz".format(tmpDir.path())

0 comments on commit b88c2f4

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