Isis 3 Programmer Reference
CloseProjectWorkOrder.cpp
Go to the documentation of this file.
1 
23 #include "CloseProjectWorkOrder.h"
24 
25 #include <QCoreApplication>
26 #include <QDebug>
27 #include <QFileDialog>
28 #include <QMessageBox>
29 #include <QtConcurrentMap>
30 
31 #include "SaveProjectWorkOrder.h"
32 #include "Project.h"
33 
34 namespace Isis {
35 
43  WorkOrder(project) {
44  QAction::setText(tr("&Close Project"));
45  QUndoCommand::setText(tr("Close Project"));
46  m_isSavedToHistory = false;
47  m_isUndoable = false;
49  }
50 
55  WorkOrder(other) {
56  }
57 
62 
63  }
64 
71  return new CloseProjectWorkOrder(*this);
72  }
73 
80 // return (project());
81  return true;
82  }
83 
90  bool success = WorkOrder::setupExecution();
91  if (success && !project()->isClean()) {
92  QMessageBox *box = new QMessageBox(QMessageBox::NoIcon,
93  QString("Current Project Has Unsaved Changes"),
94  QString("Would you like to save your current project?"),
95  NULL, qobject_cast<QWidget *>(parent()), Qt::Dialog);
96  QPushButton *save = box->addButton("Save", QMessageBox::AcceptRole);
97  QPushButton *dontsave = box->addButton("Don't Save", QMessageBox::RejectRole);
98  QPushButton *cancel = box->addButton("Cancel", QMessageBox::NoRole);
99  box->exec();
100 
101  if (box->clickedButton() == (QAbstractButton*)cancel) {
102  success = false;
103  }
104 
105  else if (box->clickedButton() == (QAbstractButton*)dontsave) {
106  success = true;
107  }
108 
109  else if (box->clickedButton() == (QAbstractButton*)save) {
111  project()->addToProject(workOrder);
112  }
113  }
114  return success;
115  }
116 
121  project()->clear();
122  project()->setClean(true);
123  }
124 }
The main project for ipce.
Definition: Project.h:289
virtual bool isExecutable()
This method will always return true.
virtual bool setupExecution()
This sets up the state for the work order.
Definition: WorkOrder.cpp:1275
This opens a project that&#39;s saved on disk.
CloseProjectWorkOrder(Project *project)
This method sets the text of the work order to Close Project and sets setCreatesCleanState to true...
void clear()
Function to clear out all values in a project essentially making it a new project object...
Definition: Project.cpp:459
void addToProject(WorkOrder *)
This executes the WorkOrder and stores it in the project.
Definition: Project.cpp:2598
Provide Undo/redo abilities, serialization, and history for an operation.
Definition: WorkOrder.h:322
virtual CloseProjectWorkOrder * clone() const
This method clones the CloseProjectWorkOrder.
bool setupExecution()
If WorkOrder::execute() returns true, then this method returns true.
void execute()
Clear the current Project
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
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
Saves a project to disk (File->Save Project...)
Project * project() const
Returns the Project this WorkOrder is attached to.
Definition: WorkOrder.cpp:1314
bool m_isSavedToHistory
Set the work order to be shown in the HistoryTreeWidget.
Definition: WorkOrder.h:548
void setCreatesCleanState(bool createsCleanState)
Declare that this work order is saving the project.
Definition: WorkOrder.cpp:1677
void save(QXmlStreamWriter &stream) const
: Saves a WorkOrder to a data stream.
Definition: WorkOrder.cpp:558
void setClean(bool value)
Function to change the clean state of the project.
Definition: Project.cpp:1595