Commit ·
32106e7
1
Parent(s): 5864cf0
feat: 希望シフト・スケジュール画面の複数修正
Browse files- 希望シフト: 数字キーショートカットをeventFilterで実装(QComboBoxフォーカス時も動作)
- ソルバー: 制約充足不可の場合もベストエフォートで生成し不足メッセージを表示
- スケジュール表: ホール/キッチン専任をグループ区切り行で分離・背景色で区別
- スケジュール表: 制約違反タブ内にインライン警告ラベルを表示
- スケジュール表: 日付ヘッダーをクリックするとその日の希望タイムラインダイアログを表示
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- optimizer/solver.py +152 -23
- ui/schedule_view.py +420 -44
- ui/shift_input_view.py +19 -6
optimizer/solver.py
CHANGED
|
@@ -258,24 +258,8 @@ def solve(
|
|
| 258 |
status_name = solver.status_name(status)
|
| 259 |
|
| 260 |
if status in (cp_model.OPTIMAL, cp_model.FEASIBLE):
|
| 261 |
-
result_assignments =
|
| 262 |
-
for emp in active_employees:
|
| 263 |
-
for ds in date_strs:
|
| 264 |
-
for slot in slots:
|
| 265 |
-
for pos in positions:
|
| 266 |
-
val = solver.value(assign[emp.id][ds][slot.value][pos.value])
|
| 267 |
-
if val:
|
| 268 |
-
result_assignments.append(
|
| 269 |
-
ShiftAssignment(
|
| 270 |
-
employee_id=emp.id,
|
| 271 |
-
date=ds,
|
| 272 |
-
time_slot=slot,
|
| 273 |
-
position=pos,
|
| 274 |
-
)
|
| 275 |
-
)
|
| 276 |
-
# 警告: 人員ギリギリ日を検出
|
| 277 |
_check_warnings(result_assignments, date_strs, warnings)
|
| 278 |
-
|
| 279 |
return SolveResult(
|
| 280 |
status="optimal" if status == cp_model.OPTIMAL else "feasible",
|
| 281 |
assignments=result_assignments,
|
|
@@ -284,17 +268,162 @@ def solve(
|
|
| 284 |
solve_time_sec=elapsed,
|
| 285 |
)
|
| 286 |
else:
|
| 287 |
-
# 実行不可能 →
|
| 288 |
errs = _diagnose_infeasible(active_employees, date_strs, req_map)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 289 |
return SolveResult(
|
| 290 |
-
status="
|
| 291 |
-
assignments=
|
| 292 |
-
warnings=
|
| 293 |
-
errors=errs,
|
| 294 |
-
solve_time_sec=
|
| 295 |
)
|
| 296 |
|
| 297 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 298 |
def _check_warnings(assignments: list[ShiftAssignment], date_strs: list[str], warnings: list[str]):
|
| 299 |
from collections import defaultdict
|
| 300 |
count = defaultdict(int)
|
|
|
|
| 258 |
status_name = solver.status_name(status)
|
| 259 |
|
| 260 |
if status in (cp_model.OPTIMAL, cp_model.FEASIBLE):
|
| 261 |
+
result_assignments = _extract_assignments(solver, assign, active_employees, date_strs, slots, positions)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 262 |
_check_warnings(result_assignments, date_strs, warnings)
|
|
|
|
| 263 |
return SolveResult(
|
| 264 |
status="optimal" if status == cp_model.OPTIMAL else "feasible",
|
| 265 |
assignments=result_assignments,
|
|
|
|
| 268 |
solve_time_sec=elapsed,
|
| 269 |
)
|
| 270 |
else:
|
| 271 |
+
# 実行不可能 → 制約違反の診断メッセージを収集
|
| 272 |
errs = _diagnose_infeasible(active_employees, date_strs, req_map)
|
| 273 |
+
|
| 274 |
+
# ベストエフォート生成: 人数・リーダー制約をソフト化して再実行
|
| 275 |
+
best_assignments, best_warnings = _solve_best_effort(
|
| 276 |
+
active_employees, date_strs, slots, positions,
|
| 277 |
+
req_map, req_hours
|
| 278 |
+
)
|
| 279 |
+
_check_warnings(best_assignments, date_strs, best_warnings)
|
| 280 |
+
|
| 281 |
return SolveResult(
|
| 282 |
+
status="feasible", # ベストエフォートなので feasible 扱い
|
| 283 |
+
assignments=best_assignments,
|
| 284 |
+
warnings=best_warnings,
|
| 285 |
+
errors=errs, # どこが不足しているかを表示
|
| 286 |
+
solve_time_sec=time.time() - t0,
|
| 287 |
)
|
| 288 |
|
| 289 |
|
| 290 |
+
def _extract_assignments(solver, assign, active_employees, date_strs, slots, positions) -> list[ShiftAssignment]:
|
| 291 |
+
result = []
|
| 292 |
+
for emp in active_employees:
|
| 293 |
+
for ds in date_strs:
|
| 294 |
+
for slot in slots:
|
| 295 |
+
for pos in positions:
|
| 296 |
+
if solver.value(assign[emp.id][ds][slot.value][pos.value]):
|
| 297 |
+
result.append(ShiftAssignment(
|
| 298 |
+
employee_id=emp.id, date=ds,
|
| 299 |
+
time_slot=slot, position=pos,
|
| 300 |
+
))
|
| 301 |
+
return result
|
| 302 |
+
|
| 303 |
+
|
| 304 |
+
def _solve_best_effort(
|
| 305 |
+
active_employees, date_strs, slots, positions,
|
| 306 |
+
req_map, req_hours
|
| 307 |
+
) -> tuple[list[ShiftAssignment], list[str]]:
|
| 308 |
+
"""人数・リーダー制約をソフト化してベストエフォートのシフトを生成する"""
|
| 309 |
+
import time
|
| 310 |
+
model = cp_model.CpModel()
|
| 311 |
+
|
| 312 |
+
assign: dict = {}
|
| 313 |
+
for emp in active_employees:
|
| 314 |
+
assign[emp.id] = {}
|
| 315 |
+
for ds in date_strs:
|
| 316 |
+
assign[emp.id][ds] = {}
|
| 317 |
+
for slot in slots:
|
| 318 |
+
assign[emp.id][ds][slot.value] = {}
|
| 319 |
+
for pos in positions:
|
| 320 |
+
assign[emp.id][ds][slot.value][pos.value] = model.new_bool_var(
|
| 321 |
+
f"be_{emp.id}_{ds}_{slot.value}_{pos.value}"
|
| 322 |
+
)
|
| 323 |
+
|
| 324 |
+
# 絶対制約 0-3(ポジション・希望なし・1枠1ポジション・アルバイト1日制限)
|
| 325 |
+
for emp in active_employees:
|
| 326 |
+
if emp.primary_position is not None:
|
| 327 |
+
restricted = [p for p in positions if p.value != emp.primary_position.value]
|
| 328 |
+
for ds in date_strs:
|
| 329 |
+
for slot in slots:
|
| 330 |
+
for pos in restricted:
|
| 331 |
+
model.add(assign[emp.id][ds][slot.value][pos.value] == 0)
|
| 332 |
+
|
| 333 |
+
for emp in active_employees:
|
| 334 |
+
for ds in date_strs:
|
| 335 |
+
for slot in slots:
|
| 336 |
+
can_work = req_map.get((emp.id, ds, slot.value), False)
|
| 337 |
+
for pos in positions:
|
| 338 |
+
if not can_work:
|
| 339 |
+
model.add(assign[emp.id][ds][slot.value][pos.value] == 0)
|
| 340 |
+
|
| 341 |
+
for emp in active_employees:
|
| 342 |
+
for ds in date_strs:
|
| 343 |
+
for slot in slots:
|
| 344 |
+
model.add_at_most_one(
|
| 345 |
+
assign[emp.id][ds][slot.value][pos.value] for pos in positions
|
| 346 |
+
)
|
| 347 |
+
|
| 348 |
+
for emp in active_employees:
|
| 349 |
+
if emp.employment_type.value == "part_time":
|
| 350 |
+
for ds in date_strs:
|
| 351 |
+
all_vars = [
|
| 352 |
+
assign[emp.id][ds][slot.value][pos.value]
|
| 353 |
+
for slot in slots for pos in positions
|
| 354 |
+
]
|
| 355 |
+
model.add(sum(all_vars) <= 1)
|
| 356 |
+
|
| 357 |
+
penalty_terms = []
|
| 358 |
+
STAFF_PENALTY = 1_000_000 # 人数不足ペナルティ(非常に高い)
|
| 359 |
+
LEADER_PENALTY = 800_000 # リーダー不足ペナルティ
|
| 360 |
+
|
| 361 |
+
for ds in date_strs:
|
| 362 |
+
for slot in slots:
|
| 363 |
+
for pos in positions:
|
| 364 |
+
constraint = SHIFT_CONSTRAINTS.get((slot, pos))
|
| 365 |
+
if not constraint:
|
| 366 |
+
continue
|
| 367 |
+
min_req = constraint["min"]
|
| 368 |
+
max_req = constraint["max"]
|
| 369 |
+
staff_vars = [assign[emp.id][ds][slot.value][pos.value] for emp in active_employees]
|
| 370 |
+
|
| 371 |
+
# 最大は引き続き絶対制約
|
| 372 |
+
model.add(sum(staff_vars) <= max_req)
|
| 373 |
+
|
| 374 |
+
# 最低人数はソフト制約: shortfall 分をペナルティ
|
| 375 |
+
shortfall = model.new_int_var(0, min_req, f"sf_{ds}_{slot.value}_{pos.value}")
|
| 376 |
+
model.add(sum(staff_vars) + shortfall >= min_req)
|
| 377 |
+
penalty_terms.append(STAFF_PENALTY * shortfall)
|
| 378 |
+
|
| 379 |
+
# リーダー最低数もソフト制約
|
| 380 |
+
min_leader = constraint.get("min_leader", 0)
|
| 381 |
+
if min_leader > 0:
|
| 382 |
+
leader_vars = [
|
| 383 |
+
assign[emp.id][ds][slot.value][pos.value]
|
| 384 |
+
for emp in active_employees if emp.is_leader(pos.value)
|
| 385 |
+
]
|
| 386 |
+
lshortfall = model.new_int_var(0, min_leader, f"lsf_{ds}_{slot.value}_{pos.value}")
|
| 387 |
+
model.add(sum(leader_vars) + lshortfall >= min_leader)
|
| 388 |
+
penalty_terms.append(LEADER_PENALTY * lshortfall)
|
| 389 |
+
|
| 390 |
+
# 元のソフト制約(P1: 人件費、P3: 希望充当)も追加
|
| 391 |
+
DEFAULT_SLOT_HOURS = {TimeSlot.BREAKFAST: 5.0, TimeSlot.DINNER: 6.0}
|
| 392 |
+
for emp in active_employees:
|
| 393 |
+
for ds in date_strs:
|
| 394 |
+
for slot in slots:
|
| 395 |
+
for pos in positions:
|
| 396 |
+
var = assign[emp.id][ds][slot.value][pos.value]
|
| 397 |
+
hours = req_hours.get((emp.id, ds, slot.value), DEFAULT_SLOT_HOURS[slot])
|
| 398 |
+
penalty_terms.append(int(1000 * hours * 10) * var)
|
| 399 |
+
|
| 400 |
+
FT_PENALTY = 200_000
|
| 401 |
+
PT_PENALTY = 100
|
| 402 |
+
for emp in active_employees:
|
| 403 |
+
penalty = FT_PENALTY if emp.employment_type.value == "full_time" else PT_PENALTY
|
| 404 |
+
for ds in date_strs:
|
| 405 |
+
for slot in slots:
|
| 406 |
+
if req_map.get((emp.id, ds, slot.value)):
|
| 407 |
+
worked = sum(assign[emp.id][ds][slot.value][pos.value] for pos in positions)
|
| 408 |
+
not_worked = model.new_bool_var(f"nw_be_{emp.id}_{ds}_{slot.value}")
|
| 409 |
+
model.add(worked == 0).only_enforce_if(not_worked)
|
| 410 |
+
model.add(worked >= 1).only_enforce_if(not_worked.negated())
|
| 411 |
+
penalty_terms.append(penalty * not_worked)
|
| 412 |
+
|
| 413 |
+
model.minimize(sum(penalty_terms))
|
| 414 |
+
|
| 415 |
+
solver = cp_model.CpSolver()
|
| 416 |
+
solver.parameters.max_time_in_seconds = 30.0
|
| 417 |
+
solver.parameters.num_search_workers = 4
|
| 418 |
+
status = solver.solve(model)
|
| 419 |
+
|
| 420 |
+
warnings: list[str] = []
|
| 421 |
+
if status in (cp_model.OPTIMAL, cp_model.FEASIBLE):
|
| 422 |
+
return _extract_assignments(solver, assign, active_employees, date_strs, slots, positions), warnings
|
| 423 |
+
# フォールバック: 全員不在
|
| 424 |
+
return [], ["⚠️ ベストエフォート生成にも失敗しました。希望シフトの入力状況を確認してください。"]
|
| 425 |
+
|
| 426 |
+
|
| 427 |
def _check_warnings(assignments: list[ShiftAssignment], date_strs: list[str], warnings: list[str]):
|
| 428 |
from collections import defaultdict
|
| 429 |
count = defaultdict(int)
|
ui/schedule_view.py
CHANGED
|
@@ -7,15 +7,15 @@ from PyQt6.QtWidgets import (
|
|
| 7 |
QComboBox, QTableWidget, QTableWidgetItem, QHeaderView,
|
| 8 |
QGroupBox, QDialog, QListWidget, QListWidgetItem,
|
| 9 |
QDialogButtonBox, QScrollArea, QSizePolicy, QFrame,
|
| 10 |
-
QMessageBox, QAbstractItemView, QTabWidget
|
| 11 |
)
|
| 12 |
from PyQt6.QtCore import Qt, pyqtSignal
|
| 13 |
-
from PyQt6.QtGui import QFont, QColor, QBrush
|
| 14 |
from db import repositories as repo
|
| 15 |
from models.employee import Employee
|
| 16 |
-
from models.schedule import ShiftAssignment
|
| 17 |
from utils.constants import (
|
| 18 |
-
TimeSlot, Position, SkillLevel, DAY_OF_WEEK_LABELS,
|
| 19 |
SHIFT_CONSTRAINTS
|
| 20 |
)
|
| 21 |
from utils.theme import theme
|
|
@@ -29,12 +29,9 @@ SKILL_BADGE = {
|
|
| 29 |
}
|
| 30 |
|
| 31 |
# セル色
|
| 32 |
-
COLOR_OK = QColor("#d1fae5")
|
| 33 |
-
COLOR_WARN = QColor("#fef3c7")
|
| 34 |
-
COLOR_ERROR = QColor("#fee2e2")
|
| 35 |
-
COLOR_HEADER_DAY = QColor("#eff6ff")
|
| 36 |
-
COLOR_WEEKEND_SAT = QColor("#dbeafe")
|
| 37 |
-
COLOR_WEEKEND_SUN = QColor("#fce7f3")
|
| 38 |
|
| 39 |
|
| 40 |
class ScheduleView(QWidget):
|
|
@@ -42,8 +39,9 @@ class ScheduleView(QWidget):
|
|
| 42 |
super().__init__(parent)
|
| 43 |
self._period = None
|
| 44 |
self._employees: list[Employee] = []
|
| 45 |
-
self._assignments: dict[tuple[int, str, str], str] = {}
|
| 46 |
self._requests: dict[tuple[int, str], tuple[bool, bool]] = {}
|
|
|
|
| 47 |
self._build_ui()
|
| 48 |
self._load_periods()
|
| 49 |
|
|
@@ -74,7 +72,11 @@ class ScheduleView(QWidget):
|
|
| 74 |
# 凡例
|
| 75 |
legend = QHBoxLayout()
|
| 76 |
self._status_legend_labels: list[tuple[QLabel, str]] = []
|
| 77 |
-
for text, color_key in [
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
lbl = QLabel(text)
|
| 79 |
self._status_legend_labels.append((lbl, color_key))
|
| 80 |
legend.addWidget(lbl)
|
|
@@ -88,8 +90,10 @@ class ScheduleView(QWidget):
|
|
| 88 |
TimeSlot.DINNER: False,
|
| 89 |
}
|
| 90 |
self.tab_widget = QTabWidget()
|
| 91 |
-
tab_b_w, self.table_b,
|
| 92 |
-
|
|
|
|
|
|
|
| 93 |
self.tab_widget.addTab(tab_b_w, "🌅 朝食")
|
| 94 |
self.tab_widget.addTab(tab_d_w, "🌆 ディナー")
|
| 95 |
layout.addWidget(self.tab_widget)
|
|
@@ -100,7 +104,7 @@ class ScheduleView(QWidget):
|
|
| 100 |
self._apply_styles()
|
| 101 |
|
| 102 |
def _make_tab_widget(self, slot: TimeSlot):
|
| 103 |
-
"""タブの中身 (QWidget, QTableWidget, toggle_btn) を生成"""
|
| 104 |
container = QWidget()
|
| 105 |
vbox = QVBoxLayout(container)
|
| 106 |
vbox.setContentsMargins(0, 6, 0, 0)
|
|
@@ -117,6 +121,16 @@ class ScheduleView(QWidget):
|
|
| 117 |
row_btn.addStretch()
|
| 118 |
vbox.addLayout(row_btn)
|
| 119 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
table = QTableWidget()
|
| 121 |
table.setEditTriggers(QTableWidget.EditTrigger.NoEditTriggers)
|
| 122 |
table.setSelectionMode(QAbstractItemView.SelectionMode.SingleSelection)
|
|
@@ -125,14 +139,18 @@ class ScheduleView(QWidget):
|
|
| 125 |
table.setAlternatingRowColors(False)
|
| 126 |
table.cellClicked.connect(
|
| 127 |
lambda r, c, s=slot, t=table: self._on_cell_clicked(r, c, t, s))
|
|
|
|
|
|
|
|
|
|
| 128 |
vbox.addWidget(table)
|
| 129 |
|
| 130 |
-
return container, table, btn
|
| 131 |
|
| 132 |
def _on_toggle_other(self, slot: TimeSlot, checked: bool):
|
| 133 |
self._show_other[slot] = checked
|
| 134 |
table = self.table_b if slot == TimeSlot.BREAKFAST else self.table_d
|
| 135 |
-
self.
|
|
|
|
| 136 |
|
| 137 |
def _apply_styles(self):
|
| 138 |
c = theme.c
|
|
@@ -142,7 +160,9 @@ class ScheduleView(QWidget):
|
|
| 142 |
)
|
| 143 |
self.status_label.setStyleSheet(f"color:{c['text2']}; font-size:11px;")
|
| 144 |
for lbl, color_key in self._status_legend_labels:
|
| 145 |
-
lbl.setStyleSheet(
|
|
|
|
|
|
|
| 146 |
for btn in (self._btn_other_b, self._btn_other_d):
|
| 147 |
btn.setStyleSheet(
|
| 148 |
f"QPushButton {{ background:{c['cell_other_slot']}; border:1px solid {c['border2']}; "
|
|
@@ -195,17 +215,20 @@ class ScheduleView(QWidget):
|
|
| 195 |
(r.employee_id, r.date): (r.breakfast, r.dinner)
|
| 196 |
for r in requests
|
| 197 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
|
| 199 |
def _render_table(self):
|
| 200 |
if not self._period or not self._employees:
|
| 201 |
return
|
| 202 |
-
self._render_slot_table(self.table_b, TimeSlot.BREAKFAST)
|
| 203 |
-
self._render_slot_table(self.table_d, TimeSlot.DINNER)
|
| 204 |
|
| 205 |
-
def _render_slot_table(self, table: QTableWidget, slot: TimeSlot):
|
| 206 |
dates = self._period.date_range()
|
| 207 |
|
| 208 |
-
# 列: 氏名 + 日付ごと + 合計
|
| 209 |
col_headers = ["氏名"]
|
| 210 |
col_date_strs: list[str | None] = [None]
|
| 211 |
for d in dates:
|
|
@@ -216,19 +239,32 @@ class ScheduleView(QWidget):
|
|
| 216 |
col_date_strs.append(None)
|
| 217 |
|
| 218 |
# 従業員フィルタリング
|
| 219 |
-
# 主メンバー: primary_timeslot が None(どちらでも)またはこのスロット専任
|
| 220 |
primary_emps = [e for e in self._employees
|
| 221 |
if e.primary_timeslot is None or e.primary_timeslot == slot]
|
| 222 |
-
# 他スロット専任メンバー
|
| 223 |
other_emps = [e for e in self._employees
|
| 224 |
if e.primary_timeslot is not None and e.primary_timeslot != slot]
|
| 225 |
other_ids = {e.id for e in other_emps}
|
| 226 |
-
|
| 227 |
show_other = self._show_other.get(slot, False)
|
| 228 |
display_emps = primary_emps + (other_emps if show_other else [])
|
| 229 |
|
| 230 |
-
#
|
| 231 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 232 |
for pos in Position:
|
| 233 |
rows_data.append(("summary", pos))
|
| 234 |
|
|
@@ -236,8 +272,8 @@ class ScheduleView(QWidget):
|
|
| 236 |
table.setColumnCount(len(col_headers))
|
| 237 |
table.setHorizontalHeaderLabels(col_headers)
|
| 238 |
table.setColumnWidth(0, 95)
|
| 239 |
-
for
|
| 240 |
-
table.setColumnWidth(
|
| 241 |
table.setColumnWidth(len(col_headers) - 1, 36)
|
| 242 |
table.horizontalHeader().setSectionResizeMode(0, QHeaderView.ResizeMode.Fixed)
|
| 243 |
|
|
@@ -254,10 +290,31 @@ class ScheduleView(QWidget):
|
|
| 254 |
|
| 255 |
for row_idx, (row_type, row_data) in enumerate(rows_data):
|
| 256 |
if row_type == "employee":
|
| 257 |
-
self._fill_emp_slot_row(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 258 |
else:
|
| 259 |
-
self._fill_summary_slot_row(
|
| 260 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 261 |
|
| 262 |
def _fill_emp_slot_row(self, table: QTableWidget, row: int, emp: Employee,
|
| 263 |
slot: TimeSlot, col_date_strs: list, other_ids: set = None):
|
|
@@ -269,8 +326,16 @@ class ScheduleView(QWidget):
|
|
| 269 |
suffix = f" ↔{other_slot.short_label()}" if is_other else ""
|
| 270 |
name_item = QTableWidgetItem(f"{emp.name}{pp}{suffix}\nH:{skill_b} K:{skill_k}")
|
| 271 |
name_item.setFont(QFont("", 9))
|
|
|
|
|
|
|
|
|
|
|
|
|
| 272 |
if is_other:
|
| 273 |
-
name_item.setBackground(QBrush(QColor(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 274 |
table.setItem(row, 0, name_item)
|
| 275 |
|
| 276 |
slot_v = slot.value
|
|
@@ -282,7 +347,6 @@ class ScheduleView(QWidget):
|
|
| 282 |
req = self._requests.get((emp.id, ds))
|
| 283 |
can_work = (req[0] if slot == TimeSlot.BREAKFAST else req[1]) if req else False
|
| 284 |
|
| 285 |
-
c = theme.c
|
| 286 |
if pos_v:
|
| 287 |
skill = emp.hall_skill if pos_v == "hall" else emp.kitchen_skill
|
| 288 |
badge = SKILL_BADGE.get(skill, "")
|
|
@@ -307,6 +371,7 @@ class ScheduleView(QWidget):
|
|
| 307 |
total_item = QTableWidgetItem(str(total))
|
| 308 |
total_item.setTextAlignment(Qt.AlignmentFlag.AlignCenter)
|
| 309 |
total_item.setFont(QFont("", 9, QFont.Weight.Bold))
|
|
|
|
| 310 |
table.setItem(row, len(col_date_strs) - 1, total_item)
|
| 311 |
|
| 312 |
def _fill_summary_slot_row(self, table: QTableWidget, row: int, pos: Position,
|
|
@@ -315,6 +380,7 @@ class ScheduleView(QWidget):
|
|
| 315 |
label_item = QTableWidgetItem(pos.label())
|
| 316 |
label_item.setFont(QFont("", 8, QFont.Weight.Bold))
|
| 317 |
label_item.setBackground(QBrush(QColor(theme.c["surface2"])))
|
|
|
|
| 318 |
table.setItem(row, 0, label_item)
|
| 319 |
|
| 320 |
constraint = SHIFT_CONSTRAINTS.get((slot, pos), {})
|
|
@@ -330,6 +396,7 @@ class ScheduleView(QWidget):
|
|
| 330 |
item = QTableWidgetItem(text)
|
| 331 |
item.setTextAlignment(Qt.AlignmentFlag.AlignCenter)
|
| 332 |
item.setFont(QFont("", 8))
|
|
|
|
| 333 |
c = theme.c
|
| 334 |
if cnt < min_req or ld < min_leader:
|
| 335 |
item.setBackground(QBrush(QColor(c["status_err"])))
|
|
@@ -341,12 +408,58 @@ class ScheduleView(QWidget):
|
|
| 341 |
|
| 342 |
table.setItem(row, len(col_date_strs) - 1, QTableWidgetItem(""))
|
| 343 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 344 |
def _on_cell_clicked(self, row: int, col: int, table: QTableWidget, slot: TimeSlot):
|
| 345 |
item = table.item(row, col)
|
| 346 |
if not item:
|
| 347 |
return
|
| 348 |
data = item.data(Qt.ItemDataRole.UserRole)
|
| 349 |
-
if not data:
|
| 350 |
return
|
| 351 |
|
| 352 |
state, emp_id, ds, slot_v = data
|
|
@@ -369,7 +482,10 @@ class ScheduleView(QWidget):
|
|
| 369 |
emp = next((e for e in self._employees if e.id == emp_id), None)
|
| 370 |
if not emp:
|
| 371 |
return
|
| 372 |
-
dlg = PositionSelectDialog(
|
|
|
|
|
|
|
|
|
|
| 373 |
if dlg.exec() == QDialog.DialogCode.Accepted and dlg.selected_position:
|
| 374 |
from models.schedule import ShiftAssignment
|
| 375 |
assignment = ShiftAssignment(emp_id, ds, slot, dlg.selected_position)
|
|
@@ -385,6 +501,265 @@ class ScheduleView(QWidget):
|
|
| 385 |
dlg.exec()
|
| 386 |
|
| 387 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 388 |
class PositionSelectDialog(QDialog):
|
| 389 |
def __init__(self, emp: Employee, ds: str, slot: TimeSlot, all_employees, assignments, period_id, parent=None):
|
| 390 |
super().__init__(parent)
|
|
@@ -400,17 +775,18 @@ class PositionSelectDialog(QDialog):
|
|
| 400 |
layout.addWidget(QLabel(f"従業員: {emp.name}"))
|
| 401 |
layout.addWidget(QLabel(""))
|
| 402 |
|
| 403 |
-
# 各ポジションの現在の状況
|
| 404 |
for pos in Position:
|
| 405 |
key = (slot, pos)
|
| 406 |
constraint = SHIFT_CONSTRAINTS.get(key, {})
|
| 407 |
-
current = sum(
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
|
|
|
|
|
|
| 414 |
|
| 415 |
emp_skill = emp.skill_for(pos.value)
|
| 416 |
badge = SKILL_BADGE.get(emp_skill, "")
|
|
|
|
| 7 |
QComboBox, QTableWidget, QTableWidgetItem, QHeaderView,
|
| 8 |
QGroupBox, QDialog, QListWidget, QListWidgetItem,
|
| 9 |
QDialogButtonBox, QScrollArea, QSizePolicy, QFrame,
|
| 10 |
+
QMessageBox, QAbstractItemView, QTabWidget, QScrollBar
|
| 11 |
)
|
| 12 |
from PyQt6.QtCore import Qt, pyqtSignal
|
| 13 |
+
from PyQt6.QtGui import QFont, QColor, QBrush, QPainter, QPen, QFontMetrics
|
| 14 |
from db import repositories as repo
|
| 15 |
from models.employee import Employee
|
| 16 |
+
from models.schedule import ShiftAssignment, ShiftRequest
|
| 17 |
from utils.constants import (
|
| 18 |
+
TimeSlot, Position, PrimaryPosition, SkillLevel, DAY_OF_WEEK_LABELS,
|
| 19 |
SHIFT_CONSTRAINTS
|
| 20 |
)
|
| 21 |
from utils.theme import theme
|
|
|
|
| 29 |
}
|
| 30 |
|
| 31 |
# セル色
|
| 32 |
+
COLOR_OK = QColor("#d1fae5")
|
| 33 |
+
COLOR_WARN = QColor("#fef3c7")
|
| 34 |
+
COLOR_ERROR = QColor("#fee2e2")
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
|
| 37 |
class ScheduleView(QWidget):
|
|
|
|
| 39 |
super().__init__(parent)
|
| 40 |
self._period = None
|
| 41 |
self._employees: list[Employee] = []
|
| 42 |
+
self._assignments: dict[tuple[int, str, str], str] = {}
|
| 43 |
self._requests: dict[tuple[int, str], tuple[bool, bool]] = {}
|
| 44 |
+
self._raw_requests: dict[tuple[int, str], ShiftRequest] = {}
|
| 45 |
self._build_ui()
|
| 46 |
self._load_periods()
|
| 47 |
|
|
|
|
| 72 |
# 凡例
|
| 73 |
legend = QHBoxLayout()
|
| 74 |
self._status_legend_labels: list[tuple[QLabel, str]] = []
|
| 75 |
+
for text, color_key in [
|
| 76 |
+
("✅制約クリア", "status_ok"),
|
| 77 |
+
("⚠️最低人数ちょうど", "status_warn"),
|
| 78 |
+
("❌制約違反", "status_err"),
|
| 79 |
+
]:
|
| 80 |
lbl = QLabel(text)
|
| 81 |
self._status_legend_labels.append((lbl, color_key))
|
| 82 |
legend.addWidget(lbl)
|
|
|
|
| 90 |
TimeSlot.DINNER: False,
|
| 91 |
}
|
| 92 |
self.tab_widget = QTabWidget()
|
| 93 |
+
(tab_b_w, self.table_b,
|
| 94 |
+
self._btn_other_b, self._warn_label_b) = self._make_tab_widget(TimeSlot.BREAKFAST)
|
| 95 |
+
(tab_d_w, self.table_d,
|
| 96 |
+
self._btn_other_d, self._warn_label_d) = self._make_tab_widget(TimeSlot.DINNER)
|
| 97 |
self.tab_widget.addTab(tab_b_w, "🌅 朝食")
|
| 98 |
self.tab_widget.addTab(tab_d_w, "🌆 ディナー")
|
| 99 |
layout.addWidget(self.tab_widget)
|
|
|
|
| 104 |
self._apply_styles()
|
| 105 |
|
| 106 |
def _make_tab_widget(self, slot: TimeSlot):
|
| 107 |
+
"""タブの中身 (QWidget, QTableWidget, toggle_btn, warn_label) を生成"""
|
| 108 |
container = QWidget()
|
| 109 |
vbox = QVBoxLayout(container)
|
| 110 |
vbox.setContentsMargins(0, 6, 0, 0)
|
|
|
|
| 121 |
row_btn.addStretch()
|
| 122 |
vbox.addLayout(row_btn)
|
| 123 |
|
| 124 |
+
# 制約違反警告ラベル
|
| 125 |
+
warn_label = QLabel("")
|
| 126 |
+
warn_label.setWordWrap(True)
|
| 127 |
+
warn_label.setVisible(False)
|
| 128 |
+
warn_label.setStyleSheet(
|
| 129 |
+
"background:#fef2f2; border:1px solid #fca5a5; border-radius:4px; "
|
| 130 |
+
"padding:4px 8px; font-size:11px;"
|
| 131 |
+
)
|
| 132 |
+
vbox.addWidget(warn_label)
|
| 133 |
+
|
| 134 |
table = QTableWidget()
|
| 135 |
table.setEditTriggers(QTableWidget.EditTrigger.NoEditTriggers)
|
| 136 |
table.setSelectionMode(QAbstractItemView.SelectionMode.SingleSelection)
|
|
|
|
| 139 |
table.setAlternatingRowColors(False)
|
| 140 |
table.cellClicked.connect(
|
| 141 |
lambda r, c, s=slot, t=table: self._on_cell_clicked(r, c, t, s))
|
| 142 |
+
# 日付ヘッダークリック → タイムライン表示
|
| 143 |
+
table.horizontalHeader().sectionClicked.connect(
|
| 144 |
+
lambda col, s=slot, t=table: self._on_date_header_clicked(col, s, t))
|
| 145 |
vbox.addWidget(table)
|
| 146 |
|
| 147 |
+
return container, table, btn, warn_label
|
| 148 |
|
| 149 |
def _on_toggle_other(self, slot: TimeSlot, checked: bool):
|
| 150 |
self._show_other[slot] = checked
|
| 151 |
table = self.table_b if slot == TimeSlot.BREAKFAST else self.table_d
|
| 152 |
+
warn = self._warn_label_b if slot == TimeSlot.BREAKFAST else self._warn_label_d
|
| 153 |
+
self._render_slot_table(table, slot, warn)
|
| 154 |
|
| 155 |
def _apply_styles(self):
|
| 156 |
c = theme.c
|
|
|
|
| 160 |
)
|
| 161 |
self.status_label.setStyleSheet(f"color:{c['text2']}; font-size:11px;")
|
| 162 |
for lbl, color_key in self._status_legend_labels:
|
| 163 |
+
lbl.setStyleSheet(
|
| 164 |
+
f"background:{c[color_key]}; border-radius:3px; padding:2px 8px; font-size:11px;"
|
| 165 |
+
)
|
| 166 |
for btn in (self._btn_other_b, self._btn_other_d):
|
| 167 |
btn.setStyleSheet(
|
| 168 |
f"QPushButton {{ background:{c['cell_other_slot']}; border:1px solid {c['border2']}; "
|
|
|
|
| 215 |
(r.employee_id, r.date): (r.breakfast, r.dinner)
|
| 216 |
for r in requests
|
| 217 |
}
|
| 218 |
+
self._raw_requests = {
|
| 219 |
+
(r.employee_id, r.date): r
|
| 220 |
+
for r in requests
|
| 221 |
+
}
|
| 222 |
|
| 223 |
def _render_table(self):
|
| 224 |
if not self._period or not self._employees:
|
| 225 |
return
|
| 226 |
+
self._render_slot_table(self.table_b, TimeSlot.BREAKFAST, self._warn_label_b)
|
| 227 |
+
self._render_slot_table(self.table_d, TimeSlot.DINNER, self._warn_label_d)
|
| 228 |
|
| 229 |
+
def _render_slot_table(self, table: QTableWidget, slot: TimeSlot, warn_label: QLabel):
|
| 230 |
dates = self._period.date_range()
|
| 231 |
|
|
|
|
| 232 |
col_headers = ["氏名"]
|
| 233 |
col_date_strs: list[str | None] = [None]
|
| 234 |
for d in dates:
|
|
|
|
| 239 |
col_date_strs.append(None)
|
| 240 |
|
| 241 |
# 従業員フィルタリング
|
|
|
|
| 242 |
primary_emps = [e for e in self._employees
|
| 243 |
if e.primary_timeslot is None or e.primary_timeslot == slot]
|
|
|
|
| 244 |
other_emps = [e for e in self._employees
|
| 245 |
if e.primary_timeslot is not None and e.primary_timeslot != slot]
|
| 246 |
other_ids = {e.id for e in other_emps}
|
|
|
|
| 247 |
show_other = self._show_other.get(slot, False)
|
| 248 |
display_emps = primary_emps + (other_emps if show_other else [])
|
| 249 |
|
| 250 |
+
# ポジション別グループ分け
|
| 251 |
+
hall_emps = [e for e in display_emps
|
| 252 |
+
if e.primary_position is not None and e.primary_position.value == "hall"]
|
| 253 |
+
any_emps = [e for e in display_emps if e.primary_position is None]
|
| 254 |
+
kit_emps = [e for e in display_emps
|
| 255 |
+
if e.primary_position is not None and e.primary_position.value == "kitchen"]
|
| 256 |
+
|
| 257 |
+
rows_data: list[tuple] = []
|
| 258 |
+
for group_label, group_emps in [
|
| 259 |
+
("ホール専任", hall_emps),
|
| 260 |
+
("どちらでも", any_emps),
|
| 261 |
+
("キッチン専任", kit_emps),
|
| 262 |
+
]:
|
| 263 |
+
if not group_emps:
|
| 264 |
+
continue
|
| 265 |
+
rows_data.append(("divider", group_label))
|
| 266 |
+
for emp in group_emps:
|
| 267 |
+
rows_data.append(("employee", emp))
|
| 268 |
for pos in Position:
|
| 269 |
rows_data.append(("summary", pos))
|
| 270 |
|
|
|
|
| 272 |
table.setColumnCount(len(col_headers))
|
| 273 |
table.setHorizontalHeaderLabels(col_headers)
|
| 274 |
table.setColumnWidth(0, 95)
|
| 275 |
+
for c_idx in range(1, len(col_headers) - 1):
|
| 276 |
+
table.setColumnWidth(c_idx, 50)
|
| 277 |
table.setColumnWidth(len(col_headers) - 1, 36)
|
| 278 |
table.horizontalHeader().setSectionResizeMode(0, QHeaderView.ResizeMode.Fixed)
|
| 279 |
|
|
|
|
| 290 |
|
| 291 |
for row_idx, (row_type, row_data) in enumerate(rows_data):
|
| 292 |
if row_type == "employee":
|
| 293 |
+
self._fill_emp_slot_row(
|
| 294 |
+
table, row_idx, row_data, slot, col_date_strs, other_ids)
|
| 295 |
+
table.setRowHeight(row_idx, 28)
|
| 296 |
+
elif row_type == "divider":
|
| 297 |
+
self._fill_divider_row(table, row_idx, row_data, len(col_headers))
|
| 298 |
+
table.setRowHeight(row_idx, 18)
|
| 299 |
else:
|
| 300 |
+
self._fill_summary_slot_row(
|
| 301 |
+
table, row_idx, row_data, slot, col_date_strs, count_map, leader_map)
|
| 302 |
+
table.setRowHeight(row_idx, 28)
|
| 303 |
+
|
| 304 |
+
# 制約違反の警告更新
|
| 305 |
+
self._update_constraint_warnings(warn_label, slot, dates, count_map, leader_map)
|
| 306 |
+
|
| 307 |
+
def _fill_divider_row(self, table: QTableWidget, row: int, label: str, col_count: int):
|
| 308 |
+
"""ポジショングループの区切り行"""
|
| 309 |
+
c = theme.c
|
| 310 |
+
bg = QBrush(QColor(c["surface2"]))
|
| 311 |
+
for col in range(col_count):
|
| 312 |
+
item = QTableWidgetItem(label if col == 0 else "")
|
| 313 |
+
item.setBackground(bg)
|
| 314 |
+
item.setFont(QFont("", 8, QFont.Weight.Bold))
|
| 315 |
+
item.setForeground(QBrush(QColor(c["text3"])))
|
| 316 |
+
item.setFlags(Qt.ItemFlag.ItemIsEnabled) # 選択・編集不可
|
| 317 |
+
table.setItem(row, col, item)
|
| 318 |
|
| 319 |
def _fill_emp_slot_row(self, table: QTableWidget, row: int, emp: Employee,
|
| 320 |
slot: TimeSlot, col_date_strs: list, other_ids: set = None):
|
|
|
|
| 326 |
suffix = f" ↔{other_slot.short_label()}" if is_other else ""
|
| 327 |
name_item = QTableWidgetItem(f"{emp.name}{pp}{suffix}\nH:{skill_b} K:{skill_k}")
|
| 328 |
name_item.setFont(QFont("", 9))
|
| 329 |
+
name_item.setFlags(Qt.ItemFlag.ItemIsEnabled)
|
| 330 |
+
|
| 331 |
+
# ポジション専任で背景色を区別
|
| 332 |
+
c = theme.c
|
| 333 |
if is_other:
|
| 334 |
+
name_item.setBackground(QBrush(QColor(c["cell_other_slot"])))
|
| 335 |
+
elif emp.primary_position and emp.primary_position.value == "hall":
|
| 336 |
+
name_item.setBackground(QBrush(QColor(c["cell_breakfast"])))
|
| 337 |
+
elif emp.primary_position and emp.primary_position.value == "kitchen":
|
| 338 |
+
name_item.setBackground(QBrush(QColor(c["cell_double"])))
|
| 339 |
table.setItem(row, 0, name_item)
|
| 340 |
|
| 341 |
slot_v = slot.value
|
|
|
|
| 347 |
req = self._requests.get((emp.id, ds))
|
| 348 |
can_work = (req[0] if slot == TimeSlot.BREAKFAST else req[1]) if req else False
|
| 349 |
|
|
|
|
| 350 |
if pos_v:
|
| 351 |
skill = emp.hall_skill if pos_v == "hall" else emp.kitchen_skill
|
| 352 |
badge = SKILL_BADGE.get(skill, "")
|
|
|
|
| 371 |
total_item = QTableWidgetItem(str(total))
|
| 372 |
total_item.setTextAlignment(Qt.AlignmentFlag.AlignCenter)
|
| 373 |
total_item.setFont(QFont("", 9, QFont.Weight.Bold))
|
| 374 |
+
total_item.setFlags(Qt.ItemFlag.ItemIsEnabled)
|
| 375 |
table.setItem(row, len(col_date_strs) - 1, total_item)
|
| 376 |
|
| 377 |
def _fill_summary_slot_row(self, table: QTableWidget, row: int, pos: Position,
|
|
|
|
| 380 |
label_item = QTableWidgetItem(pos.label())
|
| 381 |
label_item.setFont(QFont("", 8, QFont.Weight.Bold))
|
| 382 |
label_item.setBackground(QBrush(QColor(theme.c["surface2"])))
|
| 383 |
+
label_item.setFlags(Qt.ItemFlag.ItemIsEnabled)
|
| 384 |
table.setItem(row, 0, label_item)
|
| 385 |
|
| 386 |
constraint = SHIFT_CONSTRAINTS.get((slot, pos), {})
|
|
|
|
| 396 |
item = QTableWidgetItem(text)
|
| 397 |
item.setTextAlignment(Qt.AlignmentFlag.AlignCenter)
|
| 398 |
item.setFont(QFont("", 8))
|
| 399 |
+
item.setFlags(Qt.ItemFlag.ItemIsEnabled)
|
| 400 |
c = theme.c
|
| 401 |
if cnt < min_req or ld < min_leader:
|
| 402 |
item.setBackground(QBrush(QColor(c["status_err"])))
|
|
|
|
| 408 |
|
| 409 |
table.setItem(row, len(col_date_strs) - 1, QTableWidgetItem(""))
|
| 410 |
|
| 411 |
+
def _update_constraint_warnings(self, warn_label: QLabel, slot: TimeSlot,
|
| 412 |
+
dates: list, count_map: dict, leader_map: dict):
|
| 413 |
+
"""制約違反を集計してタブの警告ラベルに表示"""
|
| 414 |
+
violations = []
|
| 415 |
+
for d in dates:
|
| 416 |
+
ds = d.isoformat()
|
| 417 |
+
d_label = f"{d.month}/{d.day}({DAY_OF_WEEK_LABELS[d.weekday()]})"
|
| 418 |
+
for pos in Position:
|
| 419 |
+
cnt = count_map[(ds, pos.value)]
|
| 420 |
+
ld = leader_map[(ds, pos.value)]
|
| 421 |
+
constraint = SHIFT_CONSTRAINTS.get((slot, pos), {})
|
| 422 |
+
min_req = constraint.get("min", 0)
|
| 423 |
+
min_leader = constraint.get("min_leader", 0)
|
| 424 |
+
if cnt < min_req:
|
| 425 |
+
violations.append(
|
| 426 |
+
f"❌ {d_label} {pos.label()}: {cnt}/{min_req}名不足"
|
| 427 |
+
)
|
| 428 |
+
elif ld < min_leader:
|
| 429 |
+
violations.append(
|
| 430 |
+
f"⚠️ {d_label} {pos.label()}: リーダー{ld}/{min_leader}名不足"
|
| 431 |
+
)
|
| 432 |
+
|
| 433 |
+
if violations:
|
| 434 |
+
warn_label.setText(" ".join(violations))
|
| 435 |
+
warn_label.setVisible(True)
|
| 436 |
+
else:
|
| 437 |
+
warn_label.setVisible(False)
|
| 438 |
+
|
| 439 |
+
def _on_date_header_clicked(self, col: int, slot: TimeSlot, table: QTableWidget):
|
| 440 |
+
"""日付列ヘッダークリック → その日のタイムライン表示"""
|
| 441 |
+
if col == 0 or col >= table.columnCount() - 1:
|
| 442 |
+
return # 氏名列・計列は無視
|
| 443 |
+
header_text = table.horizontalHeaderItem(col)
|
| 444 |
+
if not header_text:
|
| 445 |
+
return
|
| 446 |
+
dates = self._period.date_range()
|
| 447 |
+
date_idx = col - 1 # col=1 が dates[0]
|
| 448 |
+
if date_idx < 0 or date_idx >= len(dates):
|
| 449 |
+
return
|
| 450 |
+
ds = dates[date_idx].isoformat()
|
| 451 |
+
dlg = DayTimetableDialog(
|
| 452 |
+
ds, self._employees, self._assignments,
|
| 453 |
+
self._raw_requests, parent=self
|
| 454 |
+
)
|
| 455 |
+
dlg.exec()
|
| 456 |
+
|
| 457 |
def _on_cell_clicked(self, row: int, col: int, table: QTableWidget, slot: TimeSlot):
|
| 458 |
item = table.item(row, col)
|
| 459 |
if not item:
|
| 460 |
return
|
| 461 |
data = item.data(Qt.ItemDataRole.UserRole)
|
| 462 |
+
if not data or not isinstance(data, tuple) or data[0] not in ("assigned", "available"):
|
| 463 |
return
|
| 464 |
|
| 465 |
state, emp_id, ds, slot_v = data
|
|
|
|
| 482 |
emp = next((e for e in self._employees if e.id == emp_id), None)
|
| 483 |
if not emp:
|
| 484 |
return
|
| 485 |
+
dlg = PositionSelectDialog(
|
| 486 |
+
emp, ds, slot, self._employees, self._assignments,
|
| 487 |
+
self._period.id, parent=self
|
| 488 |
+
)
|
| 489 |
if dlg.exec() == QDialog.DialogCode.Accepted and dlg.selected_position:
|
| 490 |
from models.schedule import ShiftAssignment
|
| 491 |
assignment = ShiftAssignment(emp_id, ds, slot, dlg.selected_position)
|
|
|
|
| 501 |
dlg.exec()
|
| 502 |
|
| 503 |
|
| 504 |
+
# ── タイムラインダイアログ ─────────────────────────────────────────────
|
| 505 |
+
|
| 506 |
+
class DayTimetableDialog(QDialog):
|
| 507 |
+
"""1日分の希望シフトをタイムライン形式で表示するダイアログ"""
|
| 508 |
+
|
| 509 |
+
def __init__(self, date_str: str, employees: list[Employee],
|
| 510 |
+
assignments: dict, raw_requests: dict, parent=None):
|
| 511 |
+
super().__init__(parent)
|
| 512 |
+
d = date.fromisoformat(date_str)
|
| 513 |
+
dow = DAY_OF_WEEK_LABELS[d.weekday()]
|
| 514 |
+
self.setWindowTitle(f"{d.month}月{d.day}日({dow}) シフト希望タイムライン")
|
| 515 |
+
self.setMinimumWidth(750)
|
| 516 |
+
self.setMinimumHeight(400)
|
| 517 |
+
|
| 518 |
+
layout = QVBoxLayout(self)
|
| 519 |
+
layout.setSpacing(8)
|
| 520 |
+
|
| 521 |
+
# 説明ラベル
|
| 522 |
+
info = QLabel(
|
| 523 |
+
"■ 朝食帯(6-11時) ■ ディナー帯(17-23時) "
|
| 524 |
+
"濃色=アサイン済 / 薄色=希望のみ / 赤背景=不足時間帯"
|
| 525 |
+
)
|
| 526 |
+
info.setStyleSheet("font-size:11px; color:#6b7280;")
|
| 527 |
+
layout.addWidget(info)
|
| 528 |
+
|
| 529 |
+
# タイムラインウィジェット(スクロール可)
|
| 530 |
+
scroll = QScrollArea()
|
| 531 |
+
scroll.setWidgetResizable(True)
|
| 532 |
+
scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
|
| 533 |
+
|
| 534 |
+
tl = _TimetableWidget(date_str, employees, assignments, raw_requests)
|
| 535 |
+
scroll.setWidget(tl)
|
| 536 |
+
layout.addWidget(scroll)
|
| 537 |
+
|
| 538 |
+
# 凡例
|
| 539 |
+
legend_row = QHBoxLayout()
|
| 540 |
+
for color, text in [
|
| 541 |
+
("#3b82f6", "朝食アサイン"), ("#93c5fd", "朝食希望"),
|
| 542 |
+
("#ec4899", "ディナーアサイン"), ("#f9a8d4", "ディナー希望"),
|
| 543 |
+
("#22c55e", "ダブルアサイン"), ("#86efac", "ダブル希望"),
|
| 544 |
+
]:
|
| 545 |
+
dot = QLabel("●")
|
| 546 |
+
dot.setStyleSheet(f"color:{color}; font-size:16px;")
|
| 547 |
+
legend_row.addWidget(dot)
|
| 548 |
+
legend_row.addWidget(QLabel(text))
|
| 549 |
+
legend_row.addStretch()
|
| 550 |
+
layout.addLayout(legend_row)
|
| 551 |
+
|
| 552 |
+
btn = QPushButton("閉じる")
|
| 553 |
+
btn.clicked.connect(self.accept)
|
| 554 |
+
layout.addWidget(btn)
|
| 555 |
+
|
| 556 |
+
|
| 557 |
+
class _TimetableWidget(QWidget):
|
| 558 |
+
"""1日分のシフトをタイムラインとして描画するカスタムウィジェット"""
|
| 559 |
+
|
| 560 |
+
TIME_START = 5.0 # 5:00
|
| 561 |
+
TIME_END = 24.0 # 24:00
|
| 562 |
+
MARGIN_LEFT = 110
|
| 563 |
+
MARGIN_TOP = 28
|
| 564 |
+
MARGIN_RIGHT = 12
|
| 565 |
+
ROW_H = 22
|
| 566 |
+
COVERAGE_H = 48
|
| 567 |
+
|
| 568 |
+
def __init__(self, date_str: str, employees: list[Employee],
|
| 569 |
+
assignments: dict, raw_requests: dict, parent=None):
|
| 570 |
+
super().__init__(parent)
|
| 571 |
+
self._date_str = date_str
|
| 572 |
+
self._assignments = assignments
|
| 573 |
+
self._rows = self._build_rows(employees, assignments, raw_requests, date_str)
|
| 574 |
+
n = max(1, len(self._rows))
|
| 575 |
+
total_h = self.MARGIN_TOP + n * self.ROW_H + self.COVERAGE_H + 16
|
| 576 |
+
self.setMinimumHeight(total_h)
|
| 577 |
+
self.setMinimumWidth(700)
|
| 578 |
+
|
| 579 |
+
@staticmethod
|
| 580 |
+
def _parse_hour(t: str) -> float:
|
| 581 |
+
try:
|
| 582 |
+
h, m = map(int, t.split(":"))
|
| 583 |
+
return h + m / 60.0
|
| 584 |
+
except Exception:
|
| 585 |
+
return 0.0
|
| 586 |
+
|
| 587 |
+
@classmethod
|
| 588 |
+
def _build_rows(cls, employees, assignments, raw_requests, ds):
|
| 589 |
+
from utils.shift_patterns import PATTERN_MAP
|
| 590 |
+
rows = []
|
| 591 |
+
for emp in employees:
|
| 592 |
+
req = raw_requests.get((emp.id, ds))
|
| 593 |
+
if not req:
|
| 594 |
+
continue
|
| 595 |
+
if not req.breakfast and not req.dinner:
|
| 596 |
+
continue
|
| 597 |
+
|
| 598 |
+
start_h, end_h = None, None
|
| 599 |
+
force_both = False
|
| 600 |
+
|
| 601 |
+
if req.pattern_id and req.pattern_id != "custom":
|
| 602 |
+
p = PATTERN_MAP.get(req.pattern_id)
|
| 603 |
+
if p:
|
| 604 |
+
if p.force_both:
|
| 605 |
+
force_both = True
|
| 606 |
+
start_h = 6.0
|
| 607 |
+
end_h = 23.0
|
| 608 |
+
else:
|
| 609 |
+
start_h = p.start_hour()
|
| 610 |
+
end_h = p.end_hour()
|
| 611 |
+
elif req.pattern_id == "custom":
|
| 612 |
+
if req.custom_start:
|
| 613 |
+
start_h = cls._parse_hour(req.custom_start)
|
| 614 |
+
if req.custom_end:
|
| 615 |
+
end_h = cls._parse_hour(req.custom_end)
|
| 616 |
+
|
| 617 |
+
if start_h is None:
|
| 618 |
+
start_h = 6.0 if req.breakfast else 17.0
|
| 619 |
+
if end_h is None:
|
| 620 |
+
end_h = 11.0 if not req.dinner else 23.0
|
| 621 |
+
|
| 622 |
+
assigned_b = (emp.id, ds, "breakfast") in {
|
| 623 |
+
(eid, d2, s) for (eid, d2, s) in assignments if d2 == ds
|
| 624 |
+
}
|
| 625 |
+
assigned_d = (emp.id, ds, "dinner") in {
|
| 626 |
+
(eid, d2, s) for (eid, d2, s) in assignments if d2 == ds
|
| 627 |
+
}
|
| 628 |
+
|
| 629 |
+
rows.append({
|
| 630 |
+
"emp": emp,
|
| 631 |
+
"start_h": start_h,
|
| 632 |
+
"end_h": end_h,
|
| 633 |
+
"breakfast": req.breakfast,
|
| 634 |
+
"dinner": req.dinner,
|
| 635 |
+
"force_both": force_both,
|
| 636 |
+
"assigned_b": assigned_b,
|
| 637 |
+
"assigned_d": assigned_d,
|
| 638 |
+
})
|
| 639 |
+
return rows
|
| 640 |
+
|
| 641 |
+
def _x(self, hour: float, width: int) -> int:
|
| 642 |
+
span = self.TIME_END - self.TIME_START
|
| 643 |
+
usable = width - self.MARGIN_LEFT - self.MARGIN_RIGHT
|
| 644 |
+
return self.MARGIN_LEFT + int((hour - self.TIME_START) / span * usable)
|
| 645 |
+
|
| 646 |
+
def paintEvent(self, event):
|
| 647 |
+
painter = QPainter(self)
|
| 648 |
+
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
|
| 649 |
+
W = self.width()
|
| 650 |
+
c = theme.c
|
| 651 |
+
|
| 652 |
+
bg = QColor(c["bg"])
|
| 653 |
+
painter.fillRect(self.rect(), bg)
|
| 654 |
+
|
| 655 |
+
# 時間帯ゾーン背景
|
| 656 |
+
b_start_x = self._x(6, W)
|
| 657 |
+
b_end_x = self._x(11, W)
|
| 658 |
+
d_start_x = self._x(17, W)
|
| 659 |
+
d_end_x = self._x(23, W)
|
| 660 |
+
zone_h = self.MARGIN_TOP + len(self._rows) * self.ROW_H + self.COVERAGE_H
|
| 661 |
+
|
| 662 |
+
painter.fillRect(b_start_x, 0, b_end_x - b_start_x, zone_h, QColor("#eff6ff"))
|
| 663 |
+
painter.fillRect(d_start_x, 0, d_end_x - d_start_x, zone_h, QColor("#fdf2f8"))
|
| 664 |
+
|
| 665 |
+
# 時間軸
|
| 666 |
+
painter.setPen(QPen(QColor(c["border"]), 1))
|
| 667 |
+
font_sm = QFont("", 8)
|
| 668 |
+
painter.setFont(font_sm)
|
| 669 |
+
for h in range(int(self.TIME_START), int(self.TIME_END) + 1):
|
| 670 |
+
x = self._x(h, W)
|
| 671 |
+
painter.drawLine(x, self.MARGIN_TOP - 6, x, self.MARGIN_TOP + len(self._rows) * self.ROW_H + self.COVERAGE_H)
|
| 672 |
+
painter.setPen(QColor(c["text2"]))
|
| 673 |
+
painter.drawText(x - 10, self.MARGIN_TOP - 8, f"{h}:00")
|
| 674 |
+
painter.setPen(QPen(QColor(c["border"]), 1))
|
| 675 |
+
|
| 676 |
+
# 各従業員バー
|
| 677 |
+
painter.setFont(QFont("", 9))
|
| 678 |
+
for i, row in enumerate(self._rows):
|
| 679 |
+
y = self.MARGIN_TOP + i * self.ROW_H
|
| 680 |
+
cy = y + self.ROW_H // 2
|
| 681 |
+
|
| 682 |
+
# 名前
|
| 683 |
+
painter.setPen(QColor(c["text"]))
|
| 684 |
+
painter.drawText(4, cy + 5, row["emp"].name)
|
| 685 |
+
|
| 686 |
+
# バーの色決定
|
| 687 |
+
is_b = row["breakfast"]
|
| 688 |
+
is_d = row["dinner"]
|
| 689 |
+
is_both = row["force_both"] or (is_b and is_d)
|
| 690 |
+
assigned = row["assigned_b"] or row["assigned_d"]
|
| 691 |
+
|
| 692 |
+
if is_both:
|
| 693 |
+
bar_color = QColor("#22c55e") if assigned else QColor("#86efac")
|
| 694 |
+
elif is_b:
|
| 695 |
+
bar_color = QColor("#3b82f6") if row["assigned_b"] else QColor("#93c5fd")
|
| 696 |
+
else:
|
| 697 |
+
bar_color = QColor("#ec4899") if row["assigned_d"] else QColor("#f9a8d4")
|
| 698 |
+
|
| 699 |
+
x1 = self._x(row["start_h"], W)
|
| 700 |
+
x2 = self._x(row["end_h"], W)
|
| 701 |
+
bar_h = self.ROW_H - 4
|
| 702 |
+
painter.fillRect(x1, y + 2, max(2, x2 - x1), bar_h, bar_color)
|
| 703 |
+
|
| 704 |
+
# バー上に時刻テキスト
|
| 705 |
+
start_str = f"{int(row['start_h'])}:{int((row['start_h'] % 1) * 60):02d}"
|
| 706 |
+
end_str = f"{int(row['end_h'])}:{int((row['end_h'] % 1) * 60):02d}"
|
| 707 |
+
painter.setPen(QColor("#ffffff") if assigned else QColor(c["text"]))
|
| 708 |
+
painter.setFont(QFont("", 8))
|
| 709 |
+
if x2 - x1 > 50:
|
| 710 |
+
painter.drawText(x1 + 3, cy + 4, f"{start_str}〜{end_str}")
|
| 711 |
+
painter.setFont(QFont("", 9))
|
| 712 |
+
|
| 713 |
+
# カバレッジバー(下段)
|
| 714 |
+
cov_y = self.MARGIN_TOP + len(self._rows) * self.ROW_H + 4
|
| 715 |
+
painter.setPen(QColor(c["text2"]))
|
| 716 |
+
painter.setFont(QFont("", 8))
|
| 717 |
+
painter.drawText(4, cov_y + 14, "人数")
|
| 718 |
+
|
| 719 |
+
# 1時間ごとの在籍人数を計算
|
| 720 |
+
slot_hours = list(range(int(self.TIME_START), int(self.TIME_END)))
|
| 721 |
+
max_count = max(
|
| 722 |
+
sum(
|
| 723 |
+
1 for row in self._rows
|
| 724 |
+
if row["start_h"] <= h < row["end_h"]
|
| 725 |
+
)
|
| 726 |
+
for h in slot_hours
|
| 727 |
+
) if self._rows else 1
|
| 728 |
+
|
| 729 |
+
# 朝食・ディナーの最小必要人数(ホール+キッチン合計)
|
| 730 |
+
b_min = sum(SHIFT_CONSTRAINTS.get((TimeSlot.BREAKFAST, pos), {}).get("min", 0) for pos in Position)
|
| 731 |
+
d_min = sum(SHIFT_CONSTRAINTS.get((TimeSlot.DINNER, pos), {}).get("min", 0) for pos in Position)
|
| 732 |
+
|
| 733 |
+
bar_area_h = self.COVERAGE_H - 20
|
| 734 |
+
for h in slot_hours:
|
| 735 |
+
count = sum(
|
| 736 |
+
1 for row in self._rows
|
| 737 |
+
if row["start_h"] <= h < row["end_h"]
|
| 738 |
+
)
|
| 739 |
+
x1 = self._x(h, W)
|
| 740 |
+
x2 = self._x(h + 1, W)
|
| 741 |
+
bar_px = int(count / max(max_count, 1) * bar_area_h) if count > 0 else 0
|
| 742 |
+
|
| 743 |
+
# 不足判定
|
| 744 |
+
is_b_zone = 6 <= h < 11
|
| 745 |
+
is_d_zone = 17 <= h < 23
|
| 746 |
+
required = b_min if is_b_zone else (d_min if is_d_zone else 0)
|
| 747 |
+
shortage = required > 0 and count < required
|
| 748 |
+
|
| 749 |
+
color = QColor("#ef4444") if shortage else QColor("#60a5fa")
|
| 750 |
+
painter.fillRect(x1 + 1, cov_y + bar_area_h - bar_px + 4,
|
| 751 |
+
max(1, x2 - x1 - 2), bar_px, color)
|
| 752 |
+
|
| 753 |
+
# 人数テキスト
|
| 754 |
+
if count > 0:
|
| 755 |
+
painter.setPen(QColor(c["text"]))
|
| 756 |
+
painter.drawText(x1 + 2, cov_y + bar_area_h + 18, str(count))
|
| 757 |
+
|
| 758 |
+
painter.end()
|
| 759 |
+
|
| 760 |
+
|
| 761 |
+
# ── ポジション選択ダイアログ ─────────────────────────────────────────────
|
| 762 |
+
|
| 763 |
class PositionSelectDialog(QDialog):
|
| 764 |
def __init__(self, emp: Employee, ds: str, slot: TimeSlot, all_employees, assignments, period_id, parent=None):
|
| 765 |
super().__init__(parent)
|
|
|
|
| 775 |
layout.addWidget(QLabel(f"従業員: {emp.name}"))
|
| 776 |
layout.addWidget(QLabel(""))
|
| 777 |
|
|
|
|
| 778 |
for pos in Position:
|
| 779 |
key = (slot, pos)
|
| 780 |
constraint = SHIFT_CONSTRAINTS.get(key, {})
|
| 781 |
+
current = sum(
|
| 782 |
+
1 for (eid, d2, s2), p in assignments.items()
|
| 783 |
+
if d2 == ds and s2 == slot.value and p == pos.value
|
| 784 |
+
)
|
| 785 |
+
leaders = sum(
|
| 786 |
+
1 for (eid, d2, s2), p in assignments.items()
|
| 787 |
+
if d2 == ds and s2 == slot.value and p == pos.value
|
| 788 |
+
and any(x.id == eid and x.is_leader(pos.value) for x in all_employees)
|
| 789 |
+
)
|
| 790 |
|
| 791 |
emp_skill = emp.skill_for(pos.value)
|
| 792 |
badge = SKILL_BADGE.get(emp_skill, "")
|
ui/shift_input_view.py
CHANGED
|
@@ -216,12 +216,25 @@ class ShiftInputView(QWidget):
|
|
| 216 |
# 左右矢印キー: 従業員切り替え
|
| 217 |
QShortcut(QKeySequence(Qt.Key.Key_Left), self).activated.connect(self._on_prev_employee)
|
| 218 |
QShortcut(QKeySequence(Qt.Key.Key_Right), self).activated.connect(self._on_next_employee)
|
| 219 |
-
# 0〜9キー:
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 225 |
|
| 226 |
def _select_pattern_by_key(self, combo_index: int):
|
| 227 |
"""現在選択中の行のシフトパターンをコンボインデックスで設定"""
|
|
|
|
| 216 |
# 左右矢印キー: 従業員切り替え
|
| 217 |
QShortcut(QKeySequence(Qt.Key.Key_Left), self).activated.connect(self._on_prev_employee)
|
| 218 |
QShortcut(QKeySequence(Qt.Key.Key_Right), self).activated.connect(self._on_next_employee)
|
| 219 |
+
# 0〜9キー: QComboBox がフォーカスを持つときQShortcutが効かないため
|
| 220 |
+
# アプリレベルのイベントフィルタで処理する
|
| 221 |
+
from PyQt6.QtWidgets import QApplication
|
| 222 |
+
QApplication.instance().installEventFilter(self)
|
| 223 |
+
|
| 224 |
+
def eventFilter(self, obj, event):
|
| 225 |
+
from PyQt6.QtCore import QEvent
|
| 226 |
+
from PyQt6.QtWidgets import QApplication, QLineEdit
|
| 227 |
+
if self.isVisible() and event.type() == QEvent.Type.KeyPress:
|
| 228 |
+
focused = QApplication.focusWidget()
|
| 229 |
+
# テキスト入力中(備考欄・カスタム時刻欄)は横取りしない
|
| 230 |
+
if not isinstance(focused, QLineEdit):
|
| 231 |
+
key = event.key()
|
| 232 |
+
if Qt.Key.Key_0 <= key <= Qt.Key.Key_9:
|
| 233 |
+
idx = key - Qt.Key.Key_0
|
| 234 |
+
if idx < len(_COMBO_ITEMS):
|
| 235 |
+
self._select_pattern_by_key(idx)
|
| 236 |
+
return True
|
| 237 |
+
return False
|
| 238 |
|
| 239 |
def _select_pattern_by_key(self, combo_index: int):
|
| 240 |
"""現在選択中の行のシフトパターンをコンボインデックスで設定"""
|