Esempio n. 1
0
 def loadGroups(self, g_id = False):
     """
         Load available groups to combobox
     """
     # set groups combobox
     group_ctrl = GroupController(self.__db_ctrl)
     
     groups = group_ctrl.selectAll()
     # tmp index
     tmp = 0
     # have to increment tmp
     inc_tmp = True
     
     # fill combobox
     for group in groups:
         logging.info("adding group ID: %d", group._id)
         
         # load icon
         pix = QtGui.QPixmap()
         pix.loadFromData(group._icon._icon)
         
         # add item with icon, name and group ID
         self._group.addItem(QtGui.QIcon(pix), tr(group._name), group._id)
         
         if (g_id):
             # if a dont have curent group
             if (group._id != g_id and inc_tmp):
                 tmp += 1
                 
                 logging.info("temp group index: %d, group._id: %d, g_id: %d", tmp, group._id, g_id)
             else:
                 if inc_tmp:
                     logging.info("group found")
                     inc_tmp = False
     # set current group
     if (g_id):
         self._group.setCurrentIndex(tmp)
Esempio n. 2
0
 def initItems(self):
     """
         Initialize groups tree items. Load items from DB.
     """
     logging.debug("Adding items to tree.")
     group_ctrl = GroupController(self.__parent._db_ctrl)
     passwd_ctrl = PasswdController(self.__parent._db_ctrl, self.__parent._user._master)
     icon_ctrl = IconController(self.__parent._db_ctrl)
     
     groups = group_ctrl.selectAll()
     
     # group, that contains all passwords
     all_group = self.initItemData(icon_ctrl.selectByName("userpass")._icon, 
                                   tr("All"), -1, tr("All passwords group."), self._TYPE_ALL, -1)
     self.addTopLevelItem(all_group)
     
     # add cildren, all passwords to group all
     passwords = passwd_ctrl.selectByUserId(self.__parent._user._id)
     
     for passwd in passwords:
         child = self.initItemData(passwd._grp._icon._icon, passwd._title, passwd._id, passwd._comment, self._TYPE_PASS, passwd._grp._id)
         
         all_group.addChild(child)
     
     # insert groups to tree
     for group in groups:
         item = self.initItemData(group._icon._icon, tr(group._name), group._id, group._description, self._TYPE_GROUP, group._id)
         
         self.addTopLevelItem(item)
         
         # add cildren, all passwords to group all
         passwords = passwd_ctrl.selectByUserGrpId(self.__parent._user._id, group._id)
         
         for passwd in passwords:
             child = self.initItemData(passwd._grp._icon._icon, passwd._title, passwd._id, passwd._comment, self._TYPE_PASS, passwd._grp._id)
         
             item.addChild(child)