Loading isis/src/qisis/objs/CnetEditorView/CnetEditorView.cpp +50 −65 Original line number Diff line number Diff line Loading @@ -90,9 +90,6 @@ namespace Isis { createMenus(); createToolBars(); populateMenus(); populateToolBars(); //createActions(); } /** Loading @@ -110,26 +107,65 @@ namespace Isis { m_toolPad = 0; } /** * 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() { m_fileMenu = menuBar()->addMenu("&File"); m_tableMenu = menuBar()->addMenu("&Tables"); m_helpMenu = menuBar()->addMenu("&Help"); QMap< QAction *, QList< QString > > actionMap = m_cnetEditorWidget->menuActions(); QMapIterator< QAction *, QList< QString > > actionMapIterator(actionMap); QMap<QString, QMenu *> topLevelMenus; while ( actionMapIterator.hasNext() ) { actionMapIterator.next(); QAction *actionToAdd = actionMapIterator.key(); QList< QString > location = actionMapIterator.value(); QMenu *menuToPutActionInto = NULL; if ( location.count() ) { QString topLevelMenuTitle = location.takeFirst(); if (!topLevelMenus[topLevelMenuTitle]) { topLevelMenus[topLevelMenuTitle] = menuBar()->addMenu(topLevelMenuTitle); } 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); } } /** * 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 */ void CnetEditorView::createToolBars() { m_permToolBar = addToolBar("Standard Tools"); m_permToolBar->setObjectName("permToolBar"); m_permToolBar->setIconSize(QSize(22, 22)); // m_permToolBar = addToolBar("Standard Tools"); // m_permToolBar->setObjectName("permToolBar"); // m_permToolBar->setIconSize(QSize(22, 22)); m_toolPad = new ToolPad("Tool Pad", 0); m_toolPad->setObjectName("toolPad"); addToolBar(m_toolPad); // m_separatorAction = new QAction(this); // m_separatorAction->setSeparator(true); } void CnetEditorView::populateToolBars() { QMap< QString, QList< QAction * > > toolActionMap; toolActionMap = m_cnetEditorWidget->toolBarActions(); QMapIterator< QString, QList< QAction * > > toolActionIter(toolActionMap); Loading @@ -144,57 +180,6 @@ namespace Isis { } } void CnetEditorView::populateMenus() { QMap< QAction *, QList< QString > > menuActionMap; menuActionMap = m_cnetEditorWidget->menuActions(); QMapIterator< QAction *, QList< QString > > menuActionIter(menuActionMap); QWidget *widget = NULL; while (menuActionIter.hasNext()) { menuActionIter.next(); QAction *action = menuActionIter.key(); QList< QString > location = menuActionIter.value(); widget = menuBar(); while (location.size()) { QString menuName = location.takeFirst(); int actListIndex = indexOfActionList(widget->actions(), menuName); widget = widget->actions()[actListIndex]->menu(); } widget->addAction(action); } } void CnetEditorView::createActions() { // saveAct = new QAction(QIcon(FileName("$base/icons/filesave.png").expanded()), // tr("&Save"), this); // saveAct->setShortcut(tr("Ctrl+S")); // saveAct->setStatusTip(tr("save changes")); // connect(saveAct, SIGNAL(triggered()), this, SLOT(save())); // // saveAsAct = new QAction(QIcon(FileName("$base/icons/filesaveas.png").expanded()), // tr("Save&As"), this); // saveAsAct->setStatusTip(tr("Save control network to specified file")); // connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs())); // // m_permToolBar->addAction(saveAct); // m_permToolBar->addAction(saveAsAct); // m_fileMenu->addAction(saveAct); // m_fileMenu->addAction(saveAsAct); } int CnetEditorView::indexOfActionList(QList< QAction * > actionList, QString actionText) { int index = -1; for (int i = 0; index == -1 && i < actionList.size(); i++) if (actionList[i]->text() == actionText) index = i; return index; } /** * Returns the cnetEditorWidget. * Loading isis/src/qisis/objs/CnetEditorView/CnetEditorView.h +8 −22 Original line number Diff line number Diff line Loading @@ -51,11 +51,13 @@ namespace Isis { * @author 2018-04-04 Tracie Sucharski * * @internal * @history 2018-05-28 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-05-28 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. */ class CnetEditorView : public AbstractProjectItemView { Loading @@ -80,17 +82,8 @@ class CnetEditorView : public AbstractProjectItemView { void save(QXmlStreamWriter &stream, Project *project, FileName newProjectRoot) const; private: void createActions(); void createToolBars(); void createMenus(); int indexOfActionList(QList< QAction * > actionList, QString actionText); void populateToolBars(); void populateMenus(); // private slots: // void save(); // void saveAs(); private: /** Loading Loading @@ -119,20 +112,13 @@ class CnetEditorView : public AbstractProjectItemView { QPointer<CnetEditorWidget> m_cnetEditorWidget; QPointer<Control> m_control; //QAction *saveAct; //QAction *saveAsAct; QToolBar *m_permToolBar; //!< The permanent tool bar QToolBar *m_activeToolBar; //!< The active tool bar ToolPad *m_toolPad; //!< The tool pad QMenu *m_fileMenu; QMenu *m_helpMenu; QMenu *m_tableMenu; QList<QAction *> m_permToolBarActions; //!< The permanent tool bar actions QWidgetAction *m_activeToolBarAction; //!< Widget of the active tool QWidgetAction *m_activeToolBarAction; //!< Stores the active tool bar QList<QAction *> m_toolPadActions; //!< The tool pad actions QAction *m_separatorAction; }; } Loading Loading
isis/src/qisis/objs/CnetEditorView/CnetEditorView.cpp +50 −65 Original line number Diff line number Diff line Loading @@ -90,9 +90,6 @@ namespace Isis { createMenus(); createToolBars(); populateMenus(); populateToolBars(); //createActions(); } /** Loading @@ -110,26 +107,65 @@ namespace Isis { m_toolPad = 0; } /** * 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() { m_fileMenu = menuBar()->addMenu("&File"); m_tableMenu = menuBar()->addMenu("&Tables"); m_helpMenu = menuBar()->addMenu("&Help"); QMap< QAction *, QList< QString > > actionMap = m_cnetEditorWidget->menuActions(); QMapIterator< QAction *, QList< QString > > actionMapIterator(actionMap); QMap<QString, QMenu *> topLevelMenus; while ( actionMapIterator.hasNext() ) { actionMapIterator.next(); QAction *actionToAdd = actionMapIterator.key(); QList< QString > location = actionMapIterator.value(); QMenu *menuToPutActionInto = NULL; if ( location.count() ) { QString topLevelMenuTitle = location.takeFirst(); if (!topLevelMenus[topLevelMenuTitle]) { topLevelMenus[topLevelMenuTitle] = menuBar()->addMenu(topLevelMenuTitle); } 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); } } /** * 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 */ void CnetEditorView::createToolBars() { m_permToolBar = addToolBar("Standard Tools"); m_permToolBar->setObjectName("permToolBar"); m_permToolBar->setIconSize(QSize(22, 22)); // m_permToolBar = addToolBar("Standard Tools"); // m_permToolBar->setObjectName("permToolBar"); // m_permToolBar->setIconSize(QSize(22, 22)); m_toolPad = new ToolPad("Tool Pad", 0); m_toolPad->setObjectName("toolPad"); addToolBar(m_toolPad); // m_separatorAction = new QAction(this); // m_separatorAction->setSeparator(true); } void CnetEditorView::populateToolBars() { QMap< QString, QList< QAction * > > toolActionMap; toolActionMap = m_cnetEditorWidget->toolBarActions(); QMapIterator< QString, QList< QAction * > > toolActionIter(toolActionMap); Loading @@ -144,57 +180,6 @@ namespace Isis { } } void CnetEditorView::populateMenus() { QMap< QAction *, QList< QString > > menuActionMap; menuActionMap = m_cnetEditorWidget->menuActions(); QMapIterator< QAction *, QList< QString > > menuActionIter(menuActionMap); QWidget *widget = NULL; while (menuActionIter.hasNext()) { menuActionIter.next(); QAction *action = menuActionIter.key(); QList< QString > location = menuActionIter.value(); widget = menuBar(); while (location.size()) { QString menuName = location.takeFirst(); int actListIndex = indexOfActionList(widget->actions(), menuName); widget = widget->actions()[actListIndex]->menu(); } widget->addAction(action); } } void CnetEditorView::createActions() { // saveAct = new QAction(QIcon(FileName("$base/icons/filesave.png").expanded()), // tr("&Save"), this); // saveAct->setShortcut(tr("Ctrl+S")); // saveAct->setStatusTip(tr("save changes")); // connect(saveAct, SIGNAL(triggered()), this, SLOT(save())); // // saveAsAct = new QAction(QIcon(FileName("$base/icons/filesaveas.png").expanded()), // tr("Save&As"), this); // saveAsAct->setStatusTip(tr("Save control network to specified file")); // connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs())); // // m_permToolBar->addAction(saveAct); // m_permToolBar->addAction(saveAsAct); // m_fileMenu->addAction(saveAct); // m_fileMenu->addAction(saveAsAct); } int CnetEditorView::indexOfActionList(QList< QAction * > actionList, QString actionText) { int index = -1; for (int i = 0; index == -1 && i < actionList.size(); i++) if (actionList[i]->text() == actionText) index = i; return index; } /** * Returns the cnetEditorWidget. * Loading
isis/src/qisis/objs/CnetEditorView/CnetEditorView.h +8 −22 Original line number Diff line number Diff line Loading @@ -51,11 +51,13 @@ namespace Isis { * @author 2018-04-04 Tracie Sucharski * * @internal * @history 2018-05-28 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-05-28 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. */ class CnetEditorView : public AbstractProjectItemView { Loading @@ -80,17 +82,8 @@ class CnetEditorView : public AbstractProjectItemView { void save(QXmlStreamWriter &stream, Project *project, FileName newProjectRoot) const; private: void createActions(); void createToolBars(); void createMenus(); int indexOfActionList(QList< QAction * > actionList, QString actionText); void populateToolBars(); void populateMenus(); // private slots: // void save(); // void saveAs(); private: /** Loading Loading @@ -119,20 +112,13 @@ class CnetEditorView : public AbstractProjectItemView { QPointer<CnetEditorWidget> m_cnetEditorWidget; QPointer<Control> m_control; //QAction *saveAct; //QAction *saveAsAct; QToolBar *m_permToolBar; //!< The permanent tool bar QToolBar *m_activeToolBar; //!< The active tool bar ToolPad *m_toolPad; //!< The tool pad QMenu *m_fileMenu; QMenu *m_helpMenu; QMenu *m_tableMenu; QList<QAction *> m_permToolBarActions; //!< The permanent tool bar actions QWidgetAction *m_activeToolBarAction; //!< Widget of the active tool QWidgetAction *m_activeToolBarAction; //!< Stores the active tool bar QList<QAction *> m_toolPadActions; //!< The tool pad actions QAction *m_separatorAction; }; } Loading