mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge pull request #6614
bodwok (1): fix(FriendList): exclusion of possible undefined behavior
This commit is contained in:
commit
6cc9366ebe
@ -40,6 +40,11 @@ bool FriendListManager::getPositionsChanged() const
|
|||||||
return positionsChanged;
|
return positionsChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FriendListManager::getGroupsOnTop() const
|
||||||
|
{
|
||||||
|
return groupsOnTop;
|
||||||
|
}
|
||||||
|
|
||||||
void FriendListManager::addFriendListItem(IFriendListItem *item)
|
void FriendListManager::addFriendListItem(IFriendListItem *item)
|
||||||
{
|
{
|
||||||
if (item->isGroup() && item->getWidget() != nullptr) {
|
if (item->isGroup() && item->getWidget() != nullptr) {
|
||||||
|
@ -38,6 +38,7 @@ public:
|
|||||||
bool needHideCircles() const;
|
bool needHideCircles() const;
|
||||||
// If the contact positions have changed, need to redraw view
|
// If the contact positions have changed, need to redraw view
|
||||||
bool getPositionsChanged() const;
|
bool getPositionsChanged() const;
|
||||||
|
bool getGroupsOnTop() const;
|
||||||
|
|
||||||
void addFriendListItem(IFriendListItem* item);
|
void addFriendListItem(IFriendListItem* item);
|
||||||
void removeFriendListItem(IFriendListItem* item);
|
void removeFriendListItem(IFriendListItem* item);
|
||||||
@ -69,11 +70,11 @@ private:
|
|||||||
|
|
||||||
bool byName = true;
|
bool byName = true;
|
||||||
bool hideCircles = false;
|
bool hideCircles = false;
|
||||||
bool groupsOnTop;
|
bool groupsOnTop = true;
|
||||||
bool positionsChanged;
|
bool positionsChanged = false;
|
||||||
bool needSort;
|
bool needSort = false;
|
||||||
QVector<IFriendListItemPtr> items;
|
QVector<IFriendListItemPtr> items;
|
||||||
// At startup, while the size of items is less than countContacts, the view will not be processed to improve performance
|
// At startup, while the size of items is less than countContacts, the view will not be processed to improve performance
|
||||||
int countContacts;
|
int countContacts = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -148,6 +148,11 @@ public:
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool getGroupsOnTop()
|
||||||
|
{
|
||||||
|
return groupsOnTop;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief buildUnsorted Creates items to init the FriendListManager.
|
* @brief buildUnsorted Creates items to init the FriendListManager.
|
||||||
* FriendListManager will own and manage these items
|
* FriendListManager will own and manage these items
|
||||||
@ -341,6 +346,7 @@ void TestFriendListManager::testSortByName()
|
|||||||
QCOMPARE(success, true);
|
QCOMPARE(success, true);
|
||||||
QCOMPARE(manager->getPositionsChanged(), false);
|
QCOMPARE(manager->getPositionsChanged(), false);
|
||||||
QCOMPARE(manager->getItems().size(), sortedVec.size());
|
QCOMPARE(manager->getItems().size(), sortedVec.size());
|
||||||
|
QCOMPARE(manager->getGroupsOnTop(), listBuilder.getGroupsOnTop());
|
||||||
|
|
||||||
for (int i = 0; i < sortedVec.size(); ++i) {
|
for (int i = 0; i < sortedVec.size(); ++i) {
|
||||||
IFriendListItem* fromManager = manager->getItems().at(i).get();
|
IFriendListItem* fromManager = manager->getItems().at(i).get();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user