def insert(self, index, item): self.native.BeginUpdate() item._impl = WinForms.ListViewItem([ str(getattr(item, attr)) for attr in self.interface._accessors ]) self.native.Items.Insert(index, item._impl) self.native.EndUpdate()
def winforms_retrieve_virtual_item(self, sender, e): # Because ListView is in VirtualMode, it's necessary implement # VirtualItemsSelectionRangeChanged event to create ListViewItem when it's needed if self._cache and e.ItemIndex >= self._first_item and \ e.ItemIndex < self._first_item + len(self._cache): e.Item = self._cache[e.ItemIndex - self._first_item] else: e.Item = WinForms.ListViewItem(self.row_data(self.interface.data[e.ItemIndex]))
def update_data(self): self.native.BeginUpdate() self.native.Items.Clear() items = [] for item in self.interface.data: item._impl = WinForms.ListViewItem(self.row_data(item)) items.append(item._impl) self.native.Items.AddRange(items) self.native.EndUpdate()
def winforms_cache_virtual_items(self, sender, e): if self._cache and e.StartIndex >= self._first_item and \ e.EndIndex <= self._first_item + len(self._cache): # If the newly requested cache is a subset of the old cache, # no need to rebuild everything, so do nothing return # Now we need to rebuild the cache. self._first_item = e.StartIndex new_length = e.EndIndex - e.StartIndex + 1 self._cache = [] # Fill the cache with the appropriate ListViewItems. for i in range(new_length): self._cache.append(WinForms.ListViewItem(self.row_data(self.interface.data[i])))
def insert(self, index, item): item._impl = WinForms.ListViewItem( [getattr(item, attr) for attr in self.interface._accessors]) self.native.Items.Insert(index, item._impl)
def update_data(self): self.native.Items.Clear() for index, row in enumerate(self.interface.data): row._impl = WinForms.ListViewItem( [getattr(row, attr) for attr in self.interface._accessors]) self.native.Items.Insert(index, row._impl)
def change_source(self, source): for index, row in enumerate(self.interface.data): row._impl = WinForms.ListViewItem( [getattr(row, attr) for attr in self.interface._accessors]) self.native.Items.Insert(index, row._impl)
def insert(self, index, item): self.native.BeginUpdate() item._impl = WinForms.ListViewItem(self.row_data(item)) self.native.Items.Insert(index, item._impl) self.native.EndUpdate()