MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / AddNodeCommand

Class AddNodeCommand

Gui/MultiInstancePanel.cpp:606–653  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

604} // createMultiInstanceGui
605
606class AddNodeCommand
607 : public QUndoCommand
608{
609 Q_DECLARE_TR_FUNCTIONS(AddNodeCommand)
610
611private:
612 bool _firstRedoCalled;
613 NodePtr _node;
614 MultiInstancePanel* _panel;
615
616public:
617
618 AddNodeCommand(MultiInstancePanel* panel,
619 const NodePtr & node,
620 QUndoCommand* parent = 0)
621 : QUndoCommand(parent)
622 , _firstRedoCalled(false)
623 , _node(node)
624 , _panel(panel)
625 {
626 }
627
628 virtual ~AddNodeCommand()
629 {
630 }
631
632 virtual void undo() OVERRIDE FINAL
633 {
634 int index = _panel->getNodeIndex(_node);
635
636 assert(index != -1);
637 _panel->removeRow(index);
638 _node->deactivate();
639 _panel->getMainInstance()->getApp()->redrawAllViewers();
640 setText( tr("Add %1").arg( QString::fromUtf8( _node->getLabel().c_str() ) ) );
641 }
642
643 virtual void redo() OVERRIDE FINAL
644 {
645 if (_firstRedoCalled) {
646 _node->activate();
647 _panel->addRow(_node);
648 _panel->getMainInstance()->getApp()->redrawAllViewers();
649 }
650 _firstRedoCalled = true;
651 setText( tr("Add %1").arg( QString::fromUtf8( _node->getLabel().c_str() ) ) );
652 }
653};
654
655NodePtr
656MultiInstancePanel::createNewInstance(bool useUndoRedoStack)

Callers

nothing calls this directly

Calls 10

setTextFunction · 0.85
getNodeIndexMethod · 0.80
getMainInstanceMethod · 0.80
addRowMethod · 0.80
removeRowMethod · 0.45
deactivateMethod · 0.45
redrawAllViewersMethod · 0.45
getAppMethod · 0.45
getLabelMethod · 0.45
activateMethod · 0.45

Tested by

no test coverage detected