def check_out(self, undolist=[]):

        # TOOD: make sure we are finished with editing the treeview
        
        ul = UndoList().describe("Set Line Property")

        model = self.treeview.get_model()
        model_lines = []

        def get_column(column, default=None):
            """
            Returns the value of the specified column from the model, or if
            it is an empty string, returns the default value given.
            """
            rv = model.get_value(treeiter, column)
            if isinstance(rv, basestring) and len(rv) == 0:
                return default
            else:
                return rv
        
        n=0        
        treeiter = model.get_iter_first()
        while treeiter:
            # Is this row an existing line or a new one?
            line = model.get_value(treeiter, self.COL_LINE)
            if line in self.layer.lines:
                # existing line
                source_key = model.get_value(treeiter, self.COL_SOURCE_KEY)
                if not source_key:
                    source = None
                else:
                    source = self.app.project.get_dataset(source_key, default=None)
                        
                uwrap.smart_set(line,
                          'visible', get_column(self.COL_VISIBLE),
                         'label', get_column(self.COL_LABEL),
                         'style', get_column(self.COL_STYLE),
                         'marker', get_column(self.COL_MARKER),
                         'width', get_column(self.COL_WIDTH),
                         'source', source,
                         'cx', get_column(self.COL_CX),
                         'cy', get_column(self.COL_CY),
                         'row_first', get_column(self.COL_ROW_FIRST),
                         'row_last', get_column(self.COL_ROW_LAST),
                         'cxerr', get_column(self.COL_CXERR),
                         'cyerr', get_column(self.COL_CYERR),
                         undolist=ul)
            else:
                ulist.append( self.layer.lines, line, undolist=ul )

            model_lines.append(line)
            treeiter = model.iter_next(treeiter)
            n+=1

        # now we need to check if we have removed any lines
        for line in self.layer.lines:
            if line not in model_lines:
                ulist.remove( self.layer.lines, line, undolist=ul)
            
        undolist.append(ul)
    def action_DeleteLine(self, action):
        logger.debug("action: DeleteLine")

        model, pathlist = self.popup_info
        for path in pathlist:
            line = model.get_value(model.get_iter(path), 0)            
            layer = self.find_parent(model, path, objects.Layer)

            ul = UndoList("Remove Line")
            ulist.remove(layer.lines, line, undolist=ul)
            globals.app.project.journal.append(ul)            
Example #3
0
    def on_remove(self, sender):
        (model, pathlist) = self.treeview.get_selection().get_selected_rows()
        if model is None:
            return
        project = self.get_data("project")
        label = model.get_value(model.get_iter(pathlist[0]), 0)

        ul = UndoList().describe("Remove label.")
        ulist.remove(self.layer.labels, label, undolist=ul)
        uwrap.emit_last(self.layer, "notify::labels", updateinfo={"remove": label}, undolist=ul)
        project.journal.append(ul)