added game filter dialog in GameSelector; switched all dialogs to QDialogButtonBox; issue #32 fixed
This commit is contained in:
parent
facfc3cc52
commit
6b14b4e543
21 changed files with 310 additions and 116 deletions
|
@ -6,6 +6,7 @@ SET(cockatrice_SOURCES
|
||||||
src/abstractcounter.cpp
|
src/abstractcounter.cpp
|
||||||
src/counter_general.cpp
|
src/counter_general.cpp
|
||||||
src/dlg_creategame.cpp
|
src/dlg_creategame.cpp
|
||||||
|
src/dlg_filter_games.cpp
|
||||||
src/dlg_connect.cpp
|
src/dlg_connect.cpp
|
||||||
src/dlg_create_token.cpp
|
src/dlg_create_token.cpp
|
||||||
src/abstractclient.cpp
|
src/abstractclient.cpp
|
||||||
|
@ -79,6 +80,7 @@ SET(cockatrice_HEADERS
|
||||||
src/abstractcounter.h
|
src/abstractcounter.h
|
||||||
src/counter_general.h
|
src/counter_general.h
|
||||||
src/dlg_creategame.h
|
src/dlg_creategame.h
|
||||||
|
src/dlg_filter_games.h
|
||||||
src/dlg_connect.h
|
src/dlg_connect.h
|
||||||
src/dlg_create_token.h
|
src/dlg_create_token.h
|
||||||
src/gamesmodel.h
|
src/gamesmodel.h
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPushButton>
|
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
#include "dlg_connect.h"
|
#include "dlg_connect.h"
|
||||||
|
|
||||||
DlgConnect::DlgConnect(QWidget *parent)
|
DlgConnect::DlgConnect(QWidget *parent)
|
||||||
|
@ -32,10 +32,6 @@ DlgConnect::DlgConnect(QWidget *parent)
|
||||||
savePasswordCheckBox = new QCheckBox(tr("&Save password"));
|
savePasswordCheckBox = new QCheckBox(tr("&Save password"));
|
||||||
savePasswordCheckBox->setChecked(settings.value("save_password", 1).toInt());
|
savePasswordCheckBox->setChecked(settings.value("save_password", 1).toInt());
|
||||||
|
|
||||||
okButton = new QPushButton(tr("&OK"));
|
|
||||||
okButton->setDefault(true);
|
|
||||||
cancelButton = new QPushButton(tr("&Cancel"));
|
|
||||||
|
|
||||||
QGridLayout *grid = new QGridLayout;
|
QGridLayout *grid = new QGridLayout;
|
||||||
grid->addWidget(hostLabel, 0, 0);
|
grid->addWidget(hostLabel, 0, 0);
|
||||||
grid->addWidget(hostEdit, 0, 1);
|
grid->addWidget(hostEdit, 0, 1);
|
||||||
|
@ -47,22 +43,18 @@ DlgConnect::DlgConnect(QWidget *parent)
|
||||||
grid->addWidget(passwordEdit, 3, 1);
|
grid->addWidget(passwordEdit, 3, 1);
|
||||||
grid->addWidget(savePasswordCheckBox, 4, 0, 1, 2);
|
grid->addWidget(savePasswordCheckBox, 4, 0, 1, 2);
|
||||||
|
|
||||||
QHBoxLayout *buttonLayout = new QHBoxLayout;
|
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
buttonLayout->addStretch();
|
connect(buttonBox, SIGNAL(accepted()), this, SLOT(actOk()));
|
||||||
buttonLayout->addWidget(okButton);
|
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||||
buttonLayout->addWidget(cancelButton);
|
|
||||||
|
|
||||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||||
mainLayout->addLayout(grid);
|
mainLayout->addLayout(grid);
|
||||||
mainLayout->addLayout(buttonLayout);
|
mainLayout->addWidget(buttonBox);
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
|
|
||||||
setWindowTitle(tr("Connect to server"));
|
setWindowTitle(tr("Connect to server"));
|
||||||
setFixedHeight(sizeHint().height());
|
setFixedHeight(sizeHint().height());
|
||||||
setMinimumWidth(300);
|
setMinimumWidth(300);
|
||||||
|
|
||||||
connect(okButton, SIGNAL(clicked()), this, SLOT(actOk()));
|
|
||||||
connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DlgConnect::actOk()
|
void DlgConnect::actOk()
|
||||||
|
|
|
@ -22,7 +22,6 @@ private:
|
||||||
QLabel *hostLabel, *portLabel, *playernameLabel, *passwordLabel;
|
QLabel *hostLabel, *portLabel, *playernameLabel, *passwordLabel;
|
||||||
QLineEdit *hostEdit, *portEdit, *playernameEdit, *passwordEdit;
|
QLineEdit *hostEdit, *portEdit, *playernameEdit, *passwordEdit;
|
||||||
QCheckBox *savePasswordCheckBox;
|
QCheckBox *savePasswordCheckBox;
|
||||||
QPushButton *okButton, *cancelButton;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QPushButton>
|
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
#include "dlg_create_token.h"
|
#include "dlg_create_token.h"
|
||||||
|
|
||||||
DlgCreateToken::DlgCreateToken(QWidget *parent)
|
DlgCreateToken::DlgCreateToken(QWidget *parent)
|
||||||
|
@ -38,10 +38,6 @@ DlgCreateToken::DlgCreateToken(QWidget *parent)
|
||||||
destroyCheckBox = new QCheckBox(tr("&Destroy token when it leaves the table"));
|
destroyCheckBox = new QCheckBox(tr("&Destroy token when it leaves the table"));
|
||||||
destroyCheckBox->setChecked(true);
|
destroyCheckBox->setChecked(true);
|
||||||
|
|
||||||
okButton = new QPushButton(tr("&OK"));
|
|
||||||
okButton->setDefault(true);
|
|
||||||
cancelButton = new QPushButton(tr("&Cancel"));
|
|
||||||
|
|
||||||
QGridLayout *grid = new QGridLayout;
|
QGridLayout *grid = new QGridLayout;
|
||||||
grid->addWidget(nameLabel, 0, 0);
|
grid->addWidget(nameLabel, 0, 0);
|
||||||
grid->addWidget(nameEdit, 0, 1);
|
grid->addWidget(nameEdit, 0, 1);
|
||||||
|
@ -53,22 +49,18 @@ DlgCreateToken::DlgCreateToken(QWidget *parent)
|
||||||
grid->addWidget(annotationEdit, 3, 1);
|
grid->addWidget(annotationEdit, 3, 1);
|
||||||
grid->addWidget(destroyCheckBox, 4, 0, 1, 2);
|
grid->addWidget(destroyCheckBox, 4, 0, 1, 2);
|
||||||
|
|
||||||
QHBoxLayout *buttonLayout = new QHBoxLayout;
|
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
buttonLayout->addStretch();
|
connect(buttonBox, SIGNAL(accepted()), this, SLOT(actOk()));
|
||||||
buttonLayout->addWidget(okButton);
|
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||||
buttonLayout->addWidget(cancelButton);
|
|
||||||
|
|
||||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||||
mainLayout->addLayout(grid);
|
mainLayout->addLayout(grid);
|
||||||
mainLayout->addLayout(buttonLayout);
|
mainLayout->addWidget(buttonBox);
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
|
|
||||||
setWindowTitle(tr("Create token"));
|
setWindowTitle(tr("Create token"));
|
||||||
setFixedHeight(sizeHint().height());
|
setFixedHeight(sizeHint().height());
|
||||||
setMinimumWidth(300);
|
setMinimumWidth(300);
|
||||||
|
|
||||||
connect(okButton, SIGNAL(clicked()), this, SLOT(actOk()));
|
|
||||||
connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DlgCreateToken::actOk()
|
void DlgCreateToken::actOk()
|
||||||
|
|
|
@ -25,7 +25,6 @@ private:
|
||||||
QComboBox *colorEdit;
|
QComboBox *colorEdit;
|
||||||
QLineEdit *nameEdit, *ptEdit, *annotationEdit;
|
QLineEdit *nameEdit, *ptEdit, *annotationEdit;
|
||||||
QCheckBox *destroyCheckBox;
|
QCheckBox *destroyCheckBox;
|
||||||
QPushButton *okButton, *cancelButton;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include "dlg_creategame.h"
|
#include "dlg_creategame.h"
|
||||||
|
@ -85,18 +86,12 @@ void DlgCreateGame::sharedCtor()
|
||||||
grid->addWidget(joinRestrictionsGroupBox, 0, 1);
|
grid->addWidget(joinRestrictionsGroupBox, 0, 1);
|
||||||
grid->addWidget(gameTypeGroupBox, 1, 1);
|
grid->addWidget(gameTypeGroupBox, 1, 1);
|
||||||
|
|
||||||
okButton = new QPushButton(tr("&OK"));
|
buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok);
|
||||||
okButton->setDefault(true);
|
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||||
cancelButton = new QPushButton(tr("&Cancel"));
|
|
||||||
|
|
||||||
QHBoxLayout *buttonLayout = new QHBoxLayout;
|
|
||||||
buttonLayout->addStretch();
|
|
||||||
buttonLayout->addWidget(okButton);
|
|
||||||
buttonLayout->addWidget(cancelButton);
|
|
||||||
|
|
||||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||||
mainLayout->addLayout(grid);
|
mainLayout->addLayout(grid);
|
||||||
mainLayout->addLayout(buttonLayout);
|
mainLayout->addWidget(buttonBox);
|
||||||
|
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
|
|
||||||
|
@ -108,10 +103,10 @@ DlgCreateGame::DlgCreateGame(TabRoom *_room, const QMap<int, QString> &_gameType
|
||||||
{
|
{
|
||||||
sharedCtor();
|
sharedCtor();
|
||||||
|
|
||||||
setWindowTitle(tr("Create game"));
|
buttonBox->addButton(QDialogButtonBox::Cancel);
|
||||||
|
connect(buttonBox, SIGNAL(accepted()), this, SLOT(actOK()));
|
||||||
|
|
||||||
connect(okButton, SIGNAL(clicked()), this, SLOT(actOK()));
|
setWindowTitle(tr("Create game"));
|
||||||
connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DlgCreateGame::DlgCreateGame(const ServerInfo_Game &gameInfo, const QMap<int, QString> &_gameTypes, QWidget *parent)
|
DlgCreateGame::DlgCreateGame(const ServerInfo_Game &gameInfo, const QMap<int, QString> &_gameTypes, QWidget *parent)
|
||||||
|
@ -151,10 +146,9 @@ DlgCreateGame::DlgCreateGame(const ServerInfo_Game &gameInfo, const QMap<int, QS
|
||||||
gameTypeCheckBox->setChecked(types.contains(gameTypeIterator.key()));
|
gameTypeCheckBox->setChecked(types.contains(gameTypeIterator.key()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
|
||||||
|
|
||||||
setWindowTitle(tr("Game information"));
|
setWindowTitle(tr("Game information"));
|
||||||
okButton->setAutoDefault(true);
|
|
||||||
cancelButton->hide();
|
|
||||||
connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DlgCreateGame::actOK()
|
void DlgCreateGame::actOK()
|
||||||
|
@ -181,14 +175,12 @@ void DlgCreateGame::actOK()
|
||||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(checkResponse(Response)));
|
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(checkResponse(Response)));
|
||||||
room->sendRoomCommand(pend);
|
room->sendRoomCommand(pend);
|
||||||
|
|
||||||
okButton->setEnabled(false);
|
buttonBox->setEnabled(false);
|
||||||
cancelButton->setEnabled(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DlgCreateGame::checkResponse(const Response &response)
|
void DlgCreateGame::checkResponse(const Response &response)
|
||||||
{
|
{
|
||||||
okButton->setEnabled(true);
|
buttonBox->setEnabled(true);
|
||||||
cancelButton->setEnabled(true);
|
|
||||||
|
|
||||||
if (response.response_code() == Response::RespOk)
|
if (response.response_code() == Response::RespOk)
|
||||||
accept();
|
accept();
|
||||||
|
|
|
@ -10,6 +10,7 @@ class QPushButton;
|
||||||
class QCheckBox;
|
class QCheckBox;
|
||||||
class QGroupBox;
|
class QGroupBox;
|
||||||
class QSpinBox;
|
class QSpinBox;
|
||||||
|
class QDialogButtonBox;
|
||||||
class TabRoom;
|
class TabRoom;
|
||||||
|
|
||||||
class Response;
|
class Response;
|
||||||
|
@ -35,7 +36,7 @@ private:
|
||||||
QSpinBox *maxPlayersEdit;
|
QSpinBox *maxPlayersEdit;
|
||||||
QCheckBox *onlyBuddiesCheckBox, *onlyRegisteredCheckBox;
|
QCheckBox *onlyBuddiesCheckBox, *onlyRegisteredCheckBox;
|
||||||
QCheckBox *spectatorsAllowedCheckBox, *spectatorsNeedPasswordCheckBox, *spectatorsCanTalkCheckBox, *spectatorsSeeEverythingCheckBox;
|
QCheckBox *spectatorsAllowedCheckBox, *spectatorsNeedPasswordCheckBox, *spectatorsCanTalkCheckBox, *spectatorsSeeEverythingCheckBox;
|
||||||
QPushButton *okButton, *cancelButton;
|
QDialogButtonBox *buttonBox;
|
||||||
|
|
||||||
void sharedCtor();
|
void sharedCtor();
|
||||||
};
|
};
|
||||||
|
|
160
cockatrice/src/dlg_filter_games.cpp
Normal file
160
cockatrice/src/dlg_filter_games.cpp
Normal file
|
@ -0,0 +1,160 @@
|
||||||
|
#include "dlg_filter_games.h"
|
||||||
|
#include <QCheckBox>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QSpinBox>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QGroupBox>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QGridLayout>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
|
||||||
|
DlgFilterGames::DlgFilterGames(const QMap<int, QString> &allGameTypes, QWidget *parent)
|
||||||
|
: QDialog(parent)
|
||||||
|
{
|
||||||
|
unavailableGamesVisibleCheckBox = new QCheckBox(tr("Show &unavailable games"));
|
||||||
|
|
||||||
|
QLabel *gameNameFilterLabel = new QLabel(tr("Game &description:"));
|
||||||
|
gameNameFilterEdit = new QLineEdit;
|
||||||
|
|
||||||
|
QLabel *creatorNameFilterLabel = new QLabel(tr("&Creator name:"));
|
||||||
|
creatorNameFilterEdit = new QLineEdit;
|
||||||
|
|
||||||
|
QVBoxLayout *gameTypeFilterLayout = new QVBoxLayout;
|
||||||
|
QMapIterator<int, QString> gameTypesIterator(allGameTypes);
|
||||||
|
while (gameTypesIterator.hasNext()) {
|
||||||
|
gameTypesIterator.next();
|
||||||
|
QCheckBox *temp = new QCheckBox(gameTypesIterator.value());
|
||||||
|
gameTypeFilterCheckBoxes.insert(gameTypesIterator.key(), temp);
|
||||||
|
gameTypeFilterLayout->addWidget(temp);
|
||||||
|
}
|
||||||
|
QGroupBox *gameTypeFilterGroupBox;
|
||||||
|
if (!allGameTypes.isEmpty()) {
|
||||||
|
gameTypeFilterGroupBox = new QGroupBox(tr("&Game types"));
|
||||||
|
gameTypeFilterGroupBox->setLayout(gameTypeFilterLayout);
|
||||||
|
} else
|
||||||
|
gameTypeFilterGroupBox = 0;
|
||||||
|
|
||||||
|
QLabel *maxPlayersFilterMinLabel = new QLabel(tr("at &least:"));
|
||||||
|
maxPlayersFilterMinSpinBox = new QSpinBox;
|
||||||
|
maxPlayersFilterMinSpinBox->setMinimum(1);
|
||||||
|
maxPlayersFilterMinSpinBox->setMaximum(99);
|
||||||
|
maxPlayersFilterMinSpinBox->setValue(1);
|
||||||
|
maxPlayersFilterMinLabel->setBuddy(maxPlayersFilterMinSpinBox);
|
||||||
|
|
||||||
|
QLabel *maxPlayersFilterMaxLabel = new QLabel(tr("at &most:"));
|
||||||
|
maxPlayersFilterMaxSpinBox = new QSpinBox;
|
||||||
|
maxPlayersFilterMaxSpinBox->setMinimum(1);
|
||||||
|
maxPlayersFilterMaxSpinBox->setMaximum(99);
|
||||||
|
maxPlayersFilterMaxSpinBox->setValue(99);
|
||||||
|
maxPlayersFilterMaxLabel->setBuddy(maxPlayersFilterMaxSpinBox);
|
||||||
|
|
||||||
|
QGridLayout *maxPlayersFilterLayout = new QGridLayout;
|
||||||
|
maxPlayersFilterLayout->addWidget(maxPlayersFilterMinLabel, 0, 0);
|
||||||
|
maxPlayersFilterLayout->addWidget(maxPlayersFilterMinSpinBox, 0, 1);
|
||||||
|
maxPlayersFilterLayout->addWidget(maxPlayersFilterMaxLabel, 1, 0);
|
||||||
|
maxPlayersFilterLayout->addWidget(maxPlayersFilterMaxSpinBox, 1, 1);
|
||||||
|
|
||||||
|
QGroupBox *maxPlayersGroupBox = new QGroupBox(tr("Maximum player count"));
|
||||||
|
maxPlayersGroupBox->setLayout(maxPlayersFilterLayout);
|
||||||
|
|
||||||
|
QGridLayout *leftColumn = new QGridLayout;
|
||||||
|
leftColumn->addWidget(gameNameFilterLabel, 0, 0);
|
||||||
|
leftColumn->addWidget(gameNameFilterEdit, 0, 1);
|
||||||
|
leftColumn->addWidget(creatorNameFilterLabel, 1, 0);
|
||||||
|
leftColumn->addWidget(creatorNameFilterEdit, 1, 1);
|
||||||
|
leftColumn->addWidget(maxPlayersGroupBox, 2, 0, 1, 2);
|
||||||
|
|
||||||
|
QVBoxLayout *rightColumn = new QVBoxLayout;
|
||||||
|
rightColumn->addWidget(gameTypeFilterGroupBox);
|
||||||
|
|
||||||
|
QHBoxLayout *hbox = new QHBoxLayout;
|
||||||
|
hbox->addLayout(leftColumn);
|
||||||
|
hbox->addLayout(rightColumn);
|
||||||
|
|
||||||
|
QPushButton *okButton = new QPushButton(tr("O&K"));
|
||||||
|
okButton->setDefault(true);
|
||||||
|
okButton->setAutoDefault(true);
|
||||||
|
connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
|
||||||
|
QPushButton *cancelButton = new QPushButton(tr("&Cancel"));
|
||||||
|
connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
|
||||||
|
|
||||||
|
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
|
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
|
||||||
|
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||||
|
|
||||||
|
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||||
|
mainLayout->addLayout(hbox);
|
||||||
|
mainLayout->addWidget(buttonBox);
|
||||||
|
|
||||||
|
setLayout(mainLayout);
|
||||||
|
setWindowTitle(tr("Filter games"));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DlgFilterGames::getUnavailableGamesVisible() const
|
||||||
|
{
|
||||||
|
return unavailableGamesVisibleCheckBox->isChecked();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DlgFilterGames::setUnavailableGamesVisible(bool _unavailableGamesVisible)
|
||||||
|
{
|
||||||
|
unavailableGamesVisibleCheckBox->setChecked(_unavailableGamesVisible);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DlgFilterGames::getGameNameFilter() const
|
||||||
|
{
|
||||||
|
return gameNameFilterEdit->text();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DlgFilterGames::setGameNameFilter(const QString &_gameNameFilter)
|
||||||
|
{
|
||||||
|
gameNameFilterEdit->setText(_gameNameFilter);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DlgFilterGames::getCreatorNameFilter() const
|
||||||
|
{
|
||||||
|
return creatorNameFilterEdit->text();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DlgFilterGames::setCreatorNameFilter(const QString &_creatorNameFilter)
|
||||||
|
{
|
||||||
|
creatorNameFilterEdit->setText(_creatorNameFilter);
|
||||||
|
}
|
||||||
|
|
||||||
|
QSet<int> DlgFilterGames::getGameTypeFilter() const
|
||||||
|
{
|
||||||
|
QSet<int> result;
|
||||||
|
QMapIterator<int, QCheckBox *> i(gameTypeFilterCheckBoxes);
|
||||||
|
while (i.hasNext()) {
|
||||||
|
i.next();
|
||||||
|
if (i.value()->isChecked())
|
||||||
|
result.insert(i.key());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DlgFilterGames::setGameTypeFilter(const QSet<int> &_gameTypeFilter)
|
||||||
|
{
|
||||||
|
QMapIterator<int, QCheckBox *> i(gameTypeFilterCheckBoxes);
|
||||||
|
while (i.hasNext()) {
|
||||||
|
i.next();
|
||||||
|
i.value()->setChecked(_gameTypeFilter.contains(i.key()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int DlgFilterGames::getMaxPlayersFilterMin() const
|
||||||
|
{
|
||||||
|
return maxPlayersFilterMinSpinBox->value();
|
||||||
|
}
|
||||||
|
|
||||||
|
int DlgFilterGames::getMaxPlayersFilterMax() const
|
||||||
|
{
|
||||||
|
return maxPlayersFilterMaxSpinBox->value();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DlgFilterGames::setMaxPlayersFilter(int _maxPlayersFilterMin, int _maxPlayersFilterMax)
|
||||||
|
{
|
||||||
|
maxPlayersFilterMinSpinBox->setValue(_maxPlayersFilterMin);
|
||||||
|
maxPlayersFilterMaxSpinBox->setValue(_maxPlayersFilterMax == -1 ? maxPlayersFilterMaxSpinBox->maximum() : _maxPlayersFilterMax);
|
||||||
|
}
|
37
cockatrice/src/dlg_filter_games.h
Normal file
37
cockatrice/src/dlg_filter_games.h
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
#ifndef DLG_FILTER_GAMES_H
|
||||||
|
#define DLG_FILTER_GAMES_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QSet>
|
||||||
|
#include <QMap>
|
||||||
|
|
||||||
|
class QCheckBox;
|
||||||
|
class QLineEdit;
|
||||||
|
class QSpinBox;
|
||||||
|
|
||||||
|
class DlgFilterGames : public QDialog {
|
||||||
|
Q_OBJECT
|
||||||
|
private:
|
||||||
|
QCheckBox *unavailableGamesVisibleCheckBox;
|
||||||
|
QLineEdit *gameNameFilterEdit;
|
||||||
|
QLineEdit *creatorNameFilterEdit;
|
||||||
|
QMap<int, QCheckBox *> gameTypeFilterCheckBoxes;
|
||||||
|
QSpinBox *maxPlayersFilterMinSpinBox;
|
||||||
|
QSpinBox *maxPlayersFilterMaxSpinBox;
|
||||||
|
public:
|
||||||
|
DlgFilterGames(const QMap<int, QString> &allGameTypes, QWidget *parent = 0);
|
||||||
|
|
||||||
|
bool getUnavailableGamesVisible() const;
|
||||||
|
void setUnavailableGamesVisible(bool _unavailableGamesVisible);
|
||||||
|
QString getGameNameFilter() const;
|
||||||
|
void setGameNameFilter(const QString &_gameNameFilter);
|
||||||
|
QString getCreatorNameFilter() const;
|
||||||
|
void setCreatorNameFilter(const QString &_creatorNameFilter);
|
||||||
|
QSet<int> getGameTypeFilter() const;
|
||||||
|
void setGameTypeFilter(const QSet<int> &_gameTypeFilter);
|
||||||
|
int getMaxPlayersFilterMin() const;
|
||||||
|
int getMaxPlayersFilterMax() const;
|
||||||
|
void setMaxPlayersFilter(int _maxPlayersFilterMin, int _maxPlayersFilterMax);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -6,6 +6,7 @@
|
||||||
#include <QKeySequence>
|
#include <QKeySequence>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include "dlg_load_deck_from_clipboard.h"
|
#include "dlg_load_deck_from_clipboard.h"
|
||||||
#include "decklist.h"
|
#include "decklist.h"
|
||||||
|
@ -17,29 +18,22 @@ DlgLoadDeckFromClipboard::DlgLoadDeckFromClipboard(QWidget *parent)
|
||||||
|
|
||||||
refreshButton = new QPushButton(tr("&Refresh"));
|
refreshButton = new QPushButton(tr("&Refresh"));
|
||||||
refreshButton->setShortcut(QKeySequence("F5"));
|
refreshButton->setShortcut(QKeySequence("F5"));
|
||||||
okButton = new QPushButton(tr("&OK"));
|
connect(refreshButton, SIGNAL(clicked()), this, SLOT(actRefresh()));
|
||||||
okButton->setDefault(true);
|
|
||||||
cancelButton = new QPushButton(tr("&Cancel"));
|
|
||||||
|
|
||||||
QHBoxLayout *buttonLayout = new QHBoxLayout;
|
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
buttonLayout->addWidget(refreshButton);
|
buttonBox->addButton(refreshButton, QDialogButtonBox::ActionRole);
|
||||||
buttonLayout->addStretch();
|
connect(buttonBox, SIGNAL(accepted()), this, SLOT(actOK()));
|
||||||
buttonLayout->addWidget(okButton);
|
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||||
buttonLayout->addWidget(cancelButton);
|
|
||||||
|
|
||||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||||
mainLayout->addWidget(contentsEdit);
|
mainLayout->addWidget(contentsEdit);
|
||||||
mainLayout->addLayout(buttonLayout);
|
mainLayout->addWidget(buttonBox);
|
||||||
|
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
|
|
||||||
setWindowTitle(tr("Load deck from clipboard"));
|
setWindowTitle(tr("Load deck from clipboard"));
|
||||||
resize(500, 500);
|
resize(500, 500);
|
||||||
|
|
||||||
connect(refreshButton, SIGNAL(clicked()), this, SLOT(actRefresh()));
|
|
||||||
connect(okButton, SIGNAL(clicked()), this, SLOT(actOK()));
|
|
||||||
connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
|
|
||||||
|
|
||||||
actRefresh();
|
actRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ public:
|
||||||
DeckList *getDeckList() const { return deckList; }
|
DeckList *getDeckList() const { return deckList; }
|
||||||
private:
|
private:
|
||||||
QPlainTextEdit *contentsEdit;
|
QPlainTextEdit *contentsEdit;
|
||||||
QPushButton *refreshButton, *okButton, *cancelButton;
|
QPushButton *refreshButton;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
#include "remotedecklist_treewidget.h"
|
#include "remotedecklist_treewidget.h"
|
||||||
#include "dlg_load_remote_deck.h"
|
#include "dlg_load_remote_deck.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
@ -10,35 +11,26 @@ DlgLoadRemoteDeck::DlgLoadRemoteDeck(AbstractClient *_client, QWidget *parent)
|
||||||
{
|
{
|
||||||
dirView = new RemoteDeckList_TreeWidget(client);
|
dirView = new RemoteDeckList_TreeWidget(client);
|
||||||
|
|
||||||
okButton = new QPushButton(tr("O&K"));
|
buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
okButton->setDefault(true);
|
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
|
||||||
okButton->setAutoDefault(true);
|
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||||
okButton->setEnabled(false);
|
|
||||||
cancelButton = new QPushButton(tr("&Cancel"));
|
|
||||||
|
|
||||||
QHBoxLayout *buttonLayout = new QHBoxLayout;
|
|
||||||
buttonLayout->addStretch();
|
|
||||||
buttonLayout->addWidget(okButton);
|
|
||||||
buttonLayout->addWidget(cancelButton);
|
|
||||||
|
|
||||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||||
mainLayout->addWidget(dirView);
|
mainLayout->addWidget(dirView);
|
||||||
mainLayout->addLayout(buttonLayout);
|
mainLayout->addWidget(buttonBox);
|
||||||
|
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
|
|
||||||
setWindowTitle(tr("Load deck"));
|
setWindowTitle(tr("Load deck"));
|
||||||
setMinimumWidth(sizeHint().width());
|
setMinimumWidth(sizeHint().width());
|
||||||
resize(300, 500);
|
resize(400, 600);
|
||||||
|
|
||||||
connect(dirView->selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(currentItemChanged(const QModelIndex &, const QModelIndex &)));
|
connect(dirView->selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(currentItemChanged(const QModelIndex &, const QModelIndex &)));
|
||||||
connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
|
|
||||||
connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DlgLoadRemoteDeck::currentItemChanged(const QModelIndex ¤t, const QModelIndex & /*previous*/)
|
void DlgLoadRemoteDeck::currentItemChanged(const QModelIndex ¤t, const QModelIndex & /*previous*/)
|
||||||
{
|
{
|
||||||
okButton->setEnabled(dynamic_cast<RemoteDeckList_TreeModel::FileNode *>(dirView->getNode(current)));
|
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(dynamic_cast<RemoteDeckList_TreeModel::FileNode *>(dirView->getNode(current)));
|
||||||
}
|
}
|
||||||
|
|
||||||
int DlgLoadRemoteDeck::getDeckId() const
|
int DlgLoadRemoteDeck::getDeckId() const
|
||||||
|
|
|
@ -7,13 +7,14 @@ class RemoteDeckList_TreeWidget;
|
||||||
class QModelIndex;
|
class QModelIndex;
|
||||||
class AbstractClient;
|
class AbstractClient;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
|
class QDialogButtonBox;
|
||||||
|
|
||||||
class DlgLoadRemoteDeck: public QDialog {
|
class DlgLoadRemoteDeck: public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
AbstractClient *client;
|
AbstractClient *client;
|
||||||
RemoteDeckList_TreeWidget *dirView;
|
RemoteDeckList_TreeWidget *dirView;
|
||||||
QPushButton *okButton, *cancelButton;
|
QDialogButtonBox *buttonBox;
|
||||||
private slots:
|
private slots:
|
||||||
void currentItemChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
void currentItemChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
#include "carddatabase.h"
|
#include "carddatabase.h"
|
||||||
#include "dlg_settings.h"
|
#include "dlg_settings.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
@ -606,9 +607,6 @@ DlgSettings::DlgSettings(QWidget *parent)
|
||||||
pagesWidget->addWidget(new DeckEditorSettingsPage);
|
pagesWidget->addWidget(new DeckEditorSettingsPage);
|
||||||
pagesWidget->addWidget(new MessagesSettingsPage);
|
pagesWidget->addWidget(new MessagesSettingsPage);
|
||||||
|
|
||||||
closeButton = new QPushButton;
|
|
||||||
connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
|
|
||||||
|
|
||||||
createIcons();
|
createIcons();
|
||||||
contentsWidget->setCurrentRow(0);
|
contentsWidget->setCurrentRow(0);
|
||||||
|
|
||||||
|
@ -616,14 +614,13 @@ DlgSettings::DlgSettings(QWidget *parent)
|
||||||
hboxLayout->addWidget(contentsWidget);
|
hboxLayout->addWidget(contentsWidget);
|
||||||
hboxLayout->addWidget(pagesWidget);
|
hboxLayout->addWidget(pagesWidget);
|
||||||
|
|
||||||
QHBoxLayout *buttonsLayout = new QHBoxLayout;
|
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok);
|
||||||
buttonsLayout->addStretch(1);
|
connect(buttonBox, SIGNAL(accepted()), this, SLOT(close()));
|
||||||
buttonsLayout->addWidget(closeButton);
|
|
||||||
|
|
||||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||||
mainLayout->addLayout(hboxLayout);
|
mainLayout->addLayout(hboxLayout);
|
||||||
mainLayout->addSpacing(12);
|
mainLayout->addSpacing(12);
|
||||||
mainLayout->addLayout(buttonsLayout);
|
mainLayout->addWidget(buttonBox);
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
|
|
||||||
retranslateUi();
|
retranslateUi();
|
||||||
|
@ -712,8 +709,6 @@ void DlgSettings::retranslateUi()
|
||||||
deckEditorButton->setText(tr("Deck editor"));
|
deckEditorButton->setText(tr("Deck editor"));
|
||||||
messagesButton->setText(tr("Messages"));
|
messagesButton->setText(tr("Messages"));
|
||||||
|
|
||||||
closeButton->setText(tr("&Close"));
|
|
||||||
|
|
||||||
for (int i = 0; i < pagesWidget->count(); i++)
|
for (int i = 0; i < pagesWidget->count(); i++)
|
||||||
dynamic_cast<AbstractSettingsPage *>(pagesWidget->widget(i))->retranslateUi();
|
dynamic_cast<AbstractSettingsPage *>(pagesWidget->widget(i))->retranslateUi();
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,7 +129,6 @@ private:
|
||||||
QListWidget *contentsWidget;
|
QListWidget *contentsWidget;
|
||||||
QStackedWidget *pagesWidget;
|
QStackedWidget *pagesWidget;
|
||||||
QListWidgetItem *generalButton, *appearanceButton, *userInterfaceButton, *deckEditorButton, *messagesButton;
|
QListWidgetItem *generalButton, *appearanceButton, *userInterfaceButton, *deckEditorButton, *messagesButton;
|
||||||
QPushButton *closeButton;
|
|
||||||
void createIcons();
|
void createIcons();
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include "tab_supervisor.h"
|
#include "tab_supervisor.h"
|
||||||
#include "dlg_creategame.h"
|
#include "dlg_creategame.h"
|
||||||
|
#include "dlg_filter_games.h"
|
||||||
#include "gameselector.h"
|
#include "gameselector.h"
|
||||||
#include "gamesmodel.h"
|
#include "gamesmodel.h"
|
||||||
#include "tab_room.h"
|
#include "tab_room.h"
|
||||||
|
@ -32,10 +33,13 @@ GameSelector::GameSelector(AbstractClient *_client, TabSupervisor *_tabSuperviso
|
||||||
gameListView->header()->hideSection(1);
|
gameListView->header()->hideSection(1);
|
||||||
gameListView->header()->setResizeMode(1, QHeaderView::ResizeToContents);
|
gameListView->header()->setResizeMode(1, QHeaderView::ResizeToContents);
|
||||||
|
|
||||||
showUnavailableGamesCheckBox = new QCheckBox;
|
filterButton = new QPushButton;
|
||||||
|
filterButton->setIcon(QIcon(":/resources/icon_search.svg"));
|
||||||
QVBoxLayout *filterLayout = new QVBoxLayout;
|
connect(filterButton, SIGNAL(clicked()), this, SLOT(actSetFilter()));
|
||||||
filterLayout->addWidget(showUnavailableGamesCheckBox);
|
clearFilterButton = new QPushButton;
|
||||||
|
clearFilterButton->setIcon(QIcon(":/resources/icon_clearsearch.svg"));
|
||||||
|
clearFilterButton->setEnabled(false);
|
||||||
|
connect(clearFilterButton, SIGNAL(clicked()), this, SLOT(actClearFilter()));
|
||||||
|
|
||||||
if (room) {
|
if (room) {
|
||||||
createButton = new QPushButton;
|
createButton = new QPushButton;
|
||||||
|
@ -46,20 +50,18 @@ GameSelector::GameSelector(AbstractClient *_client, TabSupervisor *_tabSuperviso
|
||||||
spectateButton = new QPushButton;
|
spectateButton = new QPushButton;
|
||||||
|
|
||||||
QHBoxLayout *buttonLayout = new QHBoxLayout;
|
QHBoxLayout *buttonLayout = new QHBoxLayout;
|
||||||
|
buttonLayout->addWidget(filterButton);
|
||||||
|
buttonLayout->addWidget(clearFilterButton);
|
||||||
|
buttonLayout->addStretch();
|
||||||
if (room)
|
if (room)
|
||||||
buttonLayout->addWidget(createButton);
|
buttonLayout->addWidget(createButton);
|
||||||
buttonLayout->addWidget(joinButton);
|
buttonLayout->addWidget(joinButton);
|
||||||
buttonLayout->addWidget(spectateButton);
|
buttonLayout->addWidget(spectateButton);
|
||||||
buttonLayout->setAlignment(Qt::AlignTop);
|
buttonLayout->setAlignment(Qt::AlignTop);
|
||||||
|
|
||||||
QHBoxLayout *hbox = new QHBoxLayout;
|
|
||||||
hbox->addLayout(filterLayout);
|
|
||||||
hbox->addStretch();
|
|
||||||
hbox->addLayout(buttonLayout);
|
|
||||||
|
|
||||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||||
mainLayout->addWidget(gameListView);
|
mainLayout->addWidget(gameListView);
|
||||||
mainLayout->addLayout(hbox);
|
mainLayout->addLayout(buttonLayout);
|
||||||
|
|
||||||
retranslateUi();
|
retranslateUi();
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
|
@ -67,14 +69,39 @@ GameSelector::GameSelector(AbstractClient *_client, TabSupervisor *_tabSuperviso
|
||||||
setMinimumWidth((qreal) (gameListView->columnWidth(0) * gameListModel->columnCount()) / 1.5);
|
setMinimumWidth((qreal) (gameListView->columnWidth(0) * gameListModel->columnCount()) / 1.5);
|
||||||
setMinimumHeight(200);
|
setMinimumHeight(200);
|
||||||
|
|
||||||
connect(showUnavailableGamesCheckBox, SIGNAL(stateChanged(int)), this, SLOT(showUnavailableGamesChanged(int)));
|
|
||||||
connect(joinButton, SIGNAL(clicked()), this, SLOT(actJoin()));
|
connect(joinButton, SIGNAL(clicked()), this, SLOT(actJoin()));
|
||||||
connect(spectateButton, SIGNAL(clicked()), this, SLOT(actJoin()));
|
connect(spectateButton, SIGNAL(clicked()), this, SLOT(actJoin()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameSelector::showUnavailableGamesChanged(int state)
|
void GameSelector::actSetFilter()
|
||||||
{
|
{
|
||||||
gameListProxyModel->setUnavailableGamesVisible(state);
|
GameTypeMap gameTypeMap;
|
||||||
|
if (room)
|
||||||
|
gameTypeMap = gameListModel->getGameTypes().value(room->getRoomId());
|
||||||
|
DlgFilterGames dlg(gameTypeMap, this);
|
||||||
|
dlg.setUnavailableGamesVisible(gameListProxyModel->getUnavailableGamesVisible());
|
||||||
|
dlg.setGameNameFilter(gameListProxyModel->getGameNameFilter());
|
||||||
|
dlg.setCreatorNameFilter(gameListProxyModel->getCreatorNameFilter());
|
||||||
|
dlg.setGameTypeFilter(gameListProxyModel->getGameTypeFilter());
|
||||||
|
dlg.setMaxPlayersFilter(gameListProxyModel->getMaxPlayersFilterMin(), gameListProxyModel->getMaxPlayersFilterMax());
|
||||||
|
|
||||||
|
if (!dlg.exec())
|
||||||
|
return;
|
||||||
|
|
||||||
|
clearFilterButton->setEnabled(true);
|
||||||
|
|
||||||
|
gameListProxyModel->setUnavailableGamesVisible(dlg.getUnavailableGamesVisible());
|
||||||
|
gameListProxyModel->setGameNameFilter(dlg.getGameNameFilter());
|
||||||
|
gameListProxyModel->setCreatorNameFilter(dlg.getCreatorNameFilter());
|
||||||
|
gameListProxyModel->setGameTypeFilter(dlg.getGameTypeFilter());
|
||||||
|
gameListProxyModel->setMaxPlayersFilter(dlg.getMaxPlayersFilterMin(), dlg.getMaxPlayersFilterMax());
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameSelector::actClearFilter()
|
||||||
|
{
|
||||||
|
clearFilterButton->setEnabled(false);
|
||||||
|
|
||||||
|
gameListProxyModel->resetFilterParameters();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameSelector::actCreate()
|
void GameSelector::actCreate()
|
||||||
|
@ -145,7 +172,8 @@ void GameSelector::actJoin()
|
||||||
void GameSelector::retranslateUi()
|
void GameSelector::retranslateUi()
|
||||||
{
|
{
|
||||||
setTitle(tr("Games"));
|
setTitle(tr("Games"));
|
||||||
showUnavailableGamesCheckBox->setText(tr("Show u&navailable games"));
|
filterButton->setText(tr("&Filter games"));
|
||||||
|
clearFilterButton->setText(tr("C&lear filter"));
|
||||||
if (createButton)
|
if (createButton)
|
||||||
createButton->setText(tr("C&reate"));
|
createButton->setText(tr("C&reate"));
|
||||||
joinButton->setText(tr("&Join"));
|
joinButton->setText(tr("&Join"));
|
||||||
|
|
|
@ -19,7 +19,8 @@ class Response;
|
||||||
class GameSelector : public QGroupBox {
|
class GameSelector : public QGroupBox {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private slots:
|
private slots:
|
||||||
void showUnavailableGamesChanged(int state);
|
void actSetFilter();
|
||||||
|
void actClearFilter();
|
||||||
void actCreate();
|
void actCreate();
|
||||||
void actJoin();
|
void actJoin();
|
||||||
void checkResponse(const Response &response);
|
void checkResponse(const Response &response);
|
||||||
|
@ -33,8 +34,7 @@ private:
|
||||||
QTreeView *gameListView;
|
QTreeView *gameListView;
|
||||||
GamesModel *gameListModel;
|
GamesModel *gameListModel;
|
||||||
GamesProxyModel *gameListProxyModel;
|
GamesProxyModel *gameListProxyModel;
|
||||||
QPushButton *createButton, *joinButton, *spectateButton;
|
QPushButton *filterButton, *clearFilterButton, *createButton, *joinButton, *spectateButton;
|
||||||
QCheckBox *showUnavailableGamesCheckBox;
|
|
||||||
public:
|
public:
|
||||||
GameSelector(AbstractClient *_client, TabSupervisor *_tabSupervisor, TabRoom *_room, const QMap<int, QString> &_rooms, const QMap<int, GameTypeMap> &_gameTypes, QWidget *parent = 0);
|
GameSelector(AbstractClient *_client, TabSupervisor *_tabSupervisor, TabRoom *_room, const QMap<int, QString> &_rooms, const QMap<int, GameTypeMap> &_gameTypes, QWidget *parent = 0);
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
|
|
|
@ -147,6 +147,8 @@ void GamesProxyModel::resetFilterParameters()
|
||||||
gameTypeFilter.clear();
|
gameTypeFilter.clear();
|
||||||
maxPlayersFilterMin = -1;
|
maxPlayersFilterMin = -1;
|
||||||
maxPlayersFilterMax = -1;
|
maxPlayersFilterMax = -1;
|
||||||
|
|
||||||
|
invalidateFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GamesProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &/*sourceParent*/) const
|
bool GamesProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &/*sourceParent*/) const
|
||||||
|
|
|
@ -26,6 +26,7 @@ public:
|
||||||
|
|
||||||
const ServerInfo_Game &getGame(int row);
|
const ServerInfo_Game &getGame(int row);
|
||||||
void updateGameList(const ServerInfo_Game &game);
|
void updateGameList(const ServerInfo_Game &game);
|
||||||
|
const QMap<int, GameTypeMap> &getGameTypes() { return gameTypes; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class GamesProxyModel : public QSortFilterProxyModel {
|
class GamesProxyModel : public QSortFilterProxyModel {
|
||||||
|
@ -39,10 +40,16 @@ private:
|
||||||
public:
|
public:
|
||||||
GamesProxyModel(QObject *parent = 0, ServerInfo_User *_ownUser = 0);
|
GamesProxyModel(QObject *parent = 0, ServerInfo_User *_ownUser = 0);
|
||||||
|
|
||||||
|
bool getUnavailableGamesVisible() const { return unavailableGamesVisible; }
|
||||||
void setUnavailableGamesVisible(bool _unavailableGamesVisible);
|
void setUnavailableGamesVisible(bool _unavailableGamesVisible);
|
||||||
|
QString getGameNameFilter() const { return gameNameFilter; }
|
||||||
void setGameNameFilter(const QString &_gameNameFilter);
|
void setGameNameFilter(const QString &_gameNameFilter);
|
||||||
|
QString getCreatorNameFilter() const { return creatorNameFilter; }
|
||||||
void setCreatorNameFilter(const QString &_creatorNameFilter);
|
void setCreatorNameFilter(const QString &_creatorNameFilter);
|
||||||
|
QSet<int> getGameTypeFilter() const { return gameTypeFilter; }
|
||||||
void setGameTypeFilter(const QSet<int> &_gameTypeFilter);
|
void setGameTypeFilter(const QSet<int> &_gameTypeFilter);
|
||||||
|
int getMaxPlayersFilterMin() const { return maxPlayersFilterMin; }
|
||||||
|
int getMaxPlayersFilterMax() const { return maxPlayersFilterMax; }
|
||||||
void setMaxPlayersFilter(int _maxPlayersFilterMin, int _maxPlayersFilterMax);
|
void setMaxPlayersFilter(int _maxPlayersFilterMin, int _maxPlayersFilterMax);
|
||||||
void resetFilterParameters();
|
void resetFilterParameters();
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -82,6 +82,7 @@ void ToggleButton::paintEvent(QPaintEvent *event)
|
||||||
void ToggleButton::setState(bool _state)
|
void ToggleButton::setState(bool _state)
|
||||||
{
|
{
|
||||||
state = _state;
|
state = _state;
|
||||||
|
emit stateChanged();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,6 +100,7 @@ DeckViewContainer::DeckViewContainer(int _playerId, TabGame *parent)
|
||||||
connect(loadRemoteButton, SIGNAL(clicked()), this, SLOT(loadRemoteDeck()));
|
connect(loadRemoteButton, SIGNAL(clicked()), this, SLOT(loadRemoteDeck()));
|
||||||
connect(readyStartButton, SIGNAL(clicked()), this, SLOT(readyStart()));
|
connect(readyStartButton, SIGNAL(clicked()), this, SLOT(readyStart()));
|
||||||
connect(sideboardLockButton, SIGNAL(clicked()), this, SLOT(sideboardLockButtonClicked()));
|
connect(sideboardLockButton, SIGNAL(clicked()), this, SLOT(sideboardLockButtonClicked()));
|
||||||
|
connect(sideboardLockButton, SIGNAL(stateChanged()), this, SLOT(updateSideboardLockButtonText()));
|
||||||
|
|
||||||
QHBoxLayout *buttonHBox = new QHBoxLayout;
|
QHBoxLayout *buttonHBox = new QHBoxLayout;
|
||||||
buttonHBox->addWidget(loadLocalButton);
|
buttonHBox->addWidget(loadLocalButton);
|
||||||
|
@ -219,7 +221,6 @@ void DeckViewContainer::setReadyStart(bool ready)
|
||||||
void DeckViewContainer::setSideboardLocked(bool locked)
|
void DeckViewContainer::setSideboardLocked(bool locked)
|
||||||
{
|
{
|
||||||
sideboardLockButton->setState(!locked);
|
sideboardLockButton->setState(!locked);
|
||||||
updateSideboardLockButtonText();
|
|
||||||
deckView->setLocked(readyStartButton->getState() || !sideboardLockButton->getState());
|
deckView->setLocked(readyStartButton->getState() || !sideboardLockButton->getState());
|
||||||
if (locked)
|
if (locked)
|
||||||
deckView->resetSideboardPlan();
|
deckView->resetSideboardPlan();
|
||||||
|
|
|
@ -59,6 +59,8 @@ class ToggleButton : public QPushButton {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
bool state;
|
bool state;
|
||||||
|
signals:
|
||||||
|
void stateChanged();
|
||||||
public:
|
public:
|
||||||
ToggleButton(QWidget *parent = 0);
|
ToggleButton(QWidget *parent = 0);
|
||||||
bool getState() const { return state; }
|
bool getState() const { return state; }
|
||||||
|
@ -81,7 +83,6 @@ private slots:
|
||||||
void deckSelectFinished(const Response &r);
|
void deckSelectFinished(const Response &r);
|
||||||
void sideboardPlanChanged();
|
void sideboardPlanChanged();
|
||||||
void sideboardLockButtonClicked();
|
void sideboardLockButtonClicked();
|
||||||
private:
|
|
||||||
void updateSideboardLockButtonText();
|
void updateSideboardLockButtonText();
|
||||||
signals:
|
signals:
|
||||||
void newCardAdded(AbstractCardItem *card);
|
void newCardAdded(AbstractCardItem *card);
|
||||||
|
|
Loading…
Reference in a new issue