Isis 3 Programmer Reference
CnetEditorViewWorkOrder.cpp
1
7/* SPDX-License-Identifier: CC0-1.0 */
8
9#include "CnetEditorViewWorkOrder.h"
10
11#include <QtDebug>
12
13#include <QAction>
14#include <QUndoCommand>
15
16#include "CnetEditorView.h"
17#include "Control.h"
18#include "ControlList.h"
19#include "Directory.h"
20#include "Project.h"
21
22namespace Isis {
23
24 CnetEditorViewWorkOrder::CnetEditorViewWorkOrder(Project *project) :
25 WorkOrder(project) {
26 QAction::setText(tr("View &Network..."));
27 m_isSavedToHistory = false;
28 m_isUndoable = false;
29 }
30
31
32 CnetEditorViewWorkOrder::CnetEditorViewWorkOrder(const CnetEditorViewWorkOrder &other) :
33 WorkOrder(other) {
34 }
35
36
37 CnetEditorViewWorkOrder::~CnetEditorViewWorkOrder() {
38 }
39
40
41 CnetEditorViewWorkOrder *CnetEditorViewWorkOrder::clone() const {
42 return new CnetEditorViewWorkOrder(*this);
43 }
44
45
46 bool CnetEditorViewWorkOrder::isExecutable(ControlList * controls) {
47
48
49 if (controls) {
50 return (controls->count() >= 1);
51 }
52 return false;
53 }
54
55
56 bool CnetEditorViewWorkOrder::setupExecution() {
57 bool success = WorkOrder::setupExecution();
58
59 if (success) {
60 QUndoCommand::setText(tr("View control network [%1] in new cnet editor view")
61 .arg(controlList()->first()->displayProperties()->displayName()));
62 }
63
64 return success;
65 }
66
67
68 bool CnetEditorViewWorkOrder::dependsOn(WorkOrder *other) const {
69 // depend on types of ourselves.
70 return dynamic_cast<CnetEditorViewWorkOrder *>(other);
71 }
72
73
74 void CnetEditorViewWorkOrder::execute() {
75
76 for (int i = 0; i < controlList()->size(); i++) {
77 project()->directory()->addCnetEditorView(controlList()->at(i));
78 }
79 project()->setClean(false);
80 }
81
82 void CnetEditorViewWorkOrder::undoExecution() {
83 delete project()->directory()->cnetEditorViews().last();
84 }
85}
This work order allows the user to open a cnet editor (table) view of a single control network.
Maintains a list of Controls so that control nets can easily be copied from one Project to another,...
Definition ControlList.h:44
CnetEditorView * addCnetEditorView(Control *control, QString objectName="")
Add the widget for the cnet editor view to the window.
Provide Undo/redo abilities, serialization, and history for an operation.
Definition WorkOrder.h:311
Directory * directory() const
return the workorder project directory Returns the Directory object of the Project this WorkOrder is ...
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16