Created
May 11, 2013 08:08
-
-
Save geojeff/5559270 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def delete_data_item(self, item): | |
if item in self.data: | |
index = self.data.index(item) | |
if item in self.selection: | |
self.dispatch('on_selection_change') | |
self.data.remove(item) | |
self.dispatch('on_data_item_delete', index) | |
def delete_data_item_at_index(self, index): | |
if 0 <= index < len(self.data): | |
item = self.data[index] | |
if item in self.selection: | |
self.dispatch('on_selection_change') | |
self.data.remove(item) | |
self.dispatch('on_data_item_delete', index) | |
def add_data_item(self, item): | |
self.data.append(item) | |
self.dispatch('on_data_item_add', len(self.data)-1) | |
def add_data_item_at_index(self, index, item): | |
self.data.insert(index, item) | |
self.dispatch('on_data_item_add', index) | |
def move_data_item(self, old_index, new_index): | |
self.data.insert(newindex, self.data.pop(oldindex)) | |
self.dispatch('on_data_item_move', (old_index, new_index)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment