diff --git a/cockatrice/src/gameselector.cpp b/cockatrice/src/gameselector.cpp index 63ede6ec..db6402c5 100644 --- a/cockatrice/src/gameselector.cpp +++ b/cockatrice/src/gameselector.cpp @@ -29,12 +29,10 @@ GameSelector::GameSelector(AbstractClient *_client, TabSupervisor *_tabSuperviso gameListView->header()->hideSection(1); gameListView->header()->setResizeMode(1, QHeaderView::ResizeToContents); - showFullGamesCheckBox = new QCheckBox; - showRunningGamesCheckBox = new QCheckBox; + showUnjoinableGamesCheckBox = new QCheckBox; QVBoxLayout *filterLayout = new QVBoxLayout; - filterLayout->addWidget(showFullGamesCheckBox); - filterLayout->addWidget(showRunningGamesCheckBox); + filterLayout->addWidget(showUnjoinableGamesCheckBox); if (room) createButton = new QPushButton; @@ -65,21 +63,15 @@ GameSelector::GameSelector(AbstractClient *_client, TabSupervisor *_tabSuperviso setMinimumWidth((qreal) (gameListView->columnWidth(0) * gameListModel->columnCount()) / 1.5); setMinimumHeight(200); - connect(showFullGamesCheckBox, SIGNAL(stateChanged(int)), this, SLOT(showFullGamesChanged(int))); - connect(showRunningGamesCheckBox, SIGNAL(stateChanged(int)), this, SLOT(showRunningGamesChanged(int))); + connect(showUnjoinableGamesCheckBox, SIGNAL(stateChanged(int)), this, SLOT(showUnjoinableGamesChanged(int))); connect(createButton, SIGNAL(clicked()), this, SLOT(actCreate())); connect(joinButton, SIGNAL(clicked()), this, SLOT(actJoin())); connect(spectateButton, SIGNAL(clicked()), this, SLOT(actJoin())); } -void GameSelector::showFullGamesChanged(int state) +void GameSelector::showUnjoinableGamesChanged(int state) { - gameListProxyModel->setFullGamesVisible(state); -} - -void GameSelector::showRunningGamesChanged(int state) -{ - gameListProxyModel->setRunningGamesVisible(state); + gameListProxyModel->setUnjoinableGamesVisible(state); } void GameSelector::actCreate() @@ -138,8 +130,7 @@ void GameSelector::actJoin() void GameSelector::retranslateUi() { setTitle(tr("Games")); - showFullGamesCheckBox->setText(tr("Show &full games")); - showRunningGamesCheckBox->setText(tr("Show &running games")); + showUnjoinableGamesCheckBox->setText(tr("Show u&njoinable games")); if (createButton) createButton->setText(tr("C&reate")); joinButton->setText(tr("&Join")); diff --git a/cockatrice/src/gameselector.h b/cockatrice/src/gameselector.h index 16fc2d7d..38acda2d 100644 --- a/cockatrice/src/gameselector.h +++ b/cockatrice/src/gameselector.h @@ -18,8 +18,7 @@ class TabRoom; class GameSelector : public QGroupBox { Q_OBJECT private slots: - void showFullGamesChanged(int state); - void showRunningGamesChanged(int state); + void showUnjoinableGamesChanged(int state); void actCreate(); void actJoin(); void checkResponse(ResponseCode response); @@ -34,11 +33,11 @@ private: GamesModel *gameListModel; GamesProxyModel *gameListProxyModel; QPushButton *createButton, *joinButton, *spectateButton; - QCheckBox *showFullGamesCheckBox, *showRunningGamesCheckBox; + QCheckBox *showUnjoinableGamesCheckBox; public: GameSelector(AbstractClient *_client, TabSupervisor *_tabSupervisor, TabRoom *_room, const QMap &_rooms, const QMap &_gameTypes, QWidget *parent = 0); void retranslateUi(); void processGameInfo(ServerInfo_Game *info); }; -#endif \ No newline at end of file +#endif diff --git a/cockatrice/src/gamesmodel.cpp b/cockatrice/src/gamesmodel.cpp index 031c4207..46a93d73 100644 --- a/cockatrice/src/gamesmodel.cpp +++ b/cockatrice/src/gamesmodel.cpp @@ -107,20 +107,14 @@ void GamesModel::updateGameList(ServerInfo_Game *_game) } GamesProxyModel::GamesProxyModel(QObject *parent) - : QSortFilterProxyModel(parent), fullGamesVisible(false) + : QSortFilterProxyModel(parent), unjoinableGamesVisible(false) { setDynamicSortFilter(true); } -void GamesProxyModel::setFullGamesVisible(bool _fullGamesVisible) +void GamesProxyModel::setUnjoinableGamesVisible(bool _unjoinableGamesVisible) { - fullGamesVisible = _fullGamesVisible; - invalidateFilter(); -} - -void GamesProxyModel::setRunningGamesVisible(bool _runningGamesVisible) -{ - runningGamesVisible = _runningGamesVisible; + unjoinableGamesVisible = _unjoinableGamesVisible; invalidateFilter(); } @@ -131,10 +125,12 @@ bool GamesProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &/*sourc return false; ServerInfo_Game *game = model->getGame(sourceRow); - if ((game->getPlayerCount() == game->getMaxPlayers()) && !fullGamesVisible) - return false; - if (game->getStarted() && !runningGamesVisible) - return false; + if (!unjoinableGamesVisible) { + if (game->getPlayerCount() == game->getMaxPlayers()) + return false; + if (game->getStarted()) + return false; + } return true; } diff --git a/cockatrice/src/gamesmodel.h b/cockatrice/src/gamesmodel.h index 8461faf6..5a859abe 100644 --- a/cockatrice/src/gamesmodel.h +++ b/cockatrice/src/gamesmodel.h @@ -29,12 +29,10 @@ public: class GamesProxyModel : public QSortFilterProxyModel { Q_OBJECT private: - bool fullGamesVisible; - bool runningGamesVisible; + bool unjoinableGamesVisible; public: GamesProxyModel(QObject *parent = 0); - void setFullGamesVisible(bool _fullGamesVisible); - void setRunningGamesVisible(bool _runningGamesVisible); + void setUnjoinableGamesVisible(bool _unjoinableGamesVisible); protected: bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; };