mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2025-12-21 06:42:41 -08:00
Reduce data dependency for GamesProxyModel
This commit is contained in:
committed by
Gavin Bisesi
parent
d65a444ac5
commit
c5aa75d4d1
@@ -25,7 +25,8 @@ GameSelector::GameSelector(AbstractClient *_client, const TabSupervisor *_tabSup
|
|||||||
gameListModel = new GamesModel(_rooms, _gameTypes, this);
|
gameListModel = new GamesModel(_rooms, _gameTypes, this);
|
||||||
if(showfilters)
|
if(showfilters)
|
||||||
{
|
{
|
||||||
gameListProxyModel = new GamesProxyModel(this, tabSupervisor->getUserInfo());
|
bool ownUserIsRegistered = (bool)(tabSupervisor->getUserInfo()->user_level() & ServerInfo_User::IsRegistered);
|
||||||
|
gameListProxyModel = new GamesProxyModel(this, ownUserIsRegistered);
|
||||||
gameListProxyModel->setSourceModel(gameListModel);
|
gameListProxyModel->setSourceModel(gameListModel);
|
||||||
gameListProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
gameListProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||||
gameListView->setModel(gameListProxyModel);
|
gameListView->setModel(gameListProxyModel);
|
||||||
|
|||||||
@@ -225,9 +225,9 @@ void GamesModel::updateGameList(const ServerInfo_Game &game)
|
|||||||
endInsertRows();
|
endInsertRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
GamesProxyModel::GamesProxyModel(QObject *parent, ServerInfo_User *_ownUser)
|
GamesProxyModel::GamesProxyModel(QObject *parent, bool _ownUserIsRegistered)
|
||||||
: QSortFilterProxyModel(parent),
|
: QSortFilterProxyModel(parent),
|
||||||
ownUser(_ownUser),
|
ownUserIsRegistered(_ownUserIsRegistered),
|
||||||
showBuddiesOnlyGames(false),
|
showBuddiesOnlyGames(false),
|
||||||
unavailableGamesVisible(false),
|
unavailableGamesVisible(false),
|
||||||
showPasswordProtectedGames(true),
|
showPasswordProtectedGames(true),
|
||||||
@@ -348,7 +348,7 @@ bool GamesProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &/*sourc
|
|||||||
return false;
|
return false;
|
||||||
if (game.started())
|
if (game.started())
|
||||||
return false;
|
return false;
|
||||||
if (!(ownUser->user_level() & ServerInfo_User::IsRegistered))
|
if (!ownUserIsRegistered)
|
||||||
if (game.only_registered())
|
if (game.only_registered())
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class ServerInfo_User;
|
|||||||
class GamesProxyModel : public QSortFilterProxyModel {
|
class GamesProxyModel : public QSortFilterProxyModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
ServerInfo_User *ownUser;
|
bool ownUserIsRegistered;
|
||||||
bool showBuddiesOnlyGames;
|
bool showBuddiesOnlyGames;
|
||||||
bool unavailableGamesVisible;
|
bool unavailableGamesVisible;
|
||||||
bool showPasswordProtectedGames;
|
bool showPasswordProtectedGames;
|
||||||
@@ -56,7 +56,7 @@ private:
|
|||||||
|
|
||||||
static const int DEFAULT_MAX_PLAYERS_MAX = 99;
|
static const int DEFAULT_MAX_PLAYERS_MAX = 99;
|
||||||
public:
|
public:
|
||||||
GamesProxyModel(QObject *parent = 0, ServerInfo_User *_ownUser = 0);
|
GamesProxyModel(QObject *parent = 0, bool _ownUserIsRegistered = false);
|
||||||
|
|
||||||
bool getShowBuddiesOnlyGames() const {return showBuddiesOnlyGames; }
|
bool getShowBuddiesOnlyGames() const {return showBuddiesOnlyGames; }
|
||||||
void setShowBuddiesOnlyGames(bool _showBuddiesOnlyGames);
|
void setShowBuddiesOnlyGames(bool _showBuddiesOnlyGames);
|
||||||
|
|||||||
Reference in New Issue
Block a user