Switch to QTableWidget for ingredients list

This commit is contained in:
Marcel Kapfer 2020-04-30 22:17:14 +02:00
parent 3423bc3b75
commit 7c661ce01f
Signed by: mmk2410
GPG key ID: CADE6F0C09F21B09
2 changed files with 41 additions and 4 deletions

View file

@ -108,8 +108,18 @@ class Ui_MainWindow(object):
self.t_ingredients.setObjectName("t_ingredients") self.t_ingredients.setObjectName("t_ingredients")
self.horizontalLayout_14 = QtWidgets.QHBoxLayout(self.t_ingredients) self.horizontalLayout_14 = QtWidgets.QHBoxLayout(self.t_ingredients)
self.horizontalLayout_14.setObjectName("horizontalLayout_14") self.horizontalLayout_14.setObjectName("horizontalLayout_14")
self.v_ingredients = QtWidgets.QListWidget(self.t_ingredients) self.v_ingredients = QtWidgets.QTableWidget(self.t_ingredients)
self.v_ingredients.setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection)
self.v_ingredients.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
self.v_ingredients.setObjectName("v_ingredients") self.v_ingredients.setObjectName("v_ingredients")
self.v_ingredients.setColumnCount(2)
self.v_ingredients.setRowCount(0)
item = QtWidgets.QTableWidgetItem()
self.v_ingredients.setHorizontalHeaderItem(0, item)
item = QtWidgets.QTableWidgetItem()
self.v_ingredients.setHorizontalHeaderItem(1, item)
self.v_ingredients.horizontalHeader().setStretchLastSection(True)
self.v_ingredients.verticalHeader().setVisible(False)
self.horizontalLayout_14.addWidget(self.v_ingredients) self.horizontalLayout_14.addWidget(self.v_ingredients)
self.verticalLayout_7 = QtWidgets.QVBoxLayout() self.verticalLayout_7 = QtWidgets.QVBoxLayout()
self.verticalLayout_7.setObjectName("verticalLayout_7") self.verticalLayout_7.setObjectName("verticalLayout_7")
@ -347,7 +357,7 @@ class Ui_MainWindow(object):
self.menuBar.addAction(self.menuMen.menuAction()) self.menuBar.addAction(self.menuMen.menuAction())
self.retranslateUi(MainWindow) self.retranslateUi(MainWindow)
self.tabWidget.setCurrentIndex(0) self.tabWidget.setCurrentIndex(1)
QtCore.QMetaObject.connectSlotsByName(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow)
MainWindow.setTabOrder(self.e_recipe_name, self.e_servings) MainWindow.setTabOrder(self.e_recipe_name, self.e_servings)
MainWindow.setTabOrder(self.e_servings, self.e_time) MainWindow.setTabOrder(self.e_servings, self.e_time)
@ -385,6 +395,10 @@ class Ui_MainWindow(object):
self.b_category_remove.setText(_translate("MainWindow", "Ausgewähltes entfernen")) self.b_category_remove.setText(_translate("MainWindow", "Ausgewähltes entfernen"))
self.b_category_add.setText(_translate("MainWindow", "Hinzufügen")) self.b_category_add.setText(_translate("MainWindow", "Hinzufügen"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.t_basics), _translate("MainWindow", "Grundsätzliches")) self.tabWidget.setTabText(self.tabWidget.indexOf(self.t_basics), _translate("MainWindow", "Grundsätzliches"))
item = self.v_ingredients.horizontalHeaderItem(0)
item.setText(_translate("MainWindow", "Menge"))
item = self.v_ingredients.horizontalHeaderItem(1)
item.setText(_translate("MainWindow", "Zutat"))
self.l_ingredient.setText(_translate("MainWindow", "Zutat")) self.l_ingredient.setText(_translate("MainWindow", "Zutat"))
self.l_amount.setText(_translate("MainWindow", "Menge")) self.l_amount.setText(_translate("MainWindow", "Menge"))
self.c_heading.setText(_translate("MainWindow", "Zwischenüberschrift")) self.c_heading.setText(_translate("MainWindow", "Zwischenüberschrift"))

View file

@ -68,7 +68,7 @@
<item row="0" column="0"> <item row="0" column="0">
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="t_basics"> <widget class="QWidget" name="t_basics">
<attribute name="title"> <attribute name="title">
@ -213,7 +213,30 @@
</attribute> </attribute>
<layout class="QHBoxLayout" name="horizontalLayout_14"> <layout class="QHBoxLayout" name="horizontalLayout_14">
<item> <item>
<widget class="QListWidget" name="v_ingredients"/> <widget class="QTableWidget" name="v_ingredients">
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string>Menge</string>
</property>
</column>
<column>
<property name="text">
<string>Zutat</string>
</property>
</column>
</widget>
</item> </item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_7"> <layout class="QVBoxLayout" name="verticalLayout_7">