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 "XmlStackedHandlerReader.h"
32#include "ProjectItemViewMenu.h"
33
34namespace Isis {
38 CnetEditorView::CnetEditorView(Directory *directory, Control *control, FileName configFile,
39 QWidget *parent) : AbstractProjectItemView(parent) {
40
41 // TODO: This layout should be inside of the cnet editor widget, but I put it here to not
42 // conflict with current work in the cnet editor widget code.
43 //QWidget *result = new QWidget;
44
45 QWidget *centralWidget = new QWidget;
46 setCentralWidget(centralWidget);
47 QGridLayout *resultLayout = new QGridLayout;
48 centralWidget->setLayout(resultLayout);
49
50 m_cnetEditorWidget = new CnetEditorWidget(control, configFile.expanded());
51 m_control = control;
52
53 resultLayout->addWidget(m_cnetEditorWidget, 0, 0, 1, 2);
54
55 QTabWidget *treeViews = new QTabWidget;
56 treeViews->addTab( m_cnetEditorWidget->pointTreeView(), tr("Point View") );
57 treeViews->addTab( m_cnetEditorWidget->serialTreeView(), tr("Serial View") );
58 treeViews->addTab( m_cnetEditorWidget->connectionTreeView(), tr("Connection View") );
59 resultLayout->addWidget(treeViews, 1, 0, 1, 1);
60
61 QTabWidget *filterViews = new QTabWidget;
62 filterViews->addTab( m_cnetEditorWidget->pointFilterWidget(), tr("Filter Points and Measures") );
63 filterViews->addTab( m_cnetEditorWidget->serialFilterWidget(), tr("Filter Images and Points") );
64 filterViews->addTab( m_cnetEditorWidget->connectionFilterWidget(), tr("Filter Connections") );
65 resultLayout->addWidget(filterViews, 1, 1, 1, 1);
66
69
70 // Store the actions for easy enable/disable.
71 foreach (QAction *action, m_permToolBar->actions()) {
72 addAction(action);
73 }
74 // On default, actions are disabled until the cursor enters the view.
76 }
77
82
83 delete m_cnetEditorWidget;
84 delete m_permToolBar;
85 delete m_tablesMenu;
86
87 m_tablesMenu = 0;
88 m_permToolBar = 0;
89 }
90
96 QMap< QAction *, QList< QString > > actionMap = m_cnetEditorWidget->menuActions();
97 QMapIterator< QAction *, QList< QString > > actionMapIter(actionMap);
98
99 m_tablesMenu = new ProjectItemViewMenu("&Tables");
100 connect(m_tablesMenu, SIGNAL(menuClosed()), this, SLOT(disableActions()));
101 menuBar()->addMenu(m_tablesMenu);
102
103 while ( actionMapIter.hasNext() ) {
104 actionMapIter.next();
105 QAction *actionToAdd = actionMapIter.key();
106
107 // Skip the "What's This?" action because it is in the main help menu of IPCE
108 if (actionToAdd->text() == "What's This?") {
109 continue;
110 }
111 m_tablesMenu->addAction(actionToAdd);
112 }
113 }
114
115
122 m_permToolBar = addToolBar("Standard Tools");
123 m_permToolBar->setObjectName("permToolBar");
124 m_permToolBar->setIconSize(QSize(22, 22));
125
126 QMap< QString, QList< QAction * > > actionMap;
127 actionMap = m_cnetEditorWidget->toolBarActions();
128 QMapIterator< QString, QList< QAction * > > actionIter(actionMap);
129
130 while (actionIter.hasNext()) {
131 actionIter.next();
132 QString objName = actionIter.key();
133 QList< QAction * > actionList = actionIter.value();
134 foreach (QAction *action, actionList) {
135 m_permToolBar->addAction(action);
136 }
137 }
138 }
139
140
148 void CnetEditorView::leaveEvent(QEvent *event) {
149 if (!m_tablesMenu->isVisible()) {
151 }
152 }
153
154
162 return m_cnetEditorWidget;
163 }
164
165
172 return m_control;
173 }
174
175
182 xmlReader->pushContentHandler(new XmlHandler(this));
183 }
184
185
193 void CnetEditorView::save(QXmlStreamWriter &stream, Project *, FileName) const {
194
195 stream.writeStartElement("cnetEditorView");
196 stream.writeAttribute("objectName", objectName());
197 stream.writeAttribute("id", m_control->id());
198 stream.writeEndElement();
199 }
200
201
208 m_cnetEditorView = cnetEditorView;
209 }
210
211
216 delete m_cnetEditorView;
217 m_cnetEditorView = NULL;
218 }
219
220
232 bool CnetEditorView::XmlHandler::startElement(const QString &namespaceURI,
233 const QString &localName, const QString &qName, const QXmlAttributes &atts) {
234
235 bool result = XmlStackedHandler::startElement(namespaceURI, localName, qName, atts);
236 return result;
237 }
238
239
250 bool CnetEditorView::XmlHandler::endElement(const QString &namespaceURI,
251 const QString &localName, const QString &qName) {
252
253 bool result = XmlStackedHandler::endElement(namespaceURI, localName, qName);
254 return result;
255 }
256}
AbstractProjectItemView is a base class for views of a ProjectItemModel in Qt's model-view framework.
virtual void disableActions()
Disables toolbars and toolpad actions.
XmlHandler(CnetEditorView *cnetEditorView)
Creates an XmlHandler for cnetEditor.
CnetEditorView * m_cnetEditorView
The view we are working with.
virtual bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)
Placeholder for later serialization of CnetEditorViews.
virtual bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName)
This method calls XmlStackedHandler's endElement() and dereferences pointers according to the value o...
Ipce view containing the CnetEditorWidget.
CnetEditorWidget * cnetEditorWidget()
Returns the cnetEditorWidget.
ProjectItemViewMenu * m_tablesMenu
View menu for storing actions.
void load(XmlStackedHandlerReader *xmlReader)
This method pushes a new XmlHandler into the parser stack.
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:66
File name manipulation and expansion.
Definition FileName.h:100
The main project for ipce.
Definition Project.h:289
QMenu subclass that overrides the closeEvent.
Manage a stack of content handlers for reading XML files.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16