Exemplo n.º 1
0
    def __init__(self, db):
        QtCore.QAbstractListModel.__init__(self)
        self.__db = db
        self.gen_cursor = db.get_person_cursor
        self.sort_func = self.sort_name
        self.node_map = FlatNodeMap()
        self._reverse = False
        #build node map with all peopls
        allkeys = self.sort_keys()
        ident = True
        dlist = allkeys
        self.node_map.set_path_map(dlist,
                                   allkeys,
                                   identical=ident,
                                   reverse=self._reverse)

        #every column has a role from 0 to nrcol-1, and name as in COLUMNS
        self.setRoleNames(dict(QMLPersonListModel.COLUMNS))
        #we create an array with all the QMLPerson that we need so
        #that we can match a rowindex with correct QMLPerson
        self._qmlpersons = []
        for _, handle in self.node_map.full_srtkey_hndl_map():
            self._qmlpersons.append(QMLPerson(self.__db, handle))