コード例 #1
0
 def __setitem__(self, index, item):
     current_item = self._items[index]
     if item == current_item:
         return
     if current_item is not None:
         current_item.unregister_listener(self)
     self._items[index] = item
     if item is not None:
         item.register_listener(self, Path.for_item(index))
     self.handle_event(ValueChangedEvent(), Path.for_item(index))
コード例 #2
0
 def insert(self, index, item):
     assert index >= 0
     self.wrapped_object.insert(index, item.wrapped_object)
     self._items.insert(index, item)
     self._attach_child(item, Path.for_item(index))
     for i in range(index + 1, len(self)):
         item = self._items[i]
         item.unregister_listener(self)
         item.register_listener(self, Path.for_item(i))
     self.handle_event(ItemInsertEvent(index))
コード例 #3
0
 def emit_event(self, event, path=Path()):
     i = 0
     while i < len(self._listener_registrations):
         registration = self._listener_registrations[i]
         if not registration.still_active:
             del self._listener_registrations[i]
             continue
         registration.listener.handle_event(event, registration.path + path)
         i += 1
コード例 #4
0
 def __delitem__(self, key):
     assert isinstance(key, int)
     assert key >= 0
     self._detach_child(self._items[key])
     del self._items[key]
     del self.wrapped_object[key]
     for i in range(key, len(self)):
         item = self._items[i]
         item.unregister_listener(self)
         item.register_listener(self, Path.for_item(i))
     self.handle_event(ItemRemoveEvent(key))
コード例 #5
0
ファイル: explorer_widget.py プロジェクト: blank63/j3dview
 def canDropMimeData(self, mime_data, action, row, column, parent):
     if not action == Qt.MoveAction:
         return False
     if not mime_data.hasFormat(self.MIME_TYPE):
         return False
     data = mime_data.data(self.MIME_TYPE).data()
     path = Path.from_string(data.decode())
     if path.match(+_p.materials[...]):
         return parent == self.get_item_index(self.material_list)
     if path.match(+_p.textures[...]):
         return parent == self.get_item_index(self.texture_list)
     return False
コード例 #6
0
ファイル: explorer_widget.py プロジェクト: blank63/j3dview
 def dropMimeData(self, mime_data, action, row, column, parent):
     if not self.canDropMimeData(mime_data, action, row, column, parent):
         return False
     data = mime_data.data(self.MIME_TYPE).data()
     path = Path.from_string(data.decode())
     from_index = path[-1].key
     if row < from_index:
         to_index = row
     else:
         # Account for the row being moved out from under where it is moved to
         to_index = row - 1
     if path.match(+_p.materials[...]):
         self.move_material(from_index, to_index)
     elif path.match(+_p.textures[...]):
         self.move_texture(from_index, to_index)
     self.rowDropped.emit(parent, to_index)
     return True
コード例 #7
0
 def __init__(self, item_type, wrapped_object):
     super().__init__(wrapped_object)
     self._items = [item_type(item) for item in wrapped_object]
     for i, item in enumerate(self._items):
         self._attach_child(item, Path.for_item(i))
コード例 #8
0
 def __setitem__(self, key, value):
     current_value = self.wrapped_object[key]
     if value == current_value:
         return
     self.wrapped_object[key] = value
     self.handle_event(ValueChangedEvent(), Path.for_item(key))
コード例 #9
0
 def __set_name__(self, owner, name):
     self.path = Path.for_attribute(name)
     if self.source_path is None:
         self.source_path = self.path
     self.private_name = '_' + name
コード例 #10
0
 def __set_name__(self, owner, name):
     self.path = Path.for_attribute(name)
     self.private_name = '_' + name
コード例 #11
0
 def handle_event(self, event, path=Path()):
     self.emit_event(event, path)
コード例 #12
0
 def register_listener(self, listener, path=Path()):
     registration = ListenerRegistration(listener, path)
     self._listener_registrations.append(registration)
コード例 #13
0
 def __init__(self, items=tuple()):
     super().__init__()
     self._items = list(items)
     for i, item in enumerate(self._items):
         if item is not None:
             item.register_listener(self, Path.for_item(i))