11 """ Area for drawing connectable widgets. 13 New widgets have to be added by using the addWidget function. 14 The WidgetView takes of the selection of widgets. 17 LABEL =
"&Widget View" 20 logging.debug(__name__ +
": __init__")
21 AbstractView.__init__(self)
22 ZoomableScrollableWidgetOwner.__init__(self, parent)
29 return self._widgetDict.values()
32 """ Emits signal widgetSelected that the TabController can connect to. 34 logging.debug(__name__ +
": widgetSelected")
35 ZoomableScrollableWidgetOwner.widgetSelected(self, widget, multiSelect)
37 if hasattr(widget,
"positionName"):
39 self.emit(SIGNAL(
"selected"), widget.object)
41 self.emit(SIGNAL(
"selected"), widget.object())
44 """ Deselect all widget in view. 46 ZoomableScrollableWidgetOwner.deselectAllWidgets(self, exception)
50 self.emit(SIGNAL(
"selected"),
None)
54 for positionName, widget
in self._widgetDict.items():
55 if widget.object == object:
56 widgets += [(positionName, widget)]
58 return sorted(widgets)[0][1]
63 """ Mark an object as selected. 70 if self.parent()
and isinstance(self.parent().
parent(), ZoomableScrollArea):
71 self.parent().
parent().ensureWidgetVisible(widget,offset,offset)
80 """ Restore selection. 86 if self.parent()
and isinstance(self.parent().
parent(), ZoomableScrollArea):
87 self.parent().
parent().ensureWidgetVisible(widget,offset,offset)
91 """ Return the currently selected object. 99 """ Deletes all boxes in the WidgetView 102 logging.debug(__name__ +
": clear")
104 for w
in self.children():
105 if isinstance(w,QWidget):
109 def addWidget(self, widget, object=None, positionName=0):
110 """ Add widget to the view and map it to an id. 114 while positionName
in self._widgetDict.keys():
117 widget.object = object
125 AbstractView.setDataObjects(self, objects)
129 if event.button()==Qt.RightButton:
130 self.emit(SIGNAL(
"mouseRightPressed"), event.globalPos())
131 ZoomableScrollableWidgetOwner.mousePressEvent(self,event)
137 """ Emits signal doubleClicked that the TabController can connect to. 139 logging.debug(__name__ +
": widgetDoubleClicked")
140 ZoomableScrollableWidgetOwner.widgetDoubleClicked(self, widget)
141 if hasattr(widget,
"object"):
142 if hasattr(widget,
"positionName"):
144 self.emit(SIGNAL(
"doubleClicked"), widget.object)
146 self.emit(SIGNAL(
"doubleClicked"), widget.object())