mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-08-26 10:45:02 -05:00
[UserList] Show amount of online buddies (#7126)
Some checks failed
Build Desktop / Configure (push) Has been cancelled
Build Desktop / Debian 13 (push) Has been cancelled
Build Desktop / Debian 12 (push) Has been cancelled
Build Desktop / Fedora 44 (push) Has been cancelled
Build Desktop / Fedora 43 (push) Has been cancelled
Build Desktop / Servatrice_Debian 12 (push) Has been cancelled
Build Desktop / Ubuntu 26.04 (push) Has been cancelled
Build Desktop / Ubuntu 24.04 (push) Has been cancelled
Build Desktop / Arch (push) Has been cancelled
Build Desktop / macOS 14 (push) Has been cancelled
Build Desktop / macOS 15 (push) Has been cancelled
Build Desktop / macOS 13 Intel (push) Has been cancelled
Build Desktop / macOS 15 Debug (push) Has been cancelled
Build Desktop / Windows 10 (push) Has been cancelled
Build Docker Image / amd64 & arm64 (push) Has been cancelled
Some checks failed
Build Desktop / Configure (push) Has been cancelled
Build Desktop / Debian 13 (push) Has been cancelled
Build Desktop / Debian 12 (push) Has been cancelled
Build Desktop / Fedora 44 (push) Has been cancelled
Build Desktop / Fedora 43 (push) Has been cancelled
Build Desktop / Servatrice_Debian 12 (push) Has been cancelled
Build Desktop / Ubuntu 26.04 (push) Has been cancelled
Build Desktop / Ubuntu 24.04 (push) Has been cancelled
Build Desktop / Arch (push) Has been cancelled
Build Desktop / macOS 14 (push) Has been cancelled
Build Desktop / macOS 15 (push) Has been cancelled
Build Desktop / macOS 13 Intel (push) Has been cancelled
Build Desktop / macOS 15 Debug (push) Has been cancelled
Build Desktop / Windows 10 (push) Has been cancelled
Build Docker Image / amd64 & arm64 (push) Has been cancelled
* [UserList] Show amount of online buddies Took 11 minutes * [UserList] Replace early return with if-else in updateSectionDivider RickyRister nit: the code is easier to follow with a standard if-else branch instead of an early return for the Buddy section. Took 1 minute --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
@@ -1639,15 +1639,27 @@ void UserListWidget::updateSectionDivider(Section section)
|
||||
return;
|
||||
}
|
||||
int visible = 0;
|
||||
int online = 0;
|
||||
for (int i = 0; i < divider->childCount(); ++i) {
|
||||
if (!divider->child(i)->isHidden()) {
|
||||
QTreeWidgetItem *child = divider->child(i);
|
||||
if (!child->isHidden()) {
|
||||
++visible;
|
||||
if (child->data(0, UserListRoles::Online).toBool()) {
|
||||
++online;
|
||||
}
|
||||
}
|
||||
}
|
||||
// The tree draws no branches (rows are flush), so the divider carries its
|
||||
// own collapse arrow glyph.
|
||||
const QString arrow = divider->isExpanded() ? QStringLiteral("\u25BE") : QStringLiteral("\u25B8");
|
||||
divider->setText(0, tr("%1 %2 (%3)").arg(arrow, sectionTitle(section)).arg(visible));
|
||||
if (section == Section::Buddy) {
|
||||
// The buddy divider reports how many of the shown buddies are online,
|
||||
// mirroring the "Buddies online: %1 / %2" title of the non-sectioned
|
||||
// buddy list.
|
||||
divider->setText(0, tr("%1 %2 (%3/%4)").arg(arrow, sectionTitle(section)).arg(online).arg(visible));
|
||||
} else {
|
||||
divider->setText(0, tr("%1 %2 (%3)").arg(arrow, sectionTitle(section)).arg(visible));
|
||||
}
|
||||
}
|
||||
|
||||
void UserListWidget::handleSectionExpansion(QTreeWidgetItem *item, bool expanded)
|
||||
|
||||
Reference in New Issue
Block a user