mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-29 22:45:34 +00:00
[Browser] Mark unreachable servers as "Unreachable" instead 999
This commit is contained in:
parent
fe9a3088bd
commit
57353cdfff
3 changed files with 23 additions and 1 deletions
|
@ -6,6 +6,7 @@
|
|||
#include "ServerModel.hpp"
|
||||
|
||||
#include <qdebug.h>
|
||||
#include <apps/browser/netutils/Utils.hpp>
|
||||
|
||||
bool MySortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
||||
{
|
||||
|
@ -28,6 +29,25 @@ bool MySortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &
|
|||
return QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent);
|
||||
}
|
||||
|
||||
bool MySortFilterProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
|
||||
{
|
||||
if(sortColumn() == ServerData::PING)
|
||||
{
|
||||
bool valid;
|
||||
QModelIndex cLeft = source_left;
|
||||
QModelIndex cRight = source_right;
|
||||
|
||||
int pingright = sourceModel()->data(source_right).toInt(&valid);
|
||||
pingright = valid ? pingright : PING_UNREACHABLE;
|
||||
|
||||
int pingleft = sourceModel()->data(source_left).toInt(&valid);
|
||||
pingleft = valid ? pingleft : PING_UNREACHABLE;
|
||||
return pingleft < pingright;
|
||||
}
|
||||
else
|
||||
return QSortFilterProxyModel::lessThan(source_left, source_right);
|
||||
}
|
||||
|
||||
MySortFilterProxyModel::MySortFilterProxyModel(QObject *parent) : QSortFilterProxyModel(parent)
|
||||
{
|
||||
filterEmpty = false;
|
||||
|
|
|
@ -13,6 +13,7 @@ class MySortFilterProxyModel : public QSortFilterProxyModel
|
|||
Q_OBJECT
|
||||
protected:
|
||||
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const Q_DECL_FINAL;
|
||||
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const Q_DECL_FINAL;
|
||||
public:
|
||||
explicit MySortFilterProxyModel(QObject *parent);
|
||||
void filterFullServer(bool state);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <qmessagebox.h>
|
||||
#include "ServerModel.hpp"
|
||||
#include <qdebug.h>
|
||||
#include <apps/browser/netutils/Utils.hpp>
|
||||
|
||||
ServerModel::ServerModel(QObject *parent) : QAbstractTableModel(parent)
|
||||
{
|
||||
|
@ -43,7 +44,7 @@ QVariant ServerModel::data(const QModelIndex &index, int role) const
|
|||
var = QString(sd.rules.at("name").str.c_str());
|
||||
break;
|
||||
case ServerData::PING:
|
||||
var = sd.ping;
|
||||
var = sd.ping == PING_UNREACHABLE ? QVariant("Unreachable") : sd.ping;
|
||||
break;
|
||||
case ServerData::MODNAME:
|
||||
if (sd.rules.at("gamemode").str == "")
|
||||
|
|
Loading…
Reference in a new issue