|
@@ -1083,10 +1083,11 @@ class MainWindow(QtWidgets.QMainWindow):
|
|
|
else:
|
|
|
item.setText("{} ({})".format(shape.label, shape.group_id))
|
|
|
self.setDirty()
|
|
|
- if not self.uniqLabelList.findItemsByLabel(shape.label):
|
|
|
- item = QtWidgets.QListWidgetItem()
|
|
|
- item.setData(Qt.UserRole, shape.label)
|
|
|
+ if self.uniqLabelList.findItemByLabel(shape.label) is None:
|
|
|
+ item = self.uniqLabelList.createItemFromLabel(shape.label)
|
|
|
self.uniqLabelList.addItem(item)
|
|
|
+ rgb = self._get_rgb_by_label(shape.label)
|
|
|
+ self.uniqLabelList.setItemLabel(item, shape.label, rgb)
|
|
|
|
|
|
def fileSearchChanged(self):
|
|
|
self.importDirImages(
|
|
@@ -1136,7 +1137,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
|
|
text = "{} ({})".format(shape.label, shape.group_id)
|
|
|
label_list_item = LabelListWidgetItem(text, shape)
|
|
|
self.labelList.addItem(label_list_item)
|
|
|
- if not self.uniqLabelList.findItemsByLabel(shape.label):
|
|
|
+ if self.uniqLabelList.findItemByLabel(shape.label) is None:
|
|
|
item = self.uniqLabelList.createItemFromLabel(shape.label)
|
|
|
self.uniqLabelList.addItem(item)
|
|
|
rgb = self._get_rgb_by_label(shape.label)
|
|
@@ -1163,7 +1164,12 @@ class MainWindow(QtWidgets.QMainWindow):
|
|
|
|
|
|
def _get_rgb_by_label(self, label):
|
|
|
if self._config["shape_color"] == "auto":
|
|
|
- item = self.uniqLabelList.findItemsByLabel(label)[0]
|
|
|
+ item = self.uniqLabelList.findItemByLabel(label)
|
|
|
+ if item is None:
|
|
|
+ item = self.uniqLabelList.createItemFromLabel(label)
|
|
|
+ self.uniqLabelList.addItem(item)
|
|
|
+ rgb = self._get_rgb_by_label(label)
|
|
|
+ self.uniqLabelList.setItemLabel(item, label, rgb)
|
|
|
label_id = self.uniqLabelList.indexFromItem(item).row() + 1
|
|
|
label_id += self._config["shift_auto_shape_color"]
|
|
|
return LABEL_COLORMAP[label_id % len(LABEL_COLORMAP)]
|