def _exec(self): if self.col != 'all': ids = [x.id for x in self.col] else: ids = 'all' self.acts.append(command.ActChangeAttr(self.tab, 'group_by', ids)) for x in self.tab.all_columns: if not x.is_category(): self.acts.append( command.ActChangeAttr(x, 'real_data_groupfun', self.fun)) self._redo() return True
def apply(self): if not self.has_changes(): return # -------------- Table edit # remove table if self.do_remove: self.act_remove_table() return # change table name if self.new_name != self.table.name: a = command.ActChangeAttr(self.table, 'name', self.new_name) a.redo() self.acts.append(a) # change comments if self.new_comment != self.table.comment: a = command.ActChangeAttr(self.table, 'comment', self.new_comment) a.redo() self.acts.append(a) # -------------- Columns edit # additional removes for c in self.implicit_removes(): c.do_remove = True # anon filters adjust for f in self.table.all_anon_filters[:]: self.adjust_filter(f) # change name/remove/reformat for original columns cnitems = [c for c in self.citems if c.need_alter()] if len(cnitems) > 0: self._alter_origs() # remove deleted from citems self.citems = [ c for c in self.citems if not c.col.is_original() or not c.do_remove ] # change columns for c in self.citems: c.apply() # remove deleted from citems self.citems = [c for c in self.citems if not c.do_remove] self._final_reassemble()
def __init__(self, tmod, cols, isvis): super().__init__() self.check_consistency(tmod, cols) ac = [tmod.dt.all_columns[0]] + cols vc = [tmod.dt.all_columns[0]] for v, c in zip(isvis, cols): if v: vc.append(c) # check for deleted dependencies badcols = ComSetColumns.badcols(ac, tmod.dt.all_columns) for b in badcols: if b in ac: ac.remove(b) if b in vc: vc.remove(b) tmod.dt._fix_column_order(ac) tmod.dt._fix_column_order(vc) self.acts = [] self.act_update = ActModelUpdate(tmod) self.acts.append(command.ActChangeAttr(tmod.dt, 'all_columns', ac)) self.acts.append(command.ActChangeAttr(tmod.dt, 'visible_columns', vc))
def _exec(self): for f in self.remf: self.acts.append( command.ActFromCommand(comproj.RemoveFilter(self.tmod.dt, f))) self.acts[-1].redo() for f in self.newf: self.acts.append( command.ActFromCommand( comproj.AddFilter(self.tmod.dt.proj, f, [self.tmod.dt]))) self.acts[-1].redo() uf = [f.id for f in self.usedf] self.acts.append( command.ActChangeAttr(self.tmod.dt, 'used_filters', uf)) self.acts[-1].redo() self.act_update.redo() return True
def _exec(self): if self.fold is None: f1, f2 = None, None else: f1, f2 = self.fold, not self.fold if self.rows == 'all': assert self.fold is not None a = command.ActChangeAttr(self.tmod, '_unfolded_groups', f2) self.acts.append(a) self.fin_act = self.tmod.view_update else: for r in self.rows: ind = self.tmod.createIndex(r, 0) a = basic.CustomObject() a.redo = functools.partial(self.tmod.unfold_row, ind, f2) a.undo = functools.partial(self.tmod.unfold_row, ind, f1) self.acts.append(a) self._redo() return True
def __init__(self, mod, icol, asc): super().__init__() colid = mod.dt.get_column(ivis=icol).id asc = 'ASC' if asc else 'DESC' self.act_update = ActModelUpdate(mod) self.act = command.ActChangeAttr(mod.dt, 'ordering', (colid, asc))
def _exec(self): for k, v in self.kw.items(): self.acts.append(command.ActChangeAttr(self.mw.opts, k, v)) self._redo() return True
def act_change_colattr(self, attr, newattr): a = command.ActChangeAttr(self.col, attr, newattr) a.redo() self.acts.append(a)