def __init__(self, distributedObjects): """ init tracepoint controller and members. @param distributedObjects: passing distributed objects @note There are following signals: \n * insertDockWidgets() : necessary for plugin system\n * clicked(QModelIndex): if a row in tracepointView is clicked\n * cleanupModels(): clear Tracepoints\n * runClicked((): clear Tracepoint Data on every click on run button\n """ QObject.__init__(self) self.distributedObjects = distributedObjects self._model = TracepointModel(self.distributedObjects) self.tracepointView = TracepointView(self.distributedObjects) self.tracepointView.setModel(self._model) # register with session manager to save Tracepoints self.distributedObjects.signalProxy.registerWithSessionManager.emit(self, "Tracepoints") self.tracepointView.clicked.connect(self.updateWaveforms) self.distributedObjects.signalProxy.inferiorStoppedNormally.connect(self.updateWaveforms) self.distributedObjects.signalProxy.cleanupModels.connect(self._model.clearBreakpoints) self.distributedObjects.signalProxy.runClicked.connect(self._model.clearTracepointData) self.distributedObjects.mainwindow.insertDockWidget(self.tracepointView, "Tracepoints", Qt.BottomDockWidgetArea, True, Icons.tp)
def __init__(self, distributedObjects): """ init tracepoint controller and members. @param distributedObjects: passing distributed objects @note There are following signals: \n * insertDockWidgets() : necessary for plugin system\n * clicked(QModelIndex): if a row in tracepointView is clicked\n * cleanupModels(): clear Tracepoints\n * runClicked((): clear Tracepoint Data on every click on run button\n """ QObject.__init__(self) self.distributedObjects = distributedObjects """@var self._model: (TracepointModel), this class provides the model for tracepointView""" self._model = TracepointModel(self.distributedObjects) """@var self.tracepointView: (TracepointView), this class presents data from _model""" self.tracepointView = TracepointView() self.tracepointView.tracepointView.setModel(self._model) #register with session manager to save Tracepoints self.distributedObjects.signalProxy.emitRegisterWithSessionManager(self, "Tracepoints") self.distributedObjects.signalProxy.insertDockWidgets.connect(self.insertDockWidgets) self.tracepointView.tracepointView.clicked.connect(self.updateWaveforms) self.distributedObjects.signalProxy.inferiorStoppedNormally.connect(self.updateWaveforms) self.distributedObjects.signalProxy.cleanupModels.connect(self._model.clearTracepoints) self.distributedObjects.signalProxy.runClicked.connect(self._model.clearTracepointData)
class TracepointController(QObject): def __init__(self, distributedObjects): """ init tracepoint controller and members. @param distributedObjects: passing distributed objects @note There are following signals: \n * insertDockWidgets() : necessary for plugin system\n * clicked(QModelIndex): if a row in tracepointView is clicked\n * cleanupModels(): clear Tracepoints\n * runClicked((): clear Tracepoint Data on every click on run button\n """ QObject.__init__(self) self.distributedObjects = distributedObjects """@var self._model: (TracepointModel), this class provides the model for tracepointView""" self._model = TracepointModel(self.distributedObjects) """@var self.tracepointView: (TracepointView), this class presents data from _model""" self.tracepointView = TracepointView() self.tracepointView.tracepointView.setModel(self._model) #register with session manager to save Tracepoints self.distributedObjects.signalProxy.emitRegisterWithSessionManager(self, "Tracepoints") self.distributedObjects.signalProxy.insertDockWidgets.connect(self.insertDockWidgets) self.tracepointView.tracepointView.clicked.connect(self.updateWaveforms) self.distributedObjects.signalProxy.inferiorStoppedNormally.connect(self.updateWaveforms) self.distributedObjects.signalProxy.cleanupModels.connect(self._model.clearTracepoints) self.distributedObjects.signalProxy.runClicked.connect(self._model.clearTracepointData) def updateWaveforms(self): '''update tracepoint waveforms''' index = self.tracepointView.getSelectedRow() if index != None: self._model.selectionMade(index) def insertDockWidgets(self): """needed for plugin system""" self.tracepointDock = QDockWidget("Tracepoints") self.tracepointDock.setObjectName("TracepointView") self.tracepointDock.setWidget(self.tracepointView) self.distributedObjects.signalProxy.emitAddDockWidget(Qt.BottomDockWidgetArea, self.tracepointDock, True) def toggleTracepoint(self, file_, line): """ toggles the breakpoint in file file_ with linenumber line @param file_: (string), fullname of file @param line: (int), linenumber where the breakpoint should be toggled """ return self._model.toggleTracepoint(file_, line) def getTracepointsFromModel(self): """returns a list of tracepoints @return tracepoints: a list of tracepoints """ return self._model.getTracepoints() def saveSession(self, xmlHandler): """Insert session info to xml file""" tpparent = xmlHandler.createNode("Tracepoints") for tp in self._model.getTracepoints(): tpnode = xmlHandler.createNode("Tracepoint", tpparent, {"file": tp.file, "line": tp.line}) for var in tp.wave: xmlHandler.createNode("TracepointVariable", tpnode, {"name": var.name}) def loadSession(self, xmlHandler): """load session info to xml file""" tpparent = xmlHandler.getNode("Tracepoints") if tpparent != None: childnodes = tpparent.childNodes() for i in range(childnodes.size()): attr = xmlHandler.getAttributes(childnodes.at(i)) self._model.insertTracepoint(attr["file"], attr["line"]) for j in range(vars.size()): attr = xmlHandler.getAttributes(vars.at(j)) self._model.getTracepoints()[i].addVar(attr["name"]) def model(self): return self._model
class TracepointController(QObject): def __init__(self, distributedObjects): """ init tracepoint controller and members. @param distributedObjects: passing distributed objects @note There are following signals: \n * insertDockWidgets() : necessary for plugin system\n * clicked(QModelIndex): if a row in tracepointView is clicked\n * cleanupModels(): clear Tracepoints\n * runClicked((): clear Tracepoint Data on every click on run button\n """ QObject.__init__(self) self.distributedObjects = distributedObjects self._model = TracepointModel(self.distributedObjects) self.tracepointView = TracepointView(self.distributedObjects) self.tracepointView.setModel(self._model) # register with session manager to save Tracepoints self.distributedObjects.signalProxy.registerWithSessionManager.emit(self, "Tracepoints") self.tracepointView.clicked.connect(self.updateWaveforms) self.distributedObjects.signalProxy.inferiorStoppedNormally.connect(self.updateWaveforms) self.distributedObjects.signalProxy.cleanupModels.connect(self._model.clearBreakpoints) self.distributedObjects.signalProxy.runClicked.connect(self._model.clearTracepointData) self.distributedObjects.mainwindow.insertDockWidget(self.tracepointView, "Tracepoints", Qt.BottomDockWidgetArea, True, Icons.tp) def updateWaveforms(self): '''update tracepoint waveforms''' index = self.tracepointView.getSelectedRow() if index != None: self._model.selectionMade(index) def toggleTracepoint(self, file_, line): """ toggles the breakpoint in file file_ with linenumber line @param file_: (string), fullname of file @param line: (int), linenumber where the breakpoint should be toggled """ return self._model.toggleBreakpoint(file_, line) def getTracepointsFromModel(self): """returns a list of tracepoints @return tracepoints: a list of tracepoints """ return self._model.breakpoints def saveSession(self, xmlHandler): """Insert session info to xml file""" tpparent = xmlHandler.createNode("Tracepoints") for tp in self._model.getTracepoints(): tpnode = xmlHandler.createNode("Tracepoint", tpparent, {"file": tp.file, "line": tp.line}) for var in tp.wave: xmlHandler.createNode("TracepointVariable", tpnode, {"name": var.name}) def loadSession(self, xmlHandler): """load session info to xml file""" tpparent = xmlHandler.getNode("Tracepoints") if tpparent is not None: childnodes = tpparent.childNodes() for i in range(childnodes.size()): attr = xmlHandler.getAttributes(childnodes.at(i)) self._model.insertTracepoint(attr["file"], attr["line"]) for j in range(vars.size()): attr = xmlHandler.getAttributes(vars.at(j)) self._model.getTracepoints()[i].addVar(attr["name"]) def model(self): return self._model