mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2025-01-04 03:24:13 +08:00
.
This commit is contained in:
parent
d4f4854d10
commit
95010beaff
@ -2693,7 +2693,7 @@ function safe_mdict_entry_call(word){
|
|||||||
return self.ref.gettitle(self.f, self.index)
|
return self.ref.gettitle(self.f, self.index)
|
||||||
|
|
||||||
def childrens(self) -> list:
|
def childrens(self) -> list:
|
||||||
return self.index.get_mdx_keys("*")
|
return sorted(list(set(self.index.get_mdx_keys("*"))))
|
||||||
|
|
||||||
class DictTreeRoot(DictTree):
|
class DictTreeRoot(DictTree):
|
||||||
def __init__(self, ref) -> None:
|
def __init__(self, ref) -> None:
|
||||||
|
@ -831,18 +831,15 @@ class DynamicTreeModel(QStandardItemModel):
|
|||||||
self.setData(index, len(childs) > 0, DeterminedhasChildren)
|
self.setData(index, len(childs) > 0, DeterminedhasChildren)
|
||||||
thisitem = self.itemFromIndex(index)
|
thisitem = self.itemFromIndex(index)
|
||||||
maketuples = tuple((tuple(_) for _ in globalconfig["wordlabel"]))
|
maketuples = tuple((tuple(_) for _ in globalconfig["wordlabel"]))
|
||||||
dump = set()
|
rows = []
|
||||||
for c in childs:
|
for c in childs:
|
||||||
if isinstance(c, str):
|
if isinstance(c, str):
|
||||||
if c in dump:
|
|
||||||
continue
|
|
||||||
dump.add(c)
|
|
||||||
t = c
|
t = c
|
||||||
has = False
|
has = False
|
||||||
else:
|
else:
|
||||||
t = c.text()
|
t = c.text()
|
||||||
has = True
|
has = True
|
||||||
item = QStandardItem(t)
|
item = QStandardItem(t.replace("\n", ""))
|
||||||
if has:
|
if has:
|
||||||
item.setData(c, DictNodeRole)
|
item.setData(c, DictNodeRole)
|
||||||
else:
|
else:
|
||||||
@ -852,8 +849,9 @@ class DynamicTreeModel(QStandardItemModel):
|
|||||||
item.setData(
|
item.setData(
|
||||||
QBrush(Qt.GlobalColor.cyan), Qt.ItemDataRole.BackgroundRole
|
QBrush(Qt.GlobalColor.cyan), Qt.ItemDataRole.BackgroundRole
|
||||||
)
|
)
|
||||||
thisitem.appendRow([item])
|
rows.append(item)
|
||||||
self.ref(index)
|
thisitem.appendRows(rows)
|
||||||
|
self.ref(index, True)
|
||||||
|
|
||||||
def onDoubleClicked(self, index: QModelIndex):
|
def onDoubleClicked(self, index: QModelIndex):
|
||||||
if not self.data(index, isWordNode):
|
if not self.data(index, isWordNode):
|
||||||
@ -874,8 +872,10 @@ class kpQTreeView(QTreeView):
|
|||||||
|
|
||||||
|
|
||||||
class showdiction(QWidget):
|
class showdiction(QWidget):
|
||||||
def setwordfilter(self, index=None):
|
def setwordfilter(self, index=None, first=False):
|
||||||
w = self.word.text()
|
w = self.word.text()
|
||||||
|
if (not w) and first:
|
||||||
|
return
|
||||||
if index is None:
|
if index is None:
|
||||||
item = self.model.invisibleRootItem()
|
item = self.model.invisibleRootItem()
|
||||||
index = self.model.indexFromItem(self.model.invisibleRootItem())
|
index = self.model.indexFromItem(self.model.invisibleRootItem())
|
||||||
@ -979,7 +979,7 @@ class showdiction(QWidget):
|
|||||||
if len(cishus) == 1:
|
if len(cishus) == 1:
|
||||||
try:
|
try:
|
||||||
for node in cishus[0].tree().childrens():
|
for node in cishus[0].tree().childrens():
|
||||||
item = QStandardItem(node.text())
|
item = QStandardItem(node.text().replace("\n", ""))
|
||||||
item.setData(node, DictNodeRole)
|
item.setData(node, DictNodeRole)
|
||||||
rows.append(item)
|
rows.append(item)
|
||||||
except:
|
except:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user