修复重命名可以为空的bug,还需要实现通过刷新按钮加载list_name功能
This commit is contained in:
parent
f6345e7739
commit
fdbc135d13
7 changed files with 37 additions and 46 deletions
|
@ -231,6 +231,7 @@ class MainWidget(QWidget):
|
|||
|
||||
def change_name(self, item_name):
|
||||
# print(item_name)
|
||||
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()
|
||||
|
|
|
@ -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('<BasicUtils>'+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('<BasicUtils>'+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
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
||||
|
|
|
@ -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;')
|
||||
|
|
|
@ -261,6 +261,7 @@ class Important(QWidget):
|
|||
|
||||
def change_name(self, item_name):
|
||||
# print(item_name)
|
||||
if item_name:
|
||||
my_day_list = load_myday_important('Important')
|
||||
change_value(my_day_list[self.todo_list.currentRow()][1], 'title', item_name)
|
||||
# 重命名发送信号
|
||||
|
|
|
@ -243,7 +243,6 @@ class MyDay(QWidget):
|
|||
# 重命名分组
|
||||
|
||||
def rename_item(self):
|
||||
|
||||
self.dialog = QDialog()
|
||||
self.dialog.setWindowTitle('重命名')
|
||||
self.dialog_layout = QVBoxLayout()
|
||||
|
@ -258,11 +257,11 @@ 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)
|
||||
if item_name:
|
||||
my_day_list = load_myday_important('MyDay')
|
||||
change_value(my_day_list[self.todo_list.currentRow()][1], 'title', item_name)
|
||||
# 重命名发送信号
|
||||
|
|
|
@ -255,8 +255,8 @@ class ToDoList(QWidget):
|
|||
|
||||
def change_name(self, item_name):
|
||||
# print(item_name)
|
||||
if 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)
|
||||
# 重命名发送信号
|
||||
|
|
Loading…
Reference in a new issue