Increase completion-tree width, support ctrl-space toggle
parent
2471ce446e
commit
d8a200aadc
|
@ -233,6 +233,9 @@ class CompleterView(QTreeView):
|
||||||
# instead its child.
|
# instead its child.
|
||||||
self.select_from_idx(model.index(0, 0, QModelIndex()))
|
self.select_from_idx(model.index(0, 0, QModelIndex()))
|
||||||
|
|
||||||
|
# self.resize()
|
||||||
|
self.show_matches()
|
||||||
|
|
||||||
def show_matches(self) -> None:
|
def show_matches(self) -> None:
|
||||||
self.show()
|
self.show()
|
||||||
self.resize()
|
self.resize()
|
||||||
|
@ -252,7 +255,8 @@ class CompleterView(QTreeView):
|
||||||
|
|
||||||
# TODO: probably make this more general / less hacky
|
# TODO: probably make this more general / less hacky
|
||||||
self.setMinimumSize(self.width(), rows * row_px)
|
self.setMinimumSize(self.width(), rows * row_px)
|
||||||
self.setMaximumSize(self.width(), rows * row_px)
|
self.setMaximumSize(self.width() + 10, rows * row_px)
|
||||||
|
self.setFixedWidth(333)
|
||||||
|
|
||||||
def select_previous(self) -> QModelIndex:
|
def select_previous(self) -> QModelIndex:
|
||||||
cidx = self.currentIndex()
|
cidx = self.currentIndex()
|
||||||
|
@ -328,7 +332,7 @@ class SearchBar(QtWidgets.QLineEdit):
|
||||||
# size it as we specify
|
# size it as we specify
|
||||||
# https://doc.qt.io/qt-5/qsizepolicy.html#Policy-enum
|
# https://doc.qt.io/qt-5/qsizepolicy.html#Policy-enum
|
||||||
self.setSizePolicy(
|
self.setSizePolicy(
|
||||||
QtWidgets.QSizePolicy.Fixed,
|
QtWidgets.QSizePolicy.Expanding,
|
||||||
QtWidgets.QSizePolicy.Fixed,
|
QtWidgets.QSizePolicy.Fixed,
|
||||||
)
|
)
|
||||||
self.setFont(font.font)
|
self.setFont(font.font)
|
||||||
|
@ -356,7 +360,6 @@ class SearchBar(QtWidgets.QLineEdit):
|
||||||
"""
|
"""
|
||||||
psh = super().sizeHint()
|
psh = super().sizeHint()
|
||||||
psh.setHeight(self.dpi_font.px_size + 2)
|
psh.setHeight(self.dpi_font.px_size + 2)
|
||||||
psh.setWidth(6*6*6)
|
|
||||||
return psh
|
return psh
|
||||||
|
|
||||||
def unfocus(self) -> None:
|
def unfocus(self) -> None:
|
||||||
|
@ -535,16 +538,12 @@ async def handle_keyboard_input(
|
||||||
bar = search.bar
|
bar = search.bar
|
||||||
view = bar.view
|
view = bar.view
|
||||||
view.set_font_size(bar.dpi_font.px_size)
|
view.set_font_size(bar.dpi_font.px_size)
|
||||||
# model = view.model()
|
|
||||||
# nidx = cidx = view.currentIndex()
|
|
||||||
nidx = view.currentIndex()
|
nidx = view.currentIndex()
|
||||||
# sel = view.selectionModel()
|
|
||||||
|
|
||||||
symsearch = get_multi_search()
|
symsearch = get_multi_search()
|
||||||
send, recv = trio.open_memory_channel(16)
|
send, recv = trio.open_memory_channel(16)
|
||||||
|
|
||||||
async with trio.open_nursery() as n:
|
async with trio.open_nursery() as n:
|
||||||
# TODO: async debouncing?
|
|
||||||
n.start_soon(
|
n.start_soon(
|
||||||
partial(
|
partial(
|
||||||
fill_results,
|
fill_results,
|
||||||
|
@ -557,8 +556,6 @@ async def handle_keyboard_input(
|
||||||
async for key, mods, txt in recv_chan:
|
async for key, mods, txt in recv_chan:
|
||||||
|
|
||||||
log.debug(f'key: {key}, mods: {mods}, txt: {txt}')
|
log.debug(f'key: {key}, mods: {mods}, txt: {txt}')
|
||||||
# parent = view.currentIndex()
|
|
||||||
# cidx = sel.currentIndex()
|
|
||||||
|
|
||||||
ctrl = False
|
ctrl = False
|
||||||
if mods == Qt.ControlModifier:
|
if mods == Qt.ControlModifier:
|
||||||
|
@ -572,18 +569,6 @@ async def handle_keyboard_input(
|
||||||
|
|
||||||
provider, symbol = value
|
provider, symbol = value
|
||||||
|
|
||||||
# # TODO: get rid of this hard coded column -> 1
|
|
||||||
# # and use the ``CompleterView`` schema/settings
|
|
||||||
# # to figure out the desired field(s)
|
|
||||||
# # https://doc.qt.io/qt-5/qstandarditemmodel.html#itemFromIndex
|
|
||||||
# node = model.itemFromIndex(cidx.siblingAtColumn(1))
|
|
||||||
# if node:
|
|
||||||
# symbol = node.text()
|
|
||||||
# provider = node.parent().text()
|
|
||||||
# # print(f' value: {value}')
|
|
||||||
# else:
|
|
||||||
# continue
|
|
||||||
|
|
||||||
log.info(f'Requesting symbol: {symbol}.{provider}')
|
log.info(f'Requesting symbol: {symbol}.{provider}')
|
||||||
|
|
||||||
# app = search.chart_app
|
# app = search.chart_app
|
||||||
|
@ -606,7 +591,7 @@ async def handle_keyboard_input(
|
||||||
# we're in select mode or cancelling
|
# we're in select mode or cancelling
|
||||||
if ctrl:
|
if ctrl:
|
||||||
# cancel and close
|
# cancel and close
|
||||||
if key == Qt.Key_C:
|
if (key == Qt.Key_C) or (key == Qt.Key_Space):
|
||||||
search.bar.unfocus()
|
search.bar.unfocus()
|
||||||
|
|
||||||
# kill the search and focus back on main chart
|
# kill the search and focus back on main chart
|
||||||
|
@ -634,19 +619,9 @@ async def handle_keyboard_input(
|
||||||
if parent_item and parent_item.text() == 'cache':
|
if parent_item and parent_item.text() == 'cache':
|
||||||
|
|
||||||
value = search.get_current()
|
value = search.get_current()
|
||||||
|
|
||||||
if value is not None:
|
if value is not None:
|
||||||
# continue
|
|
||||||
|
|
||||||
provider, symbol = value
|
provider, symbol = value
|
||||||
# node = model.itemFromIndex(
|
|
||||||
# i.siblingAtColumn(1)
|
|
||||||
# )
|
|
||||||
# if node:
|
|
||||||
|
|
||||||
# TODO: parse out provider from
|
|
||||||
# cached value.
|
|
||||||
# value = node.text()
|
|
||||||
|
|
||||||
search.chart_app.load_symbol(
|
search.chart_app.load_symbol(
|
||||||
provider,
|
provider,
|
||||||
symbol,
|
symbol,
|
||||||
|
|
Loading…
Reference in New Issue