Commit 0437f417 authored by Cole Neubauer's avatar Cole Neubauer
Browse files

Fixed apsolute paths not being read correctly in cubelis Fixes #4956

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/branches/ipce@8298 41f8697f-d340-4b68-9986-7bafba869bb8
parent 37e45462
Loading
Loading
Loading
Loading
+22 −14
Original line number Original line Diff line number Diff line
@@ -136,7 +136,7 @@ namespace Isis {
          tr("Import Images"), "",
          tr("Import Images"), "",
          tr("Isis cubes and list files (*.cub *.lis);;All Files (*)"));
          tr("Isis cubes and list files (*.cub *.lis);;All Files (*)"));


      QStringList stateToSave;
      QStringList* stateToSave = new QStringList();


      if (!fileNames.isEmpty()) {
      if (!fileNames.isEmpty()) {
        foreach (FileName fileName, fileNames) {
        foreach (FileName fileName, fileNames) {
@@ -146,21 +146,29 @@ namespace Isis {
            QString lineOfListFile;
            QString lineOfListFile;


            while (listFile.GetLine(lineOfListFile)) {
            while (listFile.GetLine(lineOfListFile)) {
              if (lineOfListFile.contains(path)){
              FileName relFileName(path + "/" + lineOfListFile);
                stateToSave.append(lineOfListFile);
              if (relFileName.fileExists() ) {
                stateToSave->append(path + "/" + lineOfListFile);
              }
              }
              else {
              else {
                stateToSave.append(path + "/" + lineOfListFile);
                FileName absFileName(lineOfListFile);
                if ( absFileName.fileExists() && lineOfListFile.startsWith("/") ) {
                  stateToSave->append(lineOfListFile);
                }

                else {
                  project()->warn("File " + lineOfListFile + " not found");
                }
              }
              }
            }
            }
          }
          }
          else {
          else {
            stateToSave.append(fileName.original());
            stateToSave->append(fileName.original());
          }
          }
        }
        }


        QMessageBox::StandardButton saveProjectAnswer = QMessageBox::No;
        QMessageBox::StandardButton saveProjectAnswer = QMessageBox::No;
        if (stateToSave.count() >= 100 && project()->isTemporaryProject()) {
        if (stateToSave->count() >= 100 && project()->isTemporaryProject()) {
          saveProjectAnswer = QMessageBox::question(qobject_cast<QWidget *>(parent()),
          saveProjectAnswer = QMessageBox::question(qobject_cast<QWidget *>(parent()),
                   tr("Save Project Before Importing Images"),
                   tr("Save Project Before Importing Images"),
                   tr("Would you like to save your project <b>before</b> importing images? It can be "
                   tr("Would you like to save your project <b>before</b> importing images? It can be "
@@ -176,7 +184,7 @@ namespace Isis {
        }
        }


        QMessageBox::StandardButton copyImagesAnswer = QMessageBox::No;
        QMessageBox::StandardButton copyImagesAnswer = QMessageBox::No;
        if (!fileNames.isEmpty() && saveProjectAnswer != QMessageBox::Cancel) {
        if (!stateToSave->isEmpty() && saveProjectAnswer != QMessageBox::Cancel) {
          copyImagesAnswer = QMessageBox::question(qobject_cast<QWidget *>(parent()),
          copyImagesAnswer = QMessageBox::question(qobject_cast<QWidget *>(parent()),
                   tr("Copy Images into Project"),
                   tr("Copy Images into Project"),
                   tr("Should images (DN data) be copied into project?"),
                   tr("Should images (DN data) be copied into project?"),
@@ -186,23 +194,23 @@ namespace Isis {


        bool copyDnData = (copyImagesAnswer == QMessageBox::Yes);
        bool copyDnData = (copyImagesAnswer == QMessageBox::Yes);


        stateToSave.prepend(copyDnData? "copy" : "nocopy");
        stateToSave->prepend(copyDnData? "copy" : "nocopy");


        if (fileNames.count() > 1) {
        if (fileNames.count() > 1) {
          QUndoCommand::setText(tr("Import %1 Images").arg(stateToSave.count() - 1));
          QUndoCommand::setText(tr("Import %1 Images").arg(stateToSave->count() - 1));
        }
        }
        else if (fileNames.count() == 1 && stateToSave.count() > 2) {
        else if (fileNames.count() == 1 && stateToSave->count() > 2) {
          QUndoCommand::setText(tr("Import %1 Images from %2").arg(
          QUndoCommand::setText(tr("Import %1 Images from %2").arg(
                        QString::number(stateToSave.count() - 1), fileNames.first()));
                        QString::number(stateToSave->count() - 1), fileNames.first()));
        }
        }
        else {
        else {
          QUndoCommand::setText(tr("Import %1").arg(fileNames.first()));
          QUndoCommand::setText(tr("Import %1").arg(fileNames.first()));
        }
        }


        // The internal data will look like: [ copy|nocopy, img1, img2, ... ]
        // The internal data will look like: [ copy|nocopy, img1, img2, ... ]
        setInternalData(stateToSave);
        setInternalData(*stateToSave);


        bool doImport = fileNames.count() > 0 && saveProjectAnswer != QMessageBox::Cancel &&
        bool doImport = stateToSave->count() > 1 && saveProjectAnswer != QMessageBox::Cancel &&
                        copyImagesAnswer != QMessageBox::Cancel;
                        copyImagesAnswer != QMessageBox::Cancel;


        return doImport;
        return doImport;
+2 −0
Original line number Original line Diff line number Diff line
@@ -86,6 +86,8 @@ namespace Isis {
   *   @history 2017-11-02 Tyler Wilson - Added a null pointer check around ProjectItem *item pointer
   *   @history 2017-11-02 Tyler Wilson - Added a null pointer check around ProjectItem *item pointer
   *                           in isExecutable to prevent potential seg faults.  References #4492.
   *                           in isExecutable to prevent potential seg faults.  References #4492.
   *
   *
   *   @history 2017-11-13 Cole Neubauer - Fixed apsolute paths not being read correctly in cubelis
   *                           Fixes #4956
   */
   */
  class ImportImagesWorkOrder : public WorkOrder {
  class ImportImagesWorkOrder : public WorkOrder {
      Q_OBJECT
      Q_OBJECT