From fdbc135d13d41fd34b9e6bc079ccffc22e67589f Mon Sep 17 00:00:00 2001 From: liyp Date: Sat, 30 Apr 2022 22:17:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=87=8D=E5=91=BD=E5=90=8D?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E4=B8=BA=E7=A9=BA=E7=9A=84bug=EF=BC=8C?= =?UTF-8?q?=E8=BF=98=E9=9C=80=E8=A6=81=E5=AE=9E=E7=8E=B0=E9=80=9A=E8=BF=87?= =?UTF-8?q?=E5=88=B7=E6=96=B0=E6=8C=89=E9=92=AE=E5=8A=A0=E8=BD=BDlist=5Fna?= =?UTF-8?q?me=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/main.py | 15 ++++++++------- utils/BasicUtils.py | 21 ++++++--------------- utils/Sync.py | 1 - view/AddListLabel.py | 2 +- view/ImportantView.py | 13 +++++++------ view/MyDayView.py | 15 +++++++-------- view/ToDoListView.py | 16 ++++++++-------- 7 files changed, 37 insertions(+), 46 deletions(-) diff --git a/main/main.py b/main/main.py index 4e9c113..8931d1f 100644 --- a/main/main.py +++ b/main/main.py @@ -231,13 +231,14 @@ class MainWidget(QWidget): def change_name(self, item_name): # print(item_name) - load_list = get_todo_list() - change_value(load_list[self.system_listWidget.currentRow() - 2][1], 'title', item_name) - self.update_signal.emit() - # 重命名发送信号 - self.initUI() - # self.update_signal.emit() - self.dialog.close() + if item_name: + load_list = get_todo_list() + change_value(load_list[self.system_listWidget.currentRow() - 2][1], 'title', item_name) + self.update_signal.emit() + # 重命名发送信号 + self.initUI() + # self.update_signal.emit() + self.dialog.close() class MainWindow(QWidget): diff --git a/utils/BasicUtils.py b/utils/BasicUtils.py index b11e3f2..0c9a2f4 100644 --- a/utils/BasicUtils.py +++ b/utils/BasicUtils.py @@ -170,12 +170,12 @@ def change_value(uid, key, value): current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') with open(todo_path + '{' + uid + '}.otl', 'r') as f: - # print(f.read()) + json_file = json.load(f) - # print(''+json_file) + json_file[key] = value json_file['updatedAt'] = current_time - # print(json_file[key]) + with open(todo_path + '{' + uid + '}.otl', 'w') as f: json.dump(json_file, f, indent=4, ensure_ascii=False) @@ -185,9 +185,9 @@ def load_value(uid, key): todo_path = config_path + 'ToDoList/' with open(todo_path + '{' + uid + '}.otl', 'r') as f: - # print(f.read()) + json_file = json.load(f) - # print(''+json_file) + return json_file[key] @@ -197,14 +197,11 @@ def remove_todo_list(uid): os.remove(todo_path + '{' + uid + '}.otl') for root, dirs, files in os.walk(todo_path, topdown=False): for name in files: - # print(os.path.join(root, name)) with open(os.path.join(root, name), 'r') as f: - # print(f.read()) json_file = json.load(f) - # print(json_file['itemType']) if json_file['itemType'] == 'Todo' and json_file['todoListUid'] == uid: - # print(os.path.join(root, name)) + os.remove(os.path.join(root, name)) @@ -246,12 +243,6 @@ def check_login_status(): return True else: return False - # - # for i in init_file_list: - # if i == 'None': - # return False - # else: - # return True except TypeError as e: return False diff --git a/utils/Sync.py b/utils/Sync.py index f9c8bf6..6ed362e 100644 --- a/utils/Sync.py +++ b/utils/Sync.py @@ -11,7 +11,6 @@ class Sync(QThread): super(Sync, self).__init__() self.sync_path = return_work_dir() self.config_info = read_init_file() - # print(self.config_info[0], self.config_info[1], self.config_info[2]) def run(self): diff --git a/view/AddListLabel.py b/view/AddListLabel.py index ac11157..76c06db 100644 --- a/view/AddListLabel.py +++ b/view/AddListLabel.py @@ -25,7 +25,7 @@ class AddListAction(QLabel): def mousePressEvent(self, QMouseEvent): if QMouseEvent.buttons() == Qt.LeftButton: - print('点击QLabel') + # print('点击QLabel') self.create_todo_list.emit() self.setStyleSheet('background-color:#eaeaea;') diff --git a/view/ImportantView.py b/view/ImportantView.py index ce787ce..526eb38 100644 --- a/view/ImportantView.py +++ b/view/ImportantView.py @@ -261,12 +261,13 @@ class Important(QWidget): def change_name(self, item_name): # print(item_name) - my_day_list = load_myday_important('Important') - change_value(my_day_list[self.todo_list.currentRow()][1], 'title', item_name) - # 重命名发送信号 - self.refresh_action() - self.update_signal.emit() - self.dialog.close() + if item_name: + my_day_list = load_myday_important('Important') + change_value(my_day_list[self.todo_list.currentRow()][1], 'title', item_name) + # 重命名发送信号 + self.refresh_action() + self.update_signal.emit() + self.dialog.close() def mark_done(self, uid): # print('mark done:', uid) diff --git a/view/MyDayView.py b/view/MyDayView.py index c36d601..b576889 100644 --- a/view/MyDayView.py +++ b/view/MyDayView.py @@ -243,7 +243,6 @@ class MyDay(QWidget): # 重命名分组 def rename_item(self): - self.dialog = QDialog() self.dialog.setWindowTitle('重命名') self.dialog_layout = QVBoxLayout() @@ -258,17 +257,17 @@ class MyDay(QWidget): self.dialog_layout.addWidget(confirm_button) confirm_button.setStyleSheet('background-color:#bcbcbc;border-radius:5px;') confirm_button.clicked.connect(lambda: self.change_name(line_edit.text())) - self.dialog.exec_() def change_name(self, item_name): # print(item_name) - my_day_list = load_myday_important('MyDay') - change_value(my_day_list[self.todo_list.currentRow()][1], 'title', item_name) - # 重命名发送信号 - self.refresh_action() - self.update_signal.emit() - self.dialog.close() + if item_name: + my_day_list = load_myday_important('MyDay') + change_value(my_day_list[self.todo_list.currentRow()][1], 'title', item_name) + # 重命名发送信号 + self.refresh_action() + self.update_signal.emit() + self.dialog.close() def mark_done(self, uid): # print('mark done:', uid) diff --git a/view/ToDoListView.py b/view/ToDoListView.py index bef471d..0796cd4 100644 --- a/view/ToDoListView.py +++ b/view/ToDoListView.py @@ -255,14 +255,14 @@ class ToDoList(QWidget): def change_name(self, item_name): # print(item_name) - load_todo = get_todo(self.uid) - # load_todo = get_todo(my_day_list[self.todo_list.currentRow()][1]) - uid = load_todo[self.todo_list.currentRow()][1] - change_value(uid, 'title', item_name) - # 重命名发送信号 - self.refresh_action() - self.update_signal.emit() - self.dialog.close() + if item_name: + load_todo = get_todo(self.uid) + uid = load_todo[self.todo_list.currentRow()][1] + change_value(uid, 'title', item_name) + # 重命名发送信号 + self.refresh_action() + self.update_signal.emit() + self.dialog.close() def mark_done(self, uid): # print('uid:',uid)