67 lines
1.7 KiB
Python
67 lines
1.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""
|
|
메모 입력 다이얼로그 모듈
|
|
메모 입력을 위한 다이얼로그입니다.
|
|
"""
|
|
|
|
from datetime import date
|
|
|
|
from ui.base.base_dialog import BaseDialog
|
|
from ui.components.custom_input import CustomTextEdit, LabeledInput
|
|
from database.models import Memo
|
|
from core.logger import get_logger
|
|
|
|
logger = get_logger(__name__)
|
|
|
|
|
|
class MemoInputDialog(BaseDialog):
|
|
"""
|
|
메모 입력 다이얼로그
|
|
|
|
메모 내용을 입력합니다.
|
|
"""
|
|
|
|
def __init__(
|
|
self,
|
|
parent=None,
|
|
memo_date: date = None,
|
|
memo: Memo = None
|
|
):
|
|
title = "메모 추가" if memo is None else "메모 편집"
|
|
super().__init__(parent, title=title, width=450, height=350)
|
|
|
|
self.memo_date = memo_date or date.today()
|
|
self.memo = memo
|
|
|
|
self._setup_fields()
|
|
self.add_confirm_cancel_buttons()
|
|
|
|
if memo:
|
|
self._load_memo(memo)
|
|
|
|
def _setup_fields(self):
|
|
"""필드 설정"""
|
|
# 내용
|
|
self.content_input = CustomTextEdit(
|
|
placeholder="메모 내용을 입력하세요",
|
|
min_height=150
|
|
)
|
|
self.content_layout.addWidget(
|
|
LabeledInput("메모", self.content_input, required=True)
|
|
)
|
|
|
|
self.content_layout.addStretch()
|
|
|
|
def _load_memo(self, memo: Memo):
|
|
"""메모 데이터 로드"""
|
|
self.content_input.set_text(memo.content or "")
|
|
|
|
def get_data(self) -> dict:
|
|
"""입력 데이터 반환"""
|
|
return {
|
|
"memo_date": self.memo_date.isoformat(),
|
|
"content": self.content_input.get_text(),
|
|
}
|
|
|
|
|