Compare commits
No commits in common. "35a884ea1ec8ae2117a27cac38d151d86de02e5f" and "41299784e7e5b8023c2f88d937cf84b4c0a5a1da" have entirely different histories.
35a884ea1e
...
41299784e7
@ -130,12 +130,8 @@ class Report(QtWidgets.QDialog):
|
|||||||
self.tableWidget.resizeColumnToContents(0)
|
self.tableWidget.resizeColumnToContents(0)
|
||||||
|
|
||||||
if self.tableWidget.rowCount() > 4:
|
if self.tableWidget.rowCount() > 4:
|
||||||
self.tableWidget.setMinimumHeight(
|
self.tableWidget.setMinimumHeight(min((self.tableWidget.rowCount() + 2) * self.tableWidget.rowHeight(0),
|
||||||
min(
|
get_screen_height(self.tableWidget) * 0.8))
|
||||||
(self.tableWidget.rowCount()) * self.tableWidget.rowHeight(0) + self.header.height() + 4,
|
|
||||||
get_screen_height(self.tableWidget) * 0.8
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
def update_prev_next(self):
|
def update_prev_next(self):
|
||||||
prev, _next = self._report.prev_next_avail()
|
prev, _next = self._report.prev_next_avail()
|
||||||
|
@ -11,43 +11,14 @@ import fime.icons
|
|||||||
|
|
||||||
|
|
||||||
class Worklog(QtWidgets.QDialog):
|
class Worklog(QtWidgets.QDialog):
|
||||||
class TabTable(QtWidgets.QTableWidget):
|
|
||||||
def __init__(self, parent, *args, **kwargs):
|
|
||||||
super().__init__(parent, *args, **kwargs)
|
|
||||||
|
|
||||||
def focusNextPrevChild(self, next):
|
|
||||||
if self.currentColumn() == 1:
|
|
||||||
event = QtGui.QKeyEvent(QtCore.QEvent.KeyPress,
|
|
||||||
QtCore.Qt.Key_Down if next else QtCore.Qt.Key_Up,
|
|
||||||
QtCore.Qt.NoModifier)
|
|
||||||
self.keyPressEvent(event)
|
|
||||||
if event.isAccepted():
|
|
||||||
return True
|
|
||||||
return super().focusNextPrevChild(next)
|
|
||||||
|
|
||||||
class ClickWidget(QtWidgets.QWidget):
|
|
||||||
def __init__(self, item, table, parent, *args, **kwargs):
|
|
||||||
super().__init__(parent, *args, **kwargs)
|
|
||||||
self.item = item
|
|
||||||
self.table = table
|
|
||||||
|
|
||||||
def mouseDoubleClickEvent(self, event):
|
|
||||||
self.table.removeCellWidget(self.item.row(), self.item.column())
|
|
||||||
self.table.openPersistentEditor(self.item)
|
|
||||||
editor = self.table.cellWidget(self.table.currentRow(), self.table.currentColumn())
|
|
||||||
editor.setFocus()
|
|
||||||
|
|
||||||
def __init__(self, parent, *args, **kwargs):
|
def __init__(self, parent, *args, **kwargs):
|
||||||
super().__init__(parent, *args, **kwargs)
|
super().__init__(parent, *args, **kwargs)
|
||||||
|
|
||||||
self.setWindowTitle("Worklog")
|
self.setWindowTitle("Worklog")
|
||||||
|
|
||||||
self._changing_items = False
|
self.tableWidget = QtWidgets.QTableWidget()
|
||||||
|
|
||||||
self.tableWidget = Worklog.TabTable(self)
|
|
||||||
self.tableWidget.setColumnCount(3)
|
self.tableWidget.setColumnCount(3)
|
||||||
self.tableWidget.setHorizontalHeaderLabels(["Task", "Comment", "Duration"])
|
self.tableWidget.setHorizontalHeaderLabels(["Task", "Comment", "Duration"])
|
||||||
self.tableWidget.cellChanged.connect(self.cell_changed)
|
|
||||||
self.hheader = QtWidgets.QHeaderView(QtCore.Qt.Orientation.Horizontal)
|
self.hheader = QtWidgets.QHeaderView(QtCore.Qt.Orientation.Horizontal)
|
||||||
self.hheader.setMinimumSectionSize(1)
|
self.hheader.setMinimumSectionSize(1)
|
||||||
self.hheader.setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents)
|
self.hheader.setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents)
|
||||||
@ -64,7 +35,7 @@ class Worklog(QtWidgets.QDialog):
|
|||||||
self.refresh_table()
|
self.refresh_table()
|
||||||
|
|
||||||
class TableTextEdit(QtWidgets.QTextEdit):
|
class TableTextEdit(QtWidgets.QTextEdit):
|
||||||
def __init__(self, text, parent, *args, **kwargs):
|
def __init__(self, text, start_height, parent, *args, **kwargs):
|
||||||
super().__init__(parent, *args, **kwargs)
|
super().__init__(parent, *args, **kwargs)
|
||||||
self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
|
self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
|
||||||
self.setLineWrapMode(QtWidgets.QTextEdit.WidgetWidth)
|
self.setLineWrapMode(QtWidgets.QTextEdit.WidgetWidth)
|
||||||
@ -81,7 +52,6 @@ class Worklog(QtWidgets.QDialog):
|
|||||||
self.setFixedHeight(self.document().size().toSize().height())
|
self.setFixedHeight(self.document().size().toSize().height())
|
||||||
|
|
||||||
def refresh_table(self):
|
def refresh_table(self):
|
||||||
self._changing_items = True
|
|
||||||
self._report_data = [
|
self._report_data = [
|
||||||
["ASG-8690 Ansible - Debian 11 Support", "Impl\nMore impl", "01:23"],
|
["ASG-8690 Ansible - Debian 11 Support", "Impl\nMore impl", "01:23"],
|
||||||
["ASG-8342 Ansible - MariaDB Rolle überarbeiten ", "Test", "03:57"],
|
["ASG-8342 Ansible - MariaDB Rolle überarbeiten ", "Test", "03:57"],
|
||||||
@ -91,39 +61,45 @@ class Worklog(QtWidgets.QDialog):
|
|||||||
|
|
||||||
for row, _ in enumerate(self._report_data):
|
for row, _ in enumerate(self._report_data):
|
||||||
item0 = QtWidgets.QTableWidgetItem(self._report_data[row][0])
|
item0 = QtWidgets.QTableWidgetItem(self._report_data[row][0])
|
||||||
|
item0.setToolTip("something has gone wrong")
|
||||||
self.tableWidget.setItem(row, 0, item0)
|
self.tableWidget.setItem(row, 0, item0)
|
||||||
size = self.tableWidget.rowHeight(row)
|
size = self.tableWidget.rowHeight(row)
|
||||||
if row == 1:
|
if row == 1:
|
||||||
icon = ProgressIndicator(self)
|
qpi = ProgressIndicator(self)
|
||||||
icon.setMaximumSize(QtCore.QSize(size * 0.75, size * 0.75))
|
qpi.setMaximumSize(QtCore.QSize(size * 0.75, size * 0.75))
|
||||||
icon.setAnimationDelay(70)
|
qpi.setAnimationDelay(70)
|
||||||
icon.startAnimation()
|
qpi.startAnimation()
|
||||||
|
layout = QtWidgets.QVBoxLayout()
|
||||||
|
layout.addWidget(qpi, alignment=QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
|
||||||
|
layout.setContentsMargins(size * 0.1, size * 0.1, size * 0.1, size * 0.1)
|
||||||
|
wdgt = QtWidgets.QWidget()
|
||||||
|
wdgt.setLayout(layout)
|
||||||
|
#label.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
|
||||||
|
#label.setMargin(size * 0.1)
|
||||||
|
label = wdgt
|
||||||
else:
|
else:
|
||||||
|
label = QtWidgets.QLabel()
|
||||||
if row == 0:
|
if row == 0:
|
||||||
item_name = "dialog-ok"
|
item_name = "dialog-ok"
|
||||||
elif row == 2:
|
elif row == 2:
|
||||||
item_name = "edit-delete-remove"
|
item_name = "edit-delete-remove"
|
||||||
icon = QtWidgets.QLabel()
|
label.setPixmap(QtGui.QIcon.fromTheme(item_name).pixmap(size * 0.75, size * 0.75))
|
||||||
icon.setPixmap(QtGui.QIcon.fromTheme(item_name).pixmap(size * 0.75, size * 0.75))
|
label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
|
||||||
icon.setToolTip("something has gone wrong")
|
label.setMargin(size*0.1)
|
||||||
layout = QtWidgets.QHBoxLayout()
|
self.tableWidget.setCellWidget(row, 0, label)
|
||||||
layout.addWidget(icon, alignment=QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
|
|
||||||
layout.setContentsMargins(size * 0.1, size * 0.1, size * 0.1, size * 0.1)
|
|
||||||
wdgt = Worklog.ClickWidget(item0, self.tableWidget, self)
|
|
||||||
wdgt.setLayout(layout)
|
|
||||||
self.tableWidget.setCellWidget(row, 0, wdgt)
|
|
||||||
#item1 = QtWidgets.QTableWidgetItem(self._report_data[row][1])
|
#item1 = QtWidgets.QTableWidgetItem(self._report_data[row][1])
|
||||||
#self.tableWidget.setItem(row, 1, item1)
|
#self.tableWidget.setItem(row, 1, item1)
|
||||||
#print(self.tableWidget.cellWidget(0, 0).height())
|
#print(self.tableWidget.cellWidget(0, 0).height())
|
||||||
text_edit = Worklog.TableTextEdit(self._report_data[row][1], self)
|
text_edit = Worklog.TableTextEdit(self._report_data[row][1],
|
||||||
|
self.tableWidget.cellWidget(0, 0).height(),
|
||||||
|
self)
|
||||||
text_edit.textChanged.connect(self.on_resize)
|
text_edit.textChanged.connect(self.on_resize)
|
||||||
text_edit.setFrameStyle(QtWidgets.QFrame.NoFrame)
|
|
||||||
self.tableWidget.setCellWidget(row, 1, text_edit)
|
self.tableWidget.setCellWidget(row, 1, text_edit)
|
||||||
if row == 0:
|
if row == 0:
|
||||||
text_edit.setFocus()
|
text_edit.setFocus()
|
||||||
item2 = QtWidgets.QTableWidgetItem(self._report_data[row][2])
|
item2 = QtWidgets.QTableWidgetItem(self._report_data[row][2])
|
||||||
self.tableWidget.setItem(row, 2, item2)
|
self.tableWidget.setItem(row, 2, item2)
|
||||||
item2.setFlags(item2.flags() & QtCore.Qt.ItemIsEnabled)
|
#item2.setFlags(item2.flags() & QtCore.Qt.ItemIsEnabled)
|
||||||
self.tableWidget.resizeColumnToContents(0)
|
self.tableWidget.resizeColumnToContents(0)
|
||||||
# TODO integrate entered text and max screen width
|
# TODO integrate entered text and max screen width
|
||||||
comment_width = get_screen_width(self) * 0.2
|
comment_width = get_screen_width(self) * 0.2
|
||||||
@ -131,8 +107,6 @@ class Worklog(QtWidgets.QDialog):
|
|||||||
self.tableWidget.setColumnWidth(0, self.tableWidget.columnWidth(0) * 1.05)
|
self.tableWidget.setColumnWidth(0, self.tableWidget.columnWidth(0) * 1.05)
|
||||||
# broken
|
# broken
|
||||||
#self.tableWidget.setTabOrder(self.tableWidget.cellWidget(0, 1), self.tableWidget.cellWidget(1, 1))
|
#self.tableWidget.setTabOrder(self.tableWidget.cellWidget(0, 1), self.tableWidget.cellWidget(1, 1))
|
||||||
QtWidgets.QWidget.setTabOrder(self.tableWidget.cellWidget(0, 1), self.tableWidget.cellWidget(1, 1))
|
|
||||||
self._changing_items = False
|
|
||||||
|
|
||||||
@QtCore.Slot()
|
@QtCore.Slot()
|
||||||
def on_resize(self):
|
def on_resize(self):
|
||||||
@ -145,10 +119,3 @@ class Worklog(QtWidgets.QDialog):
|
|||||||
@QtCore.Slot()
|
@QtCore.Slot()
|
||||||
def enable_buttons(self):
|
def enable_buttons(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@QtCore.Slot()
|
|
||||||
def cell_changed(self, row, column):
|
|
||||||
if self._changing_items:
|
|
||||||
return
|
|
||||||
print(f"cell changed: {row}, {column}")
|
|
||||||
self.refresh_table()
|
|
||||||
|
Loading…
Reference in New Issue
Block a user