Esempio n. 1
0
 def getModelMimeData(self):
     """ Used for drag events """
     model, mimeData = '', None
     try:
         #model = getattr(self.scene().itemAt(*self.mousePos),'_name','')
         selected = self.scene()._selectedItems
         if not selected:
             self.debug('jdrawView.getModelMimeData(%s): nothing to drag' %
                        model)
             return
         model = getattr(([
             s for s in selected
             if s.isUnderMouse() and getattr(s, '_name', '')
         ] or [selected])[0], '_name', '')
         self.debug('getModelMimeData(%s)' % model)
         mimeData = Qt.QMimeData()
         if model:
             if DeviceNameValidator().getParams(model):
                 self.debug('getMimeData(): DeviceModel at %s: %s',
                            self.mousePos, model)
                 mimeData.setData(TAURUS_DEV_MIME_TYPE, model)
             elif AttributeNameValidator().getParams(model):
                 self.debug('getMimeData(): AttributeModel at %s: %s',
                            self.mousePos, model)
                 mimeData.setData(TAURUS_ATTR_MIME_TYPE, model)
             else:
                 self.debug('getMimeData(): UnknownModel at %s: %s',
                            self.mousePos, model)
                 mimeData.setData(TAURUS_MODEL_MIME_TYPE, model)
     except:
         self.debug(
             'jdrawView.getModelMimeData(%s): unable to get MimeData' %
             model)
         self.debug(traceback.format_exc())
     return mimeData
Esempio n. 2
0
 def __init__(self, parent=None, *args, **kwargs):
     super(SynopticWidget, self).__init__(parent)
     self.attribute_name_validator = AttributeNameValidator()