add setDelegateIndex method to listViewFocusController
This commit is contained in:
parent
f331c11f51
commit
3cc70790bd
2 changed files with 10 additions and 3 deletions
|
|
@ -141,6 +141,12 @@ int ListViewFocusController::currentIndex() const
|
||||||
return m_delegateIndex;
|
return m_delegateIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ListViewFocusController::setDelegateIndex(int index)
|
||||||
|
{
|
||||||
|
m_delegateIndex = index;
|
||||||
|
m_listView->setProperty("currentIndex", index);
|
||||||
|
}
|
||||||
|
|
||||||
void ListViewFocusController::nextDelegate()
|
void ListViewFocusController::nextDelegate()
|
||||||
{
|
{
|
||||||
const auto sectionName = m_currentSectionString[static_cast<int>(m_currentSection)];
|
const auto sectionName = m_currentSectionString[static_cast<int>(m_currentSection)];
|
||||||
|
|
@ -164,7 +170,7 @@ void ListViewFocusController::nextDelegate()
|
||||||
}
|
}
|
||||||
case Section::Delegate:
|
case Section::Delegate:
|
||||||
if (m_delegateIndex < (size() - 1)) {
|
if (m_delegateIndex < (size() - 1)) {
|
||||||
m_delegateIndex++;
|
setDelegateIndex(m_delegateIndex + 1);
|
||||||
viewAtCurrentIndex();
|
viewAtCurrentIndex();
|
||||||
break;
|
break;
|
||||||
} else if (hasFooter()) {
|
} else if (hasFooter()) {
|
||||||
|
|
@ -199,14 +205,14 @@ void ListViewFocusController::previousDelegate()
|
||||||
case Section::Footer: {
|
case Section::Footer: {
|
||||||
if (size() > 0) {
|
if (size() > 0) {
|
||||||
m_currentSection = Section::Delegate;
|
m_currentSection = Section::Delegate;
|
||||||
m_delegateIndex = size() - 1;
|
setDelegateIndex(size() - 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
}
|
}
|
||||||
case Section::Delegate: {
|
case Section::Delegate: {
|
||||||
if (m_delegateIndex > 0) {
|
if (m_delegateIndex > 0) {
|
||||||
m_delegateIndex--;
|
setDelegateIndex(m_delegateIndex - 1);
|
||||||
break;
|
break;
|
||||||
} else if (hasHeader()) {
|
} else if (hasHeader()) {
|
||||||
m_currentSection = Section::Header;
|
m_currentSection = Section::Header;
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ private:
|
||||||
|
|
||||||
int size() const;
|
int size() const;
|
||||||
int currentIndex() const;
|
int currentIndex() const;
|
||||||
|
void setDelegateIndex(int index);
|
||||||
void viewAtCurrentIndex() const;
|
void viewAtCurrentIndex() const;
|
||||||
QQuickItem* itemAtIndex(const int index) const;
|
QQuickItem* itemAtIndex(const int index) const;
|
||||||
QQuickItem* currentDelegate() const;
|
QQuickItem* currentDelegate() const;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue