Assembly: Enable Insert Component taskbox to grow when more items are added.

This commit is contained in:
PaddleStroke
2024-06-25 16:05:13 +02:00
committed by Chris Hennes
parent 99d63a9693
commit 6640815c4d
2 changed files with 31 additions and 3 deletions

View File

@@ -207,6 +207,27 @@ class TaskAssemblyInsertLink(QtCore.QObject):
process_objects(guiDoc.TreeRootObjects, docItem)
self.form.partList.expandAll()
self.adjustTreeWidgetSize()
def adjustTreeWidgetSize(self):
# Adjust the height of the part list based on item count
item_count = 1
def count_items(item):
nonlocal item_count
item_count += 1
for i in range(item.childCount()):
count_items(item.child(i))
for i in range(self.form.partList.topLevelItemCount()):
count_items(self.form.partList.topLevelItem(i))
item_height = self.form.partList.sizeHintForRow(0)
total_height = item_count * item_height
max_height = 500
self.form.partList.setMinimumHeight(min(total_height, max_height))
def onFilterChange(self):
filter_str = self.form.filterPartList.text().strip().lower()

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>376</width>
<height>387</height>
<width>200</width>
<height>200</height>
</rect>
</property>
<property name="windowTitle">
@@ -22,7 +22,14 @@
</widget>
</item>
<item row="1" column="0">
<widget class="QTreeWidget" name="partList"/>
<widget class="QTreeWidget" name="partList">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="hLayout">