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

PROG: Moved xml serialization to newly created CnetEditorView.

parent e1a994bc
Loading
Loading
Loading
Loading
+1 −78
Original line number Diff line number Diff line
@@ -98,6 +98,7 @@ namespace Isis {
   * Destructor
   */
  CnetEditorWidget::~CnetEditorWidget() {

    writeSettings();

    delete m_workingVersion;
@@ -1040,82 +1041,4 @@ namespace Isis {
      m_connectionModel->setFrozen(false);
    }
  }


  /**
   * This method pushes a new XmlHandler into the parser stack.
   *
   * @param xmlReader This is the parser stack.
   */
  void CnetEditorWidget::load(XmlStackedHandlerReader *xmlReader) {
    xmlReader->pushContentHandler(new XmlHandler(this));
  }


  /**
   * This method saves the Controls object ids to the stream.
   *
   * @param stream The stream that will output to directory.xml
   * @param project The project to save the users settings to
   * @param newProjectRoot New project's root directory
   */
  void CnetEditorWidget::save(QXmlStreamWriter &stream, Project *project, FileName newProjectRoot) {
    stream.writeStartElement("control");
    stream.writeAttribute("id", m_control->id());
    stream.writeEndElement();
  }


  /**
   * Creates an XmlHandler for cnetEditor
   *
   * @param cnetEditor The widget to be serialized
   */
  CnetEditorWidget::XmlHandler::XmlHandler(CnetEditorWidget *cnetEditor) {
    m_cnetEditor = cnetEditor;
  }


  /**
   * Destructor
   */
  CnetEditorWidget::XmlHandler::~XmlHandler() {
    delete m_cnetEditor;
    m_cnetEditor = NULL;
  }


  /**
   * Placeholder for later serialization of CnetEditorWidgets
   *
   * @param cnetEditor The widget to be serialized
   * @param namespaceURI ???
   * @param localName Determines what attributes to retrieve from atts.
   * @param qName ???
   * @param atts Stores the attributes.
   *
   * @return @b bool The result of XmlStackedHandler's startElement() method.
   */
  bool CnetEditorWidget::XmlHandler::startElement(const QString &namespaceURI,
      const QString &localName, const QString &qName, const QXmlAttributes &atts) {
    bool result = XmlStackedHandler::startElement(namespaceURI, localName, qName, atts);
    return result;
  }


  /**
   * This method calls XmlStackedHandler's endElement() and dereferences pointers according to
   * the value of localName.
   *
   * @param namespaceURI ???
   * @param localName Determines which pointers to dereference.
   * @param qName ???
   *
   * @return @b bool The result of XmlStackedHandler's endElement() method.
   */
  bool CnetEditorWidget::XmlHandler::endElement(const QString &namespaceURI,
      const QString &localName, const QString &qName) {
    bool result = XmlStackedHandler::endElement(namespaceURI, localName, qName);
    return result;
  }
}
+2 −31
Original line number Diff line number Diff line
@@ -71,6 +71,8 @@ namespace Isis {
   *                           a ControlNet. Added load and save methods as well as an XmlHandler
   *                           to allow for serialization of the widget into the project.
   *                           Fixes #4989.
   *   @history 2018-04-11 Tracie Sucharski - Moved the Xml serialization to the newly created
   *                           CnetEditorView class for ipce.
   */
  class CnetEditorWidget : public QWidget {
      Q_OBJECT
@@ -116,9 +118,6 @@ namespace Isis {
      void setPointTableSortingEnabled(bool enabled);
      void setPointTableSortLimit(int limit);

      void load(XmlStackedHandlerReader *xmlReader);
      void save(QXmlStreamWriter &stream, Project *project, FileName newProjectRoot);


    public slots:
      void configSorting();
@@ -191,34 +190,6 @@ namespace Isis {
      QMap< QString, QList< QAction * > > * m_toolBarActions;   //!< QMap of tool bar actions

      QString *m_settingsPath; //!< Path to read/write settings


    private:
      /**
       * This class is a placeholder for future plans to serialize more of
       * CnetEditorWidget's configurations when saving a project.
       *  
       * @author 2017-07-25 Christopher Combs
       * @internal
       *   @history 2017-07-25 Christopher Combs - Added Xml StackedHandler class
       *                           to implement serialization of the CnetEditorWidget.
       *                           References #4989.
       */
      class XmlHandler : public XmlStackedHandler {
        public:
          XmlHandler(CnetEditorWidget *cnetEditor);
          ~XmlHandler();

          virtual bool startElement(const QString &namespaceURI, const QString &localName,
                                    const QString &qName, const QXmlAttributes &atts);
          virtual bool endElement(const QString &namespaceURI, const QString &localName,
                                  const QString &qName);

        private:
          Q_DISABLE_COPY(XmlHandler);

          CnetEditorWidget *m_cnetEditor;
      };
  };
}