Ejemplo n.º 1
0
 def update_species_table(self):
     self._species_features = []
     table = self.species_table
     # remove all rows
     table.setRowCount(0)
     stored_species = self.store.list_categories()
     for row, species in enumerate(stored_species):
         table.insertRow(row)
         species_check = QTableWidgetItem(species)
         species_check.setCheckState(False)
         feat_txts = []
         feats = []
         feat_missing = False
         for feature_type in FEATURES:
             feat_count = self.store.get_feature_count(
                 species, feature_type)
             label = feature_type.label
             feat_txt = '{}: {}'.format(label, feat_count)
             feat_txts.append(feat_txt)
             if feat_count > 0:
                 feats.append(feature_type)
         feat_item = QTableWidgetItem(' | '.join(feat_txts))
         # there is no function to add extra data, so just appended
         # available features to object (not a good style but needed to do
         # coloring without updating table again)
         feat_item.features = feats
         table.setItem(row, 0, species_check)
         table.setItem(row, 1, feat_item)
     self.color_species_table()
     self.species_table.resizeColumnsToContents()