示例#1
0
    def _rename__do(cmd):
        self = project[cmd.ws][cmd.old]
        newname = cmd.new
        name = cmd.old
        
        self._name = newname
        
        project.lock_undo()
        try:
            for cdep in self.deps:
                patt = r'\b%s\.%s\b' % (self.worksheet.name, name)
                repl = '%s.%s' % (self.worksheet.name, newname)
                cdep.calc = re.sub (patt, repl, cdep.calc)
        finally:
            project.unlock_undo()
    
        for graph, dset in project.used_by(self.worksheet, name):
            if dset.colx == name:
                dset.colx = newname
            if dset.coly == name:
                dset.coly = newname
            graph.legend.update()

        if self.worksheet._view is not None:
            self.worksheet._view.set_column_name(self.index(), self.name)
        return cmd
示例#2
0
 def update_data(self, column = None):
     if self.worksheet._frozen: 
         return
     if column is not None:
         column = column.name
     for graph, dataset in project.used_by(self.worksheet, column):
         dataset.update()
         graph.redraw()
     self._table.updateContents()
示例#3
0
 def update_data(self, column=None):
     if self.worksheet._frozen:
         return
     if column is not None:
         column = column.name
     for graph, dataset in project.used_by(self.worksheet, column):
         dataset.update()
         graph.redraw()
     self._table.updateContents()
示例#4
0
    def __delattr__(self, name):
        if name in self.column_names:
            col = self[name]
            if len(col.deps) > 0:
                QMessageBox.information(None, "grafit", 
                            "<b>Cannot remove</b><p>Column %s is being used by another one" % (com.colname,))
                return

            if len(project.used_by(self, col.name)) > 0:
                QMessageBox.information(None, "grafit", 
                            "<b>Cannot remove</b><p>Column %s is being used in a graph" % (col.name,))
                return

            Worksheet.del_column___(self.name, name).do().register()
        else:
            del self.__dict__[name]
示例#5
0
    def __delattr__(self, name):
        if name in self.column_names:
            col = self[name]
            if len(col.deps) > 0:
                QMessageBox.information(
                    None, "grafit",
                    "<b>Cannot remove</b><p>Column %s is being used by another one"
                    % (com.colname, ))
                return

            if len(project.used_by(self, col.name)) > 0:
                QMessageBox.information(
                    None, "grafit",
                    "<b>Cannot remove</b><p>Column %s is being used in a graph"
                    % (col.name, ))
                return

            Worksheet.del_column___(self.name, name).do().register()
        else:
            del self.__dict__[name]
示例#6
0
    def _rename__do(cmd):
        self = project[cmd.old]
        name = cmd.new
#        if not re.match('^[a-zA-Z]\w*$', name):
#            raise NameError, "Invalid name for worksheet: %s" % name

        use = project.used_by(self)

        oldname = self._name
        self._name = name

        for graph, das in use:
            das.wsname = name
        for graph, das in use:
            graph.legend.update()

        if self._view is not None:
            self._view.setCaption(self.name)
        if self._explorer_item is not None:
            self._explorer_item.setText(0, self.name)
 
        if self in project.worksheets:
            try:
                del project.main_dict[oldname]
            except KeyError:
                pass
            project.main_dict[self.name] = self

        project.lock_undo()
        try:
            for col in self.columns:
                for cdep in col.deps:
                    patt = r'\b%s\.%s\b' % (oldname, col.name)
                    repl = '%s.%s' % (self.name, col.name)
                    cdep.calc = re.sub (patt, repl, cdep.calc)
        finally:
            project.unlock_undo()

        return cmd
示例#7
0
    def _rename__do(cmd):
        self = project[cmd.old]
        name = cmd.new
        #        if not re.match('^[a-zA-Z]\w*$', name):
        #            raise NameError, "Invalid name for worksheet: %s" % name

        use = project.used_by(self)

        oldname = self._name
        self._name = name

        for graph, das in use:
            das.wsname = name
        for graph, das in use:
            graph.legend.update()

        if self._view is not None:
            self._view.setCaption(self.name)
        if self._explorer_item is not None:
            self._explorer_item.setText(0, self.name)

        if self in project.worksheets:
            try:
                del project.main_dict[oldname]
            except KeyError:
                pass
            project.main_dict[self.name] = self

        project.lock_undo()
        try:
            for col in self.columns:
                for cdep in col.deps:
                    patt = r'\b%s\.%s\b' % (oldname, col.name)
                    repl = '%s.%s' % (self.name, col.name)
                    cdep.calc = re.sub(patt, repl, cdep.calc)
        finally:
            project.unlock_undo()

        return cmd