Loading isis/src/qisis/objs/Project/Project.cpp +106 −50 Original line number Diff line number Diff line Loading @@ -268,6 +268,7 @@ namespace Isis { m_images = NULL; } if (m_shapes) { foreach (ShapeList *shapeList, *m_shapes) { foreach (Shape *shape, *shapeList) { Loading @@ -294,6 +295,21 @@ namespace Isis { m_controls = NULL; } if (m_templates) { foreach (TemplateList *templateList, *m_templates) { foreach (Template *templateFile, *templateList) { delete templateFile; } delete templateList; } delete m_templates; m_templates = NULL; } m_activeControl = NULL; m_activeImageList = NULL; Loading Loading @@ -434,6 +450,8 @@ namespace Isis { bool images = false; QStringList cnetDirList; bool controls = false; QStringList templateDirList; bool templates = false; QStringList bundleDirList; bool bundles = false; QFile projectXml(projectRoot() + "/project.xml"); Loading @@ -442,6 +460,7 @@ namespace Isis { QTextStream projectXmlInput(&projectXml); while (!projectXmlInput.atEnd() ) { QString line = projectXmlInput.readLine(); if (controls || line.contains("<controlNets>") ) { Loading Loading @@ -480,6 +499,19 @@ namespace Isis { } } else if (templates || line.contains("<templateLists>") ) { templates = true; if (line.contains("</templateLists>") ) { templates = false; } else if (!line.contains("<templateLists>") ) { QList<QString> components = line.split('"'); templateDirList.append(components.at(5)); } } else if (bundles || line.contains("<bundleSolutionInfo>") ) { bundles = true; Loading Loading @@ -529,6 +561,32 @@ namespace Isis { } } QDir mapTemplatesDir(m_projectRoot->path() + "/templates/maps"); mapTemplatesDir.setFilter(QDir::NoDotAndDotDot | QDir::Dirs); QStringList mapTemplatesList = mapTemplatesDir.entryList(); foreach (QString dir, mapTemplatesList) { dir = dir.simplified(); if ( !templateDirList.contains("maps/" + dir) && !templateDirList.contains("registrations/" + dir)) { QDir tempDir(mapTemplatesDir.path() + "/" + dir); tempDir.removeRecursively(); } } QDir regTemplatesDir(m_projectRoot->path() + "/templates/registrations"); regTemplatesDir.setFilter(QDir::NoDotAndDotDot | QDir::Dirs); QStringList regTemplatesList = regTemplatesDir.entryList(); foreach (QString dir, regTemplatesList) { dir = dir.simplified(); if ( !templateDirList.contains("maps/" + dir) && !templateDirList.contains("registrations/" + dir)) { QDir tempDir(regTemplatesDir.path() + "/" + dir); tempDir.removeRecursively(); } } QDir bundlesDir(m_projectRoot->path() + "/results/bundle/"); bundlesDir.setFilter(QDir::NoDotAndDotDot | QDir::Dirs); QStringList bundleList = bundlesDir.entryList(); Loading Loading @@ -1027,7 +1085,6 @@ namespace Isis { * @param prefix The name of the director under templates/ to store the template file. */ QDir Project::addTemplateFolder(QString prefix) { QDir templateFolder = templateRoot(); prefix += "%1"; int prefixCounter = 0; Loading Loading @@ -2862,7 +2919,7 @@ namespace Isis { m_shapeLists.append(new ShapeList(m_project, reader())); } else if (localName == "templateList") { m_templates.append( new TemplateList(m_project, reader())); m_templateLists.append( new TemplateList(m_project, reader())); } // workOrders are stored in history.xml, using same reader as project.xml else if (localName == "workOrder") { Loading Loading @@ -2933,6 +2990,11 @@ namespace Isis { m_project->shapesReady(*shapeList); } } else if (localName == "templateLists") { foreach (TemplateList *templateList, m_templateLists) { m_project->addTemplates(templateList); } } else if (localName == "workOrder") { m_project->m_workOrderHistory->append(m_workOrder); m_workOrder = NULL; Loading @@ -2958,12 +3020,6 @@ namespace Isis { } } } else if (localName == "templateLists") { foreach (TemplateList *list, m_templates) { m_project->addTemplates(list); } } return XmlStackedHandler::endElement(namespaceURI, localName, qName); } } isis/src/qisis/objs/Project/Project.h +3 −1 Original line number Diff line number Diff line Loading @@ -255,6 +255,8 @@ namespace Isis { * the wrong place on the project tree. Fixes #5274. * @history 2018-06-06 Kaitlyn Lee - activeControlModified() calls setClean(false) to enable the save * button when the active control net is modified, i.e. a point is modified. * @history 2018-06-28 Summer Stapleton - Added clean-up of unsaved templates at project close * in Project::clear(). * */ class Project : public QObject { Loading Loading @@ -563,7 +565,7 @@ namespace Isis { QList<ShapeList *> m_shapeLists; QList<ControlList *> m_controls; QList<BundleSolutionInfo *> m_bundleSolutionInfos; QList<TemplateList *> m_templates; QList<TemplateList *> m_templateLists; WorkOrder *m_workOrder; }; Loading isis/src/qisis/objs/TemplateEditorWidget/TemplateEditorWidget.cpp +64 −23 Original line number Diff line number Diff line Loading @@ -4,6 +4,9 @@ #include "Directory.h" #include "Template.h" #include <QDir> #include <QFileDialog> namespace Isis { Loading @@ -11,6 +14,8 @@ namespace Isis { QWidget *parent) : m_ui(new Ui::TemplateEditorWidget) { m_ui->setupUi(this); m_template = currentTemplate; m_directory = directory; m_fileType = m_template->templateType(); QFile templateFile(m_template->fileName()); templateFile.open(QFile::ReadOnly | QFile::Text); Loading @@ -19,7 +24,7 @@ namespace Isis { templateFile.close(); connect(m_ui->templateTextSave, SIGNAL (released()),this, SLOT (saveText())); // connect(m_ui->templateTextSaveAs, SIGNAL (released()),this, SLOT (saveAsText())); connect(m_ui->templateTextSaveAs, SIGNAL (released()),this, SLOT (saveAsText())); } Loading @@ -42,26 +47,62 @@ namespace Isis { // Future plans to include Save As button // void TemplateEditorWidget::saveAsText() { // //We create a new QFile just in case the template's file name has changed // // QString templateFileName = QFileDialog::getSaveFileName( // qobject_cast<QWidget *>(parent()), // "Save File", // QString(),); // // Template *newTemplate(m_template); // newTemplate->fileName = templateFileName; // m_template = newTemplate; // // m_directory->project()-> // add to project item model // // QFile templateFile(templateFileName); // // if (templateFile.open(QFile::WriteOnly | QFile::Text)) { // templateFile.resize(0); // templateFile.write(m_ui->templateTextEdit->toPlainText().toUtf8()); // templateFile.close(); void TemplateEditorWidget::saveAsText() { //We create a new QFile just in case the template's file name has changed // First need to get the filename to save to via a QFileDialog QFileDialog *fileDialog = new QFileDialog(qobject_cast<QWidget *>(parent()), "Save Template File"); fileDialog->setAcceptMode(QFileDialog::AcceptSave); fileDialog->setDirectory(QDir::currentPath()); fileDialog->setNameFilter("DEF (*.def);;MAP (*.map);;All (*)"); // Need .pvl? fileDialog->exec(); // Add file extension based on selected filter if extension not provided, defaulting to ".def" QString extension = fileDialog->selectedNameFilter().split("(")[1].mid(1, 4); if (QString::compare(extension, ".def") == 0 || QString::compare(extension, ".map") == 0) { fileDialog->setDefaultSuffix(extension); } else { fileDialog->setDefaultSuffix(".def"); } QString templateFileName = fileDialog->selectedFiles().first(); // Write the file out QFile templateFile(templateFileName); qDebug() << "Template file name right after selection: " << templateFileName; if (templateFile.open(QFile::WriteOnly | QFile::Text)) { templateFile.resize(0); templateFile.write(m_ui->templateTextEdit->toPlainText().toUtf8()); templateFile.close(); } // Import the newly created template file to the project if (templateFile.exists()) { qDebug() << "File Type in SaveAs method: " << m_fileType; QDir templateFolder = m_directory->project()->addTemplateFolder(m_fileType + "/import"); TemplateList *templateList = new TemplateList(templateFolder.dirName(), m_fileType, m_fileType + "/" + templateFolder.dirName() ); QFile::copy(templateFileName, templateFolder.path() + "/" + templateFileName.split("/").last()); templateList->append(new Template(templateFolder.path() + "/" + templateFileName.split("/").last(), m_fileType, templateFolder.dirName())); // if (compare(m_fileType, "maps") == 0) { // project->addMapTemplates(templateList); // } // else if (compare(m_fileType, "registrations") == 0) { // project->addRegistrationTemplates(templateList); // } m_directory->project()->addTemplates(templateList); m_directory->project()->setClean(false); } else { } } } isis/src/qisis/objs/TemplateEditorWidget/TemplateEditorWidget.h +4 −2 Original line number Diff line number Diff line Loading @@ -36,12 +36,14 @@ namespace Isis { public slots: void saveText(); void saveAsText(); private: Ui::TemplateEditorWidget *m_ui; Directory *m_directory; Template *m_template; Directory *m_directory; // The directory of the open project Template *m_template; // The template being modified QString m_fileType; // The file type of the template ("Maps" or "Registrations") }; } Loading isis/src/qisis/objs/TemplateEditorWidget/TemplateEditorWidget.ui +7 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,13 @@ </property> </widget> </item> <item> <widget class="QPushButton" name="templateTextSaveAs"> <property name="text"> <string> Save Changes As... </string> </property> </widget> </item> </layout> </widget> <resources/> Loading Loading
isis/src/qisis/objs/Project/Project.cpp +106 −50 Original line number Diff line number Diff line Loading @@ -268,6 +268,7 @@ namespace Isis { m_images = NULL; } if (m_shapes) { foreach (ShapeList *shapeList, *m_shapes) { foreach (Shape *shape, *shapeList) { Loading @@ -294,6 +295,21 @@ namespace Isis { m_controls = NULL; } if (m_templates) { foreach (TemplateList *templateList, *m_templates) { foreach (Template *templateFile, *templateList) { delete templateFile; } delete templateList; } delete m_templates; m_templates = NULL; } m_activeControl = NULL; m_activeImageList = NULL; Loading Loading @@ -434,6 +450,8 @@ namespace Isis { bool images = false; QStringList cnetDirList; bool controls = false; QStringList templateDirList; bool templates = false; QStringList bundleDirList; bool bundles = false; QFile projectXml(projectRoot() + "/project.xml"); Loading @@ -442,6 +460,7 @@ namespace Isis { QTextStream projectXmlInput(&projectXml); while (!projectXmlInput.atEnd() ) { QString line = projectXmlInput.readLine(); if (controls || line.contains("<controlNets>") ) { Loading Loading @@ -480,6 +499,19 @@ namespace Isis { } } else if (templates || line.contains("<templateLists>") ) { templates = true; if (line.contains("</templateLists>") ) { templates = false; } else if (!line.contains("<templateLists>") ) { QList<QString> components = line.split('"'); templateDirList.append(components.at(5)); } } else if (bundles || line.contains("<bundleSolutionInfo>") ) { bundles = true; Loading Loading @@ -529,6 +561,32 @@ namespace Isis { } } QDir mapTemplatesDir(m_projectRoot->path() + "/templates/maps"); mapTemplatesDir.setFilter(QDir::NoDotAndDotDot | QDir::Dirs); QStringList mapTemplatesList = mapTemplatesDir.entryList(); foreach (QString dir, mapTemplatesList) { dir = dir.simplified(); if ( !templateDirList.contains("maps/" + dir) && !templateDirList.contains("registrations/" + dir)) { QDir tempDir(mapTemplatesDir.path() + "/" + dir); tempDir.removeRecursively(); } } QDir regTemplatesDir(m_projectRoot->path() + "/templates/registrations"); regTemplatesDir.setFilter(QDir::NoDotAndDotDot | QDir::Dirs); QStringList regTemplatesList = regTemplatesDir.entryList(); foreach (QString dir, regTemplatesList) { dir = dir.simplified(); if ( !templateDirList.contains("maps/" + dir) && !templateDirList.contains("registrations/" + dir)) { QDir tempDir(regTemplatesDir.path() + "/" + dir); tempDir.removeRecursively(); } } QDir bundlesDir(m_projectRoot->path() + "/results/bundle/"); bundlesDir.setFilter(QDir::NoDotAndDotDot | QDir::Dirs); QStringList bundleList = bundlesDir.entryList(); Loading Loading @@ -1027,7 +1085,6 @@ namespace Isis { * @param prefix The name of the director under templates/ to store the template file. */ QDir Project::addTemplateFolder(QString prefix) { QDir templateFolder = templateRoot(); prefix += "%1"; int prefixCounter = 0; Loading Loading @@ -2862,7 +2919,7 @@ namespace Isis { m_shapeLists.append(new ShapeList(m_project, reader())); } else if (localName == "templateList") { m_templates.append( new TemplateList(m_project, reader())); m_templateLists.append( new TemplateList(m_project, reader())); } // workOrders are stored in history.xml, using same reader as project.xml else if (localName == "workOrder") { Loading Loading @@ -2933,6 +2990,11 @@ namespace Isis { m_project->shapesReady(*shapeList); } } else if (localName == "templateLists") { foreach (TemplateList *templateList, m_templateLists) { m_project->addTemplates(templateList); } } else if (localName == "workOrder") { m_project->m_workOrderHistory->append(m_workOrder); m_workOrder = NULL; Loading @@ -2958,12 +3020,6 @@ namespace Isis { } } } else if (localName == "templateLists") { foreach (TemplateList *list, m_templates) { m_project->addTemplates(list); } } return XmlStackedHandler::endElement(namespaceURI, localName, qName); } }
isis/src/qisis/objs/Project/Project.h +3 −1 Original line number Diff line number Diff line Loading @@ -255,6 +255,8 @@ namespace Isis { * the wrong place on the project tree. Fixes #5274. * @history 2018-06-06 Kaitlyn Lee - activeControlModified() calls setClean(false) to enable the save * button when the active control net is modified, i.e. a point is modified. * @history 2018-06-28 Summer Stapleton - Added clean-up of unsaved templates at project close * in Project::clear(). * */ class Project : public QObject { Loading Loading @@ -563,7 +565,7 @@ namespace Isis { QList<ShapeList *> m_shapeLists; QList<ControlList *> m_controls; QList<BundleSolutionInfo *> m_bundleSolutionInfos; QList<TemplateList *> m_templates; QList<TemplateList *> m_templateLists; WorkOrder *m_workOrder; }; Loading
isis/src/qisis/objs/TemplateEditorWidget/TemplateEditorWidget.cpp +64 −23 Original line number Diff line number Diff line Loading @@ -4,6 +4,9 @@ #include "Directory.h" #include "Template.h" #include <QDir> #include <QFileDialog> namespace Isis { Loading @@ -11,6 +14,8 @@ namespace Isis { QWidget *parent) : m_ui(new Ui::TemplateEditorWidget) { m_ui->setupUi(this); m_template = currentTemplate; m_directory = directory; m_fileType = m_template->templateType(); QFile templateFile(m_template->fileName()); templateFile.open(QFile::ReadOnly | QFile::Text); Loading @@ -19,7 +24,7 @@ namespace Isis { templateFile.close(); connect(m_ui->templateTextSave, SIGNAL (released()),this, SLOT (saveText())); // connect(m_ui->templateTextSaveAs, SIGNAL (released()),this, SLOT (saveAsText())); connect(m_ui->templateTextSaveAs, SIGNAL (released()),this, SLOT (saveAsText())); } Loading @@ -42,26 +47,62 @@ namespace Isis { // Future plans to include Save As button // void TemplateEditorWidget::saveAsText() { // //We create a new QFile just in case the template's file name has changed // // QString templateFileName = QFileDialog::getSaveFileName( // qobject_cast<QWidget *>(parent()), // "Save File", // QString(),); // // Template *newTemplate(m_template); // newTemplate->fileName = templateFileName; // m_template = newTemplate; // // m_directory->project()-> // add to project item model // // QFile templateFile(templateFileName); // // if (templateFile.open(QFile::WriteOnly | QFile::Text)) { // templateFile.resize(0); // templateFile.write(m_ui->templateTextEdit->toPlainText().toUtf8()); // templateFile.close(); void TemplateEditorWidget::saveAsText() { //We create a new QFile just in case the template's file name has changed // First need to get the filename to save to via a QFileDialog QFileDialog *fileDialog = new QFileDialog(qobject_cast<QWidget *>(parent()), "Save Template File"); fileDialog->setAcceptMode(QFileDialog::AcceptSave); fileDialog->setDirectory(QDir::currentPath()); fileDialog->setNameFilter("DEF (*.def);;MAP (*.map);;All (*)"); // Need .pvl? fileDialog->exec(); // Add file extension based on selected filter if extension not provided, defaulting to ".def" QString extension = fileDialog->selectedNameFilter().split("(")[1].mid(1, 4); if (QString::compare(extension, ".def") == 0 || QString::compare(extension, ".map") == 0) { fileDialog->setDefaultSuffix(extension); } else { fileDialog->setDefaultSuffix(".def"); } QString templateFileName = fileDialog->selectedFiles().first(); // Write the file out QFile templateFile(templateFileName); qDebug() << "Template file name right after selection: " << templateFileName; if (templateFile.open(QFile::WriteOnly | QFile::Text)) { templateFile.resize(0); templateFile.write(m_ui->templateTextEdit->toPlainText().toUtf8()); templateFile.close(); } // Import the newly created template file to the project if (templateFile.exists()) { qDebug() << "File Type in SaveAs method: " << m_fileType; QDir templateFolder = m_directory->project()->addTemplateFolder(m_fileType + "/import"); TemplateList *templateList = new TemplateList(templateFolder.dirName(), m_fileType, m_fileType + "/" + templateFolder.dirName() ); QFile::copy(templateFileName, templateFolder.path() + "/" + templateFileName.split("/").last()); templateList->append(new Template(templateFolder.path() + "/" + templateFileName.split("/").last(), m_fileType, templateFolder.dirName())); // if (compare(m_fileType, "maps") == 0) { // project->addMapTemplates(templateList); // } // else if (compare(m_fileType, "registrations") == 0) { // project->addRegistrationTemplates(templateList); // } m_directory->project()->addTemplates(templateList); m_directory->project()->setClean(false); } else { } } }
isis/src/qisis/objs/TemplateEditorWidget/TemplateEditorWidget.h +4 −2 Original line number Diff line number Diff line Loading @@ -36,12 +36,14 @@ namespace Isis { public slots: void saveText(); void saveAsText(); private: Ui::TemplateEditorWidget *m_ui; Directory *m_directory; Template *m_template; Directory *m_directory; // The directory of the open project Template *m_template; // The template being modified QString m_fileType; // The file type of the template ("Maps" or "Registrations") }; } Loading
isis/src/qisis/objs/TemplateEditorWidget/TemplateEditorWidget.ui +7 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,13 @@ </property> </widget> </item> <item> <widget class="QPushButton" name="templateTextSaveAs"> <property name="text"> <string> Save Changes As... </string> </property> </widget> </item> </layout> </widget> <resources/> Loading