From 38fa6fc2915c2cb598404eb7810014a0be48b3ff Mon Sep 17 00:00:00 2001 From: TheSpiritXIII Date: Fri, 5 Jun 2015 13:54:55 -0400 Subject: [PATCH] Fix sorting and cycling bugs for circles --- src/widget/circlewidget.cpp | 6 ++++++ src/widget/friendlistwidget.cpp | 4 ---- src/widget/genericchatitemlayout.cpp | 9 ++++++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/widget/circlewidget.cpp b/src/widget/circlewidget.cpp index 0b07801c5..b893c2bee 100644 --- a/src/widget/circlewidget.cpp +++ b/src/widget/circlewidget.cpp @@ -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; } } diff --git a/src/widget/friendlistwidget.cpp b/src/widget/friendlistwidget.cpp index 67459de9b..3032771ef 100644 --- a/src/widget/friendlistwidget.cpp +++ b/src/widget/friendlistwidget.cpp @@ -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; diff --git a/src/widget/genericchatitemlayout.cpp b/src/widget/genericchatitemlayout.cpp index ae3153428..cf47a5fa6 100644 --- a/src/widget/genericchatitemlayout.cpp +++ b/src/widget/genericchatitemlayout.cpp @@ -102,7 +102,14 @@ int GenericChatItemLayout::indexOfClosestSortedWidget(GenericChatItemWidget* wid GenericChatItemWidget* atMid = dynamic_cast(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;