forked from mirror/openmw-tes3mp
[Browser] Implement filters
This commit is contained in:
parent
e3a304dd03
commit
cb0f5524be
2 changed files with 35 additions and 5 deletions
|
@ -23,7 +23,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
|
|
||||||
browser = new ServerModel;
|
browser = new ServerModel;
|
||||||
favorites = new ServerModel;
|
favorites = new ServerModel;
|
||||||
proxyModel = new QSortFilterProxyModel;
|
proxyModel = new MySortFilterProxyModel(this);
|
||||||
proxyModel->setSourceModel(browser);
|
proxyModel->setSourceModel(browser);
|
||||||
tblServerBrowser->setModel(proxyModel);
|
tblServerBrowser->setModel(proxyModel);
|
||||||
tblFavorites->setModel(proxyModel);
|
tblFavorites->setModel(proxyModel);
|
||||||
|
@ -41,7 +41,10 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
connect(tblFavorites, SIGNAL(clicked(QModelIndex)), this, SLOT(serverSelected()));
|
connect(tblFavorites, SIGNAL(clicked(QModelIndex)), this, SLOT(serverSelected()));
|
||||||
connect(tblFavorites, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(play()));
|
connect(tblFavorites, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(play()));
|
||||||
connect(tblServerBrowser, 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();
|
loadFavorites();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,3 +190,26 @@ void MainWindow::loadFavorites()
|
||||||
|
|
||||||
file.close();
|
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 "ui_Main.h"
|
||||||
#include "ServerModel.hpp"
|
#include "ServerModel.hpp"
|
||||||
#include <QSortFilterProxyModel>
|
#include "MySortFilterProxyModel.hpp"
|
||||||
#include <components/process/processinvoker.hpp>
|
#include <components/process/processinvoker.hpp>
|
||||||
|
|
||||||
class MainWindow : public QMainWindow, private Ui::MainWindow
|
class MainWindow : public QMainWindow, private Ui::MainWindow
|
||||||
|
@ -29,10 +29,14 @@ protected slots:
|
||||||
void deleteServer();
|
void deleteServer();
|
||||||
void play();
|
void play();
|
||||||
void serverSelected();
|
void serverSelected();
|
||||||
|
void notFullySwitch(bool state);
|
||||||
|
void havePlayersSwitch(bool state);
|
||||||
|
void maxLatencyChanged(int index);
|
||||||
|
void gamemodeChanged(const QString &text);
|
||||||
private:
|
private:
|
||||||
Process::ProcessInvoker *mGameInvoker;
|
Process::ProcessInvoker *mGameInvoker;
|
||||||
ServerModel *browser, *favorites;
|
ServerModel *browser, *favorites;
|
||||||
QSortFilterProxyModel *proxyModel;
|
MySortFilterProxyModel *proxyModel;
|
||||||
void loadFavorites();
|
void loadFavorites();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue