HAL
hal::UserAction Class Referenceabstract

The UserAction class is the abstract base class for user interactions. More...

#include <user_action.h>

Inheritance diagram for hal::UserAction:
Inheritance graph
Collaboration diagram for hal::UserAction:
Collaboration graph

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
 
UserActionundoAction () 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< u32setFromText (const QString &s)
 
static QString gridToText (const QHash< hal::Node, QPoint > &grid)
 
static QHash< hal::Node, QPointgridFromText (const QString &txt)
 

Protected Attributes

UserActionObject mObject
 
UserActionObject mParentObject
 
int mCompoundOrder
 
UserActionmUndoAction
 
qint64 mTimeStamp
 
bool mObjectLock
 
bool mParentObjectLock
 
bool mProjectModified
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ~UserAction()

hal::UserAction::~UserAction ( )
virtual

The destructor.

Definition at line 18 of file user_action.cpp.

References mUndoAction.

◆ UserAction()

hal::UserAction::UserAction ( )
protected

Definition at line 12 of file user_action.cpp.

Member Function Documentation

◆ addToHash()

void hal::UserAction::addToHash ( QCryptographicHash cryptoHash) const
virtual

◆ compoundOrder()

int hal::UserAction::compoundOrder ( ) const
inline

Get the order number in action compound, -1 if not in compound.

Returns
The order number in action compount.

Definition at line 116 of file user_action.h.

References mCompoundOrder.

Referenced by hal::UserActionManager::setStopRecording(), and hal::UserActionManager::undoLastAction().

◆ cryptographicHash()

QString hal::UserAction::cryptographicHash ( int  recordNo) const

Get the cryptographic hash to detect manipulations in xml macro file.

Parameters
recordNo- A nonce.
Returns
The hash.

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().

◆ debugDump()

QString hal::UserAction::debugDump ( ) const

Dump action in debug window.

Returns
The debug string.

Definition at line 143 of file user_action.cpp.

References QString::arg(), hal::UserActionObject::debugDump(), mCompoundOrder, mObject, and tagname().

Referenced by hal::UserActionManager::addExecutedAction().

◆ exec()

bool hal::UserAction::exec ( )
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.

Returns
True on success, False otherwise.

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().

◆ gridFromText()

QHash< hal::Node, QPoint > hal::UserAction::gridFromText ( const QString txt)
staticprotected

◆ gridToText()

QString hal::UserAction::gridToText ( const QHash< hal::Node, QPoint > &  grid)
staticprotected

◆ hasProjectModified()

bool hal::UserAction::hasProjectModified ( ) const
inline

Executing this action will modify the project thus a warning pops up when leaving hal without saving.

Returns
True if executing the action will modify the project, false otherwise.

Definition at line 179 of file user_action.h.

References mProjectModified.

Referenced by exec().

◆ object()

virtual UserActionObject hal::UserAction::object ( ) const
inlinevirtual

◆ readFromXml()

◆ readParentObjectFromXml()

void hal::UserAction::readParentObjectFromXml ( QXmlStreamReader xmlIn)
protected

Utility function that can be used to read the parent object if necessary. (Also does the checking)

Parameters
xmlIn- The reader.

Definition at line 119 of file user_action.cpp.

References mParentObject, QXmlStreamReader::name(), hal::UserActionObject::readFromXml(), and QXmlStreamReader::readNext().

◆ setCompoundOrder()

void hal::UserAction::setCompoundOrder ( int  cmpord)
inline

Setter for compoundOrder.

Parameters
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().

◆ setFromText()

QSet< u32 > hal::UserAction::setFromText ( const QString s)
staticprotected

◆ setObject()

void hal::UserAction::setObject ( const UserActionObject obj)
virtual

Setter for object argument of interaction.

Parameters
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().

◆ setObjectLock()

void hal::UserAction::setObjectLock ( bool  lock)
inline

Refuse set object requests (e.g. in UserActionCompound)

Parameters
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().

◆ setParentObjectLock()

void hal::UserAction::setParentObjectLock ( bool  lock)
inline

Refuse set parent object requests (in case if needed)

Parameters
lock- Param to set parent lock.

Definition at line 173 of file user_action.h.

References mParentObjectLock.

◆ setToText()

◆ tagname()

◆ timeStamp()

qint64 hal::UserAction::timeStamp ( ) const
inline

Get the time stamp for execution time.

Returns
The time stamp.

Definition at line 130 of file user_action.h.

References mTimeStamp.

Referenced by hal::UserActionManager::setStopRecording().

◆ undoAction()

UserAction* hal::UserAction::undoAction ( ) const
inline

Get the action to reverse last action (nullptr if action cant be undone).

Returns
The reverse action.

Definition at line 152 of file user_action.h.

References mUndoAction.

Referenced by hal::UserActionManager::undoLastAction().

◆ writeParentObjectToXml()

void hal::UserAction::writeParentObjectToXml ( QXmlStreamWriter xmlOut) const
protected

Utility function to write the parent object. (Also checks if it is even necessary)

Parameters
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().

◆ writeToXml()

Member Data Documentation

◆ mCompoundOrder

int hal::UserAction::mCompoundOrder
protected

Definition at line 185 of file user_action.h.

Referenced by compoundOrder(), debugDump(), and setCompoundOrder().

◆ mObject

◆ mObjectLock

bool hal::UserAction::mObjectLock
protected

Definition at line 188 of file user_action.h.

Referenced by setObject(), and setObjectLock().

◆ mParentObject

UserActionObject hal::UserAction::mParentObject
protected

◆ mParentObjectLock

bool hal::UserAction::mParentObjectLock
protected

Definition at line 189 of file user_action.h.

Referenced by setParentObjectLock().

◆ mProjectModified

bool hal::UserAction::mProjectModified
protected

◆ mTimeStamp

qint64 hal::UserAction::mTimeStamp
protected

Definition at line 187 of file user_action.h.

Referenced by cryptographicHash(), exec(), and timeStamp().

◆ mUndoAction


The documentation for this class was generated from the following files: