refact
This commit is contained in:
parent
2e348e68b4
commit
aebdf2d7c9
@ -290,22 +290,11 @@ class Log:
|
||||
return None
|
||||
return log[-1][1]
|
||||
|
||||
def report(self):
|
||||
return Report(self._data)
|
||||
|
||||
def worklog(self):
|
||||
return Worklog(self._data)
|
||||
|
||||
|
||||
# TODO remove
|
||||
dEV = False
|
||||
|
||||
|
||||
def summary(lcd: LogCommentsData, pdate: date) -> Tuple[Dict[str, timedelta], timedelta]:
|
||||
log = lcd.get_log(pdate)
|
||||
if dEV:
|
||||
if pdate == date.today():
|
||||
log.append((datetime.now(), "End"))
|
||||
if pdate == date.today():
|
||||
log.append((datetime.now(), "End"))
|
||||
tasks_sums = {}
|
||||
total_sum = timedelta()
|
||||
for i, le in enumerate(log):
|
||||
|
@ -13,10 +13,10 @@ except ImportError:
|
||||
from PySide2 import QtCore, QtWidgets
|
||||
PYSIDE_6 = False
|
||||
|
||||
from fime.data import Tasks, Log, Data, LogCommentsData, Worklog
|
||||
from fime.data import Tasks, Log, Data, LogCommentsData, Worklog, Report
|
||||
from fime.exceptions import FimeException
|
||||
from fime.import_task import ImportTask
|
||||
from fime.report import Report
|
||||
from fime.report import ReportDialog
|
||||
from fime.task_edit import TaskEdit
|
||||
from fime.util import get_screen_height, get_icon
|
||||
|
||||
@ -29,7 +29,6 @@ class App:
|
||||
data = Data()
|
||||
self.tasks = Tasks(data)
|
||||
lcd = LogCommentsData(data)
|
||||
self.worklogData = Worklog(lcd)
|
||||
self.log = Log(lcd)
|
||||
self._active_task = self.log.last_log() or "Nothing"
|
||||
|
||||
@ -47,11 +46,11 @@ class App:
|
||||
self.taskEdit = TaskEdit(None)
|
||||
self.taskEdit.accepted.connect(self.tasks_edited)
|
||||
|
||||
self.reportDialog = Report(self.tasks, None)
|
||||
self.reportDialog.accepted.connect(self.report_done)
|
||||
self.reportDialog = ReportDialog(self.tasks, Report(lcd), None)
|
||||
self.reportDialog.accepted.connect(self.log_edited)
|
||||
|
||||
self.worklogDialog = WorklogDialog(config, None)
|
||||
self.worklogDialog.accepted.connect(self.report_done)
|
||||
self.worklogDialog = WorklogDialog(config, Worklog(lcd), None)
|
||||
self.worklogDialog.accepted.connect(self.log_edited)
|
||||
|
||||
self.tray = QtWidgets.QSystemTrayIcon()
|
||||
self.tray.setIcon(icon)
|
||||
@ -72,7 +71,7 @@ class App:
|
||||
self.update_tray_menu()
|
||||
|
||||
@QtCore.Slot()
|
||||
def report_done(self):
|
||||
def log_edited(self):
|
||||
self.active_task = self.log.last_log() or "Nothing"
|
||||
|
||||
@property
|
||||
@ -123,10 +122,10 @@ class App:
|
||||
edit_action.triggered.connect(self.edit_tasks)
|
||||
|
||||
report_action = self.menu.addAction("Report")
|
||||
report_action.triggered.connect(self.report)
|
||||
report_action.triggered.connect(self.reportDialog.show)
|
||||
|
||||
worklog_action = self.menu.addAction("Worklog")
|
||||
worklog_action.triggered.connect(self.worklog)
|
||||
worklog_action.triggered.connect(self.worklogDialog.show)
|
||||
|
||||
self.menu.addSeparator()
|
||||
|
||||
@ -149,16 +148,6 @@ class App:
|
||||
else:
|
||||
self.app.exec_()
|
||||
|
||||
@QtCore.Slot()
|
||||
def report(self):
|
||||
self.reportDialog.set_data(self.log.report())
|
||||
self.reportDialog.show()
|
||||
|
||||
@QtCore.Slot()
|
||||
def worklog(self):
|
||||
self.worklogDialog.set_data(self.worklogData)
|
||||
self.worklogDialog.show()
|
||||
|
||||
@QtCore.Slot()
|
||||
def new_task_slot(self):
|
||||
self.import_task.reset_task_text()
|
||||
|
@ -11,7 +11,7 @@ from fime.data import Tasks, Report
|
||||
from fime.util import get_screen_height, get_icon, EditStartedDetector
|
||||
|
||||
|
||||
class Report(QtWidgets.QDialog):
|
||||
class ReportDialog(QtWidgets.QDialog):
|
||||
class TaskItemCompleter(EditStartedDetector):
|
||||
def __init__(self, tasks: Tasks, parent=None):
|
||||
super().__init__(parent)
|
||||
@ -25,9 +25,9 @@ class Report(QtWidgets.QDialog):
|
||||
editor.setCompleter(completer)
|
||||
return editor
|
||||
|
||||
def __init__(self, tasks: Tasks, parent, *args, **kwargs):
|
||||
def __init__(self, tasks: Tasks, report: Report, parent, *args, **kwargs):
|
||||
super().__init__(parent, *args, **kwargs)
|
||||
self._report: Optional[Report] = None
|
||||
self._report = report
|
||||
self._report_data: Optional[List[List[str]]] = None
|
||||
self._changing_items = False
|
||||
self._new_log_task = ""
|
||||
@ -41,7 +41,7 @@ class Report(QtWidgets.QDialog):
|
||||
self.tableWidget.setColumnCount(3)
|
||||
self.tableWidget.setHorizontalHeaderLabels(["Task", "Start time", "Duration"])
|
||||
self.tableWidget.cellChanged.connect(self.cell_changed)
|
||||
taskItemCompleter = Report.TaskItemCompleter(tasks, self)
|
||||
taskItemCompleter = ReportDialog.TaskItemCompleter(tasks, self)
|
||||
taskItemCompleter.editStarted.connect(self.disable_buttons)
|
||||
taskItemCompleter.editFinished.connect(self.enable_buttons)
|
||||
self.tableWidget.setItemDelegateForColumn(0, taskItemCompleter)
|
||||
@ -97,8 +97,7 @@ class Report(QtWidgets.QDialog):
|
||||
layout.addLayout(blayout)
|
||||
self.setLayout(layout)
|
||||
|
||||
def set_data(self, data: Report):
|
||||
self._report = data
|
||||
def showEvent(self, _):
|
||||
self.update_title()
|
||||
self.refresh_table()
|
||||
self.update_prev_next()
|
||||
|
@ -1,6 +1,7 @@
|
||||
from functools import reduce, partial
|
||||
from typing import Optional, List, Tuple
|
||||
|
||||
from fime.config import Config
|
||||
from fime.data import Worklog, duration_to_str
|
||||
from fime.progressindicator import ProgressIndicator
|
||||
from fime.task_completer import TaskCompleter
|
||||
@ -92,13 +93,13 @@ class WorklogDialog(QtWidgets.QDialog):
|
||||
if not self.return_:
|
||||
self.edit_finished_row.emit(row)
|
||||
|
||||
def __init__(self, config, parent, *args, **kwargs):
|
||||
def __init__(self, config: Config, worklog: Worklog, parent, *args, **kwargs):
|
||||
super().__init__(parent, *args, **kwargs)
|
||||
|
||||
self.rest = WorklogRest(config)
|
||||
|
||||
self._changing_items = False
|
||||
self._worklog: Optional[Worklog] = None
|
||||
self._worklog = worklog
|
||||
self._worklog_data: List[List[str]] = []
|
||||
self._statuses: List[Tuple[Status, str]] = []
|
||||
self.row_height = None
|
||||
@ -170,8 +171,7 @@ class WorklogDialog(QtWidgets.QDialog):
|
||||
self.update_timer.setInterval(500)
|
||||
self.update_timer.timeout.connect(self.update_statuses)
|
||||
|
||||
def set_data(self, worklog: Worklog):
|
||||
self._worklog = worklog
|
||||
def showEvent(self, _):
|
||||
self.rest.purge_cache()
|
||||
self.update_all()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user