Commit 30af0e2d authored by Tracie Sucharski's avatar Tracie Sucharski
Browse files

PROG: If the control has been modified, saved to new project location.

parent bd460f6b
Loading
Loading
Loading
Loading
+25 −6
Original line number Diff line number Diff line
@@ -174,6 +174,7 @@ namespace Isis {
  /**
   * @description Write control net to disk.  This method is used instead of calling 
   * ControlNet::Write directly so that Control knows the modification state of the control net. 
   * Note that if there is not a control net opened, there should no be any changes to write.
   *  
   * @return @b bool Returns false if there is not a control net open to write 
   *  
@@ -283,17 +284,35 @@ namespace Isis {
   *                       will be copied.
   */
  void Control::copyToNewProjectRoot(const Project *project, FileName newProjectRoot) {

    if (FileName(newProjectRoot).toString() != FileName(project->projectRoot()).toString()) {
  
      QString newNetworkPath =  project->cnetRoot(newProjectRoot.toString()) + "/" +
                  FileName(m_fileName).dir().dirName() + "/" + FileName(m_fileName).name();

      // If there is active control & it has been modified, write to disk instead of copying
      //  Leave control net at old location in unmodified state
      if (isModified()) {
        controlNet()->Write(newNetworkPath);
        setModified(false);
      }
      else {
        QString oldNetworkPath = project->cnetRoot(project->projectRoot()) + "/" +
                    FileName(m_fileName).dir().dirName() + "/" + FileName(m_fileName).name();
        if (!QFile::copy(oldNetworkPath,newNetworkPath) ) {
          throw IException(IException::Io, "Error saving control net.", _FILEINFO_);
        }
    }//end outer-if
      }
    }
    //   Project "Save" to current location, if active control exists & is modified, write to disk
    //  Note:  It does not look like this code is ever executed.  If project is saved with a
    //         "Save" this method is not called.
    else {
      if (isModified()) {
        write();
        setModified(false);
      }
    }

  }

+4 −1
Original line number Diff line number Diff line
@@ -71,7 +71,10 @@ namespace Isis {
   *                           track of the modification state of the control net. Add write method
   *                           to write the control net to disk.  This write method should be called
   *                           by ipce classes instead of calling the ControlNet::Write directly so
   *                           that control knows the state of the control net.
   *                           that control knows the state of the control net. If a project
   *                           is performing a "Save As", and there is a modified active control,the
   *                           cnet is written out to the new location, it is not save in the old
   *                           project location.
   */
  class Control : public QObject {
    Q_OBJECT