Fix worklog gui
This commit is contained in:
parent
210aaba92b
commit
169d9749af
@ -72,26 +72,27 @@ class WorklogDialog(QtWidgets.QDialog):
|
||||
def __init__(self, config, parent=None):
|
||||
super().__init__(parent)
|
||||
self.config = config
|
||||
#self.row = -1
|
||||
self.return_ = False
|
||||
|
||||
def createEditor(self, parent, option, index):
|
||||
editor = super().createEditor(parent, option, index)
|
||||
#self.row = index.row()
|
||||
#editor.editingFinished.connect(partial(self.edit_finished_row_target, index.row()))
|
||||
#editor.editingFinished.connect(self.edit_finished_row_target)
|
||||
#self.editFinished.connect(self.edit_finished_row_target)
|
||||
#self.editFinished.connect(partial(self.edit_finished_row_target, index.row()))
|
||||
self.editFinished.connect(partial(self.edit_finished_row_target, index.row()))
|
||||
self.return_ = False
|
||||
editor.returnPressed.connect(self.return_pressed)
|
||||
completer = TaskCompleter(self.config)
|
||||
completer.setFilterMode(QtCore.Qt.MatchFlag.MatchContains)
|
||||
completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
|
||||
editor.setCompleter(completer)
|
||||
return editor
|
||||
|
||||
@QtCore.Slot()
|
||||
def return_pressed(self):
|
||||
self.return_ = True
|
||||
|
||||
@QtCore.Slot()
|
||||
def edit_finished_row_target(self, row):
|
||||
#def edit_finished_row_target(self):
|
||||
if not self.return_:
|
||||
self.edit_finished_row.emit(row)
|
||||
#self.edit_finished_row.emit(self.row)
|
||||
|
||||
class Status(enum.Enum):
|
||||
PROGRESS = enum.auto()
|
||||
@ -110,16 +111,14 @@ class WorklogDialog(QtWidgets.QDialog):
|
||||
self.row_height = None
|
||||
self._focussed = False
|
||||
|
||||
#self.tableWidget = WorklogDialog.TabTable(self)
|
||||
self.tableWidget = QtWidgets.QTableWidget(self)
|
||||
self.tableWidget = WorklogDialog.TabTable(self)
|
||||
self.tableWidget.setColumnCount(3)
|
||||
self.tableWidget.setHorizontalHeaderLabels(["Task", "Comment", "Duration"])
|
||||
self.tableWidget.cellChanged.connect(self.cell_changed)
|
||||
taskItemCompleter = WorklogDialog.TaskItemCompleter(config, self)
|
||||
taskItemCompleter.editStarted.connect(self.disable_buttons)
|
||||
taskItemCompleter.editFinished.connect(self.enable_buttons)
|
||||
#taskItemCompleter.editFinished.connect(self.ensure_stati)
|
||||
#taskItemCompleter.edit_finished_row.connect(self.update_status_view)
|
||||
taskItemCompleter.edit_finished_row.connect(self.update_status_view)
|
||||
self.tableWidget.setItemDelegateForColumn(0, taskItemCompleter)
|
||||
self.hheader = QtWidgets.QHeaderView(QtCore.Qt.Orientation.Horizontal)
|
||||
self.hheader.setMinimumSectionSize(10)
|
||||
@ -233,23 +232,13 @@ class WorklogDialog(QtWidgets.QDialog):
|
||||
self.tableWidget.setMinimumWidth(min(desired_width, self.tableWidget.maximumWidth()))
|
||||
self.adjustSize()
|
||||
|
||||
def center_dialog(self):
|
||||
screen = QtGui.QGuiApplication.screenAt(self.pos())
|
||||
x = ((screen.size().width() - self.tableWidget.width()) // 2) + screen.geometry().left()
|
||||
y = ((screen.size().height() - self.height()) // 2) + screen.geometry().top()
|
||||
self.move(x, y)
|
||||
|
||||
@QtCore.Slot()
|
||||
def ensure_stati(self):
|
||||
print("ensure_stati")
|
||||
for i in range(len(self._worklog_data)-1):
|
||||
cw = self.tableWidget.cellWidget(i, 0)
|
||||
if type(cw) is not WorklogDialog.ClickWidget:
|
||||
print(f"ensure_stati: {self.tableWidget.item(i, 0).text()}")
|
||||
self.update_status_view(i)
|
||||
#print(cw)
|
||||
|
||||
def update_status_view(self, row):
|
||||
print(self.tableWidget.item(row, 0).text())
|
||||
if self._status[row][0] is WorklogDialog.Status.PROGRESS:
|
||||
icon = ProgressIndicator(self)
|
||||
icon.setMaximumSize(QtCore.QSize(self.row_height * 0.75, self.row_height * 0.75))
|
||||
@ -300,6 +289,7 @@ class WorklogDialog(QtWidgets.QDialog):
|
||||
self.update_title()
|
||||
self._focussed = False
|
||||
self.refresh_table()
|
||||
self.center_dialog()
|
||||
self.update_prev_next()
|
||||
|
||||
@QtCore.Slot()
|
||||
@ -309,14 +299,13 @@ class WorklogDialog(QtWidgets.QDialog):
|
||||
self.update_title()
|
||||
self._focussed = False
|
||||
self.refresh_table()
|
||||
self.center_dialog()
|
||||
self.update_prev_next()
|
||||
|
||||
@QtCore.Slot()
|
||||
def cell_changed(self, row, _):
|
||||
#print(f"{datetime.now()} cell_changed: {self._changing_items}")
|
||||
if self._changing_items:
|
||||
return
|
||||
print(f"{datetime.now()} cell_changed")
|
||||
self._worklog_data[row][0] = self.tableWidget.item(row, 0).text()
|
||||
self.save()
|
||||
self.update_status(row, WorklogDialog.Status.PROGRESS, "Fetching")
|
||||
|
Loading…
Reference in New Issue
Block a user