This commit is contained in:
恍兮惚兮 2024-10-24 23:07:01 +08:00
parent 766c0e54a3
commit 5344ab40f0
31 changed files with 257 additions and 36 deletions

View File

@ -4,6 +4,11 @@ from traceback import print_exc
from myutils.proxy import getproxy
class DictTree:
def text(self) -> str: ...
def childrens(self) -> list: ...
class cishubase:
typename = None

View File

@ -1,7 +1,7 @@
import sqlite3, os
import winsharedutils, re
from myutils.utils import argsort, autosql
from cishu.cishubase import cishubase
from cishu.cishubase import cishubase, DictTree
class edict(cishubase):
@ -41,3 +41,19 @@ class edict(cishubase):
saveres.append(x[0] + "<hr>" + re.sub("/EntL.*/", "", x[1][1:]))
return "<hr>".join(saveres)
def tree(self):
if not self.sql:
return
class DictTreeRoot(DictTree):
def __init__(self, ref) -> None:
self.ref = ref
def childrens(self):
c = []
for _ in self.ref.sql.execute("select text from surface").fetchall():
c.append(_[0])
return c
return DictTreeRoot(self)

View File

@ -2,7 +2,7 @@ import winsharedutils, os
import re
from myutils.utils import argsort
from traceback import print_exc
from cishu.cishubase import cishubase
from cishu.cishubase import cishubase, DictTree
class edict2(cishubase):
@ -43,3 +43,16 @@ class edict2(cishubase):
savew[ii] + "<hr>" + re.sub("/EntL.*/", "", self.save[savew[ii]][1:])
)
return "<hr>".join(saveres)
def tree(self):
if not self.save:
return
class DictTreeRoot(DictTree):
def __init__(self, ref) -> None:
self.ref = ref
def childrens(self):
return list(self.ref.save.keys())
return DictTreeRoot(self)

View File

@ -2,7 +2,7 @@ from myutils.utils import autosql
import sqlite3
import winsharedutils
import os
from cishu.cishubase import cishubase
from cishu.cishubase import cishubase, DictTree
class linggesi(cishubase):
@ -48,3 +48,21 @@ class linggesi(cishubase):
x = sorted(list(mp.keys()), key=lambda x: mp[x][1])[: self.config["max_num"]]
save = [w + "<hr>" + mp[w][0] for w in x]
return "<hr>".join(save)
def tree(self):
if not self.sql:
return
class DictTreeRoot(DictTree):
def __init__(self, ref) -> None:
self.ref = ref
def childrens(self):
c = []
for _ in self.ref.sql.execute(
"select word from entry"
).fetchall():
c.append(_[0])
return c
return DictTreeRoot(self)

View File

@ -1,5 +1,5 @@
import math, base64, uuid, gobject
import threading, time
from cishu.cishubase import DictTree
class FlexBuffer:
@ -2032,11 +2032,11 @@ class mdict(cishubase):
distance = self.config["distance"]
return distance
def gettitle(self, f, index):
def gettitle(self, f, index: IndexBuilder):
_ = self.extraconf[f]
title = _["title"]
if title is None:
t = os.path.basename(f)[:-4]
t: str = os.path.basename(f)[:-4]
if index._title.strip() != "":
t1 = index._title.strip()
if (t1.isascii()) and (t.isascii()):
@ -2086,7 +2086,6 @@ class mdict(cishubase):
self.extraconf = json.loads(ff.read())
except:
self.extraconf = {}
self.sql = None
paths = self.config["paths"]
self.builders = []
@ -2629,3 +2628,37 @@ if (content.style.display === 'block') {
return self.generatehtml_tabswitch(allres)
elif self.config["stylehv"] == 1:
return self.generatehtml_flow(allres)
def tree(self):
if len(self.builders) == 0:
return
class everydict(DictTree):
def __init__(self, ref, f, index: IndexBuilder) -> None:
self.f = f
self.index = index
self.ref = ref
def text(self):
return self.ref.gettitle(self.f, self.index)
def childrens(self) -> list:
return self.index.get_mdx_keys("*")
class DictTreeRoot(DictTree):
def __init__(self, ref) -> None:
self.ref = ref
def childrens(self):
saves = []
for f, index in self.ref.builders:
saves.append(
(self.ref.getpriority(f), everydict(self.ref, f, index))
)
saves.sort(key=lambda x: x[0])
i = []
for _, _i in saves:
i.append(_i)
return i
return DictTreeRoot(self)

View File

@ -1,8 +1,7 @@
import sqlite3, os, re
import winsharedutils
from myutils.utils import argsort, autosql
from cishu.cishubase import cishubase
from cishu.cishubase import cishubase, DictTree
class xiaoxueguan(cishubase):
@ -48,3 +47,21 @@ class xiaoxueguan(cishubase):
srt = argsort(dis)[: self.config["max_num"]]
save = ["<span h>" + exp[i][1].replace("\\n", "") for i in srt]
return "<hr>".join(save)
def tree(self):
if not self.sql:
return
class DictTreeRoot(DictTree):
def __init__(self, ref) -> None:
self.ref = ref
def childrens(self):
c = []
for _ in self.ref.sql.execute(
"select word from xiaoxueguanrizhong"
).fetchall():
c.append(_[0])
return c
return DictTreeRoot(self)

View File

@ -1,5 +1,3 @@
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QWidget
from qtsymbols import *
import os, functools, uuid, threading, shutil, time
from traceback import print_exc

View File

@ -13,6 +13,7 @@ from gui.usefulwidget import (
auto_select_webview,
)
from gui.setting_display_text import on_not_find_qweb
from gui.showword import showdiction
def setTabcishu(self, basel):
@ -220,6 +221,10 @@ def setTabcishu_l(self):
lambda: gobject.baseobject.searchwordW.showsignal.emit(),
"fa.search",
),
D_getIconButton(
lambda: showdiction(self).show(),
"fa.book",
),
"",
"辞书显示顺序",
D_getIconButton(
@ -235,12 +240,14 @@ def setTabcishu_l(self):
1,
),
"",
"",
("点击单词复制"),
(
D_getsimpleswitch(globalconfig, "usecopyword"),
1,
),
"",
"",
("使用原型查询"),
(
D_getsimpleswitch(globalconfig, "usewordorigin"),

View File

@ -30,7 +30,15 @@ from gui.usefulwidget import (
saveposwindow,
tabadd_lazy,
)
from gui.dynalang import LPushButton, LLabel, LTabWidget, LTabBar, LFormLayout, LLabel
from gui.dynalang import (
LPushButton,
LLabel,
LTabWidget,
LTabBar,
LFormLayout,
LLabel,
LMainWindow,
)
def getimageformatlist():
@ -750,6 +758,92 @@ class CustomTabBar(LTabBar):
return self.savesizehint
from cishu.cishubase import DictTree
DictNodeRole = Qt.ItemDataRole.UserRole + 1
DeterminedhasChildren = DictNodeRole + 1
isWordNode = DeterminedhasChildren + 1
class DynamicTreeModel(QStandardItemModel):
def __init__(self):
super().__init__()
def hasChildren(self, index):
if self.data(index, isWordNode):
return False
_DeterminedhasChildren = self.data(index, DeterminedhasChildren)
if _DeterminedhasChildren is not None:
return _DeterminedhasChildren
return self.data(index, DictNodeRole) is not None
def loadChildren(self, index: QModelIndex):
if not index.isValid():
return
if self.data(index, isWordNode):
return
if self.data(index, DeterminedhasChildren) is not None:
return
node: DictTree = self.data(index, DictNodeRole)
if not node:
return
childs = node.childrens()
self.setData(index, len(childs) > 0, DeterminedhasChildren)
thisitem = self.itemFromIndex(index)
for c in childs:
if isinstance(c, str):
t = c
has = False
else:
t = c.text()
has = True
item = QStandardItem(t)
if has:
item.setData(c, DictNodeRole)
else:
item.setData(True, isWordNode)
thisitem.appendRow([item])
def onDoubleClicked(self, index: QModelIndex):
if not self.data(index, isWordNode):
return
gobject.baseobject.searchwordW.search_word.emit(self.itemFromIndex(index).text(), False)
class showdiction(LMainWindow):
def __init__(self, parent):
super(showdiction, self).__init__(parent)
self.resize(400, parent.height())
self.setWindowTitle("查看")
self.tree = QTreeView(self)
self.tree.setHeaderHidden(True)
self.tree.setEditTriggers(QAbstractItemView.EditTrigger.NoEditTriggers)
self.setCentralWidget(self.tree)
self.model = DynamicTreeModel()
self.tree.setModel(self.model)
self.tree.expanded.connect(self.model.loadChildren)
root = self.model.invisibleRootItem()
self.tree.doubleClicked.connect(self.model.onDoubleClicked)
good = False
for k in globalconfig["cishuvisrank"]:
cishu = gobject.baseobject.cishus[k]
if not hasattr(cishu, "tree"):
continue
try:
tree = cishu.tree()
except:
continue
if not tree:
continue
item = QStandardItem(globalconfig["cishu"][k]["name"])
item.setData(tree, DictNodeRole)
root.appendRow([item])
good = True
root.setData(good, DeterminedhasChildren)
class searchwordW(closeashidewindow):
search_word = pyqtSignal(str, bool)
show_dict_result = pyqtSignal(float, str, str)

View File

@ -1,6 +1,6 @@
try:
from PyQt5 import QtSvg
from PyQt5.QtWidgets import QFrame,QListView,QCheckBox,QAbstractItemView,QTextEdit,QTableView,QHeaderView,QColorDialog,QSpinBox,QDoubleSpinBox,QComboBox,QDialogButtonBox,QMainWindow,QMessageBox,QDialog,QGridLayout,QTextBrowser,QGraphicsDropShadowEffect,QWidget,QSizePolicy,QScrollArea,QApplication,QPushButton,QSystemTrayIcon,QPlainTextEdit,QAction,QMenu,QFileDialog,QKeySequenceEdit,QLabel,QSpacerItem,QWidgetItem,QLayout,QTextBrowser,QLineEdit,QFormLayout,QSizePolicy,QTabWidget,QTabBar,QSplitter,QListWidget,QListWidgetItem,QHBoxLayout,QVBoxLayout,QSizeGrip,QFontComboBox,QProgressBar,QRadioButton,QButtonGroup,QSlider,QToolTip,QGroupBox,QGraphicsOpacityEffect,QStackedWidget,QStyledItemDelegate,QStyleOptionViewItem,QFontDialog
from PyQt5.QtWidgets import QFrame,QListView,QCheckBox,QAbstractItemView,QTextEdit,QTableView,QHeaderView,QColorDialog,QSpinBox,QDoubleSpinBox,QComboBox,QDialogButtonBox,QMainWindow,QMessageBox,QDialog,QGridLayout,QTextBrowser,QGraphicsDropShadowEffect,QWidget,QSizePolicy,QScrollArea,QApplication,QPushButton,QSystemTrayIcon,QPlainTextEdit,QAction,QMenu,QFileDialog,QKeySequenceEdit,QLabel,QSpacerItem,QWidgetItem,QLayout,QTextBrowser,QLineEdit,QFormLayout,QSizePolicy,QTabWidget,QTabBar,QSplitter,QListWidget,QListWidgetItem,QHBoxLayout,QVBoxLayout,QSizeGrip,QFontComboBox,QProgressBar,QRadioButton,QButtonGroup,QSlider,QToolTip,QGroupBox,QGraphicsOpacityEffect,QStackedWidget,QStyledItemDelegate,QStyleOptionViewItem,QFontDialog,QTreeView
from PyQt5.QtGui import QIconEngine,QIntValidator,QStandardItem,QStandardItemModel,QImageWriter,QIcon,QTextCharFormat,QTextBlockFormat,QResizeEvent,QTextCursor,QFontMetricsF,QMouseEvent,QImage,QPainter,QRegion,QCloseEvent,QFontDatabase,QKeySequence,QPixmap,QCursor,QColor,QFont,QPen,QPainterPath,QBrush,QFontMetrics,QShowEvent,QWheelEvent,QPaintEvent,QTextLayout, QTextOption,QDragEnterEvent, QDropEvent,QTransform
from PyQt5.QtCore import QObject,pyqtSignal,Qt,QSize,QByteArray,QBuffer,QPointF,QPoint,QRect,QEvent,QModelIndex,QTimer,QRectF,QVariantAnimation,QUrl,QPropertyAnimation,QLocale,QSignalBlocker
isqt5 = True
@ -11,7 +11,7 @@ except:
#from traceback import print_exc
#print_exc()
from PyQt6 import QtSvg
from PyQt6.QtWidgets import QFrame,QListView,QCheckBox,QAbstractItemView,QTextEdit,QTableView,QHeaderView,QColorDialog,QSpinBox,QDoubleSpinBox,QComboBox,QDialogButtonBox,QMainWindow,QMessageBox,QDialog,QGridLayout,QTextBrowser,QGraphicsDropShadowEffect,QWidget,QSizePolicy,QScrollArea,QApplication,QPushButton,QSystemTrayIcon,QPlainTextEdit,QMenu,QFileDialog,QKeySequenceEdit,QLabel,QSpacerItem,QWidgetItem,QLayout,QTextBrowser,QLineEdit,QFormLayout,QSizePolicy,QTabWidget,QTabBar,QSplitter,QListWidget,QListWidgetItem,QHBoxLayout,QVBoxLayout,QSizeGrip,QFontComboBox,QProgressBar,QRadioButton,QButtonGroup,QSlider,QToolTip,QGroupBox,QGraphicsOpacityEffect,QStackedWidget
from PyQt6.QtWidgets import QFrame,QListView,QCheckBox,QAbstractItemView,QTextEdit,QTableView,QHeaderView,QColorDialog,QSpinBox,QDoubleSpinBox,QComboBox,QDialogButtonBox,QMainWindow,QMessageBox,QDialog,QGridLayout,QTextBrowser,QGraphicsDropShadowEffect,QWidget,QSizePolicy,QScrollArea,QApplication,QPushButton,QSystemTrayIcon,QPlainTextEdit,QMenu,QFileDialog,QKeySequenceEdit,QLabel,QSpacerItem,QWidgetItem,QLayout,QTextBrowser,QLineEdit,QFormLayout,QSizePolicy,QTabWidget,QTabBar,QSplitter,QListWidget,QListWidgetItem,QHBoxLayout,QVBoxLayout,QSizeGrip,QFontComboBox,QProgressBar,QRadioButton,QButtonGroup,QSlider,QToolTip,QGroupBox,QGraphicsOpacityEffect,QStackedWidget,QTreeView
from PyQt6.QtGui import QIconEngine,QIntValidator,QAction,QStandardItem,QStandardItemModel,QImageWriter,QIcon,QTextCharFormat,QTextBlockFormat,QResizeEvent,QTextCursor,QFontMetricsF,QMouseEvent,QImage,QPainter,QRegion,QCloseEvent,QFontDatabase,QKeySequence,QPixmap,QCursor,QColor,QFont,QPen,QPainterPath,QBrush,QFontMetrics,QShowEvent,QWheelEvent,QPaintEvent,QTextLayout, QTextOption
from PyQt6.QtCore import QObject,pyqtSignal,Qt,QSize,QByteArray,QBuffer,QPointF,QPoint,QRect,QEvent,QModelIndex,QTimer,QRectF,QVariantAnimation,QUrl,QPropertyAnimation,QLocale
isqt5 = False

View File

@ -810,5 +810,6 @@
"百度翻译开放平台": "بايدو ترجمة منصة مفتوحة",
"百度智能云": "بايدو سحابة ذكية",
"支持gpt词典": "( دعم قاموس GPT )",
"日志": "سجل ."
"日志": "سجل .",
"查看": "عرض ."
}

View File

@ -810,5 +810,6 @@
"百度翻译开放平台": "百度翻譯開放平台",
"百度智能云": "百度智慧雲",
"支持gpt词典": "(支援 GPT 詞典)",
"日志": "日誌"
"日志": "日誌",
"查看": "查看"
}

View File

@ -810,5 +810,6 @@
"百度翻译开放平台": "Baidu Translation Open Platform",
"百度智能云": "Cloud AI Baidu",
"支持gpt词典": "(Podporuje GPT slovník)",
"日志": "deník"
"日志": "deník",
"查看": "viz"
}

View File

@ -810,5 +810,6 @@
"百度翻译开放平台": "Baidu Translation Open Platform",
"百度智能云": "Baidu AI Cloud",
"支持gpt词典": "(Unterstützt GPT Wörterbuch)",
"日志": "Journal"
"日志": "Journal",
"查看": "siehe"
}

View File

@ -810,5 +810,6 @@
"百度翻译开放平台": "Baidu Translation Open Platform",
"百度智能云": "Baidu AI Cloud",
"支持gpt词典": "(Supports GPT dictionary)",
"日志": "journal"
"日志": "journal",
"查看": "see"
}

View File

@ -810,5 +810,6 @@
"百度翻译开放平台": "Baidu Translation Open Platform",
"百度智能云": "Baidu SMART Cloud",
"支持gpt词典": "(admite diccionarios gpt)",
"日志": "Diario"
"日志": "Diario",
"查看": "Ver"
}

View File

@ -810,5 +810,6 @@
"百度翻译开放平台": "Baidu traduction plateforme ouverte",
"百度智能云": "Baidu intelligent Cloud",
"支持gpt词典": "(support du dictionnaire GPT)",
"日志": "Logs"
"日志": "Logs",
"查看": "Voir"
}

View File

@ -810,5 +810,6 @@
"百度翻译开放平台": "Piattaforma aperta di traduzione Baidu",
"百度智能云": "Baidu AI Cloud",
"支持gpt词典": "(Supporta il dizionario GPT)",
"日志": "diario"
"日志": "diario",
"查看": "vedi"
}

View File

@ -810,5 +810,6 @@
"百度翻译开放平台": "百度翻訳オープンプラットフォーム",
"百度智能云": "百度知能クラウド",
"支持gpt词典": "gpt辞書対応",
"日志": "ログ#ログ#"
"日志": "ログ#ログ#",
"查看": "表示#ヒョウジ#"
}

View File

@ -810,5 +810,6 @@
"百度翻译开放平台": "바이두 번역 오픈 플랫폼",
"百度智能云": "바이두 스마트 클라우드",
"支持gpt词典": "(gpt 사전 지원)",
"日志": "로그"
"日志": "로그",
"查看": "보기"
}

View File

@ -810,5 +810,6 @@
"百度翻译开放平台": "Baidu Translation Open Platform",
"百度智能云": "Baidu AI Cloud",
"支持gpt词典": "(Ondersteunt GPT woordenboek)",
"日志": "dagboek"
"日志": "dagboek",
"查看": "zie"
}

View File

@ -810,5 +810,6 @@
"百度翻译开放平台": "Otwarta platforma tłumaczeń Baidu",
"百度智能云": "Chmura AI Baidu",
"支持gpt词典": "(Obsługuje słownik GPT)",
"日志": "dziennik"
"日志": "dziennik",
"查看": "zobacz"
}

View File

@ -810,5 +810,6 @@
"百度翻译开放平台": "Plataforma Aberta de Tradução Baidu",
"百度智能云": "Nuvem AI Baidu",
"支持gpt词典": "(Suporta dicionário GPT)",
"日志": "diário"
"日志": "diário",
"查看": "ver"
}

View File

@ -810,5 +810,6 @@
"百度翻译开放平台": "Открытая платформа для перевода.",
"百度智能云": "Сто умных облаков",
"支持gpt词典": "(Поддержка словаря GPT)",
"日志": "Журнал"
"日志": "Журнал",
"查看": "Посмотреть"
}

View File

@ -810,5 +810,6 @@
"百度翻译开放平台": "Öppen plattform för översättning av Baidu",
"百度智能云": "Baidu AI- molnName",
"支持gpt词典": "(Stöder GPT-ordlista)",
"日志": "journal"
"日志": "journal",
"查看": "se"
}

View File

@ -810,5 +810,6 @@
"百度翻译开放平台": "แพลตฟอร์มเปิด Baidu Translation",
"百度智能云": "Baidu สมาร์ทคลาวด์",
"支持gpt词典": "(รองรับพจนานุกรม gpt)",
"日志": "บันทึกประจำวัน"
"日志": "บันทึกประจำวัน",
"查看": "ดู"
}

View File

@ -810,5 +810,6 @@
"百度翻译开放平台": "Baidu Çeviri Açık Platformu",
"百度智能云": "Baidu AI Bulud",
"支持gpt词典": "(GPT sözlük destekliyor)",
"日志": "Günlük"
"日志": "Günlük",
"查看": "Gördün mü?"
}

View File

@ -810,5 +810,6 @@
"百度翻译开放平台": "Відкрита платформа перекладу Baidu",
"百度智能云": "Хмари Baidu AIweather condition",
"支持gpt词典": "(Підтримує словник GPT)",
"日志": "журнал"
"日志": "журнал",
"查看": "див."
}

View File

@ -810,5 +810,6 @@
"百度翻译开放平台": "100 phiên dịch mở",
"百度智能云": "100 đám mây thông minh",
"支持gpt词典": "(Hỗ trợ GPT Dictionary)",
"日志": "Đăng nhập"
"日志": "Đăng nhập",
"查看": "Xem thêm"
}

View File

@ -810,5 +810,6 @@
"百度翻译开放平台": "",
"百度智能云": "",
"支持gpt词典": "",
"日志": ""
"日志": "",
"查看": ""
}

View File

@ -28,8 +28,8 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/version)
include(generate_product_version)
set(VERSION_MAJOR 5)
set(VERSION_MINOR 45)
set(VERSION_PATCH 7)
set(VERSION_MINOR 46)
set(VERSION_PATCH 0)
add_library(pch pch.cpp)
target_precompile_headers(pch PUBLIC pch.h)