def _show_parent_info(self, active_only): panel_parent_icons = self._panel_parent_icons panel_parent_info = self._panel_parent_info if not self._items_path: self['panel_parent'].SetBackgroundColour( self.wnd.GetBackgroundColour()) self['btn_parent_edit'].Enable(False) self.wnd.FindWindowById(wx.ID_UP).Enable(False) panel_parent_info.set_task(None) panel_parent_icons.set_task(None) self['l_parent_due'].SetLabel("") else: self['panel_parent'].SetBackgroundColour(wx.WHITE) self['btn_parent_edit'].Enable(True) self.wnd.FindWindowById(wx.ID_UP).Enable(True) parent = self._items_path[-1] panel_parent_info.set_task(parent) panel_parent_icons.set_task(parent) if parent.type == enums.TYPE_PROJECT: self['l_parent_due'].SetLabel(fmt.format_timestamp( parent.due_date_project, parent.due_time_set).replace(' ', '\n')) else: self['l_parent_due'].SetLabel(fmt.format_timestamp( parent.due_date, parent.due_time_set).replace(' ', '\n')) panel_parent_icons.active_only = active_only panel_parent_info.Refresh() panel_parent_info.Update() panel_parent_icons.Refresh() panel_parent_icons.Update() self['panel_parent'].GetSizer().Layout()
def _refresh_pages(self): self._session.expire_all() # pylint: disable=E1101 sel_folder = self.selected_folder_uuid self._lb_pages.DeleteAllItems() self._pages_uuid.clear() query = self._session.query(OBJ.NotebookPage)\ .filter(OBJ.NotebookPage.deleted.is_(None)) if sel_folder is None: query = query.filter(OBJ.NotebookPage.folder_uuid.is_(None)) elif sel_folder != '-': query = query.filter(OBJ.NotebookPage.folder_uuid == sel_folder) col = [OBJ.NotebookPage.title, OBJ.NotebookPage.created, OBJ.NotebookPage.modified][self._current_sort_col or 0] if self._current_sort_ord == 1: query = query.order_by(col.asc()) else: query = query.order_by(col.desc()) idx = 0 for idx, page in enumerate(query): self._lb_pages.InsertStringItem(idx, page.title) self._lb_pages.SetStringItem(idx, 1, fmt.format_timestamp(page.created)) self._lb_pages.SetStringItem(idx, 2, fmt.format_timestamp(page.modified)) self._lb_pages.SetItemData(idx, idx) self._pages_uuid[idx] = page.uuid self.wnd.SetStatusText(ngettext("%d item", "%d items", idx) % idx, 1) self._lb_pages.SetColumnWidth(0, wx.LIST_AUTOSIZE) self._lb_pages.SetColumnWidth(1, wx.LIST_AUTOSIZE) self._lb_pages.SetColumnWidth(2, wx.LIST_AUTOSIZE)
def _refresh_static_texts(self): """ Odświeżenie pól dat na dlg """ BaseTaskFrame._refresh_static_texts(self) task = self._task due_date = (task.due_date_project if task.type == enums.TYPE_PROJECT else task.due_date) self['l_due'].SetLabel(fmt.format_timestamp(due_date, task.due_time_set)) self['l_start_date'].SetLabel(fmt.format_timestamp(task.start_date, task.start_time_set)) self['l_tags'].SetLabel(", ".join(tag.title for tag in task.tags) or '') if task.alarm_pattern: self['l_remind'].SetLabel(enums.REMIND_PATTERNS[task.alarm_pattern]) elif task.alarm: self['l_remind'].SetLabel(fmt.format_timestamp(task.alarm, True)) else: self['l_remind'].SetLabel('') if task.hide_pattern and task.hide_pattern != 'given date': self['l_hide_until'].SetLabel(enums.HIDE_PATTERNS[task.hide_pattern]) elif task.hide_until: self['l_hide_until'].SetLabel(fmt.format_timestamp(task.hide_until, True)) else: self['l_hide_until'].SetLabel('') self['l_repeat'].SetLabel(enums.REPEAT_PATTERN.get(task.repeat_pattern, task.repeat_pattern or "")) self['l_prio'].SetLabel(enums.PRIORITIES[task.priority]) self['l_type'].SetLabel(enums.TYPES[task.type or enums.TYPE_TASK]) self['btn_change_type'].Enable(task.type != enums.TYPE_CHECKLIST_ITEM)
def dump_tasks_to_text(tasks, verbose, output=sys.stdout, title_width=80): """ Export task list to stdout in human-friendly format. """ types = {enums.TYPE_PROJECT: 'P', enums.TYPE_CHECKLIST: 'C', enums.TYPE_CHECKLIST_ITEM: '-', enums.TYPE_CALL: 'c', enums.TYPE_RETURN_CALL: 'r', enums.TYPE_EMAIL: 'e', enums.TYPE_SMS: 's'} for task in tasks: if verbose > 0: output.write(('*' if task.starred else ' ')) output.write(types.get(task.type, ' ')) output.write(str(task.priority) if task.priority >= 0 else ' ') output.write(' [F] ' if task.completed else ' ') output.write('%-80s' % task.title[:title_width]) output.write('%-19s' % fmt.format_timestamp(task.due_date, task.due_time_set)) output.write('%-19s' % fmt.format_timestamp(task.start_date, task.start_time_set)) if verbose > 0: flags = ("[" + ("r" if task.repeat_pattern else " ") + ("a" if task.alarm else " ") + ("n" if task.note else " ") + "]") output.write(flags + " ") if verbose > 1: output.write(task.uuid) output.write('\n')
def _setup(self, task): _LOG.debug("BaseTaskFrame.setup(%r)", task.uuid) self._original_task = task.clone(cleanup=False) self._data = {'prev_completed': task.completed} self['tc_title'].SetValidator(Validator(task, 'title', validators=LVALID.NotEmptyValidator(), field='title')) self['tc_note'].SetValidator(Validator(task, 'note',)) self['l_created'].SetLabel(fmt.format_timestamp(task.created)) self['l_modified'].SetLabel(fmt.format_timestamp(task.modified)) self['l_deleted'].SetLabel(fmt.format_timestamp(task.deleted)) self['cb_completed'].SetValidator(Validator(task, 'task_completed')) self['cb_starred'].SetValidator(Validator(task, 'starred')) self['tc_note'].Bind(wx.EVT_TEXT_URL, self._on_text_url) self['tc_title'].Bind(wx.EVT_TEXT_URL, self._on_text_url)
def _setup(self, items, session): self._items = list(items) self._session = session lc_items = self._lc_items = self['lc_items'] lc_items.InsertColumn(0, _("Title")) lc_items.InsertColumn(1, _("Created")) lc_items.InsertColumn(2, _("Deleted")) for idx, item in enumerate(items): lc_items.InsertStringItem(idx, item.title) lc_items.SetStringItem(idx, 1, fmt.format_timestamp(item.created)) lc_items.SetStringItem(idx, 2, fmt.format_timestamp(item.deleted)) lc_items.SetItemData(idx, idx) lc_items.SetColumnWidth(0, wx.LIST_AUTOSIZE) lc_items.SetColumnWidth(1, wx.LIST_AUTOSIZE) lc_items.SetColumnWidth(2, wx.LIST_AUTOSIZE)
def dump_tasks_to_csv(tasks, verbose, output=sys.stdout): """ Export task list to stdout in cvs format. """ fields = [] if verbose > 0: fields = [_('Starred'), _('Type'), _('Priority')] fields.append(_('Title')) fields.append(_('Completed')) fields.append(_('Due date')) fields.append(_('Start date')) if verbose > 0: fields.append(_('Alarm')) fields.append(_('Repeat')) fields.append(_('Note')) if verbose > 1: fields.append(_('Task UUID')) writer = csv.writer(output, delimiter=';') writer.writerow([col.encode('utf-8') for col in fields]) types = {enums.TYPE_PROJECT: _('project'), enums.TYPE_CHECKLIST: _('checklist'), enums.TYPE_CHECKLIST_ITEM: _('checklist item'), enums.TYPE_CALL: _('call'), enums.TYPE_RETURN_CALL: _('return call'), enums.TYPE_EMAIL: _('email'), enums.TYPE_SMS: _('sms')} for task in tasks: row = [task.title, fmt.format_timestamp(task.completed, True), fmt.format_timestamp(task.due_date, task.due_time_set), fmt.format_timestamp(task.start_date, task.start_time_set)] if verbose > 0: row.append('*' if task.starred else '') row.append(types.get(task.type, 'task')) row.append(str(task.priority) if task.priority >= 0 else '') row.append(fmt.format_timestamp(task.alarm, True)) row.append(task.repeat_pattern or '') row.append(task.note or '') if verbose > 1: row.append(task.uuid) writer.writerow([col.encode('utf-8') for col in row])
def _refresh_static_texts(self): """ Odświeżenie pól dat na dlg """ task = self._task lb_notes_list = self['lb_notes_list'] lb_notes_list.Clear() for note in task.notes: lb_notes_list.Append(note.title[:50], note.uuid) self['l_project'].SetLabel(task.parent.title if task.parent else '') if task.completed: self['l_completed_date'].SetLabel(fmt.format_timestamp(task.completed, True)) else: self['l_completed_date'].SetLabel('')
def fill(self, tasks, active_only=False): """ Fill the list with tasks. Args: task: list of tasks active_only: boolean - show/count only active tasks. """ # pylint: disable=R0915 self.Freeze() current_sort_state = self.GetSortState() if current_sort_state[0] == -1: current_sort_state = (2, 1) self._drag_item_start = None self._items.clear() self.itemDataMap.clear() self._mainWin.HideWindows() # workaround for some bug in ULC self.DeleteAllItems() icon_completed = self._icons.get_image_index('task_done') prio_icon = {-1: self._icons.get_image_index('prio-1'), 0: self._icons.get_image_index('prio0'), 1: self._icons.get_image_index('prio1'), 2: self._icons.get_image_index('prio2'), 3: self._icons.get_image_index('prio3')} index = -1 for task in tasks: child_count = task.active_child_count if active_only else \ task.child_count if active_only and child_count == 0 and task.completed: continue task_is_overdue = task.overdue or (child_count > 0 and task.child_overdue) icon = icon_completed if task.completed else prio_icon[task.priority] index = self.InsertImageStringItem(sys.maxint, "", icon) self.SetStringItem(index, 1, "") self.SetItemCustomRenderer(index, 1, _ListItemRenderer(self, task, task_is_overdue)) if task.type == enums.TYPE_CHECKLIST_ITEM: self.SetStringItem(index, 2, str(task.importance + 1)) elif task.type == enums.TYPE_PROJECT: self.SetStringItem(index, 2, fmt.format_timestamp(task.due_date_project, False).replace(' ', '\n')) else: self.SetStringItem(index, 2, fmt.format_timestamp(task.due_date, task.due_time_set).replace(' ', '\n')) self.SetItemCustomRenderer(index, 3, _ListItemRendererIcons(self, task, task_is_overdue, active_only)) self.SetItemData(index, index) col = 4 if self._buttons & BUTTON_DISMISS: item = self.GetItem(index, col) btn = wx.Button(self, -1, _("Dismiss")) btn.task = task.uuid item.SetWindow(btn) self.SetItem(item) col += 1 self.Bind(wx.EVT_BUTTON, self._on_list_btn_dismiss_click, btn) if self._buttons & BUTTON_SNOOZE: item = self.GetItem(index, col) btn = wx.Button(self, -1, _("Snooze")) btn.task = task.uuid item.SetWindow(btn) self.SetItem(item) self.Bind(wx.EVT_BUTTON, self._on_list_btn_snooze_click, btn) self._items[index] = (task.uuid, task.type) self.itemDataMap[index] = tuple(_get_sort_info_for_task(task)) if task_is_overdue: self.SetItemTextColour(index, wx.RED) self._mainWin.ResetCurrent() if index > 0: self.SortListItems(*current_sort_state) # pylint: disable=W0142 self.Thaw() self.Update()