| 893 | } |
| 894 | |
| 895 | class RemoveNodeCommand |
| 896 | : public QUndoCommand |
| 897 | { |
| 898 | Q_DECLARE_TR_FUNCTIONS(RemoveNodeCommand) |
| 899 | |
| 900 | private: |
| 901 | MultiInstancePanel* _panel; |
| 902 | std::list<NodePtr> _nodes; |
| 903 | |
| 904 | public: |
| 905 | |
| 906 | RemoveNodeCommand(MultiInstancePanel* panel, |
| 907 | const std::list<NodePtr> & nodes, |
| 908 | QUndoCommand* parent = 0) |
| 909 | : QUndoCommand(parent) |
| 910 | , _panel(panel) |
| 911 | , _nodes(nodes) |
| 912 | { |
| 913 | setText( tr("Remove instance(s)") ); |
| 914 | } |
| 915 | |
| 916 | virtual ~RemoveNodeCommand() |
| 917 | { |
| 918 | } |
| 919 | |
| 920 | virtual void undo() OVERRIDE FINAL |
| 921 | { |
| 922 | _panel->setRedrawOnSelectionChanged(false); |
| 923 | _panel->addInstances(_nodes); |
| 924 | _panel->setRedrawOnSelectionChanged(true); |
| 925 | _panel->getMainInstance()->getApp()->triggerAutoSave(); |
| 926 | _panel->getMainInstance()->getApp()->redrawAllViewers(); |
| 927 | } |
| 928 | |
| 929 | virtual void redo() OVERRIDE FINAL |
| 930 | { |
| 931 | _panel->setRedrawOnSelectionChanged(false); |
| 932 | _panel->removeInstances(_nodes); |
| 933 | _panel->setRedrawOnSelectionChanged(true); |
| 934 | _panel->getMainInstance()->getApp()->triggerAutoSave(); |
| 935 | _panel->getMainInstance()->getApp()->redrawAllViewers(); |
| 936 | } |
| 937 | }; |
| 938 | |
| 939 | void |
| 940 | MultiInstancePanel::removeInstances(const std::list<NodePtr>& instances) |
nothing calls this directly
no test coverage detected