Пример #1
0
 def dropped(self, data):
     source = data.source()
     if source is None:
         return
     listview = self.listView()
     if source == listview:
         item = source.currentItem()
         if item == self or self.hasParent(item):
             self.setStatus(self.tr('Drop aborted, invalid target.'))
             return
         if isinstance(item, PredefContainerItem) and self._accepts_child_class(ContainerItem):
             self.insertItem( item.new_reference(self) )
             self.setOpen(True)
         elif self._accepts_child_class(item.__class__):
             self.moveChild(item)
             self.setOpen(True)
     elif source.name() == 'node_attribute_list':
         model = self.model
         item = source.currentItem()
         if hasattr(item, 'text'):
             name = qstrpy( item.text() )
             if not name:
                 return
             access_name = self.build_access_name(name, model)
             new_model = buildMessageElement(model, 'attribute',
                                             readable_name=qstrpy(self.tr('Attribute')),
                                             type_name=name,
                                             access_name=access_name)
             item = AttributeContentItem(self.editor, self, new_model)
             self.setOpen(True)
     else:
         self.setStatus('DROP from %s' % source.name())
Пример #2
0
 def action_method():
     model = buildMessageElement(
         item_parent.model,
         model_type,
         type_name=type_name or model_type,
         readable_name=item_name or readable_name)
     item_class(editor, item_parent, model)
     item_parent.setOpen(True)
Пример #3
0
 def new_reference(self, new_parent):
     if self.REF_MODEL_TYPE and self.REF_ITEM_CLASS:
         ref_item_class = self.REF_ITEM_CLASS
         type_name = self.__model.type_name
         ref_model = buildMessageElement(
             new_parent.model, self.REF_MODEL_TYPE,
             type_name=type_name,
             access_name=self.build_access_name(type_name, new_parent.model),
             readable_name = ">"+ref_item_class.READABLE_NAME)
         return ref_item_class(self.editor, new_parent, ref_model)
     else:
         return None