Filter registered-only games as unavailable when user isn't regged
This commit is contained in:
parent
eebc615c1c
commit
edd429d874
6 changed files with 17 additions and 10 deletions
|
@ -18,7 +18,7 @@ GameSelector::GameSelector(AbstractClient *_client, TabSupervisor *_tabSuperviso
|
||||||
{
|
{
|
||||||
gameListView = new QTreeView;
|
gameListView = new QTreeView;
|
||||||
gameListModel = new GamesModel(_rooms, _gameTypes, this);
|
gameListModel = new GamesModel(_rooms, _gameTypes, this);
|
||||||
gameListProxyModel = new GamesProxyModel(this);
|
gameListProxyModel = new GamesProxyModel(this, room->getCurrentUser());
|
||||||
gameListProxyModel->setSourceModel(gameListModel);
|
gameListProxyModel->setSourceModel(gameListModel);
|
||||||
gameListProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
gameListProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||||
gameListView->setModel(gameListProxyModel);
|
gameListView->setModel(gameListProxyModel);
|
||||||
|
|
|
@ -106,8 +106,8 @@ void GamesModel::updateGameList(ServerInfo_Game *_game)
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
GamesProxyModel::GamesProxyModel(QObject *parent)
|
GamesProxyModel::GamesProxyModel(QObject *parent, ServerInfo_User *_ownUser)
|
||||||
: QSortFilterProxyModel(parent), unjoinableGamesVisible(false)
|
: QSortFilterProxyModel(parent), ownUser(_ownUser), unjoinableGamesVisible(false)
|
||||||
{
|
{
|
||||||
setDynamicSortFilter(true);
|
setDynamicSortFilter(true);
|
||||||
}
|
}
|
||||||
|
@ -130,6 +130,9 @@ bool GamesProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &/*sourc
|
||||||
return false;
|
return false;
|
||||||
if (game->getStarted())
|
if (game->getStarted())
|
||||||
return false;
|
return false;
|
||||||
|
if (!(ownUser->getUserLevel() & ServerInfo_User::IsRegistered))
|
||||||
|
if (game->getOnlyRegistered())
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include "gametypemap.h"
|
#include "gametypemap.h"
|
||||||
|
#include "protocol_datastructures.h"
|
||||||
|
|
||||||
class ServerInfo_Game;
|
class ServerInfo_Game;
|
||||||
|
|
||||||
|
@ -29,9 +30,10 @@ public:
|
||||||
class GamesProxyModel : public QSortFilterProxyModel {
|
class GamesProxyModel : public QSortFilterProxyModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
|
ServerInfo_User *ownUser;
|
||||||
bool unjoinableGamesVisible;
|
bool unjoinableGamesVisible;
|
||||||
public:
|
public:
|
||||||
GamesProxyModel(QObject *parent = 0);
|
GamesProxyModel(QObject *parent = 0, ServerInfo_User *_ownUser = 0);
|
||||||
void setUnjoinableGamesVisible(bool _unjoinableGamesVisible);
|
void setUnjoinableGamesVisible(bool _unjoinableGamesVisible);
|
||||||
protected:
|
protected:
|
||||||
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
|
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
#include "chatview.h"
|
#include "chatview.h"
|
||||||
#include "gameselector.h"
|
#include "gameselector.h"
|
||||||
|
|
||||||
TabRoom::TabRoom(TabSupervisor *_tabSupervisor, AbstractClient *_client, const QString &_ownName, ServerInfo_Room *info)
|
TabRoom::TabRoom(TabSupervisor *_tabSupervisor, AbstractClient *_client, ServerInfo_User *_ownUser, ServerInfo_Room *info)
|
||||||
: Tab(_tabSupervisor), client(_client), roomId(info->getRoomId()), roomName(info->getName()), ownName(_ownName)
|
: Tab(_tabSupervisor), client(_client), roomId(info->getRoomId()), roomName(info->getName()), ownUser(_ownUser)
|
||||||
{
|
{
|
||||||
const QList<ServerInfo_GameType *> gameTypeList = info->getGameTypeList();
|
const QList<ServerInfo_GameType *> gameTypeList = info->getGameTypeList();
|
||||||
for (int i = 0; i < gameTypeList.size(); ++i)
|
for (int i = 0; i < gameTypeList.size(); ++i)
|
||||||
|
@ -30,7 +30,7 @@ TabRoom::TabRoom(TabSupervisor *_tabSupervisor, AbstractClient *_client, const Q
|
||||||
userList = new UserList(tabSupervisor, client, UserList::RoomList);
|
userList = new UserList(tabSupervisor, client, UserList::RoomList);
|
||||||
connect(userList, SIGNAL(openMessageDialog(const QString &, bool)), this, SIGNAL(openMessageDialog(const QString &, bool)));
|
connect(userList, SIGNAL(openMessageDialog(const QString &, bool)), this, SIGNAL(openMessageDialog(const QString &, bool)));
|
||||||
|
|
||||||
chatView = new ChatView(ownName, true);
|
chatView = new ChatView(ownUser->getName(), true);
|
||||||
connect(chatView, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString)));
|
connect(chatView, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString)));
|
||||||
connect(chatView, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString)));
|
connect(chatView, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString)));
|
||||||
sayLabel = new QLabel;
|
sayLabel = new QLabel;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define TAB_ROOM_H
|
#define TAB_ROOM_H
|
||||||
|
|
||||||
#include "tab.h"
|
#include "tab.h"
|
||||||
|
#include "protocol_datastructures.h"
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
|
||||||
|
@ -28,7 +29,7 @@ private:
|
||||||
AbstractClient *client;
|
AbstractClient *client;
|
||||||
int roomId;
|
int roomId;
|
||||||
QString roomName;
|
QString roomName;
|
||||||
QString ownName;
|
ServerInfo_User *ownUser;
|
||||||
QMap<int, QString> gameTypes;
|
QMap<int, QString> gameTypes;
|
||||||
|
|
||||||
GameSelector *gameSelector;
|
GameSelector *gameSelector;
|
||||||
|
@ -53,7 +54,7 @@ private slots:
|
||||||
void processLeaveRoomEvent(Event_LeaveRoom *event);
|
void processLeaveRoomEvent(Event_LeaveRoom *event);
|
||||||
void processSayEvent(Event_RoomSay *event);
|
void processSayEvent(Event_RoomSay *event);
|
||||||
public:
|
public:
|
||||||
TabRoom(TabSupervisor *_tabSupervisor, AbstractClient *_client, const QString &_ownName, ServerInfo_Room *info);
|
TabRoom(TabSupervisor *_tabSupervisor, AbstractClient *_client, ServerInfo_User *_ownUser, ServerInfo_Room *info);
|
||||||
~TabRoom();
|
~TabRoom();
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
void closeRequest();
|
void closeRequest();
|
||||||
|
@ -62,6 +63,7 @@ public:
|
||||||
const QMap<int, QString> &getGameTypes() const { return gameTypes; }
|
const QMap<int, QString> &getGameTypes() const { return gameTypes; }
|
||||||
QString getChannelName() const { return roomName; }
|
QString getChannelName() const { return roomName; }
|
||||||
QString getTabText() const { return roomName; }
|
QString getTabText() const { return roomName; }
|
||||||
|
ServerInfo_User *getCurrentUser() { return ownUser; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -265,7 +265,7 @@ void TabSupervisor::gameLeft(TabGame *tab)
|
||||||
|
|
||||||
void TabSupervisor::addRoomTab(ServerInfo_Room *info, bool setCurrent)
|
void TabSupervisor::addRoomTab(ServerInfo_Room *info, bool setCurrent)
|
||||||
{
|
{
|
||||||
TabRoom *tab = new TabRoom(this, client, userInfo->getName(), info);
|
TabRoom *tab = new TabRoom(this, client, userInfo, info);
|
||||||
connect(tab, SIGNAL(roomClosing(TabRoom *)), this, SLOT(roomLeft(TabRoom *)));
|
connect(tab, SIGNAL(roomClosing(TabRoom *)), this, SLOT(roomLeft(TabRoom *)));
|
||||||
connect(tab, SIGNAL(openMessageDialog(const QString &, bool)), this, SLOT(addMessageTab(const QString &, bool)));
|
connect(tab, SIGNAL(openMessageDialog(const QString &, bool)), this, SLOT(addMessageTab(const QString &, bool)));
|
||||||
int tabIndex = myAddTab(tab);
|
int tabIndex = myAddTab(tab);
|
||||||
|
|
Loading…
Reference in a new issue