Isis 3 Programmer Reference
CnetEditorView.cpp
Go to the documentation of this file.
1 
23 #include "IsisDebug.h"
24 
25 #include "CnetEditorView.h"
26 
27 #include <QAction>
28 #include <QGridLayout>
29 #include <QList>
30 #include <QMap>
31 #include <QMapIterator>
32 #include <QMenu>
33 #include <QMenuBar>
34 #include <QSize>
35 #include <QSizePolicy>
36 #include <QString>
37 #include <QTabWidget>
38 #include <QToolBar>
39 #include <QtXml>
40 
41 #include "Control.h"
42 #include "ControlNet.h"
43 #include "CnetEditorWidget.h"
44 #include "Directory.h"
45 #include "FileName.h"
46 #include "Project.h"
47 #include "XmlStackedHandlerReader.h"
48 #include "ProjectItemViewMenu.h"
49 
50 namespace Isis {
54  CnetEditorView::CnetEditorView(Directory *directory, Control *control, FileName configFile,
55  QWidget *parent) : AbstractProjectItemView(parent) {
56 
57  // TODO: This layout should be inside of the cnet editor widget, but I put it here to not
58  // conflict with current work in the cnet editor widget code.
59  //QWidget *result = new QWidget;
60 
61  QWidget *centralWidget = new QWidget;
62  setCentralWidget(centralWidget);
63  QGridLayout *resultLayout = new QGridLayout;
64  centralWidget->setLayout(resultLayout);
65 
66  m_cnetEditorWidget = new CnetEditorWidget(control, configFile.expanded());
67  m_control = control;
68 
69  resultLayout->addWidget(m_cnetEditorWidget, 0, 0, 1, 2);
70 
71  QTabWidget *treeViews = new QTabWidget;
72  treeViews->addTab( m_cnetEditorWidget->pointTreeView(), tr("Point View") );
73  treeViews->addTab( m_cnetEditorWidget->serialTreeView(), tr("Serial View") );
74  treeViews->addTab( m_cnetEditorWidget->connectionTreeView(), tr("Connection View") );
75  resultLayout->addWidget(treeViews, 1, 0, 1, 1);
76 
77  QTabWidget *filterViews = new QTabWidget;
78  filterViews->addTab( m_cnetEditorWidget->pointFilterWidget(), tr("Filter Points and Measures") );
79  filterViews->addTab( m_cnetEditorWidget->serialFilterWidget(), tr("Filter Images and Points") );
80  filterViews->addTab( m_cnetEditorWidget->connectionFilterWidget(), tr("Filter Connections") );
81  resultLayout->addWidget(filterViews, 1, 1, 1, 1);
82 
83  createMenus();
85 
86  // Store the actions for easy enable/disable.
87  foreach (QAction *action, m_permToolBar->actions()) {
88  addAction(action);
89  }
90  // On default, actions are disabled until the cursor enters the view.
92  }
93 
98 
99  delete m_cnetEditorWidget;
100  delete m_permToolBar;
101  delete m_tablesMenu;
102 
103  m_tablesMenu = 0;
104  m_permToolBar = 0;
105  }
106 
112  QMap< QAction *, QList< QString > > actionMap = m_cnetEditorWidget->menuActions();
113  QMapIterator< QAction *, QList< QString > > actionMapIter(actionMap);
114 
115  m_tablesMenu = new ProjectItemViewMenu("&Tables");
116  connect(m_tablesMenu, SIGNAL(menuClosed()), this, SLOT(disableActions()));
117  menuBar()->addMenu(m_tablesMenu);
118 
119  while ( actionMapIter.hasNext() ) {
120  actionMapIter.next();
121  QAction *actionToAdd = actionMapIter.key();
122 
123  // Skip the "What's This?" action because it is in the main help menu of IPCE
124  if (actionToAdd->text() == "What's This?") {
125  continue;
126  }
127  m_tablesMenu->addAction(actionToAdd);
128  }
129  }
130 
131 
138  m_permToolBar = addToolBar("Standard Tools");
139  m_permToolBar->setObjectName("permToolBar");
140  m_permToolBar->setIconSize(QSize(22, 22));
141 
143  actionMap = m_cnetEditorWidget->toolBarActions();
144  QMapIterator< QString, QList< QAction * > > actionIter(actionMap);
145 
146  while (actionIter.hasNext()) {
147  actionIter.next();
148  QString objName = actionIter.key();
149  QList< QAction * > actionList = actionIter.value();
150  foreach (QAction *action, actionList) {
151  m_permToolBar->addAction(action);
152  }
153  }
154  }
155 
156 
164  void CnetEditorView::leaveEvent(QEvent *event) {
165  if (!m_tablesMenu->isVisible()) {
166  disableActions();
167  }
168  }
169 
170 
178  return m_cnetEditorWidget;
179  }
180 
181 
188  return m_control;
189  }
190 
191 
198  xmlReader->pushContentHandler(new XmlHandler(this));
199  }
200 
201 
209  void CnetEditorView::save(QXmlStreamWriter &stream, Project *, FileName) const {
210 
211  stream.writeStartElement("cnetEditorView");
212  stream.writeAttribute("objectName", objectName());
213  stream.writeAttribute("id", m_control->id());
214  stream.writeEndElement();
215  }
216 
217 
224  m_cnetEditorView = cnetEditorView;
225  }
226 
227 
232  delete m_cnetEditorView;
233  m_cnetEditorView = NULL;
234  }
235 
236 
248  bool CnetEditorView::XmlHandler::startElement(const QString &namespaceURI,
249  const QString &localName, const QString &qName, const QXmlAttributes &atts) {
250 
251  bool result = XmlStackedHandler::startElement(namespaceURI, localName, qName, atts);
252  return result;
253  }
254 
255 
266  bool CnetEditorView::XmlHandler::endElement(const QString &namespaceURI,
267  const QString &localName, const QString &qName) {
268 
269  bool result = XmlStackedHandler::endElement(namespaceURI, localName, qName);
270  return result;
271  }
272 }
This represents an ISIS control net in a project-based GUI interface.
Definition: Control.h:79
Ipce view containing the CnetEditorWidget.
The main project for ipce.
Definition: Project.h:289
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&#39;s toolbars Right now...
File name manipulation and expansion.
Definition: FileName.h:116
virtual void disableActions()
Disables toolbars and toolpad actions.
$Date$ $Revision$
QMenu subclass that overrides the closeEvent.
QToolBar * m_permToolBar
The permanent tool bar.
AbstractProjectItemView is a base class for views of a ProjectItemModel in Qt&#39;s model-view framework...
CnetEditorWidget * cnetEditorWidget()
Returns the cnetEditorWidget.
virtual void pushContentHandler(XmlStackedHandler *newHandler)
Push a contentHandler and maybe continue parsing...
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
Definition: FileName.cpp:212
void load(XmlStackedHandlerReader *xmlReader)
This method pushes a new XmlHandler into the parser stack.
~CnetEditorView()
Destructor.
virtual bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)
Placeholder for later serialization of CnetEditorViews.
void leaveEvent(QEvent *event)
Disables actions when cursor leaves the view.
CnetEditorView * m_cnetEditorView
The view we are working with.
virtual bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName)
This method calls XmlStackedHandler&#39;s endElement() and dereferences pointers according to the value o...
$Date$ $Revision$
ProjectItemViewMenu * m_tablesMenu
View menu for storing actions.
XmlHandler(CnetEditorView *cnetEditorView)
Creates an XmlHandler for cnetEditor.
void save(QXmlStreamWriter &stream, Project *project, FileName newProjectRoot) const
This method saves the Controls object ids to the stream.
Control * control()
Returns the Control displayed in the CnetEditorWidget
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
CnetEditorView(Directory *directory, Control *control, FileName configFile, QWidget *parent=0)
Constructor.
Manage a stack of content handlers for reading XML files.
This widget provides full editing, filtering and viewing capabilities for the raw data in a control n...