Home | Trees | Indices | Help |
|
---|
|
1 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Rickard Lindberg, Roger Lindberg 2 # 3 # This file is part of Timeline. 4 # 5 # Timeline is free software: you can redistribute it and/or modify 6 # it under the terms of the GNU General Public License as published by 7 # the Free Software Foundation, either version 3 of the License, or 8 # (at your option) any later version. 9 # 10 # Timeline is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU General Public License for more details. 14 # 15 # You should have received a copy of the GNU General Public License 16 # along with Timeline. If not, see <http://www.gnu.org/licenses/>. 17 18 19 import wx 20 21 from timelinelib.canvas.data.exceptions import TimelineIOError 22 from timelinelib.repositories.dbwrapper import DbWrapperCategoryRepository 23 from timelinelib.wxgui.dialogs.editcategory.view import EditCategoryDialog 24 import timelinelib.wxgui.utils as gui_utils 25 26289430 wx.Choice.__init__(self, parent, wx.ID_ANY, **kwargs) 31 self.timeline = timeline 32 self.category_repository = DbWrapperCategoryRepository(self.timeline) 33 self.allow_add = allow_add 34 self.Bind(wx.EVT_CHOICE, self._on_choice) 35 self._clear()3638 self.exclude = exclude 39 self._clear() 40 self._populate_tree(self.category_repository.get_tree(remove=exclude)) 41 self.SetSelectedCategory(select)4244 if self.GetSelection() == wx.NOT_FOUND: 45 return None 46 return self.GetClientData(self.GetSelection())4749 self.SetSelection(self._get_index(category)) 50 self.current_category_selection = self.GetSelection()5153 self.Clear() 54 self.add_category_item_index = None 55 self.edit_categoris_item_index = None 56 self.last_real_category_index = None 57 self.current_category_selection = self.GetSelection()5860 for index in range(self.GetCount()): 61 if self.GetClientData(index) == category: 62 return index 63 return 06466 self.Append("", None) 67 self._append_tree(tree) 68 self.last_real_category_index = self.GetCount() - 1 69 if self.allow_add: 70 self.Append("", None) 71 if self.allow_add: 72 self.add_category_item_index = self.GetCount() 73 self.Append(_("Add new"), None)7476 for (category, subtree) in tree: 77 self.Append(indent + category.name, category) 78 self._append_tree(subtree, indent + " ")7981 new_selection_index = event.GetSelection() 82 if new_selection_index > self.last_real_category_index: 83 self.SetSelection(self.current_category_selection) 84 if new_selection_index == self.add_category_item_index: 85 self._add_category() 86 else: 87 self.current_category_selection = new_selection_index8890 dialog = EditCategoryDialog(self, _("Add Category"), self.timeline, None) 91 if dialog.ShowModal() == wx.ID_OK: 92 self.Populate(select=dialog.GetEditedCategory(), exclude=self.exclude) 93 dialog.Destroy()
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sun Nov 10 02:55:34 2019 | http://epydoc.sourceforge.net |