Isis 3 Programmer Reference
TemplateEditViewWorkOrder.cpp
Go to the documentation of this file.
1
24
25#include <QFileDialog>
26#include <QInputDialog>
27#include <QtDebug>
28
29#include "Directory.h"
30#include "IException.h"
31#include "Project.h"
32#include "ProjectItem.h"
33#include "Template.h"
34#include "TemplateEditorWidget.h"
35
36namespace Isis {
37
47 WorkOrder(project) {
48 QAction::setText(tr("Edit template...") );
49 QUndoCommand::setText(tr("Edit Template"));
50
51 // This work order is not undoable
52 m_isUndoable = false;
53 m_isSavedToHistory = false;
54 }
55
56
64
65
71
72
80
81
93 if (!projectitem)
94 return false;
95
96 if (projectitem->isTemplate()) {
97
98 Template *currentTemplate = projectitem->getTemplate();
99 // if we already have a view for this target, don't redisplay
100 QList<TemplateEditorWidget *> existingViews = project()->directory()->templateEditorViews();
101 for (int i = 0; i < existingViews.size(); i++) {
102 if (existingViews.at(i)->objectName() == currentTemplate->fileName() )
103 return false;
104 }
105 return true;
106 }
107
108 return false;
109 }
110
111
120 bool success = WorkOrder::setupExecution();
121
122 if (success) {
123 // This class relies on the parent class, WorkOrder to set m_template with its setData method.
124 // We can retrieve this template for ourselves using getTemplate(), a method of WorkOrder's.
125 QString templateFileName = getTemplate()->fileName();
127 internalData.append(templateFileName);
129 }
130 return success;
131 }
132
133
140
141 TemplateEditorWidget *templateEditorWidget =
143
144 if (!templateEditorWidget) {
145 QString msg = "error displaying target info";
146 throw IException(IException::Programmer, msg, _FILEINFO_);
147 }
148 }
149
150
157 // depend on types of ourselves.
158 return dynamic_cast<TemplateEditViewWorkOrder *>(other);
159 }
160}
QList< TemplateEditorWidget * > templateEditorViews()
Accessor for the list of TemplateEditorWidgets currently available.
TemplateEditorWidget * addTemplateEditorView(Template *currentTemplate)
Add template editor view widget to the window.
Isis exception class.
Definition IException.h:91
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition IException.h:146
The main project for ipce.
Definition Project.h:289
Directory * directory() const
Returns the directory associated with this Project.
Definition Project.cpp:1228
Represents an item of a ProjectItemModel in Qt's model-view framework.
This work order allows the user to view and edit a template.
virtual bool setupExecution()
Attempt to retrieve the Target info.
TemplateEditViewWorkOrder(Project *project)
Creates a WorkOrder that will retrieve Target info.
virtual bool isExecutable(ProjectItem *projectitem)
Determines if we can get target info.
virtual void execute()
Executes this work order.
virtual TemplateEditViewWorkOrder * clone() const
Returns a copy of this TemplateEditViewWorkOrder instance.
bool dependsOn(WorkOrder *other) const
Determines whether another WorkOrder depends upon TemplateEditViewWorkOrder.
Widget for displaying information about a target.
QString fileName() const
Get the file name that this Template represents.
Definition Template.cpp:50
Provide Undo/redo abilities, serialization, and history for an operation.
Definition WorkOrder.h:311
bool m_isSavedToHistory
Set the work order to be shown in the HistoryTreeWidget.
Definition WorkOrder.h:537
Template * getTemplate()
WorkOrder::getTemplate.
bool m_isUndoable
Set the workorder to be undoable/redoable This is defaulted to true - his will allow the workorder to...
Definition WorkOrder.h:523
virtual bool setupExecution()
This sets up the state for the work order.
QStringList internalData() const
Gets the internal data for this WorkOrder.
void setInternalData(QStringList data)
Sets the internal data for this WorkOrder.
Project * project() const
Returns the Project this WorkOrder is attached to.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16