Isis 3 Programmer Reference
SaveProjectAsWorkOrder.cpp
Go to the documentation of this file.
1 
23 #include "SaveProjectAsWorkOrder.h"
24 
25 #include <QDebug>
26 #include <QFileDialog>
27 #include <QMessageBox>
28 #include <QtConcurrentMap>
29 
30 #include "Cube.h"
31 #include "CubeAttribute.h"
32 #include "FileName.h"
33 #include "Project.h"
34 
35 namespace Isis {
36 
44  WorkOrder(project) {
45  // This work order is not undoable
46  m_isUndoable = false;
47  QAction::setText(tr("Save Project &As"));
49  }
50 
51 
60  WorkOrder(other) {
61  }
62 
63 
70 
71  }
72 
73 
80  return new SaveProjectAsWorkOrder(*this);
81  }
82 
83 
95  bool success = WorkOrder::setupExecution();
96 
97  if (success) {
98  QString newDestination =
99  QFileDialog::getSaveFileName(NULL, QString("Project Location"), QString("."));
100 
101  if (!newDestination.isEmpty()) {
102  QUndoCommand::setText(tr("Save project to [%1]") .arg(newDestination));
103  QString realPath = QFileInfo(newDestination + "/").absolutePath();
104  setInternalData(QStringList(realPath));
105  }
106  else {
107  success = false;
108  }
109  }
110 
111  return success;
112  }
113 
114 
121  QString destination = internalData().first();
122  if (!destination.isEmpty()) {
123  project()->save(destination);
124  project()->open(destination);
125  project()->setClean(true);
126  }
127  }
128 }
Saves a project to disk (File->Save Project As...)
virtual SaveProjectAsWorkOrder * clone() const
Creates a clone of this work order.
The main project for ipce.
Definition: Project.h:289
virtual bool setupExecution()
This sets up the state for the work order.
Definition: WorkOrder.cpp:1275
void open(QString)
Open the project at the given path.
Definition: Project.cpp:1345
virtual void execute()
Executes the work order.
SaveProjectAsWorkOrder(Project *project)
Creates a work order to save the project to a new location.
Provide Undo/redo abilities, serialization, and history for an operation.
Definition: WorkOrder.h:322
bool m_isUndoable
Set the workorder to be undoable/redoable This is defaulted to true - his will allow the workorder to...
Definition: WorkOrder.h:534
virtual bool setupExecution()
Sets up this work order prior to execution.
bool save()
Generic save method to save the state of the project.
Definition: Project.cpp:2324
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
Project * project() const
Returns the Project this WorkOrder is attached to.
Definition: WorkOrder.cpp:1314
QStringList internalData() const
Gets the internal data for this WorkOrder.
Definition: WorkOrder.cpp:1391
void setInternalData(QStringList data)
Sets the internal data for this WorkOrder.
Definition: WorkOrder.cpp:1332
void setCreatesCleanState(bool createsCleanState)
Declare that this work order is saving the project.
Definition: WorkOrder.cpp:1677
void setClean(bool value)
Function to change the clean state of the project.
Definition: Project.cpp:1595