|
QCAD Application Framework
CAD Application Development and Automation.
|
Transaction implementation. More...
#include <RTransaction.h>
Public Member Functions | |
| void | addAffectedObject (RObject::Id objectId) |
| Adds the given object to the list of objects that are affected by this transaction. | |
| void | addAffectedObject (QSharedPointer< RObject > object) |
| void | addAffectedObjects (const QSet< RObject::Id > &objectIds) |
| Adds the given objects to the list of objects that are affected by this transaction. | |
| bool | addObject (QSharedPointer< RObject > obj, bool useCurrentAttributes=true, const QSet< RPropertyTypeId > &modifiedPropertyTypeIds=RDEFAULT_QSET_RPROPERTYTYPEID) |
| Adds the given object to the transaction. | |
| void | deleteObject (RObject::Id objectId, RDocument *document) |
| void | deleteObject (QSharedPointer< RObject > object, RDocument *document) |
| void | end () |
| Previews this transaction (as it would be applied) by exporting the result to the given exporter. | |
| void | fail () |
| QList< RObject::Id > | getAffectedObjects () |
| int | getId () |
| QMap< RObject::Id, QList < RPropertyChange > > | getPropertyChanges () |
| QSet< RObject::Id > | getStatusChanges () |
| QString | getText () |
| bool | hasOnlyChanges () |
| bool | isFailed () |
| bool | isUndoable () |
| bool | overwriteBlock (QSharedPointer< RBlock > block) |
| Overwrites an existing block with the given block. | |
| virtual void | redo (RDocument *objectContainer=NULL) |
| Applies this command to the document. | |
| RTransaction () | |
| RTransaction (RStorage &storage) | |
| Constructs an empty, invalid transaction. | |
| RTransaction (RStorage &storage, int transactionId, const QString &text, const QList< RObject::Id > &affectedObjects, const QMap< RObject::Id, QList< RPropertyChange > > &propertyChanges, RTransaction *parent=NULL) | |
| Constructor for existing transactions. | |
| RTransaction (RStorage &storage, const QString &text, bool undoable=true, RTransaction *parent=NULL) | |
| Constructor for new transactions. | |
| void | setAllowAll (bool on) |
| void | setAllowInvisible (bool on) |
| void | setId (int id) |
| Sets the ID of this transaction. | |
| void | setRecordAffectedObjects (bool on) |
| void | setSpatialIndexDisabled (bool on) |
| virtual void | undo (RDocument *objectContainer=NULL) |
| Reverts a change to the document. | |
| void | updateOverwrittenBlockReferences () |
| virtual | ~RTransaction () |
Protected Member Functions | |
| bool | addPropertyChange (RObject::Id objectId, const RPropertyChange &propertyChange) |
| Adds the given property change for the given object to this transaction. | |
| void | appendChild (RTransaction &t) |
| Appends the given child to the list of child transactions of this transaction. | |
| void | commit () |
| Saves this command to the storage of the document. | |
| void | rollback () |
Protected Attributes | |
| QList< RObject::Id > | affectedObjects |
| List of IDs of all objects that are affected by this transaction. | |
| bool | allowAll |
| True if all transactions are allowed, even transactions on locked or invisible layers. | |
| bool | allowInvisible |
| True if all transactions on invisible entities are allowed, typically transactions on invisible layers. | |
| QList< RTransaction > | childTransactions |
| Child transactions of this transaction. | |
| bool | failed |
| True if this transaction failed. | |
| bool | onlyChanges |
| True if this transaction only changed objects, no additions, no deletes. | |
| QList< RObject::Id > | overwrittenBlockReferences |
| List of IDs of all block references that need to be . | |
| QMap< RObject::Id, QList < RPropertyChange > > | propertyChanges |
| Map of properties that are changed by this transaction. | |
| bool | recordAffectedObjects |
| True if caller is intereseted in list of objects that are affected by this transaction. | |
| bool | spatialIndexDisabled |
| True to ignore spatial index. | |
| QSet< RObject::Id > | statusChanges |
| Contains affected objects that have been created or deleted in this transaction. | |
| RStorage * | storage |
| A transaction always belongs to the storage of a document. | |
| QString | text |
| Log entry for this transaction. | |
| int | transactionId |
| Unique ID of this transaction. | |
| bool | undoable |
| True if this transaction can be undone. | |
Transaction implementation.
A transaction encapsulates a change of state of a document. Every change of a drawing document is wrapped in a transaction and handled by the QCAD Application Framework as one change. A transaction might add one or multiple objects, modify existing objects or delete objects. Combinations in the same transaction are also possible.
Each transactions should contain a locical change to a drawing. For example if a selection is moved from one place to another, all entities that are part of the selection are moved in the same transaction. This is important for the undo / redo mechanism of QCAD. If each entity would be moved in a separate transaction, the user would have to issue an undo command for each entity to get back to the state before the entities were moved.
Transactions can be applied to a document and are handled by an RTransactionStack for undo / redo functionality. Transactions are stored in a storage.
Transactions in the QCAD Application Framework are a low level concept. They are unaware of graphics views or widgets that need to be updated.
| RTransaction::RTransaction | ( | ) |
| RTransaction::RTransaction | ( | RStorage & | storage | ) |
Constructs an empty, invalid transaction.
| RTransaction::RTransaction | ( | RStorage & | storage, |
| int | transactionId, | ||
| const QString & | text, | ||
| const QList< RObject::Id > & | affectedObjects, | ||
| const QMap< RObject::Id, QList< RPropertyChange > > & | propertyChanges, | ||
| RTransaction * | parent = NULL |
||
| ) |
Constructor for existing transactions.
This is used by storage implementations to instantiate transactions from a storage (e.g. DB).
| RTransaction::RTransaction | ( | RStorage & | storage, |
| const QString & | text, | ||
| bool | undoable = true, |
||
| RTransaction * | parent = NULL |
||
| ) |
Constructor for new transactions.
|
virtual |
| void RTransaction::addAffectedObject | ( | RObject::Id | objectId | ) |
Adds the given object to the list of objects that are affected by this transaction.
| void RTransaction::addAffectedObject | ( | QSharedPointer< RObject > | object | ) |
| void RTransaction::addAffectedObjects | ( | const QSet< RObject::Id > & | objectIds | ) |
Adds the given objects to the list of objects that are affected by this transaction.
| bool RTransaction::addObject | ( | QSharedPointer< RObject > | object, |
| bool | useCurrentAttributes = true, |
||
| const QSet< RPropertyTypeId > & | modifiedPropertyTypeIds = RDEFAULT_QSET_RPROPERTYTYPEID |
||
| ) |
Adds the given object to the transaction.
Adding an object to a transaction means that this transaction modifies or adds the object. Entities that are added with an invalid layer or block ID are placed on the current layer / block.
| modifiedPropertyTypeId,: | Property ID that has changed if known by caller, NULL otherwise. |
|
protected |
Adds the given property change for the given object to this transaction.
|
protected |
Appends the given child to the list of child transactions of this transaction.
This transaction takes o
|
protected |
Saves this command to the storage of the document.
| void RTransaction::deleteObject | ( | RObject::Id | objectId, |
| RDocument * | document | ||
| ) |
| void RTransaction::end | ( | ) |
Previews this transaction (as it would be applied) by exporting the result to the given exporter.
The exporter typically exports into the preview of a graphics scene.
| void RTransaction::fail | ( | ) |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
| bool RTransaction::overwriteBlock | ( | QSharedPointer< RBlock > | block | ) |
Overwrites an existing block with the given block.
|
virtual |
Applies this command to the document.
(Re-)applies this transaction to the document.
|
protected |
|
inline |
|
inline |
|
inline |
Sets the ID of this transaction.
Typically called by a storage which manages transaction IDs.
|
inline |
|
inline |
|
virtual |
| void RTransaction::updateOverwrittenBlockReferences | ( | ) |
|
protected |
List of IDs of all objects that are affected by this transaction.
|
protected |
True if all transactions are allowed, even transactions on locked or invisible layers.
Typically the case for importers.
|
protected |
True if all transactions on invisible entities are allowed, typically transactions on invisible layers.
Used to move entities to an invisible layer.
|
protected |
Child transactions of this transaction.
|
protected |
True if this transaction failed.
|
protected |
True if this transaction only changed objects, no additions, no deletes.
|
protected |
List of IDs of all block references that need to be .
|
protected |
Map of properties that are changed by this transaction.
For every undoable, a whole list of properties might have changed in a fixed order.
|
protected |
True if caller is intereseted in list of objects that are affected by this transaction.
|
protected |
True to ignore spatial index.
Used for importers which regenerate the spatial index in the end.
|
protected |
Contains affected objects that have been created or deleted in this transaction.
|
protected |
A transaction always belongs to the storage of a document.
|
protected |
Log entry for this transaction.
|
protected |
Unique ID of this transaction.
|
protected |
True if this transaction can be undone.