[Browser] Implement filters

coverity_scan^2
Koncord 8 years ago
parent e3a304dd03
commit cb0f5524be

@ -23,7 +23,7 @@ MainWindow::MainWindow(QWidget *parent)
browser = new ServerModel;
favorites = new ServerModel;
proxyModel = new QSortFilterProxyModel;
proxyModel = new MySortFilterProxyModel(this);
proxyModel->setSourceModel(browser);
tblServerBrowser->setModel(proxyModel);
tblFavorites->setModel(proxyModel);
@ -41,7 +41,10 @@ MainWindow::MainWindow(QWidget *parent)
connect(tblFavorites, SIGNAL(clicked(QModelIndex)), this, SLOT(serverSelected()));
connect(tblFavorites, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(play()));
connect(tblServerBrowser, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(play()));
connect(cBoxNotFully, SIGNAL(toggled(bool)), this, SLOT(notFullySwitch(bool)));
connect(cBoxWithPlayers, SIGNAL(toggled(bool)), this, SLOT(havePlayersSwitch(bool)));
connect(comboLatency, SIGNAL(currentIndexChanged(int)), this, SLOT(maxLatencyChanged(int)));
connect(leGamemode, SIGNAL(textChanged(const QString &)), this, SLOT(gamemodeChanged(const QString &)));
loadFavorites();
}
@ -186,4 +189,27 @@ void MainWindow::loadFavorites()
addServerAndUpdate(server.toString());
file.close();
}
}
void MainWindow::notFullySwitch(bool state)
{
proxyModel->filterFullServer(state);
}
void MainWindow::havePlayersSwitch(bool state)
{
proxyModel->filterEmptyServers(state);
}
void MainWindow::maxLatencyChanged(int index)
{
int maxLatency = index * 50;
proxyModel->pingLessThan(maxLatency);
}
void MainWindow::gamemodeChanged(const QString &text)
{
proxyModel->setFilterFixedString(text);
proxyModel->setFilterKeyColumn(ServerData::MODNAME);
}

@ -8,7 +8,7 @@
#include "ui_Main.h"
#include "ServerModel.hpp"
#include <QSortFilterProxyModel>
#include "MySortFilterProxyModel.hpp"
#include <components/process/processinvoker.hpp>
class MainWindow : public QMainWindow, private Ui::MainWindow
@ -29,10 +29,14 @@ protected slots:
void deleteServer();
void play();
void serverSelected();
void notFullySwitch(bool state);
void havePlayersSwitch(bool state);
void maxLatencyChanged(int index);
void gamemodeChanged(const QString &text);
private:
Process::ProcessInvoker *mGameInvoker;
ServerModel *browser, *favorites;
QSortFilterProxyModel *proxyModel;
MySortFilterProxyModel *proxyModel;
void loadFavorites();
};

Loading…
Cancel
Save