forked from teamnwah/openmw-tes3coop
[Browser] Add "no password" filter to browser
This commit is contained in:
parent
fb67180809
commit
ba8613a179
5 changed files with 26 additions and 1 deletions
|
@ -54,6 +54,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
connect(tblServerBrowser, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(play()));
|
||||
connect(cBoxNotFull, SIGNAL(toggled(bool)), this, SLOT(notFullSwitch(bool)));
|
||||
connect(cBoxWithPlayers, SIGNAL(toggled(bool)), this, SLOT(havePlayersSwitch(bool)));
|
||||
connect(cBBoxWOPass, SIGNAL(toggled(bool)), this, SLOT(noPasswordSwitch(bool)));
|
||||
connect(comboLatency, SIGNAL(currentIndexChanged(int)), this, SLOT(maxLatencyChanged(int)));
|
||||
connect(leGamemode, SIGNAL(textChanged(const QString &)), this, SLOT(gamemodeChanged(const QString &)));
|
||||
loadFavorites();
|
||||
|
@ -229,6 +230,11 @@ void MainWindow::havePlayersSwitch(bool state)
|
|||
proxyModel->filterEmptyServers(state);
|
||||
}
|
||||
|
||||
void MainWindow::noPasswordSwitch(bool state)
|
||||
{
|
||||
proxyModel->filterPassworded(state);
|
||||
}
|
||||
|
||||
void MainWindow::maxLatencyChanged(int index)
|
||||
{
|
||||
int maxLatency = index * 50;
|
||||
|
|
|
@ -31,6 +31,7 @@ protected slots:
|
|||
void serverSelected();
|
||||
void notFullSwitch(bool state);
|
||||
void havePlayersSwitch(bool state);
|
||||
void noPasswordSwitch(bool state);
|
||||
void maxLatencyChanged(int index);
|
||||
void gamemodeChanged(const QString &text);
|
||||
private:
|
||||
|
|
|
@ -14,6 +14,7 @@ bool MySortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &
|
|||
QModelIndex pingIndex = sourceModel()->index(sourceRow, ServerData::PING, sourceParent);
|
||||
QModelIndex plIndex = sourceModel()->index(sourceRow, ServerData::PLAYERS, sourceParent);
|
||||
QModelIndex maxPlIndex = sourceModel()->index(sourceRow, ServerData::MAX_PLAYERS, sourceParent);
|
||||
QModelIndex passwordIndex = sourceModel()->index(sourceRow, ServerData::PASSW, sourceParent);
|
||||
|
||||
bool pingOk;
|
||||
int ping = sourceModel()->data(pingIndex).toInt(&pingOk);
|
||||
|
@ -26,6 +27,8 @@ bool MySortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &
|
|||
return false;
|
||||
if (filterFull && players >= maxPlayers)
|
||||
return false;
|
||||
if(filterPasswEnabled && sourceModel()->data(passwordIndex).toString() == "Yes")
|
||||
return false;
|
||||
|
||||
return QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent);
|
||||
}
|
||||
|
@ -51,6 +54,7 @@ MySortFilterProxyModel::MySortFilterProxyModel(QObject *parent) : QSortFilterPro
|
|||
{
|
||||
filterEmpty = false;
|
||||
filterFull = false;
|
||||
filterPasswEnabled = false;
|
||||
maxPing = 0;
|
||||
setSortCaseSensitivity(Qt::CaseSensitivity::CaseInsensitive);
|
||||
}
|
||||
|
@ -72,3 +76,9 @@ void MySortFilterProxyModel::pingLessThan(int maxPing)
|
|||
this->maxPing = maxPing;
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
void MySortFilterProxyModel::filterPassworded(bool state)
|
||||
{
|
||||
filterPasswEnabled = state;
|
||||
invalidateFilter();
|
||||
}
|
||||
|
|
|
@ -18,9 +18,10 @@ public:
|
|||
explicit MySortFilterProxyModel(QObject *parent);
|
||||
void filterFullServer(bool state);
|
||||
void filterEmptyServers(bool state);
|
||||
void filterPassworded(bool state);
|
||||
void pingLessThan(int maxPing);
|
||||
private:
|
||||
bool filterEmpty, filterFull;
|
||||
bool filterEmpty, filterFull, filterPasswEnabled;
|
||||
int maxPing;
|
||||
};
|
||||
|
||||
|
|
|
@ -166,6 +166,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cBBoxWOPass">
|
||||
<property name="text">
|
||||
<string>No password</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
|
|
Loading…
Reference in a new issue