提交 3cf0237f 编写于 作者: HinGwenWoong's avatar HinGwenWoong

Select box wil select key in key list at the same time

上级 e8edb437
......@@ -465,7 +465,7 @@ class MainWindow(QMainWindow):
'Ctrl+Z', "undo", getStr("undo"), enabled=False)
change_cls = action(getStr("keyChange"), self.change_box_key,
'Ctrl+B', "undo", getStr("keyChange"), enabled=False)
'Ctrl+B', "edit", getStr("keyChange"), enabled=False)
lock = action(getStr("lockBox"), self.lockSelectedShape,
None, "lock", getStr("lockBoxDetail"),
......@@ -980,6 +980,9 @@ class MainWindow(QMainWindow):
self.labelList.scrollToItem(self.currentItem()) # QAbstractItemView.EnsureVisible
self.BoxList.scrollToItem(self.currentBox())
if len(self.canvas.selectedShapes) == 1 and self.keyList.count() > 0:
selected_key_item_row = self.keyList.findItemsByLabel(self.canvas.selectedShapes[0].key_cls, get_row=True)
self.keyList.setCurrentRow(selected_key_item_row)
self._noSelectionSlot = False
n_selected = len(selected_shapes)
......
......@@ -17,12 +17,14 @@ class UniqueLabelQListWidget(EscapableQListWidget):
if not self.indexAt(event.pos()).isValid():
self.clearSelection()
def findItemsByLabel(self, label):
def findItemsByLabel(self, label, get_row=False):
items = []
for row in range(self.count()):
item = self.item(row)
if item.data(Qt.UserRole) == label:
items.append(item)
if get_row:
return row
return items
def createItemFromLabel(self, label):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册