Improved issue verification

This commit is contained in:
Fabian 2021-11-30 15:47:04 +01:00
parent 5a24c0c5eb
commit 32621bcc87

View File

@ -100,7 +100,7 @@ class WorklogDialog(QtWidgets.QDialog):
self._changing_items = False
self._worklog: Optional[Worklog] = None
self._worklog_data: List[List[str]] = []
self._status: List[Tuple[Status, str]] = []
self._statuses: List[Tuple[Status, str]] = []
self.row_height = None
self._focussed = False
@ -172,6 +172,9 @@ class WorklogDialog(QtWidgets.QDialog):
def set_data(self, worklog: Worklog):
self._worklog = worklog
self.update_all()
def update_all(self):
self.refresh_table()
self.update_title()
self.update_prev_next()
@ -182,13 +185,15 @@ class WorklogDialog(QtWidgets.QDialog):
issue_keys = []
for row in self._worklog_data[:-1]:
issue_keys.append(row[0].split()[0])
self._status = self.rest.get_issues_state(issue_keys)
for row, _ in enumerate(self._status):
self.update_status_view(row)
all_ok = reduce(lambda acc, it: acc and it[0] is Status.OK, self._status, True)
old_statuses = self._statuses
self._statuses = self.rest.get_issues_state(issue_keys)
for row, status in enumerate(self._statuses):
if len(old_statuses) != len(self._statuses) or old_statuses[row][0] != status[0]:
self.update_status_view(row)
all_ok = reduce(lambda acc, it: acc and it[0] is Status.OK, self._statuses, True)
if all_ok:
self.upload_button.setEnabled(True)
all_done = reduce(lambda acc, it: acc and it[0] is not Status.PROGRESS, self._status, True)
all_done = reduce(lambda acc, it: acc and it[0] is not Status.PROGRESS, self._statuses, True)
if all_done:
self.update_timer.stop()
@ -200,8 +205,6 @@ class WorklogDialog(QtWidgets.QDialog):
def refresh_table(self):
self._worklog_data = self._worklog.worklog
for i, _ in enumerate(self._worklog_data[:-1]):
self._status.append((Status.PROGRESS, "Fetching"))
self._changing_items = True
if not self.row_height:
self.tableWidget.setRowCount(1)
@ -220,7 +223,6 @@ class WorklogDialog(QtWidgets.QDialog):
self.tableWidget.setItem(row, 1, item1)
item1.setFlags(item1.flags() & QtCore.Qt.ItemIsEnabled)
else:
self.update_status_view(row)
text_edit = WorklogDialog.TableTextEdit(self._worklog_data[row][1], row, self)
text_edit.textChanged.connect(self.on_resize)
text_edit.setFrameStyle(QtWidgets.QFrame.NoFrame)
@ -247,19 +249,19 @@ class WorklogDialog(QtWidgets.QDialog):
self.move(x, y)
def update_status_view(self, row):
if self._status[row][0] is Status.PROGRESS:
if self._statuses[row][0] is Status.PROGRESS:
icon = ProgressIndicator(self)
icon.setMaximumSize(QtCore.QSize(self.row_height * 0.75, self.row_height * 0.75))
icon.setAnimationDelay(70)
icon.startAnimation()
else:
if self._status[row][0] is Status.OK:
if self._statuses[row][0] is Status.OK:
item_name = "dialog-ok"
elif self._status[row][0] is Status.ERROR:
elif self._statuses[row][0] is Status.ERROR:
item_name = "edit-delete-remove"
icon = QtWidgets.QLabel()
icon.setPixmap(get_icon(item_name).pixmap(self.row_height * 0.75, self.row_height * 0.75))
icon.setToolTip(self._status[row][1])
icon.setToolTip(self._statuses[row][1])
layout = QtWidgets.QHBoxLayout()
layout.addWidget(icon, alignment=QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
layout.setContentsMargins(self.row_height * 0.1, self.row_height * 0.1,
@ -294,21 +296,15 @@ class WorklogDialog(QtWidgets.QDialog):
def previous(self):
self.save()
self._worklog.previous()
self.update_title()
self._focussed = False
self.refresh_table()
self.center_dialog()
self.update_prev_next()
self.update_all()
@QtCore.Slot()
def next(self):
self.save()
self._worklog.next()
self.update_title()
self._focussed = False
self.refresh_table()
self.center_dialog()
self.update_prev_next()
self.update_all()
@QtCore.Slot()
def cell_changed(self, row, _):
@ -316,9 +312,7 @@ class WorklogDialog(QtWidgets.QDialog):
return
self._worklog_data[row][0] = self.tableWidget.item(row, 0).text()
self.save()
self.update_statuses()
self.update_timer.start()
self.refresh_table()
self.update_all()
@QtCore.Slot()
def text_edit_changed(self, text, row):