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:
parent
0d4ca979bc
commit
38fa6fc291
|
@ -179,8 +179,10 @@ void emitChatroomWidget(QLayout* layout, int index)
|
||||||
|
|
||||||
bool CircleWidget::cycleContacts(bool forward)
|
bool CircleWidget::cycleContacts(bool forward)
|
||||||
{
|
{
|
||||||
|
qDebug() << "Cycling on contact: " << getName();
|
||||||
if (listLayout->friendTotalCount() == 0)
|
if (listLayout->friendTotalCount() == 0)
|
||||||
{
|
{
|
||||||
|
qDebug() << "Empty";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (forward)
|
if (forward)
|
||||||
|
@ -189,12 +191,14 @@ bool CircleWidget::cycleContacts(bool forward)
|
||||||
{
|
{
|
||||||
expand();
|
expand();
|
||||||
emitChatroomWidget(listLayout->getLayoutOnline(), 0);
|
emitChatroomWidget(listLayout->getLayoutOnline(), 0);
|
||||||
|
qDebug() << "emmited 1";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (listLayout->getLayoutOffline()->count() != 0)
|
else if (listLayout->getLayoutOffline()->count() != 0)
|
||||||
{
|
{
|
||||||
expand();
|
expand();
|
||||||
emitChatroomWidget(listLayout->getLayoutOffline(), 0);
|
emitChatroomWidget(listLayout->getLayoutOffline(), 0);
|
||||||
|
qDebug() << "emmited 2";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -204,12 +208,14 @@ bool CircleWidget::cycleContacts(bool forward)
|
||||||
{
|
{
|
||||||
expand();
|
expand();
|
||||||
emitChatroomWidget(listLayout->getLayoutOffline(), listLayout->getLayoutOffline()->count() - 1);
|
emitChatroomWidget(listLayout->getLayoutOffline(), listLayout->getLayoutOffline()->count() - 1);
|
||||||
|
qDebug() << "emmited 3";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (listLayout->getLayoutOnline()->count() != 0)
|
else if (listLayout->getLayoutOnline()->count() != 0)
|
||||||
{
|
{
|
||||||
expand();
|
expand();
|
||||||
emitChatroomWidget(listLayout->getLayoutOnline(), listLayout->getLayoutOnline()->count() - 1);
|
emitChatroomWidget(listLayout->getLayoutOnline(), listLayout->getLayoutOnline()->count() - 1);
|
||||||
|
qDebug() << "emmited 4";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,10 +168,6 @@ void FriendListWidget::cycleContacts(GenericChatroomWidget* activeChatroomWidget
|
||||||
circleWidget = CircleWidget::getFromID(Settings::getInstance().getFriendCircleIndex(FriendList::findFriend(friendWidget->friendId)->getToxId()));
|
circleWidget = CircleWidget::getFromID(Settings::getInstance().getFriendCircleIndex(FriendList::findFriend(friendWidget->friendId)->getToxId()));
|
||||||
if (circleWidget != nullptr)
|
if (circleWidget != nullptr)
|
||||||
{
|
{
|
||||||
if (friendWidget == nullptr)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (circleWidget->cycleContacts(friendWidget, forward))
|
if (circleWidget->cycleContacts(friendWidget, forward))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,14 @@ int GenericChatItemLayout::indexOfClosestSortedWidget(GenericChatItemWidget* wid
|
||||||
GenericChatItemWidget* atMid = dynamic_cast<GenericChatItemWidget*>(layout->itemAt(mid)->widget());
|
GenericChatItemWidget* atMid = dynamic_cast<GenericChatItemWidget*>(layout->itemAt(mid)->widget());
|
||||||
assert(atMid != nullptr);
|
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;
|
min = mid + 1;
|
||||||
else
|
else
|
||||||
max = mid;
|
max = mid;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user