diff --git a/src/fime/progressindicator.py b/src/fime/progressindicator.py index eaff1e2..8cb7b56 100644 --- a/src/fime/progressindicator.py +++ b/src/fime/progressindicator.py @@ -1,7 +1,3 @@ -""" - -""" - try: from PySide6 import QtCore, QtGui, QtWidgets except ImportError: diff --git a/src/fime/worklog.py b/src/fime/worklog.py index bea07e6..38cd042 100644 --- a/src/fime/worklog.py +++ b/src/fime/worklog.py @@ -1,18 +1,11 @@ -from PySide2.QtCore import Qt, QUrl -from PySide2.QtGui import QIcon -from PySide2.QtQuickWidgets import QQuickWidget -from PySide2.QtWidgets import QLabel - -from fime.ok_icon import OkIcon from fime.progressindicator import ProgressIndicator -from fime.spinner import Spinner try: from PySide6 import QtCore, QtGui, QtWidgets except ImportError: from PySide2 import QtCore, QtGui, QtWidgets -from fime.util import get_screen_height, get_screen_width +from fime.util import get_screen_width # noinspection PyUnresolvedReferences import fime.icons @@ -24,25 +17,45 @@ class Worklog(QtWidgets.QDialog): self.setWindowTitle("Worklog") self.tableWidget = QtWidgets.QTableWidget() - self.tableWidget.verticalHeader().hide() self.tableWidget.setColumnCount(3) self.tableWidget.setHorizontalHeaderLabels(["Task", "Comment", "Duration"]) - self.header = QtWidgets.QHeaderView(QtCore.Qt.Orientation.Horizontal) - self.header.setMinimumSectionSize(1) - self.header.setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents) - self.tableWidget.setHorizontalHeader(self.header) - self.header.setSectionResizeMode(self.header.logicalIndex(1), QtWidgets.QHeaderView.Stretch) + self.hheader = QtWidgets.QHeaderView(QtCore.Qt.Orientation.Horizontal) + self.hheader.setMinimumSectionSize(1) + self.hheader.setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents) + self.tableWidget.setHorizontalHeader(self.hheader) + self.hheader.setSectionResizeMode(self.hheader.logicalIndex(1), QtWidgets.QHeaderView.Stretch) + self.vheader = QtWidgets.QHeaderView(QtCore.Qt.Orientation.Vertical) + self.vheader.setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents) + self.vheader.hide() + self.tableWidget.setVerticalHeader(self.vheader) layout = QtWidgets.QVBoxLayout(self) layout.addWidget(self.tableWidget) self.setLayout(layout) self.refresh_table() + class TableTextEdit(QtWidgets.QTextEdit): + def __init__(self, text, start_height, parent, *args, **kwargs): + super().__init__(parent, *args, **kwargs) + self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) + self.setLineWrapMode(QtWidgets.QTextEdit.WidgetWidth) + self.setAcceptRichText(False) + self.setTabChangesFocus(True) + self.setText(text) + self.document().adjustSize() + self.on_text_changed() + self.moveCursor(QtGui.QTextCursor.End) + self.textChanged.connect(self.on_text_changed) + + @QtCore.Slot() + def on_text_changed(self): + self.setFixedHeight(self.document().size().toSize().height()) + def refresh_table(self): self._report_data = [ - ["ASG-8690 Ansible - Debian 11 Support", "", "01:23"], - ["ASG-8342 Ansible - MariaDB Rolle überarbeiten ", "", "03:57"], - ["ASG-8685 CATS Testsystem: Debian Upgrades Server mit Version kleiner 10 ", "", "02:12"], + ["ASG-8690 Ansible - Debian 11 Support", "Impl\nMore impl", "01:23"], + ["ASG-8342 Ansible - MariaDB Rolle überarbeiten ", "Test", "03:57"], + ["ASG-8685 CATS Testsystem: Debian Upgrades Server mit Version kleiner 10 ", "Doing", "02:12"], ] self.tableWidget.setRowCount(len(self._report_data)) @@ -57,7 +70,7 @@ class Worklog(QtWidgets.QDialog): qpi.setAnimationDelay(70) qpi.startAnimation() layout = QtWidgets.QVBoxLayout() - layout.addWidget(qpi, alignment=Qt.AlignRight | Qt.AlignVCenter) + 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) @@ -65,17 +78,25 @@ class Worklog(QtWidgets.QDialog): #label.setMargin(size * 0.1) label = wdgt else: - label = QLabel() + label = QtWidgets.QLabel() if row == 0: item_name = "dialog-ok" elif row == 2: item_name = "edit-delete-remove" - label.setPixmap(QIcon.fromTheme(item_name).pixmap(size * 0.75, size * 0.75)) - label.setAlignment(Qt.AlignRight | Qt.AlignVCenter) + label.setPixmap(QtGui.QIcon.fromTheme(item_name).pixmap(size * 0.75, size * 0.75)) + label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) label.setMargin(size*0.1) self.tableWidget.setCellWidget(row, 0, label) - item1 = QtWidgets.QTableWidgetItem(self._report_data[row][1]) - self.tableWidget.setItem(row, 1, item1) + #item1 = QtWidgets.QTableWidgetItem(self._report_data[row][1]) + #self.tableWidget.setItem(row, 1, item1) + #print(self.tableWidget.cellWidget(0, 0).height()) + text_edit = Worklog.TableTextEdit(self._report_data[row][1], + self.tableWidget.cellWidget(0, 0).height(), + self) + text_edit.textChanged.connect(self.on_resize) + self.tableWidget.setCellWidget(row, 1, text_edit) + if row == 0: + text_edit.setFocus() item2 = QtWidgets.QTableWidgetItem(self._report_data[row][2]) self.tableWidget.setItem(row, 2, item2) #item2.setFlags(item2.flags() & QtCore.Qt.ItemIsEnabled) @@ -84,6 +105,12 @@ class Worklog(QtWidgets.QDialog): comment_width = get_screen_width(self) * 0.2 self.tableWidget.setMinimumWidth(self.tableWidget.columnWidth(0) + comment_width + self.tableWidget.columnWidth(2)) self.tableWidget.setColumnWidth(0, self.tableWidget.columnWidth(0) * 1.05) + # broken + #self.tableWidget.setTabOrder(self.tableWidget.cellWidget(0, 1), self.tableWidget.cellWidget(1, 1)) + + @QtCore.Slot() + def on_resize(self): + self.tableWidget.resizeRowsToContents() @QtCore.Slot() def disable_buttons(self):