mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-01 00:46:20 -05:00
Add QgsProject::transactionGroup() available & with Python bindings.
This commit is contained in:
parent
590b3806a5
commit
b88c2f42ea
@ -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,6 +584,16 @@ 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.
|
||||
*
|
||||
@ -591,7 +601,6 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera
|
||||
*/
|
||||
bool evaluateDefaultValues() const;
|
||||
|
||||
|
||||
/**
|
||||
* Defines if default values should be evaluated on provider side when requested and not when committed.
|
||||
*
|
||||
|
1
tests/src/python/Testing/Temporary/CTestCostData.txt
Normal file
1
tests/src/python/Testing/Temporary/CTestCostData.txt
Normal file
@ -0,0 +1 @@
|
||||
---
|
@ -54,6 +54,11 @@ class TestQgsProject(unittest.TestCase):
|
||||
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 @@ class TestQgsProject(unittest.TestCase):
|
||||
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())
|
||||
|
Loading…
x
Reference in New Issue
Block a user