Commit d578d392 authored by Tracie Sucharski's avatar Tracie Sucharski
Browse files

PROG: Added slot, activeControlModified, which sets the modification state of...

PROG: Added slot, activeControlModified, which sets the modification state of Control's control net.
parent 5a6eba9b
Loading
Loading
Loading
Loading
+36 −0
Original line number Diff line number Diff line
@@ -1702,11 +1702,41 @@ namespace Isis {
   *                           being chosen Fixes #4969
   *  @history 2017-08-02 Cole Neubauer - Added functionality to switch between active controls
   *                           Fixes #4567
   *  @history 2018-03-30 Tracie Sucharski - If current activeControl has been modified, prompt for
   *                           saving. Emit signal to discardActiveControlEdits.
   *
   */
  void Project::setActiveControl(QString displayName) {
    Control *previousControl = m_activeControl; 
    if (m_activeControl) {
      qDebug()<<"PRoject::setActiveControl m_activeControl->isModified() = "<<m_activeControl->isModified();

      // If the current active control has been modified, ask user if they want to save or discard
      // changes.
      if (m_activeControl->isModified()) {
        QMessageBox msgBox;
        msgBox.setText("Save current active control");
        msgBox.setInformativeText("The current active control has been modified.  Do you want "
                                  "to save before setting a new active control?");
        msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
        msgBox.setDefaultButton(QMessageBox::Save);
        int ret = msgBox.exec();
        switch (ret) {
          // Save current active control
          case QMessageBox::Save:
            qDebug()<<" ** SAVE **";
            m_activeControl->write();
            break;
          // Discard any changes made to cnet
          case QMessageBox::Discard:
            emit discardActiveControlEdits();
            break;
          // Cancel operation
          case QMessageBox::Cancel:
            return;
        }
      }
      qDebug()<<"Project::setActiveControl before emit activeControlSet";
      emit activeControlSet(false);
      ProjectItem *item = directory()->model()->findItemData(m_activeControl->
                          displayProperties()->displayName(), Qt::DisplayRole);
@@ -1773,6 +1803,12 @@ namespace Isis {
  }


  void Project::activeControlModified() {
    qDebug()<<"Project::activeControlModified m_activeControl = "<<m_activeControl;
    m_activeControl->setModified(true);
  }


  /**
   * @brief Set the Active ImageList from the displayName which is saved in project.xml
   *
+13 −0
Original line number Diff line number Diff line
@@ -234,6 +234,16 @@ namespace Isis {
   *   @history 2018-03-27 Tracie Sucharski - Removed the calls to work orders from activeImageList
   *                           and activeControl methods.  Additional errors checks needed for
   *                           default values that are not in work orders.  Fixes #5256.
   *   @history 2018-03-30 Tracie Sucharski - Added public slot, activeControlModified, which sets
   *                           the modified state on the active Control. This was done, so that a
   *                           Control knows if its control net has been modified. Also added
   *                           signal, discardActiveControlEdits if user does not want to save
   *                           edits.  This is needed for CnetEditorWidgets that are displaying
   *                           the modified active control, it will effectively close that
   *                           CnetEditorView and reload with the original control net.  It was
   *                           done this way because there is no easy way to reload a control net in
   *                           the CnetEditor widgets.
   *  
   */
  class Project : public QObject {
    Q_OBJECT
@@ -475,9 +485,12 @@ namespace Isis {

      void templatesAdded(TemplateList *newTemplates);

      void discardActiveControlEdits();

    public slots:
      void open(QString);
      void setClean(bool value);
      void activeControlModified();

    private slots:
      void controlClosed(QObject *control);