Unverified Commit 1001bc94 authored by Makayla Shepherd's avatar Makayla Shepherd Committed by GitHub
Browse files

Merge pull request #239 from kdl222/ipceTools

Added toolbars and menus to CnetEditorView. Fixes #5416
parents c1959fea 77bf4b73
Loading
Loading
Loading
Loading
+4 −50
Original line number Diff line number Diff line
@@ -218,7 +218,6 @@ namespace Isis {


  void IpceMainWindow::cleanupViewDockList(QObject *obj) {

    QDockWidget *dock = static_cast<QDockWidget *>(obj);
    if (dock) {
      m_viewDocks.removeAll(dock);
@@ -227,14 +226,12 @@ namespace Isis {


  /**
   * @description This slot is connected from Directory::viewClosed(QWidget *) signal.  It will 
   * This slot is connected from Directory::viewClosed(QWidget *) signal.  It will
   * close the given view and delete the view. This was written to handle
   *
   * @param view QWidget* 
   *
   * @param view QWidget* The view to close.
   */
  void IpceMainWindow::removeView(QWidget *view) {
    
    view->close();
    delete view;
  }
@@ -343,30 +340,6 @@ namespace Isis {
    m_fileMenuActions.append(exitAction);
    m_permToolBarActions.append(exitAction);

    QAction *saveNet = new QAction("&Save Active Control Network", this);
    saveNet->setIcon( QIcon::fromTheme("document-save") );
    saveNet->setShortcut(Qt::CTRL + Qt::Key_S);
    saveNet->setToolTip("Save current active control network");
    saveNet->setStatusTip("Save current active control network");
    QString whatsThis = "<b>Function:</b> Saves the current active<i>"
                        "control network</i>";
    saveNet->setWhatsThis(whatsThis);
    connect(saveNet, SIGNAL(triggered()), m_directory, SLOT(saveActiveControl()));
    m_permToolBarActions.append(saveNet);

//  m_saveAsNet = new QAction(QPixmap(toolIconDir() + "/mActionFileSaveAs.png"),
//                            "Save Control Network &As...",
//                            m_matchTool);
//  m_saveAsNet->setToolTip("Save current control network to chosen file");
//  m_saveAsNet->setStatusTip("Save current control network to chosen file");
//  whatsThis = "<b>Function:</b> Saves the current <i>"
//      "control network</i> under chosen filename";
//  m_saveAsNet->setWhatsThis(whatsThis);
//  connect(m_saveAsNet, SIGNAL(triggered()), this, SLOT(saveAsNet()));




    QAction *undoAction = m_directory->undoAction();
    undoAction->setShortcut(Qt::Key_Z | Qt::CTRL);

@@ -490,38 +463,20 @@ namespace Isis {
   */
  void IpceMainWindow::createToolBars() {
    m_permToolBar = new QToolBar(this);
    m_activeToolBar = new QToolBar(this);
    m_toolPad = new QToolBar(this);

    QSize iconSize(25, 45);

    m_permToolBar->setIconSize(iconSize);
    m_activeToolBar->setIconSize(iconSize);
    m_toolPad->setIconSize(iconSize);

    m_permToolBar->setObjectName("PermanentToolBar");
    m_activeToolBar->setObjectName("ActiveToolBar");
    m_toolPad->setObjectName("ToolPad");

    addToolBar(m_permToolBar);
    addToolBar(m_activeToolBar);
    addToolBar(m_toolPad);

    foreach ( QAction *action, m_directory->permToolBarActions() ) {
      m_permToolBar->addAction(action);
    }

    foreach (QAction *action, m_permToolBarActions) {
      if (action->text() == "&Save Active Control Network") {
        m_permToolBar->addSeparator();
        m_permToolBar->addAction(action); 
        m_permToolBar->addSeparator();
      }
      else {
      m_permToolBar->addAction(action);
    }
  }
  }


  /**
@@ -825,5 +780,4 @@ namespace Isis {
  void IpceMainWindow::raiseWarningTab() {
    m_warningsDock->raise();
  }

}
+3 −3
Original line number Diff line number Diff line
@@ -138,6 +138,8 @@ namespace Isis {
   *                           Cleanup connections are made for the views and the docks to ensure
   *                           that cleanup happens for both.  Fixes #5433.
   *   @history 2018-06-13 Tracie Sucharski - Fixed cleanup of views and QDockWidgets.
   *   @history 2018-06-13 Kaitlyn Lee - Removed code adding the save active control net button and
   *                           the toolpad, since control nets can be saved with the project save button.
   *   @history 2018-06-15 Tracie Sucharski - Fixed break to recent projects.  The readSettings
   *                           must be called before initializeActions to get the recent projects
   *                           from the config file.
@@ -202,8 +204,6 @@ namespace Isis {
      static const int m_maxRecentProjects = 5;

      QToolBar *m_permToolBar; //!< The toolbar for actions that rarely need to be changed.
      QToolBar *m_activeToolBar; //<! The toolbar for the actions of the current tool.
      QToolBar *m_toolPad; //<! The toolbar for the actions that activate tools.

      QMenu *m_fileMenu; //!< Menu for the file actions
      QMenu *m_projectMenu; //!< Menu for the project actions
+76 −73
Original line number Diff line number Diff line
@@ -37,8 +37,6 @@
#include <QTabWidget>
#include <QToolBar>
#include <QtXml>
#include <QVBoxLayout>
#include <QWidgetAction>

#include "Control.h"
#include "ControlNet.h"
@@ -46,10 +44,8 @@
#include "Directory.h"
#include "FileName.h"
#include "Project.h"
#include "ToolPad.h"
#include "XmlStackedHandlerReader.h"


namespace Isis {
  /**
   * Constructor.
@@ -83,53 +79,95 @@ namespace Isis {
    filterViews->addTab( m_cnetEditorWidget->connectionFilterWidget(), tr("Filter Connections") );
    resultLayout->addWidget(filterViews, 1, 1, 1, 1);

    m_permToolBar = new QToolBar("Standard Tools", 0);
    m_permToolBar->setObjectName("permToolBar");
    m_permToolBar->setIconSize(QSize(22, 22));
    //toolBarLayout->addWidget(m_permToolBar);
    createMenus();
    createToolBars();
  }

    m_activeToolBar = new QToolBar("Active Tool", 0);
    m_activeToolBar->setObjectName("activeToolBar");
    m_activeToolBar->setIconSize(QSize(22, 22));
    //toolBarLayout->addWidget(m_activeToolBar);
  /**
   * Destructor
   */
  CnetEditorView::~CnetEditorView() {

    m_toolPad = new ToolPad("Tool Pad", 0);
    m_toolPad->setObjectName("toolPad");
    //toolBarLayout->addWidget(m_toolPad);
    delete m_cnetEditorWidget;
    delete m_permToolBar;

    m_permToolBar = 0;
  }

//  m_cnetEditorWidget->addToPermanent(m_permToolBar);
//  m_cnetEditorWidget->addTo(m_activeToolBar);
//  m_cnetEditorWidget->addTo(m_toolPad);
  /**
   * Uses the actions created by CnetEditorWidget, tries to find the menus to put
   * the actions under, and creates the menus if said menus do not exist. Currently,
   * the menus added are Table and Help.
   */
  void CnetEditorView::createMenus() {
    QMap< QAction *, QList< QString > > actionMap = m_cnetEditorWidget->menuActions();
    QMapIterator< QAction *, QList< QString > > actionMapIter(actionMap);
    QMap<QString, QMenu *> topLevelMenus;

    while ( actionMapIter.hasNext() ) {
      actionMapIter.next();
      QAction *actionToAdd = actionMapIter.key();
      QList< QString > location = actionMapIter.value();

      // Skip the Help menu for now because we do not want to add the "What's This?"
      // action (it is in the main help menu of IPCE)
      if (location.first() == "&Help") {
        continue;
      }

    m_activeToolBarAction = new QWidgetAction(this);
    m_activeToolBarAction->setDefaultWidget(m_activeToolBar);
      QMenu *menuToPutActionInto = NULL;

    setAcceptDrops(true);
      if ( location.count() ) {
        QString topLevelMenuTitle = location.takeFirst();
        if (!topLevelMenus[topLevelMenuTitle]) {
          topLevelMenus[topLevelMenuTitle] = menuBar()->addMenu(topLevelMenuTitle);
        }

    QSizePolicy policy = sizePolicy();
    policy.setHorizontalPolicy(QSizePolicy::Expanding);
    policy.setVerticalPolicy(QSizePolicy::Expanding);
    setSizePolicy(policy);
        menuToPutActionInto = topLevelMenus[topLevelMenuTitle];
      }

      foreach (QString menuName, location) {
        bool foundSubMenu = false;
        foreach ( QAction *possibleSubMenu, menuToPutActionInto->actions() ) {
          if (!foundSubMenu &&
              possibleSubMenu->menu() && possibleSubMenu->menu()->title() == menuName) {
            foundSubMenu = true;
            menuToPutActionInto = possibleSubMenu->menu();
          }
        }

        if (!foundSubMenu) {
          menuToPutActionInto = menuToPutActionInto->addMenu(menuName);
        }
      }

      menuToPutActionInto->addAction(actionToAdd);
    }
  }

  /**
   * Destructor
   * Uses and adds the actions created by CnetEditorWidget to the view's toolbars
   * Right now, all actions created in CnetEditorWidget are added to the toolpad.
   * This was copied from CnetEditorWindow
   */
  CnetEditorView::~CnetEditorView() {
  void CnetEditorView::createToolBars() {
    m_permToolBar = addToolBar("Standard Tools");
    m_permToolBar->setObjectName("permToolBar");
    m_permToolBar->setIconSize(QSize(22, 22));

    delete m_cnetEditorWidget;
    delete m_permToolBar;
    delete m_activeToolBar;
    delete m_toolPad;
    QMap< QString, QList< QAction * > > actionMap;
    actionMap = m_cnetEditorWidget->toolBarActions();
    QMapIterator< QString, QList< QAction * > > actionIter(actionMap);

    m_permToolBar = 0;
    m_activeToolBar = 0;
    m_toolPad = 0;
    while (actionIter.hasNext()) {
      actionIter.next();
      QString objName = actionIter.key();
      QList< QAction * > actionList = actionIter.value();
      foreach (QAction *action, actionList) {
        m_permToolBar->addAction(action);
      }
    }
  }


  /**
   * Returns the cnetEditorWidget.
@@ -161,41 +199,6 @@ namespace Isis {
    return QSize(800, 600);
  }


  /**
   * Returns a list of actions for the permanent tool bar.
   *
   * @return (QList<QAction *>) The actions
   */
  QList<QAction *> CnetEditorView::permToolBarActions() {
    return m_permToolBar->actions();
  }


  /**
   * Returns a list of actions for the active tool bar.
   *
   * @return (QList<QAction *>) The actions
   */
  QList<QAction *> CnetEditorView::activeToolBarActions() {
    QList<QAction *> actions;
    actions.append(m_activeToolBarAction);
    return actions;
  }


  /**
   * Returns a list of actions for the tool pad.
   *
   * @return (QList<QAction *>) The actions
   */
  QList<QAction *> CnetEditorView::toolPadActions() {
    return m_toolPad->actions();
  }




  /**
   * This method pushes a new XmlHandler into the parser stack.
   *
+14 −14
Original line number Diff line number Diff line
@@ -51,11 +51,17 @@ namespace Isis {
   * @author 2018-04-04 Tracie Sucharski
   *
   * @internal
   *    @history 2018-06-1 Kaitlyn Lee - Because AbstractProjectItemView now inherits
   *                                from QMainWindow, I added a dummy central widget
   *                                and set its layout to the grid layout. We used to set
   *                                the whole CnetEditorView widget's layout, now we only
   *    @history 2018-06-01 Kaitlyn Lee - Because AbstractProjectItemView now inherits from QMainWindow,
   *                            I added a dummy central widget and set its layout to the grid layout.
   *                            We used to set the whole CnetEditorView widget's layout, now we only
   *                            set the central widget's layout.
   *    @history 2018-06-05 Kaitlyn Lee - Added createMenus() and createToolBars(). The body of createMenus()
   *                            was moved from the constructor. createToolBars() was copied and edited
   *                            from CnetEditorWindow. Fixes #5416
   *    @history 2018-06-13 Kaitlyn Lee - Since views now inherit from QMainWindow, each individual
   *                            view has its own toolbar, so having getters that return toolbar
   *                            actions to fill the toolbar of the IpceMainWindow are unnecessary.
   *                            Removed methods that returned menu and toolbar actions.
   */

class CnetEditorView : public AbstractProjectItemView {
@@ -67,10 +73,6 @@ class CnetEditorView : public AbstractProjectItemView {
                   QWidget *parent = 0);
    ~CnetEditorView();

    virtual QList<QAction *> permToolBarActions();
    virtual QList<QAction *> activeToolBarActions();
    virtual QList<QAction *> toolPadActions();

    CnetEditorWidget *cnetEditorWidget();
    Control *control();

@@ -79,8 +81,10 @@ class CnetEditorView : public AbstractProjectItemView {
    void load(XmlStackedHandlerReader *xmlReader);
    void save(QXmlStreamWriter &stream, Project *project, FileName newProjectRoot) const;


  private:
    void createToolBars();
    void createMenus();

      /**
       * @author 2012-09-?? Steven Lambright
       *
@@ -108,10 +112,6 @@ class CnetEditorView : public AbstractProjectItemView {
    QPointer<Control> m_control;

    QToolBar *m_permToolBar; //!< The permanent tool bar
    QToolBar *m_activeToolBar; //!< The active tool bar
    ToolPad *m_toolPad; //!< The tool pad

    QWidgetAction *m_activeToolBarAction; //!< Stores the active tool bar
  };
}

+2 −1
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ namespace Isis {
    CnetEditorWidget *cnetWidget) : QDialog(cnetWidget) {
    m_cnetWidget = cnetWidget;

    setWindowTitle("Table Sorting");

    QGridLayout *mainLayout = new QGridLayout;
    mainLayout->setColumnMinimumWidth(0, 20);
    setLayout(mainLayout);
@@ -200,4 +202,3 @@ namespace Isis {
      m_measureSortingCheckBox->isChecked());
  }
}
Loading