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 from timelinelib.canvas.data.base import ItemBase 20 from timelinelib.canvas.data.immutable import ImmutableCategory 21 from timelinelib.canvas.drawing.drawers import get_progress_color 22 23 24 EXPORTABLE_FIELDS = FIELDS = (_("Name"), _("Color"), _("Progress Color"), _("Done Color"), _("Parent")) 25 2628 32154 155 15834 duplicate = ItemBase.duplicate(self, target_db=target_db) 35 if duplicate.db is self.db: 36 duplicate.parent = self.parent 37 return duplicate3840 self.parent = None 41 self.name = name 42 self.color = color 43 self.progress_color = get_progress_color(color) 44 self.done_color = get_progress_color(color) 45 if font_color is None: 46 self.font_color = (0, 0, 0) 47 else: 48 self.font_color = font_color 49 self.parent = parent 50 return self5153 self._update_parent_id() 54 with self._db.transaction("Save category") as t: 55 t.save_category(self._immutable_value, self.ensure_id()) 56 return self5759 if self.parent is None: 60 self._immutable_value = self._immutable_value.update( 61 parent_id=None 62 ) 63 elif self.parent.id is None: 64 raise Exception("Unknown parent") 65 else: 66 self._immutable_value = self._immutable_value.update( 67 parent_id=self.parent.id 68 )6971 with self._db.transaction("Delete category") as t: 72 t.delete_category(self.id) 73 self.id = None74 7779 return self._immutable_value.name80 84 85 name = property(get_name, set_name) 8688 return self._immutable_value.color89 93 94 color = property(get_color, set_color) 9597 return self._immutable_value.progress_color98 102 103 progress_color = property(get_progress_color, set_progress_color) 104106 return self._immutable_value.done_color107 111 112 done_color = property(get_done_color, set_done_color) 113115 return self._immutable_value.font_color116 120 121 font_color = property(get_font_color, set_font_color) 122 125 129 130 parent = property(_get_parent, set_parent) 131133 return EXPORTABLE_FIELDS134136 return "Category<id=%r, name=%r, color=%r, font_color=%r>" % ( 137 self.get_id(), self.get_name(), self.get_color(), 138 self.get_font_color())139141 if self is other: 142 return True 143 return (isinstance(other, Category) and 144 self.get_id() == other.get_id() and 145 self.get_name() == other.get_name() and 146 self.get_color() == other.get_color() and 147 self.get_progress_color() == other.get_progress_color() and 148 self.get_done_color() == other.get_done_color() and 149 self.get_font_color() == other.get_font_color() and 150 self._get_parent() == other._get_parent())151
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Wed Mar 25 02:55:27 2020 | http://epydoc.sourceforge.net |