1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +01:00

[ButtonWithMenu] Fixed selectPreviousItem not selecting first item

This commit is contained in:
nowrep 2014-02-20 17:06:21 +01:00
parent 77e8afb5ec
commit eb9b2635d5

View File

@ -58,7 +58,7 @@ void ButtonWithMenu::selectPreviousItem()
{ {
int index = m_items.indexOf(m_currentItem) - 1; int index = m_items.indexOf(m_currentItem) - 1;
if (index > 0) { if (index >= 0) {
setCurrentIndex(index); setCurrentIndex(index);
} }
} }
@ -124,20 +124,11 @@ void ButtonWithMenu::setCurrentIndex(int index, bool emitSignal)
void ButtonWithMenu::wheelEvent(QWheelEvent* event) void ButtonWithMenu::wheelEvent(QWheelEvent* event)
{ {
int currItemIndex = m_items.indexOf(m_currentItem);
int itemsCount = m_items.count();
if (itemsCount == 0) {
return;
}
if (event->delta() > 0) { if (event->delta() > 0) {
if (currItemIndex != 0) { selectPreviousItem();
setCurrentItem(m_items.at(currItemIndex - 1));
}
} }
else if (currItemIndex < itemsCount - 1) { else {
setCurrentItem(m_items.at(currItemIndex + 1)); selectNextItem();
} }
event->accept(); event->accept();