Isis 3 Programmer Reference
CloseProjectWorkOrder.cpp
1
7/* SPDX-License-Identifier: CC0-1.0 */
8
9#include "CloseProjectWorkOrder.h"
10
11#include <QCoreApplication>
12#include <QDebug>
13#include <QFileDialog>
14#include <QMessageBox>
15#include <QtConcurrentMap>
16
18#include "Project.h"
19
20namespace Isis {
21
29 WorkOrder(project) {
30 QAction::setText(tr("&Close Project"));
31 QUndoCommand::setText(tr("Close Project"));
32 m_isSavedToHistory = false;
33 m_isUndoable = false;
35 }
36
43
50
59
66// return (project());
67 return true;
68 }
69
76 bool success = WorkOrder::setupExecution();
77 if (success && !project()->isClean()) {
78 QMessageBox *box = new QMessageBox(QMessageBox::NoIcon,
79 QString("Current Project Has Unsaved Changes"),
80 QString("Would you like to save your current project?"),
81 NULL, qobject_cast<QWidget *>(parent()), Qt::Dialog);
82 QPushButton *save = box->addButton("Save", QMessageBox::AcceptRole);
83 QPushButton *dontsave = box->addButton("Don't Save", QMessageBox::RejectRole);
84 QPushButton *cancel = box->addButton("Cancel", QMessageBox::NoRole);
85 box->exec();
86
87 if (box->clickedButton() == (QAbstractButton*)cancel) {
88 success = false;
89 }
90
91 else if (box->clickedButton() == (QAbstractButton*)dontsave) {
92 success = true;
93 }
94
95 else if (box->clickedButton() == (QAbstractButton*)save) {
97 project()->addToProject(workOrder);
98 }
99 }
100 return success;
101 }
102
107 project()->clear();
108 project()->setClean(true);
109 }
110}
This opens a project that's saved on disk.
void execute()
@description Clear the current Project
virtual bool isExecutable()
This method will always return true.
virtual CloseProjectWorkOrder * clone() const
This method clones the CloseProjectWorkOrder.
CloseProjectWorkOrder(Project *project)
This method sets the text of the work order to Close Project and sets setCreatesCleanState to true.
bool setupExecution()
If WorkOrder::execute() returns true, then this method returns true.
The main project for ipce.
Definition Project.h:289
void clear()
Function to clear out all values in a project essentially making it a new project object.
Definition Project.cpp:458
void addToProject(WorkOrder *)
This executes the WorkOrder and stores it in the project.
Definition Project.cpp:2597
void setClean(bool value)
Function to change the clean state of the project.
Definition Project.cpp:1594
Saves a project to disk (File->Save Project...)
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
void save(QXmlStreamWriter &stream) const
: Saves a WorkOrder to a data stream.
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.
void setCreatesCleanState(bool createsCleanState)
Declare that this work order is saving the project.
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