Drop width check logic; only do height

windows_fixes_yo
Tyler Goodlet 2022-02-11 08:32:28 -05:00
parent 68e1db27f8
commit 412c34eba0
1 changed files with 8 additions and 13 deletions

View File

@ -112,7 +112,6 @@ class CompleterView(QTreeView):
model = QStandardItemModel(self) model = QStandardItemModel(self)
self.labels = labels self.labels = labels
self._last_window_h: Optional[int] = None
# a std "tabular" config # a std "tabular" config
self.setItemDelegate(FontScaledDelegate(self)) self.setItemDelegate(FontScaledDelegate(self))
@ -185,21 +184,14 @@ class CompleterView(QTreeView):
# inclusive of search bar and header "rows", in pixel terms. # inclusive of search bar and header "rows", in pixel terms.
if row_px > 0: if row_px > 0:
window_h = self.window().height() window_h = self.window().height()
rows = ceil(window_h / row_px) - 2 rows = ceil(window_h / row_px) - 6
else: else:
rows = 16 rows = 16
# TODO: the problem here is that this view widget is **not** self.setFixedHeight(rows * row_px)
# resizing/scaling when the parent layout is adjusted, not sure
# what exactly is up... only "scale up" the results view
# when the window size has increased/
if not self._last_window_h or self._last_window_h < window_h:
self.setMaximumSize(self.width(), rows * row_px)
self.setMinimumSize(self.width(), rows * row_px)
# self.resize(self.width(), rows * row_px) # self.resize(self.width(), rows * row_px)
self.resize(self.width(), rows * row_px) self.resize(self.width(), rows * row_px)
self._last_window_h = window_h
# size to width of longest result seen thus far # size to width of longest result seen thus far
# TODO: should we always dynamically scale to longest result? # TODO: should we always dynamically scale to longest result?
@ -255,7 +247,8 @@ class CompleterView(QTreeView):
idx: QModelIndex, idx: QModelIndex,
) -> QStandardItem: ) -> QStandardItem:
'''Select and return the item at index ``idx``. '''
Select and return the item at index ``idx``.
''' '''
sel = self.selectionModel() sel = self.selectionModel()
@ -270,7 +263,8 @@ class CompleterView(QTreeView):
return model.itemFromIndex(idx) return model.itemFromIndex(idx)
def select_first(self) -> QStandardItem: def select_first(self) -> QStandardItem:
'''Select the first depth >= 2 entry from the completer tree and '''
Select the first depth >= 2 entry from the completer tree and
return it's item. return it's item.
''' '''
@ -333,7 +327,8 @@ class CompleterView(QTreeView):
section: str, section: str,
) -> Optional[QModelIndex]: ) -> Optional[QModelIndex]:
'''Find the *first* depth = 1 section matching ``section`` in '''
Find the *first* depth = 1 section matching ``section`` in
the tree and return its index. the tree and return its index.
''' '''