Fix server columns text other than name being invisible (#4475)

This commit is contained in:
Alexandru Ionut Tripon
2025-12-14 00:54:42 +02:00
committed by GitHub

View File

@@ -112,11 +112,7 @@ struct Server {
QByteArray m_icon;
// Data - temporary
bool m_checked = false;
bool m_up = false;
QString m_motd; // https://mctools.org/motd-creator
std::optional<int> m_currentPlayers; // nullopt if not calculated/calculating
int m_maxPlayers = 0;
};
static std::unique_ptr<nbt::tag_compound> parseServersDat(const QString& filename)
@@ -312,37 +308,33 @@ class ServersModel : public QAbstractListModel {
switch (role) {
case Qt::DecorationRole: {
switch (column) {
case 0: {
auto& bytes = m_servers[row].m_icon;
if (bytes.size()) {
QPixmap px;
if (px.loadFromData(bytes))
return QIcon(px);
}
return QIcon::fromTheme("unknown_server");
if (column == 0) {
auto& bytes = m_servers[row].m_icon;
if (bytes.size()) {
QPixmap px;
if (px.loadFromData(bytes))
return QIcon(px);
}
return QIcon::fromTheme("unknown_server");
} else {
return QVariant();
}
}
case Qt::DisplayRole:
switch (column) {
case 0:
return m_servers[row].m_name;
case 1:
return m_servers[row].m_address;
default:
return QVariant();
}
case 2:
if (role == Qt::DisplayRole) {
case 2:
if (m_servers[row].m_currentPlayers) {
return *m_servers[row].m_currentPlayers;
} else {
return "...";
}
} else {
default:
return QVariant();
}
}
case Qt::DisplayRole:
if (column == 0)
return m_servers[row].m_name;
else
return QVariant();
}
case ServerPtrRole:
if (column == 0)
return QVariant::fromValue<void*>((void*)&m_servers[row]);