![]() |
HAL
|
The UserAction class is the abstract base class for user interactions. More...
#include <user_action.h>
Public Member Functions | |
virtual | ~UserAction () |
virtual bool | exec () |
virtual QString | tagname () const =0 |
virtual void | writeToXml (QXmlStreamWriter &xmlOut) const |
virtual void | readFromXml (QXmlStreamReader &xmlIn) |
virtual UserActionObject | object () const |
virtual void | setObject (const UserActionObject &obj) |
int | compoundOrder () const |
void | setCompoundOrder (int cmpord) |
qint64 | timeStamp () const |
QString | cryptographicHash (int recordNo) const |
virtual void | addToHash (QCryptographicHash &cryptoHash) const |
UserAction * | undoAction () const |
QString | debugDump () const |
void | setObjectLock (bool lock) |
void | setParentObjectLock (bool lock) |
bool | hasProjectModified () const |
Protected Member Functions | |
UserAction () | |
void | writeParentObjectToXml (QXmlStreamWriter &xmlOut) const |
void | readParentObjectFromXml (QXmlStreamReader &xmlIn) |
Static Protected Member Functions | |
static QString | setToText (const QSet< u32 > &set) |
static QSet< u32 > | setFromText (const QString &s) |
static QString | gridToText (const QHash< hal::Node, QPoint > &grid) |
static QHash< hal::Node, QPoint > | gridFromText (const QString &txt) |
Protected Attributes | |
UserActionObject | mObject |
UserActionObject | mParentObject |
int | mCompoundOrder |
UserAction * | mUndoAction |
qint64 | mTimeStamp |
bool | mObjectLock |
bool | mParentObjectLock |
bool | mProjectModified |
The UserAction class is the abstract base class for user interactions.
It is expected that the exec() method gets called eventually. The derived classes exec() method contains the implementation of the command. The exec function of the base class needs to be called as well in order to store the interaction in the user action managers history. At this point the user action manager is also supposed to take the ownership of an user action object.
While derived classes might contain additional arguments the member variable mObject holds a standard argument like a single gate or module. Aditionally a parent object can be given so that special types like pingroups can be associated and/or identified with the corresponding module.
If pointer to mUndoAction is set the interaction might be reversed using Ctrl-Z in a future version of hal
The mCompoundOrder number is the index of this action if part of an action compound. It can be used to identify actions which belong together and might be undone in a single step.
Definition at line 56 of file user_action.h.
|
virtual |
|
protected |
Definition at line 12 of file user_action.cpp.
|
virtual |
Hook for derived classes to add parameter to cryptographic hash.
cryptoHash | - Additional hash data. |
Reimplemented in hal::ActionSetSelectionFocus, hal::ActionSetObjectType, hal::ActionSetObjectData, hal::ActionSetObjectColor, hal::ActionRenameObject, hal::ActionRemoveItemsFromObject, hal::ActionPingroup, hal::ActionOpenNetlistFile, hal::ActionMoveNode, hal::ActionMoveItem, hal::ActionCreateObject, hal::ActionAddItemsToObject, and hal::ActionAddBooleanFunction.
Definition at line 138 of file user_action.cpp.
Referenced by cryptographicHash().
|
inline |
Get the order number in action compound, -1 if not in compound.
Definition at line 116 of file user_action.h.
References mCompoundOrder.
Referenced by hal::UserActionManager::setStopRecording(), and hal::UserActionManager::undoLastAction().
QString hal::UserAction::cryptographicHash | ( | int | recordNo | ) | const |
Get the cryptographic hash to detect manipulations in xml macro file.
recordNo | - A nonce. |
Definition at line 38 of file user_action.cpp.
References QCryptographicHash::addData(), addToHash(), QString::fromUtf8(), mObject, mParentObject, mTimeStamp, QCryptographicHash::result(), QCryptographicHash::Sha256, tagname(), and QByteArray::toHex().
Referenced by hal::UserActionManager::setStopRecording().
QString hal::UserAction::debugDump | ( | ) | const |
Dump action in debug window.
Definition at line 143 of file user_action.cpp.
References QString::arg(), hal::UserActionObject::debugDump(), mCompoundOrder, mObject, and tagname().
Referenced by hal::UserActionManager::addExecutedAction().
|
virtual |
Executes user interaction and returns true on success. Note: Each implementation of exec() must include a call to the exec() method of base class to store the UserAction object in history and to transfer its ownership.
Reimplemented in hal::UserActionCompound, hal::ActionUnfoldModule, hal::ActionSetSelectionFocus, hal::ActionSetObjectType, hal::ActionSetObjectData, hal::ActionSetObjectColor, hal::ActionRenameObject, hal::ActionRemoveItemsFromObject, hal::ActionPingroup, hal::ActionOpenNetlistFile, hal::ActionMoveNode, hal::ActionMoveItem, hal::ActionFoldModule, hal::ActionDeleteObject, hal::ActionCreateObject, hal::ActionAddItemsToObject, and hal::ActionAddBooleanFunction.
Definition at line 23 of file user_action.cpp.
References hal::UserActionManager::addExecutedAction(), hal::gFileStatusManager, hasProjectModified(), hal::UserActionManager::instance(), mTimeStamp, hal::FileStatusManager::netlistChanged(), and hal::UserActionManager::timeStamp().
Referenced by hal::ActionAddBooleanFunction::exec(), hal::ActionAddItemsToObject::exec(), hal::ActionCreateObject::exec(), hal::ActionDeleteObject::exec(), hal::ActionMoveItem::exec(), hal::ActionMoveNode::exec(), hal::ActionOpenNetlistFile::exec(), hal::ActionPingroup::exec(), hal::ActionRemoveItemsFromObject::exec(), hal::ActionRenameObject::exec(), hal::ActionSetObjectColor::exec(), hal::ActionSetObjectData::exec(), hal::ActionSetObjectType::exec(), hal::ActionSetSelectionFocus::exec(), hal::ActionUnfoldModule::exec(), and hal::UserActionManager::playMacro().
Definition at line 84 of file user_action.cpp.
References QList::at(), hal::Node::Gate, QHash::insert(), QList::mid(), hal::Node::Module, hal::Node::None, QList::size(), and QString::split().
Referenced by hal::ActionAddItemsToObject::readFromXml().
Definition at line 69 of file user_action.cpp.
References QString::arg(), QHash::constBegin(), QHash::constEnd(), QString::isEmpty(), and hal::Node::Module.
Referenced by hal::ActionAddItemsToObject::writeToXml().
|
inline |
Executing this action will modify the project thus a warning pops up when leaving hal without saving.
Definition at line 179 of file user_action.h.
References mProjectModified.
Referenced by exec().
|
inlinevirtual |
Getter for object argument of interaction.
Definition at line 102 of file user_action.h.
References mObject.
Referenced by hal::NetlistRelay::addToModuleDialog(), hal::GuiApiClasses::View::createNewDirectory(), hal::GuiApiClasses::View::isolateInNew(), hal::GraphContextManager::openModuleInView(), and hal::UserActionManager::setStopRecording().
|
virtual |
Reads user interaction as well as arguments from xml macro file.
xmlIn | - The xml reader. |
Reimplemented in hal::UserActionCompound, hal::ActionSetSelectionFocus, hal::ActionSetObjectType, hal::ActionSetObjectData, hal::ActionSetObjectColor, hal::ActionRenameObject, hal::ActionRemoveItemsFromObject, hal::ActionPingroup, hal::ActionOpenNetlistFile, hal::ActionMoveNode, hal::ActionMoveItem, hal::ActionCreateObject, hal::ActionAddItemsToObject, and hal::ActionAddBooleanFunction.
Definition at line 133 of file user_action.cpp.
Referenced by hal::UserActionManager::getParsedAction().
|
protected |
Utility function that can be used to read the parent object if necessary. (Also does the checking)
xmlIn | - The reader. |
Definition at line 119 of file user_action.cpp.
References mParentObject, QXmlStreamReader::name(), hal::UserActionObject::readFromXml(), and QXmlStreamReader::readNext().
|
inline |
Setter for compoundOrder.
cmpord | - The new compound order. |
Definition at line 123 of file user_action.h.
References mCompoundOrder.
Referenced by hal::UserActionCompound::addAction(), and hal::UserActionManager::getParsedAction().
Definition at line 61 of file user_action.cpp.
References QSet::insert(), and QString::split().
Referenced by hal::ActionAddItemsToObject::readFromXml(), hal::ActionRemoveItemsFromObject::readFromXml(), and hal::ActionSetSelectionFocus::readFromXml().
|
virtual |
Setter for object argument of interaction.
obj | - The object. |
Reimplemented in hal::ActionUnfoldModule, and hal::ActionSetSelectionFocus.
Definition at line 32 of file user_action.cpp.
References mObject, and mObjectLock.
Referenced by hal::ActionAddBooleanFunction::ActionAddBooleanFunction(), hal::ActionCreateObject::ActionCreateObject(), hal::ActionFoldModule::ActionFoldModule(), hal::ActionPingroup::addPinsToExistingGroup(), hal::ActionPingroup::addPinsToNewGroup(), hal::GuiApiClasses::View::addTo(), hal::NetlistRelay::addToModuleDialog(), hal::GroupingManagerWidget::assignElementsToGroupingDialog(), hal::NetlistRelay::changeElementNameDialog(), hal::NetlistRelay::changeModuleColorDialog(), hal::NetlistRelay::changeModuleTypeDialog(), hal::GuiApiClasses::View::deleteDirectory(), hal::NetlistRelay::deleteModule(), hal::ActionPingroup::deletePinGroup(), hal::GuiApiClasses::View::deleteView(), hal::ContextProxyModel::dropMimeData(), hal::ActionAddItemsToObject::exec(), hal::ActionCreateObject::exec(), hal::ActionDeleteObject::exec(), hal::ActionFoldModule::exec(), hal::ActionMoveItem::exec(), hal::ActionRemoveItemsFromObject::exec(), hal::ActionRenameObject::exec(), hal::ActionSetObjectColor::exec(), hal::ActionSetObjectData::exec(), hal::ActionSetObjectType::exec(), hal::UserActionCompound::exec(), hal::UserActionManager::getParsedAction(), hal::SelectionDetailsWidget::groupingUnassignActionFactory(), hal::ModulePinsTree::handleContextMenuRequested(), hal::AddToModuleReceiver::handleModulesPicked(), hal::GraphGraphicsView::handleRemoveFromView(), hal::GuiApiClasses::View::moveDirectory(), hal::GuiApiClasses::View::moveView(), hal::ContextTreeModel::removeDirectory(), hal::GuiApiClasses::View::removeFrom(), hal::ActionPingroup::removePinsFromGroup(), hal::SelectionDetailsWidget::selectionToGroupingAction(), hal::GuiApiClasses::View::setName(), hal::ActionSetSelectionFocus::setObject(), and hal::ActionUnfoldModule::setObject().
|
inline |
Refuse set object requests (e.g. in UserActionCompound)
lock | - Param to set the lock. |
Definition at line 166 of file user_action.h.
References mObjectLock.
Referenced by hal::SelectionDetailsWidget::groupingUnassignActionFactory(), and hal::GraphGraphicsView::handleRemoveFromView().
|
inline |
Refuse set parent object requests (in case if needed)
lock | - Param to set parent lock. |
Definition at line 173 of file user_action.h.
References mParentObjectLock.
Definition at line 50 of file user_action.cpp.
References QString::isEmpty(), QString::number(), and set().
Referenced by hal::ActionAddItemsToObject::addToHash(), hal::ActionRemoveItemsFromObject::addToHash(), hal::ActionSetSelectionFocus::addToHash(), hal::ActionAddItemsToObject::writeToXml(), hal::ActionRemoveItemsFromObject::writeToXml(), and hal::ActionSetSelectionFocus::writeToXml().
|
pure virtual |
The xml tagname for the action is purely virtual and needs to be implemented in derived class.
Implemented in hal::UserActionCompound, hal::ActionUnfoldModule, hal::ActionSetSelectionFocus, hal::ActionSetObjectType, hal::ActionSetObjectData, hal::ActionSetObjectColor, hal::ActionRenameObject, hal::ActionRemoveItemsFromObject, hal::ActionPingroup, hal::ActionOpenNetlistFile, hal::ActionMoveNode, hal::ActionMoveItem, hal::ActionFoldModule, hal::ActionDeleteObject, hal::ActionCreateObject, hal::ActionAddItemsToObject, and hal::ActionAddBooleanFunction.
Referenced by cryptographicHash(), debugDump(), hal::UserActionManager::playMacro(), and hal::UserActionManager::setStopRecording().
|
inline |
Get the time stamp for execution time.
Definition at line 130 of file user_action.h.
References mTimeStamp.
Referenced by hal::UserActionManager::setStopRecording().
|
inline |
Get the action to reverse last action (nullptr if action cant be undone).
Definition at line 152 of file user_action.h.
References mUndoAction.
Referenced by hal::UserActionManager::undoLastAction().
|
protected |
Utility function to write the parent object. (Also checks if it is even necessary)
xmlOut | - The writer. |
Definition at line 109 of file user_action.cpp.
References mParentObject, hal::UserActionObjectType::None, hal::UserActionObject::type(), QXmlStreamWriter::writeEndElement(), QXmlStreamWriter::writeStartElement(), and hal::UserActionObject::writeToXml().
Referenced by hal::ActionAddItemsToObject::writeToXml().
|
virtual |
Persist user interaction in xml macro file.
xmlOut | - The xml writer. |
Reimplemented in hal::UserActionCompound, hal::ActionSetSelectionFocus, hal::ActionSetObjectType, hal::ActionSetObjectData, hal::ActionSetObjectColor, hal::ActionRenameObject, hal::ActionRemoveItemsFromObject, hal::ActionPingroup, hal::ActionOpenNetlistFile, hal::ActionMoveNode, hal::ActionMoveItem, hal::ActionCreateObject, hal::ActionAddItemsToObject, and hal::ActionAddBooleanFunction.
Definition at line 128 of file user_action.cpp.
Referenced by hal::UserActionManager::setStopRecording().
|
protected |
Definition at line 185 of file user_action.h.
Referenced by compoundOrder(), debugDump(), and setCompoundOrder().
|
protected |
Definition at line 183 of file user_action.h.
Referenced by hal::SelectionRelay::clear(), cryptographicHash(), debugDump(), hal::ActionAddBooleanFunction::exec(), hal::ActionAddItemsToObject::exec(), hal::ActionCreateObject::exec(), hal::ActionDeleteObject::exec(), hal::ActionFoldModule::exec(), hal::ActionMoveItem::exec(), hal::ActionMoveNode::exec(), hal::ActionPingroup::exec(), hal::ActionRemoveItemsFromObject::exec(), hal::ActionRenameObject::exec(), hal::ActionSetObjectColor::exec(), hal::ActionSetObjectData::exec(), hal::ActionSetObjectType::exec(), hal::ActionSetSelectionFocus::exec(), hal::ActionUnfoldModule::exec(), hal::ActionSetSelectionFocus::hasModifications(), object(), and setObject().
|
protected |
Definition at line 188 of file user_action.h.
Referenced by setObject(), and setObjectLock().
|
protected |
Definition at line 184 of file user_action.h.
Referenced by cryptographicHash(), readParentObjectFromXml(), and writeParentObjectToXml().
|
protected |
Definition at line 189 of file user_action.h.
Referenced by setParentObjectLock().
|
protected |
Definition at line 190 of file user_action.h.
Referenced by hal::ActionOpenNetlistFile::ActionOpenNetlistFile(), hal::ActionSetSelectionFocus::ActionSetSelectionFocus(), and hasProjectModified().
|
protected |
Definition at line 187 of file user_action.h.
Referenced by cryptographicHash(), exec(), and timeStamp().
|
protected |
Definition at line 186 of file user_action.h.
Referenced by hal::ActionAddBooleanFunction::exec(), hal::ActionAddItemsToObject::exec(), hal::ActionCreateObject::exec(), hal::ActionDeleteObject::exec(), hal::ActionMoveItem::exec(), hal::ActionMoveNode::exec(), hal::ActionRemoveItemsFromObject::exec(), hal::ActionRenameObject::exec(), hal::ActionSetObjectColor::exec(), hal::ActionSetObjectData::exec(), hal::ActionSetObjectType::exec(), hal::ActionSetSelectionFocus::exec(), hal::ActionUnfoldModule::exec(), undoAction(), and ~UserAction().