Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
HIllya51 committed Dec 26, 2024
1 parent d4f4854 commit 95010be
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion py/LunaTranslator/cishu/mdict.py
Original file line number Diff line number Diff line change
Expand Up @@ -2693,7 +2693,7 @@ def text(self):
return self.ref.gettitle(self.f, self.index)

def childrens(self) -> list:
return self.index.get_mdx_keys("*")
return sorted(list(set(self.index.get_mdx_keys("*"))))

class DictTreeRoot(DictTree):
def __init__(self, ref) -> None:
Expand Down
18 changes: 9 additions & 9 deletions py/LunaTranslator/gui/showword.py
Original file line number Diff line number Diff line change
Expand Up @@ -831,18 +831,15 @@ def loadChildren(self, index: QModelIndex):
self.setData(index, len(childs) > 0, DeterminedhasChildren)
thisitem = self.itemFromIndex(index)
maketuples = tuple((tuple(_) for _ in globalconfig["wordlabel"]))
dump = set()
rows = []
for c in childs:
if isinstance(c, str):
if c in dump:
continue
dump.add(c)
t = c
has = False
else:
t = c.text()
has = True
item = QStandardItem(t)
item = QStandardItem(t.replace("\n", ""))
if has:
item.setData(c, DictNodeRole)
else:
Expand All @@ -852,8 +849,9 @@ def loadChildren(self, index: QModelIndex):
item.setData(
QBrush(Qt.GlobalColor.cyan), Qt.ItemDataRole.BackgroundRole
)
thisitem.appendRow([item])
self.ref(index)
rows.append(item)
thisitem.appendRows(rows)
self.ref(index, True)

def onDoubleClicked(self, index: QModelIndex):
if not self.data(index, isWordNode):
Expand All @@ -874,8 +872,10 @@ def keyPressEvent(self, e: QKeyEvent):


class showdiction(QWidget):
def setwordfilter(self, index=None):
def setwordfilter(self, index=None, first=False):
w = self.word.text()
if (not w) and first:
return
if index is None:
item = self.model.invisibleRootItem()
index = self.model.indexFromItem(self.model.invisibleRootItem())
Expand Down Expand Up @@ -979,7 +979,7 @@ def refresh(self):
if len(cishus) == 1:
try:
for node in cishus[0].tree().childrens():
item = QStandardItem(node.text())
item = QStandardItem(node.text().replace("\n", ""))
item.setData(node, DictNodeRole)
rows.append(item)
except:
Expand Down

0 comments on commit 95010be

Please sign in to comment.