|
@@ -7,6 +7,7 @@ from functools import partial
|
|
|
from PySide6.QtWidgets import QMessageBox, QFileDialog, QWidget, QLineEdit, QPushButton, \
|
|
from PySide6.QtWidgets import QMessageBox, QFileDialog, QWidget, QLineEdit, QPushButton, \
|
|
|
QTextEdit, QTextBrowser
|
|
QTextEdit, QTextBrowser
|
|
|
|
|
|
|
|
|
|
+from src import constant
|
|
|
from src.ui.TemplateFilteringView import Ui_Form
|
|
from src.ui.TemplateFilteringView import Ui_Form
|
|
|
|
|
|
|
|
category_pattern = re.compile(r'\[类别\]')
|
|
category_pattern = re.compile(r'\[类别\]')
|
|
@@ -17,7 +18,9 @@ CHARACTER_FILTER_STR = "[字母]"
|
|
|
DIGIT_FILTER_STR = "[数字]"
|
|
DIGIT_FILTER_STR = "[数字]"
|
|
|
CATEGORY_FILTER_STR = "[类别]"
|
|
CATEGORY_FILTER_STR = "[类别]"
|
|
|
|
|
|
|
|
-CONFIG_FILE_PATH = "../tmp/config.json"
|
|
|
|
|
|
|
+# 配置文件路径
|
|
|
|
|
+CONFIG_PATH = os.path.join(constant.GLOBAL_PROJECT_TEMP_DIR, "templateFilteringConf.json")
|
|
|
|
|
+# 配置文件属性
|
|
|
CONFIG_ITEM_LAST_SELECT_FILE_PATH = "lastSelectFilePath"
|
|
CONFIG_ITEM_LAST_SELECT_FILE_PATH = "lastSelectFilePath"
|
|
|
|
|
|
|
|
|
|
|
|
@@ -46,13 +49,15 @@ class TemplateFilteringModelAndView(QWidget, Ui_Form):
|
|
|
}
|
|
}
|
|
|
self.resultDict = {
|
|
self.resultDict = {
|
|
|
self.firstFilterBtn.objectName(): (
|
|
self.firstFilterBtn.objectName(): (
|
|
|
- self.firstKeyBox, self.firstCategoryBox, self.firstResultBox, None, self.result_label_1),
|
|
|
|
|
|
|
+ self.firstKeyBox, self.firstCategoryBox, self.firstResultBox, None, self.result_label_1),
|
|
|
self.secondFilterBtn.objectName(): (
|
|
self.secondFilterBtn.objectName(): (
|
|
|
- self.secondKeyBox, self.secondCategoryBox, self.secondResultBox, self.firstResultBox, self.result_label_2),
|
|
|
|
|
|
|
+ self.secondKeyBox, self.secondCategoryBox, self.secondResultBox, self.firstResultBox,
|
|
|
|
|
+ self.result_label_2),
|
|
|
self.threeFilterBtn.objectName(): (
|
|
self.threeFilterBtn.objectName(): (
|
|
|
- self.threeKeyBox, self.threeCategoryBox, self.threeResultBox, self.secondResultBox, self.result_label_3),
|
|
|
|
|
|
|
+ self.threeKeyBox, self.threeCategoryBox, self.threeResultBox, self.secondResultBox,
|
|
|
|
|
+ self.result_label_3),
|
|
|
self.fourFilterBtn.objectName(): (
|
|
self.fourFilterBtn.objectName(): (
|
|
|
- self.fourKeyBox, self.fourCategoryBox, self.fourResultBox, self.threeResultBox, self.result_label_4)
|
|
|
|
|
|
|
+ self.fourKeyBox, self.fourCategoryBox, self.fourResultBox, self.threeResultBox, self.result_label_4)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
self.fileBtn.clicked.connect(self.selectFile)
|
|
self.fileBtn.clicked.connect(self.selectFile)
|
|
@@ -82,14 +87,14 @@ class TemplateFilteringModelAndView(QWidget, Ui_Form):
|
|
|
self.fourFilterBtn.clicked.connect(partial(self.submit, self.fourFilterBtn))
|
|
self.fourFilterBtn.clicked.connect(partial(self.submit, self.fourFilterBtn))
|
|
|
|
|
|
|
|
def loadConfig(self):
|
|
def loadConfig(self):
|
|
|
- if os.path.isfile(CONFIG_FILE_PATH):
|
|
|
|
|
- with open(CONFIG_FILE_PATH, 'r', encoding='utf-8') as f:
|
|
|
|
|
|
|
+ if os.path.isfile(CONFIG_PATH):
|
|
|
|
|
+ with open(CONFIG_PATH, 'r', encoding='utf-8') as f:
|
|
|
config = json.loads(f.read())
|
|
config = json.loads(f.read())
|
|
|
self.filePathBox.setText(config[CONFIG_ITEM_LAST_SELECT_FILE_PATH])
|
|
self.filePathBox.setText(config[CONFIG_ITEM_LAST_SELECT_FILE_PATH])
|
|
|
|
|
|
|
|
def selectFile(self):
|
|
def selectFile(self):
|
|
|
file_path, file_type = QFileDialog.getOpenFileName(self, "选择文件")
|
|
file_path, file_type = QFileDialog.getOpenFileName(self, "选择文件")
|
|
|
- with open(CONFIG_FILE_PATH, 'w', encoding='utf-8') as f:
|
|
|
|
|
|
|
+ with open(CONFIG_PATH, 'w', encoding='utf-8') as f:
|
|
|
f.write(json.dumps({CONFIG_ITEM_LAST_SELECT_FILE_PATH: file_path}))
|
|
f.write(json.dumps({CONFIG_ITEM_LAST_SELECT_FILE_PATH: file_path}))
|
|
|
self.filePathBox.setText(file_path)
|
|
self.filePathBox.setText(file_path)
|
|
|
|
|
|