Change "Show full" "Show running" checkboxes to a single box
IMO these should not have been split
This commit is contained in:
parent
a7f3ce4050
commit
eebc615c1c
4 changed files with 20 additions and 36 deletions
|
@ -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"));
|
||||
|
|
|
@ -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<int, QString> &_rooms, const QMap<int, GameTypeMap> &_gameTypes, QWidget *parent = 0);
|
||||
void retranslateUi();
|
||||
void processGameInfo(ServerInfo_Game *info);
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue