1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Fix sorting and cycling bugs for circles

This commit is contained in:
TheSpiritXIII 2015-06-05 13:54:55 -04:00 committed by tux3
parent 0d4ca979bc
commit 38fa6fc291
3 changed files with 14 additions and 5 deletions

View File

@ -179,8 +179,10 @@ void emitChatroomWidget(QLayout* layout, int index)
bool CircleWidget::cycleContacts(bool forward)
{
qDebug() << "Cycling on contact: " << getName();
if (listLayout->friendTotalCount() == 0)
{
qDebug() << "Empty";
return false;
}
if (forward)
@ -189,12 +191,14 @@ bool CircleWidget::cycleContacts(bool forward)
{
expand();
emitChatroomWidget(listLayout->getLayoutOnline(), 0);
qDebug() << "emmited 1";
return true;
}
else if (listLayout->getLayoutOffline()->count() != 0)
{
expand();
emitChatroomWidget(listLayout->getLayoutOffline(), 0);
qDebug() << "emmited 2";
return true;
}
}
@ -204,12 +208,14 @@ bool CircleWidget::cycleContacts(bool forward)
{
expand();
emitChatroomWidget(listLayout->getLayoutOffline(), listLayout->getLayoutOffline()->count() - 1);
qDebug() << "emmited 3";
return true;
}
else if (listLayout->getLayoutOnline()->count() != 0)
{
expand();
emitChatroomWidget(listLayout->getLayoutOnline(), listLayout->getLayoutOnline()->count() - 1);
qDebug() << "emmited 4";
return true;
}
}

View File

@ -168,10 +168,6 @@ void FriendListWidget::cycleContacts(GenericChatroomWidget* activeChatroomWidget
circleWidget = CircleWidget::getFromID(Settings::getInstance().getFriendCircleIndex(FriendList::findFriend(friendWidget->friendId)->getToxId()));
if (circleWidget != nullptr)
{
if (friendWidget == nullptr)
{
return;
}
if (circleWidget->cycleContacts(friendWidget, forward))
return;

View File

@ -102,7 +102,14 @@ int GenericChatItemLayout::indexOfClosestSortedWidget(GenericChatItemWidget* wid
GenericChatItemWidget* atMid = dynamic_cast<GenericChatItemWidget*>(layout->itemAt(mid)->widget());
assert(atMid != nullptr);
if (atMid->getName().localeAwareCompare(widget->getName()) < 0)
bool lessThan = false;
int compareValue = atMid->getName().localeAwareCompare(widget->getName());
if (compareValue < 0)
lessThan = true;
else if (compareValue == 0)
lessThan = atMid < widget; // Consistent ordering.
if (lessThan)
min = mid + 1;
else
max = mid;