2022-04-21 22:42:43 +08:00
|
|
|
|
from PyQt5.QtCore import Qt, pyqtSignal
|
2022-04-14 21:22:47 +08:00
|
|
|
|
from PyQt5.QtGui import QPixmap, QIcon
|
|
|
|
|
from PyQt5.QtWidgets import *
|
|
|
|
|
from PyQt5.QtCore import Qt
|
|
|
|
|
|
2022-04-21 22:42:43 +08:00
|
|
|
|
from utils.BasicUtils import change_value
|
|
|
|
|
|
2022-04-14 21:22:47 +08:00
|
|
|
|
|
|
|
|
|
class ToDoItem(QListWidgetItem):
|
2022-04-21 22:42:43 +08:00
|
|
|
|
transaction = pyqtSignal()
|
2022-04-15 21:33:24 +08:00
|
|
|
|
"""
|
|
|
|
|
:param todo_name : 新建的待办事项名称
|
2022-04-21 22:42:43 +08:00
|
|
|
|
:param uid : 待办事项的uid
|
2022-04-15 21:33:24 +08:00
|
|
|
|
"""
|
|
|
|
|
|
2022-04-20 22:48:23 +08:00
|
|
|
|
# todo : 参数添加uid,方便设置重要和我的一天
|
2022-04-21 22:42:43 +08:00
|
|
|
|
def __init__(self, todo_name, uid=None):
|
2022-04-14 21:22:47 +08:00
|
|
|
|
super(ToDoItem, self).__init__()
|
2022-04-21 22:42:43 +08:00
|
|
|
|
# print('<ToDoItem> 添加的新ToDo:' + todo_name)
|
2022-04-14 21:22:47 +08:00
|
|
|
|
|
2022-04-15 21:33:24 +08:00
|
|
|
|
self.widget = QWidget()
|
2022-04-14 21:22:47 +08:00
|
|
|
|
layout = QHBoxLayout()
|
2022-04-15 21:33:24 +08:00
|
|
|
|
|
|
|
|
|
# self.widget.setMinimumHeight(100)
|
|
|
|
|
self.widget.setLayout(layout)
|
|
|
|
|
self.widget.show()
|
2022-04-14 21:22:47 +08:00
|
|
|
|
self.mark_icon = QPushButton()
|
2022-04-15 21:33:24 +08:00
|
|
|
|
self.mark_icon.setObjectName('todo_mark_icon')
|
2022-04-14 21:22:47 +08:00
|
|
|
|
self.mark_icon.setIcon(
|
2022-04-15 21:33:24 +08:00
|
|
|
|
QIcon(QPixmap('../images/circle.svg').scaled(200, 200, Qt.IgnoreAspectRatio, Qt.SmoothTransformation)))
|
2022-04-14 21:22:47 +08:00
|
|
|
|
self.todo_label = QLabel()
|
2022-04-15 21:33:24 +08:00
|
|
|
|
self.todo_label.setAlignment(Qt.AlignCenter)
|
|
|
|
|
if todo_name:
|
2022-04-14 21:22:47 +08:00
|
|
|
|
self.todo_label.setText(str(todo_name))
|
|
|
|
|
self.important_button = QPushButton()
|
2022-04-15 21:33:24 +08:00
|
|
|
|
self.important_button.setIcon(
|
2022-04-14 21:22:47 +08:00
|
|
|
|
QIcon(QPixmap('../images/star_list.svg').scaled(30, 30, Qt.IgnoreAspectRatio, Qt.SmoothTransformation)))
|
2022-04-15 21:33:24 +08:00
|
|
|
|
self.important_button.setObjectName('mark_important')
|
2022-04-14 21:22:47 +08:00
|
|
|
|
layout.addWidget(self.mark_icon, 2)
|
|
|
|
|
layout.addWidget(self.todo_label, 6)
|
2022-04-15 21:33:24 +08:00
|
|
|
|
layout.addWidget(self.important_button, 2)
|
2022-04-21 22:42:43 +08:00
|
|
|
|
|
|
|
|
|
self.mark_icon.clicked.connect(self.set_done)
|
|
|
|
|
print(uid)
|
|
|
|
|
|
|
|
|
|
self.important_button.clicked.connect(lambda: self.set_important(uid))
|
|
|
|
|
|
|
|
|
|
def set_done(self):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def set_myday(self, uid):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
change_value(uid, 'done', True)
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def set_important(self, uid):
|
|
|
|
|
# important = Important()
|
|
|
|
|
# important.load_important.emit()
|
|
|
|
|
# self.action.emit()
|
|
|
|
|
|
|
|
|
|
change_value(uid, 'isImportant', True)
|
|
|
|
|
self.transaction.emit()
|
|
|
|
|
pass
|