fix focus movement on dynamic delegates in listView
This commit is contained in:
parent
f8f4d75cb7
commit
867ad8ee3c
3 changed files with 12 additions and 5 deletions
|
|
@ -216,14 +216,14 @@ void FocusController::nextItem(Direction direction)
|
||||||
void FocusController::focusNextListViewItem()
|
void FocusController::focusNextListViewItem()
|
||||||
{
|
{
|
||||||
qDebug() << "===>> Calling < focusNextListViewItem >...";
|
qDebug() << "===>> Calling < focusNextListViewItem >...";
|
||||||
|
m_lvfc->reloadFocusChain();
|
||||||
if (m_lvfc->isLastFocusItemInListView() || m_lvfc->isReturnNeeded()) {
|
if (m_lvfc->isLastFocusItemInListView() || m_lvfc->isReturnNeeded()) {
|
||||||
qDebug() << "===>> Last item in [ ListView ] was reached. Going to the NEXT element after [ ListView ]";
|
qDebug() << "===>> Last item in [ ListView ] was reached. Going to the NEXT element after [ ListView ]";
|
||||||
dropListView();
|
dropListView();
|
||||||
nextItem(Direction::Forward);
|
nextItem(Direction::Forward);
|
||||||
return;
|
return;
|
||||||
} else if (m_lvfc->isLastFocusItemInDelegate()) {
|
} else if (m_lvfc->isLastFocusItemInDelegate()) {
|
||||||
qDebug() << "===>> End of delegate elements was reached. Going to the next delegate";
|
qDebug() << "===>> End of delegate's elements was reached. Going to the next delegate";
|
||||||
m_lvfc->resetFocusChain();
|
m_lvfc->resetFocusChain();
|
||||||
m_lvfc->nextDelegate();
|
m_lvfc->nextDelegate();
|
||||||
}
|
}
|
||||||
|
|
@ -234,13 +234,14 @@ void FocusController::focusNextListViewItem()
|
||||||
void FocusController::focusPreviousListViewItem()
|
void FocusController::focusPreviousListViewItem()
|
||||||
{
|
{
|
||||||
qDebug() << "===>> Calling < focusPreviousListViewItem >...";
|
qDebug() << "===>> Calling < focusPreviousListViewItem >...";
|
||||||
|
m_lvfc->reloadFocusChain();
|
||||||
if (m_lvfc->isFirstFocusItemInListView() || m_lvfc->isReturnNeeded()) {
|
if (m_lvfc->isFirstFocusItemInListView() || m_lvfc->isReturnNeeded()) {
|
||||||
qDebug() << "===>> First item in [ ListView ] was reached. Going to the PREVIOUS element after [ ListView ]";
|
qDebug() << "===>> First item in [ ListView ] was reached. Going to the PREVIOUS element after [ ListView ]";
|
||||||
dropListView();
|
dropListView();
|
||||||
nextItem(Direction::Backward);
|
nextItem(Direction::Backward);
|
||||||
return;
|
return;
|
||||||
} else if (m_lvfc->isFirstFocusItemInDelegate()) {
|
} else if (m_lvfc->isFirstFocusItemInDelegate()) {
|
||||||
|
qDebug() << "===>> End of delegate's elements was reached. Going to the previous delegate";
|
||||||
m_lvfc->resetFocusChain();
|
m_lvfc->resetFocusChain();
|
||||||
m_lvfc->previousDelegate();
|
m_lvfc->previousDelegate();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -202,7 +202,7 @@ void ListViewFocusController::focusNextItem()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_focusChain = focusControl::getItemsChain(currentDelegate());
|
reloadFocusChain();
|
||||||
|
|
||||||
if (m_focusChain.empty()) {
|
if (m_focusChain.empty()) {
|
||||||
qWarning() << "No elements found in the delegate. Going to next delegate...";
|
qWarning() << "No elements found in the delegate. Going to next delegate...";
|
||||||
|
|
@ -224,7 +224,7 @@ void ListViewFocusController::focusPreviousItem()
|
||||||
|
|
||||||
if (m_focusChain.empty()) {
|
if (m_focusChain.empty()) {
|
||||||
qDebug() << "Empty focusChain with current delegate: " << currentDelegate() << "Scanning for elements...";
|
qDebug() << "Empty focusChain with current delegate: " << currentDelegate() << "Scanning for elements...";
|
||||||
m_focusChain = focusControl::getItemsChain(currentDelegate());
|
reloadFocusChain();
|
||||||
}
|
}
|
||||||
if (m_focusChain.empty()) {
|
if (m_focusChain.empty()) {
|
||||||
qWarning() << "No elements found in the delegate. Going to next delegate...";
|
qWarning() << "No elements found in the delegate. Going to next delegate...";
|
||||||
|
|
@ -248,6 +248,11 @@ void ListViewFocusController::resetFocusChain()
|
||||||
m_focusedItemIndex = -1;
|
m_focusedItemIndex = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ListViewFocusController::reloadFocusChain()
|
||||||
|
{
|
||||||
|
m_focusChain = focusControl::getItemsChain(currentDelegate());
|
||||||
|
}
|
||||||
|
|
||||||
bool ListViewFocusController::isFirstFocusItemInDelegate() const
|
bool ListViewFocusController::isFirstFocusItemInDelegate() const
|
||||||
{
|
{
|
||||||
return m_focusedItem && (m_focusedItem == m_focusChain.first());
|
return m_focusedItem && (m_focusedItem == m_focusChain.first());
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ public:
|
||||||
void focusNextItem();
|
void focusNextItem();
|
||||||
void focusPreviousItem();
|
void focusPreviousItem();
|
||||||
void resetFocusChain();
|
void resetFocusChain();
|
||||||
|
void reloadFocusChain();
|
||||||
bool isFirstFocusItemInListView() const;
|
bool isFirstFocusItemInListView() const;
|
||||||
bool isFirstFocusItemInDelegate() const;
|
bool isFirstFocusItemInDelegate() const;
|
||||||
bool isLastFocusItemInListView() const;
|
bool isLastFocusItemInListView() const;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue