15 """ Controls a tab with a TreeView, an AbstractView and a PropertiesView.
17 The tab is filled using a DataAccessor. The controller supports find
18 functionality as well as a dialog for choosing the box content in the WidgetView.
21 logging.debug(__name__ +
": __init__")
22 TabController.__init__(self, plugin)
46 disabledCenterViewIds = []
47 for viewClass
in self.
plugin().availableCenterViews():
48 viewClassId=self.
plugin().viewClassId(viewClass)
49 if enable==
False and viewClassId!=exceptionViewClassId:
50 disabledCenterViewIds+=[viewClassId]
51 if enable==
True and viewClassId==exceptionViewClassId:
52 disabledCenterViewIds+=[viewClassId]
53 self.
plugin().setDisabledCenterViewIds(disabledCenterViewIds)
56 """ Shows view menu when user selects tab.
59 self.
tab().mainWindow().application().showPluginMenu(self.
plugin().viewMenu())
65 requestedViewClass =
None
66 for viewClass
in self.
plugin().availableCenterViews():
67 if requestedViewClassId == self.
plugin().viewClassId(viewClass):
68 requestedViewClass = viewClass
69 if not requestedViewClass
and len(self.
plugin().availableCenterViews())>0:
70 logging.warning(self.__class__.__name__ +
": switchCenterView() - Unknown view class id "+ requestedViewClassId +
".")
71 requestedViewClass = self.
plugin().availableCenterViews()[0]
72 elif not requestedViewClass:
73 logging.error(self.__class__.__name__ +
": switchCenterView() - Unknown view class id "+ requestedViewClassId +
". Aborting...")
75 self.
tab().setCenterView(requestedViewClass())
94 self._boxContentDialog.onScreen()
97 """ Makes sure an existing property view's read-only mode is set accordingly.
99 TabController.setEditable(self, edit)
100 if self.
tab()
and self.
tab().propertyView():
101 self.
tab().propertyView().setReadOnly(
not edit)
104 """ Sets tab and connects signals to tab.
106 if not (isinstance(tab.treeView(), AbstractView)
and isinstance(tab.treeView(), QWidget)):
107 raise TypeError(__name__ +
" requires a center view of type AbstractView and QWidget.")
108 if not (isinstance(tab.centerView(), AbstractView)
and isinstance(tab.centerView(), QWidget)):
109 raise TypeError(__name__ +
" requires a center view of type AbstractView and QWidget.")
110 if not isinstance(tab, BrowserTab):
111 raise TypeError(__name__ +
" requires a tab of type BrowserTab.")
112 TabController.setTab(self, tab)
127 """ Set the DataAccessor and show data in the TreeView.
129 logging.debug(__name__ +
": setDataAccessor")
135 self.
tab().treeView().setFilter(self.
filter)
142 """ Sets zoom of tab's scroll area.
144 Needed for zoom tool bar. See TabController setZoom().
146 if hasattr(self.
tab(),
"scrollArea"):
150 """ Returns zoom of tab's scoll area.
152 Needed for zoom tool bar. See TabController zoom().
154 if hasattr(self.
tab(),
"scrollArea"):
155 return self.
tab().scrollArea().
zoom()
160 """ Fill the center view from an item in the TreeView and update it """
161 logging.debug(__name__ +
": updateCenterView")
162 statusMessage = self.
plugin().application().startWorking(
"Updating center view")
167 if self.
tab().propertyView().dataObject() != select
and propertyView:
168 self.
tab().propertyView().setDataObject(select)
170 self.
plugin().application().stopWorking(statusMessage)
173 """ When object is selected in the TreeView update center view and PropertyView.
175 logging.debug(__name__ +
": onTreeViewSelected")
181 """ When object is selected in the center view update PropertyView.
183 logging.debug(__name__ +
": onSelected")
184 if self.
tab().propertyView().dataObject() != select:
185 statusMessage = self.
plugin().application().startWorking(
"Updating property view")
186 self.
tab().propertyView().setDataObject(select)
188 self.
plugin().application().stopWorking(statusMessage)
191 """ Updates all three views and restores the selection, e.g. after moving to next event.
193 logging.debug(__name__ +
": updateContent")
196 self._filterAlgoritm.setDataObjects(self._dataAccessor.topLevelObjects())
197 self._filterDialog.filter()
199 statusMessage = self.
plugin().application().startWorking(
"Updating all views")
201 self._findAlgorithm.setDataObjects(self._dataAccessor.topLevelObjects())
202 self._findDialog.edited()
203 self.
tab().treeView().setDataObjects(self._dataAccessor.topLevelObjects())
206 self.
tab().propertyView().setDataObject(self.
tab().treeView().
selection())
212 self.
plugin().application().stopWorking(statusMessage)
216 self.
tab().treeView().restoreSelection()
222 """ Open find dialog and find items.
224 logging.debug(__name__ +
": find")
228 self._findAlgorithm.setFilter(self.
filter)
233 self._findAlgorithm.setDataObjects(self._dataAccessor.topLevelObjects())
234 self._findDialog.onScreen()
237 """ Open filter dialog and filter items.
239 logging.debug(__name__ +
": filterDialog")
247 self._filterAlgoritm.setDataObjects(self._dataAccessor.topLevelObjects())
248 self._filterDialog.onScreen(
True,
False)
255 """ Select an object in all views.
257 logging.debug(__name__ +
": select : " + str(object))
260 if self.
tab().propertyView().dataObject() != object:
261 statusMessage = self.
plugin().application().startWorking(
"Updating property view")
262 self.
tab().propertyView().setDataObject(object)
264 self.
plugin().application().stopWorking(statusMessage)
267 """ Update box content of center view when script is changed.
275 return TabController.close(self)
281 """ Save screenshot of the center view to file.
286 """ Filter all final state objects using the output of the filterDialog.
290 return [o
for o
in objects
if o
in self.
_filterObjects or len(self.
filter(self._dataAccessor.children(o)))>0]
295 """ Cancel all operations in tab.
297 logging.debug(__name__ +
": cancel")
303 return self.
tab().treeView().
isBusy()
or\
308 """ write options to ini """
309 logging.debug(__name__ +
": saveIni")
311 logging.waring(self.__class__.__name__ +
": saveIni() - No plugin set. Aborting...")
313 ini = self.
plugin().application().ini()
314 if not ini.has_section(
"view"):
315 ini.add_section(
"view")
318 if hasattr(self.
centerView(),
"boxContentScript"):
319 ini.set(
"view",
"box content script", self.
centerView().boxContentScript())
320 self.
plugin().application().writeIni()
323 """ read options from ini """
324 logging.debug(__name__ +
": loadIni")
325 ini = self.
plugin().application().ini()
326 if ini.has_option(
"view",
"CurrentView"):
327 proposed_view = ini.get(
"view",
"CurrentView")
329 elif self.
plugin().defaultCenterViewId():
331 elif len(self.
plugin().availableCenterViews()) > 0:
333 if ini.has_option(
"view",
"box content script"):
334 self._boxContentDialog.setScript(str(ini.get(
"view",
"box content script")))
335 if hasattr(self.
centerView(),
"setBoxContentScript"):
336 self.
centerView().setBoxContentScript(str(ini.get(
"view",
"box content script")))
339 """ Enable/disable menu entries, when center view changes.
341 self.
plugin().boxContentAction().setVisible(hasattr(self.
tab().
centerView(),
"setBoxContentScript"))
344 self.
plugin().expandAllAction().setVisible(hasattr(self.
tab().treeView(),
"expandAll"))
345 self.
plugin().expandToDepthAction().setVisible(hasattr(self.
tab().treeView(),
"expandToDepth"))
346 self.
plugin().collapseAllAction().setVisible(hasattr(self.
tab().treeView(),
"collapseAll"))
349 action.setEnabled(
not action.data().
toString()
in self.
plugin().disabledCenterViewIds())
351 action.setChecked(currentAction)
353 self.
tab().setCenterViewHeader(action.text().
replace(
"&",
""))
354 if self.
tab().mainWindow():
356 self.
tab().mainWindow().application().showZoomToolBar()
358 self.
tab().mainWindow().application().hideZoomToolBar()
361 popup=QMenu(self.
tab().centerViewMenuButton())
362 popup.addAction(self.
plugin()._boxContentAction)
363 popup.addAction(self.
plugin()._saveImageAction)
364 popup.addAction(self.
plugin()._zoomAction)
368 popup.addAction(action)
369 if not isinstance(point,QPoint):
370 point=self.
tab().centerViewMenuButton().mapToGlobal(QPoint(self.
tab().centerViewMenuButton().
width(),0))
374 popup=QMenu(self.
tab().treeViewMenuButton())
375 popup.addAction(self.
plugin()._expandAllAction)
376 popup.addAction(self.
plugin()._expandToDepthAction)
377 popup.addAction(self.
plugin()._collapseAllAction)
378 popup.addAction(self.
plugin()._filterAction)
380 if not isinstance(point,QPoint):
381 point=self.
tab().treeViewMenuButton().mapToGlobal(QPoint(self.
tab().treeViewMenuButton().
width(),0))
def enableCenterViewSelectionMenu
roAction_t actions[nactions]
def treeViewMenuButtonClicked
std::string toString(const std::pair< T, T > &aT)
def currentCenterViewClassId
def centerViewMenuButtonClicked