Isis 3 Programmer Reference
CnetEditorView.cpp
1
7/* SPDX-License-Identifier: CC0-1.0 */
8
9#include "CnetEditorView.h"
10
11#include <QAction>
12#include <QGridLayout>
13#include <QList>
14#include <QMap>
15#include <QMapIterator>
16#include <QMenu>
17#include <QMenuBar>
18#include <QSize>
19#include <QSizePolicy>
20#include <QString>
21#include <QTabWidget>
22#include <QToolBar>
23#include <QtXml>
24
25#include "Control.h"
26#include "ControlNet.h"
27#include "CnetEditorWidget.h"
28#include "Directory.h"
29#include "FileName.h"
30#include "Project.h"
31#include "ProjectItemViewMenu.h"
32
33namespace Isis {
37 CnetEditorView::CnetEditorView(Directory *directory, Control *control, FileName configFile,
38 QWidget *parent) : AbstractProjectItemView(parent) {
39
40 // TODO: This layout should be inside of the cnet editor widget, but I put it here to not
41 // conflict with current work in the cnet editor widget code.
42 //QWidget *result = new QWidget;
43
44 QWidget *centralWidget = new QWidget;
45 setCentralWidget(centralWidget);
46 QGridLayout *resultLayout = new QGridLayout;
47 centralWidget->setLayout(resultLayout);
48
49 m_cnetEditorWidget = new CnetEditorWidget(control, configFile.expanded());
50 m_control = control;
51
52 resultLayout->addWidget(m_cnetEditorWidget, 0, 0, 1, 2);
53
54 QTabWidget *treeViews = new QTabWidget;
55 treeViews->addTab( m_cnetEditorWidget->pointTreeView(), tr("Point View") );
56 treeViews->addTab( m_cnetEditorWidget->serialTreeView(), tr("Serial View") );
57 treeViews->addTab( m_cnetEditorWidget->connectionTreeView(), tr("Connection View") );
58 resultLayout->addWidget(treeViews, 1, 0, 1, 1);
59
60 QTabWidget *filterViews = new QTabWidget;
61 filterViews->addTab( m_cnetEditorWidget->pointFilterWidget(), tr("Filter Points and Measures") );
62 filterViews->addTab( m_cnetEditorWidget->serialFilterWidget(), tr("Filter Images and Points") );
63 filterViews->addTab( m_cnetEditorWidget->connectionFilterWidget(), tr("Filter Connections") );
64 resultLayout->addWidget(filterViews, 1, 1, 1, 1);
65
68
69 // Store the actions for easy enable/disable.
70 foreach (QAction *action, m_permToolBar->actions()) {
71 addAction(action);
72 }
73 // On default, actions are disabled until the cursor enters the view.
75 }
76
81
82 delete m_cnetEditorWidget;
83 delete m_permToolBar;
84 delete m_tablesMenu;
85
86 m_tablesMenu = 0;
87 m_permToolBar = 0;
88 }
89
95 QMap< QAction *, QList< QString > > actionMap = m_cnetEditorWidget->menuActions();
96 QMapIterator< QAction *, QList< QString > > actionMapIter(actionMap);
97
98 m_tablesMenu = new ProjectItemViewMenu("&Tables");
99 connect(m_tablesMenu, SIGNAL(menuClosed()), this, SLOT(disableActions()));
100 menuBar()->addMenu(m_tablesMenu);
101
102 while ( actionMapIter.hasNext() ) {
103 actionMapIter.next();
104 QAction *actionToAdd = actionMapIter.key();
105
106 // Skip the "What's This?" action because it is in the main help menu of IPCE
107 if (actionToAdd->text() == "What's This?") {
108 continue;
109 }
110 m_tablesMenu->addAction(actionToAdd);
111 }
112 }
113
114
121 m_permToolBar = addToolBar("Standard Tools");
122 m_permToolBar->setObjectName("permToolBar");
123 m_permToolBar->setIconSize(QSize(22, 22));
124
125 QMap< QString, QList< QAction * > > actionMap;
126 actionMap = m_cnetEditorWidget->toolBarActions();
127 QMapIterator< QString, QList< QAction * > > actionIter(actionMap);
128
129 while (actionIter.hasNext()) {
130 actionIter.next();
131 QString objName = actionIter.key();
132 QList< QAction * > actionList = actionIter.value();
133 foreach (QAction *action, actionList) {
134 m_permToolBar->addAction(action);
135 }
136 }
137 }
138
139
147 void CnetEditorView::leaveEvent(QEvent *event) {
148 if (!m_tablesMenu->isVisible()) {
150 }
151 }
152
153
161 return m_cnetEditorWidget;
162 }
163
164
171 return m_control;
172 }
173
174
182 void CnetEditorView::save(QXmlStreamWriter &stream, Project *, FileName) const {
183
184 stream.writeStartElement("cnetEditorView");
185 stream.writeAttribute("objectName", objectName());
186 stream.writeAttribute("id", m_control->id());
187 stream.writeEndElement();
188 }
189}
AbstractProjectItemView is a base class for views of a ProjectItemModel in Qt's model-view framework.
virtual void disableActions()
Disables toolbars and toolpad actions.
CnetEditorWidget * cnetEditorWidget()
Returns the cnetEditorWidget.
ProjectItemViewMenu * m_tablesMenu
View menu for storing actions.
CnetEditorView(Directory *directory, Control *control, FileName configFile, QWidget *parent=0)
Constructor.
QToolBar * m_permToolBar
The permanent tool bar.
~CnetEditorView()
Destructor.
void createMenus()
Uses the actions created by CnetEditorWidget, creates the tables menu, and puts the actions into the ...
void createToolBars()
Uses and adds the actions created by CnetEditorWidget to the view's toolbars Right now,...
void leaveEvent(QEvent *event)
Disables actions when cursor leaves the view.
void save(QXmlStreamWriter &stream, Project *project, FileName newProjectRoot) const
This method saves the Controls object ids to the stream.
Control * control()
@description Returns the Control displayed in the CnetEditorWidget
This widget provides full editing, filtering and viewing capabilities for the raw data in a control n...
This represents an ISIS control net in a project-based GUI interface.
Definition Control.h:65
File name manipulation and expansion.
Definition FileName.h:100
The main project for ipce.
Definition Project.h:287
QMenu subclass that overrides the closeEvent.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16