<commit_before>from gi.repository import Gtk
from forecastmgmt.dao.person_dao import PersonDAO

class PersonListMask(Gtk.Box):

    def __init__(self):
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)
        self.store = Gtk.ListStore(str,str,str,str,bool)        
        tree = Gtk.TreeView(self.store)  
        # add person's common name              
        tree.append_column(self.add_column_to_treeview("common name", 0))
        tree.append_column(self.add_column_to_treeview("birth date", 1))
        tree.append_column(self.add_column_to_treeview("birth place", 2))
        tree.append_column(self.add_column_to_treeview("person uuid", 3))
        
        renderer_toggle=Gtk.CellRendererToggle()
        renderer_toggle.connect("toggled", self.on_cell_toggled)
        column_toggle=Gtk.TreeViewColumn("delete", renderer_toggle, active=4)
        tree.append_column(column_toggle)
        
        
        tree.set_size_request(200,300)
        self.pack_start(tree, False, False, 0)        
        self.populate_person_view_table()
        
    
    def on_cell_toggled(self,widget,path):
        self.store[path][4]=not self.store[path][4]
        
    
    def add_column_to_treeview(self, columnname, counter):
        column=Gtk.TreeViewColumn(columnname)
        renderer=Gtk.CellRendererText()
        column.pack_start(renderer, True)
        column.add_attribute(renderer, "text", counter)
        return column
        

    def populate_person_view_table(self):
        persons = PersonDAO().get_all_persons()
        for person in persons:
            self.store.append(["%s" % person.common_name, "%s" % person.birth_date, "%s" % person.birth_place, "%s" % person.person_uuid, False])
        <commit_msg>delete func in GUI added<commit_after>from gi.repository import Gtk
from forecastmgmt.dao.person_dao import PersonDAO
from forecastmgmt.model.person import Person

from ui_tools import add_column_to_treeview

class PersonListMask(Gtk.Box):

    def __init__(self):
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)
        self.store = Gtk.ListStore(str,str,str,str,bool,str)        
        tree = Gtk.TreeView(self.store)  
        # add person's common name              
        tree.append_column(add_column_to_treeview("common name", 0, False))
        tree.append_column(add_column_to_treeview("birth date", 1, False))
        tree.append_column(add_column_to_treeview("birth place", 2, False))
        tree.append_column(add_column_to_treeview("person uuid", 3, False))
        
        
        renderer_toggle=Gtk.CellRendererToggle()
        renderer_toggle.connect("toggled", self.on_cell_toggled)
        column_toggle=Gtk.TreeViewColumn("delete", renderer_toggle, active=4)
        tree.append_column(column_toggle)
        
        tree.append_column(add_column_to_treeview("person_sid", 5, True))
        
        
        tree.set_size_request(200,300)
        self.pack_start(tree, False, False, 0)        
        self.populate_person_view_table()
        
    
    def on_cell_toggled(self,widget,path):
        self.store[path][4]=not self.store[path][4]
        

    def populate_person_view_table(self):
        persons = PersonDAO().get_all_persons()
        for person in persons:
            self.store.append(["%s" % person.common_name, "%s" % person.birth_date, "%s" % person.birth_place, "%s" % person.person_uuid, False, "%s" % person.sid])
        

    def delete_person(self):
        # get chosen persons
        iter=self.store.get_iter_first()
        while iter:
            (person_sid)=self.store.get(iter, 5)
            flag_to_delete="%s" % self.store.get(iter,4)
            
            if flag_to_delete=="True":
                print("loesche: %s" % person_sid)
                PersonDAO().delete(Person(person_sid))
            iter=self.store.iter_next(iter)
            
        # delete from the database
{'fraction_non_alphanumeric': 0.10819755600814664, 'fraction_numerical': 0.007892057026476579, 'mean_word_length': 2.7347908745247147, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '397976', 'n_tokens_mistral': 1266, 'n_tokens_neox': 1233, 'n_words': 193}