Commit 1e36e509 authored by Cole Neubauer's avatar Cole Neubauer
Browse files

A user can now Close an individual Project Fixes #4521

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/branches/ipce@7877 41f8697f-d340-4b68-9986-7bafba869bb8
parent 1264cb75
Loading
Loading
Loading
Loading
+34 −22
Original line number Diff line number Diff line
@@ -24,9 +24,11 @@

#include <QCoreApplication>
#include <QDebug>
#include <QFileDialog>
#include <QMessageBox>
#include <QtConcurrentMap>

#include "SaveProjectWorkOrder.h"
#include "Project.h"

namespace Isis {
@@ -85,26 +87,36 @@ namespace Isis {
   */
  bool CloseProjectWorkOrder::setupExecution() {
    bool success = WorkOrder::setupExecution();
    if (success && !project()->isClean() && project()->isOpen() ) {
      QMessageBox *box = new QMessageBox(QMessageBox::NoIcon,
              QString("Current Project Has Unsaved Changes"),
              QString("Would you like to save your current project?"),
              NULL, qobject_cast<QWidget *>(parent()), Qt::Dialog);
      QPushButton *save = box->addButton("Save", QMessageBox::AcceptRole);
      QPushButton *dontsave = box->addButton("Don't Save", QMessageBox::RejectRole);
      QPushButton *cancel = box->addButton("Cancel", QMessageBox::NoRole);
      box->exec();

//    // If more than this work order is in the history, don't allow this operation
//    if (success && project()->workOrderHistory().count()) {
//      QMessageBox::critical(NULL, tr("Unable To Open a Project"),
//                            tr("If you have modified your current project, you cannot open a new"
//                               " project because this is not yet implemented"));
//      success = false;
//    }
//    else if (success) {
//      QString projectName = QFileDialog::getExistingDirectory(qobject_cast<QWidget *>(parent()),
//                                                              tr("Open Project"));
      if (box->clickedButton() == (QAbstractButton*)cancel) {
        success = false;
      }

//      if (!projectName.isEmpty()) {
//        project()->open(projectName);
//      }
//      else {
//        success = false;
//      }
//    }
      else if (box->clickedButton() == (QAbstractButton*)dontsave) {
        success = true;
      }

      else if (box->clickedButton() == (QAbstractButton*)save) {
        SaveProjectWorkOrder *workOrder = new SaveProjectWorkOrder(project());
        project()->addToProject(workOrder);
      }
    }
    return success;
  }

 /**
  * @description Clear the current Project
  */
  void CloseProjectWorkOrder::execute() {
    project()->clear();
  }
}
+3 −0
Original line number Diff line number Diff line
@@ -36,6 +36,8 @@ namespace Isis {
   *   @history 2016-08-25 Adam Paqeutte - Updated documentation. Fixes #4299.
   *   @history 2017-01-20 Tracie Sucharski - Add UndoCommand text to prevent error message.
   *                          Fixes #2146.
   *   @history 2017-07-18 Cole Neubauer - Finished implementing Close Project work order.
   *                          Fixes #4521
   */
  class CloseProjectWorkOrder : public WorkOrder {
      Q_OBJECT
@@ -48,6 +50,7 @@ namespace Isis {

      virtual bool isExecutable();
      bool setupExecution();
      void execute();

    signals:

+2 −1
Original line number Diff line number Diff line
@@ -271,6 +271,8 @@ namespace Isis {
   * to allow for a new project to be opened in IPCE.
   */
  void Directory::clean() {
    m_historyTreeWidget->clear();
    m_warningTreeWidget->clear();
    m_bundleObservationViews.clear();
    m_cnetEditorViewWidgets.clear();
    m_cubeDnViewWidgets.clear();
@@ -281,7 +283,6 @@ namespace Isis {
    m_sensorInfoWidgets.clear();
    m_targetInfoWidgets.clear();
    m_projectItemModel->clean();
    m_historyTreeWidget.clear();
    emit directoryCleaned();
  }

+1 −0
Original line number Diff line number Diff line
@@ -422,6 +422,7 @@ namespace Isis {
    m_workOrderHistory->clear();
    directory()->clean();
    setName("Project");
    setClean(true);
  }