修复重命名可以为空的bug,还需要实现通过刷新按钮加载list_name功能
This commit is contained in:
parent
f6345e7739
commit
fdbc135d13
7 changed files with 37 additions and 46 deletions
15
main/main.py
15
main/main.py
|
@ -231,13 +231,14 @@ class MainWidget(QWidget):
|
||||||
|
|
||||||
def change_name(self, item_name):
|
def change_name(self, item_name):
|
||||||
# print(item_name)
|
# print(item_name)
|
||||||
load_list = get_todo_list()
|
if item_name:
|
||||||
change_value(load_list[self.system_listWidget.currentRow() - 2][1], 'title', item_name)
|
load_list = get_todo_list()
|
||||||
self.update_signal.emit()
|
change_value(load_list[self.system_listWidget.currentRow() - 2][1], 'title', item_name)
|
||||||
# 重命名发送信号
|
self.update_signal.emit()
|
||||||
self.initUI()
|
# 重命名发送信号
|
||||||
# self.update_signal.emit()
|
self.initUI()
|
||||||
self.dialog.close()
|
# self.update_signal.emit()
|
||||||
|
self.dialog.close()
|
||||||
|
|
||||||
|
|
||||||
class MainWindow(QWidget):
|
class MainWindow(QWidget):
|
||||||
|
|
|
@ -170,12 +170,12 @@ def change_value(uid, key, value):
|
||||||
current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||||
|
|
||||||
with open(todo_path + '{' + uid + '}.otl', 'r') as f:
|
with open(todo_path + '{' + uid + '}.otl', 'r') as f:
|
||||||
# print(f.read())
|
|
||||||
json_file = json.load(f)
|
json_file = json.load(f)
|
||||||
# print('<BasicUtils>'+json_file)
|
|
||||||
json_file[key] = value
|
json_file[key] = value
|
||||||
json_file['updatedAt'] = current_time
|
json_file['updatedAt'] = current_time
|
||||||
# print(json_file[key])
|
|
||||||
with open(todo_path + '{' + uid + '}.otl', 'w') as f:
|
with open(todo_path + '{' + uid + '}.otl', 'w') as f:
|
||||||
json.dump(json_file, f, indent=4, ensure_ascii=False)
|
json.dump(json_file, f, indent=4, ensure_ascii=False)
|
||||||
|
|
||||||
|
@ -185,9 +185,9 @@ def load_value(uid, key):
|
||||||
todo_path = config_path + 'ToDoList/'
|
todo_path = config_path + 'ToDoList/'
|
||||||
|
|
||||||
with open(todo_path + '{' + uid + '}.otl', 'r') as f:
|
with open(todo_path + '{' + uid + '}.otl', 'r') as f:
|
||||||
# print(f.read())
|
|
||||||
json_file = json.load(f)
|
json_file = json.load(f)
|
||||||
# print('<BasicUtils>'+json_file)
|
|
||||||
return json_file[key]
|
return json_file[key]
|
||||||
|
|
||||||
|
|
||||||
|
@ -197,14 +197,11 @@ def remove_todo_list(uid):
|
||||||
os.remove(todo_path + '{' + uid + '}.otl')
|
os.remove(todo_path + '{' + uid + '}.otl')
|
||||||
for root, dirs, files in os.walk(todo_path, topdown=False):
|
for root, dirs, files in os.walk(todo_path, topdown=False):
|
||||||
for name in files:
|
for name in files:
|
||||||
# print(os.path.join(root, name))
|
|
||||||
with open(os.path.join(root, name), 'r') as f:
|
with open(os.path.join(root, name), 'r') as f:
|
||||||
# print(f.read())
|
|
||||||
json_file = json.load(f)
|
json_file = json.load(f)
|
||||||
|
|
||||||
# print(json_file['itemType'])
|
|
||||||
if json_file['itemType'] == 'Todo' and json_file['todoListUid'] == uid:
|
if json_file['itemType'] == 'Todo' and json_file['todoListUid'] == uid:
|
||||||
# print(os.path.join(root, name))
|
|
||||||
os.remove(os.path.join(root, name))
|
os.remove(os.path.join(root, name))
|
||||||
|
|
||||||
|
|
||||||
|
@ -246,12 +243,6 @@ def check_login_status():
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
#
|
|
||||||
# for i in init_file_list:
|
|
||||||
# if i == 'None':
|
|
||||||
# return False
|
|
||||||
# else:
|
|
||||||
# return True
|
|
||||||
except TypeError as e:
|
except TypeError as e:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ class Sync(QThread):
|
||||||
super(Sync, self).__init__()
|
super(Sync, self).__init__()
|
||||||
self.sync_path = return_work_dir()
|
self.sync_path = return_work_dir()
|
||||||
self.config_info = read_init_file()
|
self.config_info = read_init_file()
|
||||||
# print(self.config_info[0], self.config_info[1], self.config_info[2])
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ class AddListAction(QLabel):
|
||||||
|
|
||||||
def mousePressEvent(self, QMouseEvent):
|
def mousePressEvent(self, QMouseEvent):
|
||||||
if QMouseEvent.buttons() == Qt.LeftButton:
|
if QMouseEvent.buttons() == Qt.LeftButton:
|
||||||
print('点击QLabel')
|
# print('点击QLabel')
|
||||||
|
|
||||||
self.create_todo_list.emit()
|
self.create_todo_list.emit()
|
||||||
self.setStyleSheet('background-color:#eaeaea;')
|
self.setStyleSheet('background-color:#eaeaea;')
|
||||||
|
|
|
@ -261,12 +261,13 @@ class Important(QWidget):
|
||||||
|
|
||||||
def change_name(self, item_name):
|
def change_name(self, item_name):
|
||||||
# print(item_name)
|
# print(item_name)
|
||||||
my_day_list = load_myday_important('Important')
|
if item_name:
|
||||||
change_value(my_day_list[self.todo_list.currentRow()][1], 'title', 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.refresh_action()
|
||||||
self.dialog.close()
|
self.update_signal.emit()
|
||||||
|
self.dialog.close()
|
||||||
|
|
||||||
def mark_done(self, uid):
|
def mark_done(self, uid):
|
||||||
# print('mark done:', uid)
|
# print('mark done:', uid)
|
||||||
|
|
|
@ -243,7 +243,6 @@ class MyDay(QWidget):
|
||||||
# 重命名分组
|
# 重命名分组
|
||||||
|
|
||||||
def rename_item(self):
|
def rename_item(self):
|
||||||
|
|
||||||
self.dialog = QDialog()
|
self.dialog = QDialog()
|
||||||
self.dialog.setWindowTitle('重命名')
|
self.dialog.setWindowTitle('重命名')
|
||||||
self.dialog_layout = QVBoxLayout()
|
self.dialog_layout = QVBoxLayout()
|
||||||
|
@ -258,17 +257,17 @@ class MyDay(QWidget):
|
||||||
self.dialog_layout.addWidget(confirm_button)
|
self.dialog_layout.addWidget(confirm_button)
|
||||||
confirm_button.setStyleSheet('background-color:#bcbcbc;border-radius:5px;')
|
confirm_button.setStyleSheet('background-color:#bcbcbc;border-radius:5px;')
|
||||||
confirm_button.clicked.connect(lambda: self.change_name(line_edit.text()))
|
confirm_button.clicked.connect(lambda: self.change_name(line_edit.text()))
|
||||||
|
|
||||||
self.dialog.exec_()
|
self.dialog.exec_()
|
||||||
|
|
||||||
def change_name(self, item_name):
|
def change_name(self, item_name):
|
||||||
# print(item_name)
|
# print(item_name)
|
||||||
my_day_list = load_myday_important('MyDay')
|
if item_name:
|
||||||
change_value(my_day_list[self.todo_list.currentRow()][1], 'title', 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.refresh_action()
|
||||||
self.dialog.close()
|
self.update_signal.emit()
|
||||||
|
self.dialog.close()
|
||||||
|
|
||||||
def mark_done(self, uid):
|
def mark_done(self, uid):
|
||||||
# print('mark done:', uid)
|
# print('mark done:', uid)
|
||||||
|
|
|
@ -255,14 +255,14 @@ class ToDoList(QWidget):
|
||||||
|
|
||||||
def change_name(self, item_name):
|
def change_name(self, item_name):
|
||||||
# print(item_name)
|
# print(item_name)
|
||||||
load_todo = get_todo(self.uid)
|
if item_name:
|
||||||
# load_todo = get_todo(my_day_list[self.todo_list.currentRow()][1])
|
load_todo = get_todo(self.uid)
|
||||||
uid = load_todo[self.todo_list.currentRow()][1]
|
uid = load_todo[self.todo_list.currentRow()][1]
|
||||||
change_value(uid, 'title', item_name)
|
change_value(uid, 'title', item_name)
|
||||||
# 重命名发送信号
|
# 重命名发送信号
|
||||||
self.refresh_action()
|
self.refresh_action()
|
||||||
self.update_signal.emit()
|
self.update_signal.emit()
|
||||||
self.dialog.close()
|
self.dialog.close()
|
||||||
|
|
||||||
def mark_done(self, uid):
|
def mark_done(self, uid):
|
||||||
# print('uid:',uid)
|
# print('uid:',uid)
|
||||||
|
|
Loading…
Reference in a new issue