Skip to content

Commit

Permalink
Make filter combox items length fit with combobox width
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonSAMPERE committed Jun 2, 2022
1 parent c8a18f4 commit 7aec50e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions modules/search_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,20 @@ def pop_as_cbbs(self, tags: dict):
self.cbb_geofilter.addItem(ico_line, layer.name())
elif layer.geometryType() == 0:
self.cbb_geofilter.addItem(ico_poin, layer.name())
# Format combobox tiems text to fit with widget width
for cbb in self.cbbs_search_advanced:
cbb_width = cbb.width()
cbb_fm = cbb.fontMetrics()

for i in range(cbb.count()):
item_label = cbb.itemText(i)
item_label_width = cbb_fm.size(1, item_label).width()
if item_label_width > cbb_width:
cbb.setItemText(i, cbb_fm.elidedText(item_label, 1, cbb_width))
cbb.setItemData(i, item_label, Qt.ToolTipRole)
else:
pass
cbb.setStyleSheet("combobox-popup: 0;")
return

def pop_qs_cbbs(self, items_list: list = None):
Expand Down

0 comments on commit 7aec50e

Please sign in to comment.