fix focus movement on dynamic delegates in listView

This commit is contained in:
Cyril Anisimov 2024-12-29 00:33:05 +01:00
parent f8f4d75cb7
commit 867ad8ee3c
3 changed files with 12 additions and 5 deletions

View file

@ -202,7 +202,7 @@ void ListViewFocusController::focusNextItem()
return;
}
m_focusChain = focusControl::getItemsChain(currentDelegate());
reloadFocusChain();
if (m_focusChain.empty()) {
qWarning() << "No elements found in the delegate. Going to next delegate...";
@ -224,7 +224,7 @@ void ListViewFocusController::focusPreviousItem()
if (m_focusChain.empty()) {
qDebug() << "Empty focusChain with current delegate: " << currentDelegate() << "Scanning for elements...";
m_focusChain = focusControl::getItemsChain(currentDelegate());
reloadFocusChain();
}
if (m_focusChain.empty()) {
qWarning() << "No elements found in the delegate. Going to next delegate...";
@ -248,6 +248,11 @@ void ListViewFocusController::resetFocusChain()
m_focusedItemIndex = -1;
}
void ListViewFocusController::reloadFocusChain()
{
m_focusChain = focusControl::getItemsChain(currentDelegate());
}
bool ListViewFocusController::isFirstFocusItemInDelegate() const
{
return m_focusedItem && (m_focusedItem == m_focusChain.first());