Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
7736f7b5
Commit
7736f7b5
authored
Jan 19, 2013
by
Max-Wilhelm Bruker
Browse files
fixed #101: added option to filter password protected games
parent
89ae29aa
Changes
5
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/dlg_filter_games.cpp
View file @
7736f7b5
...
@@ -14,6 +14,7 @@ DlgFilterGames::DlgFilterGames(const QMap<int, QString> &allGameTypes, QWidget *
...
@@ -14,6 +14,7 @@ DlgFilterGames::DlgFilterGames(const QMap<int, QString> &allGameTypes, QWidget *
:
QDialog
(
parent
)
:
QDialog
(
parent
)
{
{
unavailableGamesVisibleCheckBox
=
new
QCheckBox
(
tr
(
"Show &unavailable games"
));
unavailableGamesVisibleCheckBox
=
new
QCheckBox
(
tr
(
"Show &unavailable games"
));
passwordProtectedGamesVisibleCheckBox
=
new
QCheckBox
(
tr
(
"Show &password protected games"
));
QLabel
*
gameNameFilterLabel
=
new
QLabel
(
tr
(
"Game &description:"
));
QLabel
*
gameNameFilterLabel
=
new
QLabel
(
tr
(
"Game &description:"
));
gameNameFilterEdit
=
new
QLineEdit
;
gameNameFilterEdit
=
new
QLineEdit
;
...
@@ -68,6 +69,7 @@ DlgFilterGames::DlgFilterGames(const QMap<int, QString> &allGameTypes, QWidget *
...
@@ -68,6 +69,7 @@ DlgFilterGames::DlgFilterGames(const QMap<int, QString> &allGameTypes, QWidget *
leftGrid
->
addWidget
(
creatorNameFilterEdit
,
1
,
1
);
leftGrid
->
addWidget
(
creatorNameFilterEdit
,
1
,
1
);
leftGrid
->
addWidget
(
maxPlayersGroupBox
,
2
,
0
,
1
,
2
);
leftGrid
->
addWidget
(
maxPlayersGroupBox
,
2
,
0
,
1
,
2
);
leftGrid
->
addWidget
(
unavailableGamesVisibleCheckBox
,
3
,
0
,
1
,
2
);
leftGrid
->
addWidget
(
unavailableGamesVisibleCheckBox
,
3
,
0
,
1
,
2
);
leftGrid
->
addWidget
(
passwordProtectedGamesVisibleCheckBox
,
4
,
0
,
1
,
2
);
QVBoxLayout
*
leftColumn
=
new
QVBoxLayout
;
QVBoxLayout
*
leftColumn
=
new
QVBoxLayout
;
leftColumn
->
addLayout
(
leftGrid
);
leftColumn
->
addLayout
(
leftGrid
);
...
@@ -102,6 +104,16 @@ void DlgFilterGames::setUnavailableGamesVisible(bool _unavailableGamesVisible)
...
@@ -102,6 +104,16 @@ void DlgFilterGames::setUnavailableGamesVisible(bool _unavailableGamesVisible)
unavailableGamesVisibleCheckBox
->
setChecked
(
_unavailableGamesVisible
);
unavailableGamesVisibleCheckBox
->
setChecked
(
_unavailableGamesVisible
);
}
}
bool
DlgFilterGames
::
getPasswordProtectedGamesVisible
()
const
{
return
passwordProtectedGamesVisibleCheckBox
->
isChecked
();
}
void
DlgFilterGames
::
setPasswordProtectedGamesVisible
(
bool
_passwordProtectedGamesVisible
)
{
passwordProtectedGamesVisibleCheckBox
->
setChecked
(
_passwordProtectedGamesVisible
);
}
QString
DlgFilterGames
::
getGameNameFilter
()
const
QString
DlgFilterGames
::
getGameNameFilter
()
const
{
{
return
gameNameFilterEdit
->
text
();
return
gameNameFilterEdit
->
text
();
...
...
cockatrice/src/dlg_filter_games.h
View file @
7736f7b5
...
@@ -13,6 +13,7 @@ class DlgFilterGames : public QDialog {
...
@@ -13,6 +13,7 @@ class DlgFilterGames : public QDialog {
Q_OBJECT
Q_OBJECT
private:
private:
QCheckBox
*
unavailableGamesVisibleCheckBox
;
QCheckBox
*
unavailableGamesVisibleCheckBox
;
QCheckBox
*
passwordProtectedGamesVisibleCheckBox
;
QLineEdit
*
gameNameFilterEdit
;
QLineEdit
*
gameNameFilterEdit
;
QLineEdit
*
creatorNameFilterEdit
;
QLineEdit
*
creatorNameFilterEdit
;
QMap
<
int
,
QCheckBox
*>
gameTypeFilterCheckBoxes
;
QMap
<
int
,
QCheckBox
*>
gameTypeFilterCheckBoxes
;
...
@@ -23,6 +24,8 @@ public:
...
@@ -23,6 +24,8 @@ public:
bool
getUnavailableGamesVisible
()
const
;
bool
getUnavailableGamesVisible
()
const
;
void
setUnavailableGamesVisible
(
bool
_unavailableGamesVisible
);
void
setUnavailableGamesVisible
(
bool
_unavailableGamesVisible
);
bool
getPasswordProtectedGamesVisible
()
const
;
void
setPasswordProtectedGamesVisible
(
bool
_passwordProtectedGamesVisible
);
QString
getGameNameFilter
()
const
;
QString
getGameNameFilter
()
const
;
void
setGameNameFilter
(
const
QString
&
_gameNameFilter
);
void
setGameNameFilter
(
const
QString
&
_gameNameFilter
);
QString
getCreatorNameFilter
()
const
;
QString
getCreatorNameFilter
()
const
;
...
...
cockatrice/src/gameselector.cpp
View file @
7736f7b5
...
@@ -82,6 +82,7 @@ void GameSelector::actSetFilter()
...
@@ -82,6 +82,7 @@ void GameSelector::actSetFilter()
gameTypeMap
=
gameListModel
->
getGameTypes
().
value
(
room
->
getRoomId
());
gameTypeMap
=
gameListModel
->
getGameTypes
().
value
(
room
->
getRoomId
());
DlgFilterGames
dlg
(
gameTypeMap
,
this
);
DlgFilterGames
dlg
(
gameTypeMap
,
this
);
dlg
.
setUnavailableGamesVisible
(
gameListProxyModel
->
getUnavailableGamesVisible
());
dlg
.
setUnavailableGamesVisible
(
gameListProxyModel
->
getUnavailableGamesVisible
());
dlg
.
setPasswordProtectedGamesVisible
(
gameListProxyModel
->
getPasswordProtectedGamesVisible
());
dlg
.
setGameNameFilter
(
gameListProxyModel
->
getGameNameFilter
());
dlg
.
setGameNameFilter
(
gameListProxyModel
->
getGameNameFilter
());
dlg
.
setCreatorNameFilter
(
gameListProxyModel
->
getCreatorNameFilter
());
dlg
.
setCreatorNameFilter
(
gameListProxyModel
->
getCreatorNameFilter
());
dlg
.
setGameTypeFilter
(
gameListProxyModel
->
getGameTypeFilter
());
dlg
.
setGameTypeFilter
(
gameListProxyModel
->
getGameTypeFilter
());
...
@@ -93,6 +94,7 @@ void GameSelector::actSetFilter()
...
@@ -93,6 +94,7 @@ void GameSelector::actSetFilter()
clearFilterButton
->
setEnabled
(
true
);
clearFilterButton
->
setEnabled
(
true
);
gameListProxyModel
->
setUnavailableGamesVisible
(
dlg
.
getUnavailableGamesVisible
());
gameListProxyModel
->
setUnavailableGamesVisible
(
dlg
.
getUnavailableGamesVisible
());
gameListProxyModel
->
setPasswordProtectedGamesVisible
(
dlg
.
getPasswordProtectedGamesVisible
());
gameListProxyModel
->
setGameNameFilter
(
dlg
.
getGameNameFilter
());
gameListProxyModel
->
setGameNameFilter
(
dlg
.
getGameNameFilter
());
gameListProxyModel
->
setCreatorNameFilter
(
dlg
.
getCreatorNameFilter
());
gameListProxyModel
->
setCreatorNameFilter
(
dlg
.
getCreatorNameFilter
());
gameListProxyModel
->
setGameTypeFilter
(
dlg
.
getGameTypeFilter
());
gameListProxyModel
->
setGameTypeFilter
(
dlg
.
getGameTypeFilter
());
...
...
cockatrice/src/gamesmodel.cpp
View file @
7736f7b5
...
@@ -105,6 +105,12 @@ void GamesProxyModel::setUnavailableGamesVisible(bool _unavailableGamesVisible)
...
@@ -105,6 +105,12 @@ void GamesProxyModel::setUnavailableGamesVisible(bool _unavailableGamesVisible)
invalidateFilter
();
invalidateFilter
();
}
}
void
GamesProxyModel
::
setPasswordProtectedGamesVisible
(
bool
_passwordProtectedGamesVisible
)
{
passwordProtectedGamesVisible
=
_passwordProtectedGamesVisible
;
invalidateFilter
();
}
void
GamesProxyModel
::
setGameNameFilter
(
const
QString
&
_gameNameFilter
)
void
GamesProxyModel
::
setGameNameFilter
(
const
QString
&
_gameNameFilter
)
{
{
gameNameFilter
=
_gameNameFilter
;
gameNameFilter
=
_gameNameFilter
;
...
@@ -133,6 +139,7 @@ void GamesProxyModel::setMaxPlayersFilter(int _maxPlayersFilterMin, int _maxPlay
...
@@ -133,6 +139,7 @@ void GamesProxyModel::setMaxPlayersFilter(int _maxPlayersFilterMin, int _maxPlay
void
GamesProxyModel
::
resetFilterParameters
()
void
GamesProxyModel
::
resetFilterParameters
()
{
{
unavailableGamesVisible
=
false
;
unavailableGamesVisible
=
false
;
passwordProtectedGamesVisible
=
false
;
gameNameFilter
=
QString
();
gameNameFilter
=
QString
();
creatorNameFilter
=
QString
();
creatorNameFilter
=
QString
();
gameTypeFilter
.
clear
();
gameTypeFilter
.
clear
();
...
@@ -158,6 +165,8 @@ bool GamesProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &/*sourc
...
@@ -158,6 +165,8 @@ bool GamesProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &/*sourc
if
(
game
.
only_registered
())
if
(
game
.
only_registered
())
return
false
;
return
false
;
}
}
if
(
!
passwordProtectedGamesVisible
&&
game
.
with_password
())
return
false
;
if
(
!
gameNameFilter
.
isEmpty
())
if
(
!
gameNameFilter
.
isEmpty
())
if
(
!
QString
::
fromStdString
(
game
.
description
()).
contains
(
gameNameFilter
,
Qt
::
CaseInsensitive
))
if
(
!
QString
::
fromStdString
(
game
.
description
()).
contains
(
gameNameFilter
,
Qt
::
CaseInsensitive
))
return
false
;
return
false
;
...
...
cockatrice/src/gamesmodel.h
View file @
7736f7b5
...
@@ -33,6 +33,7 @@ class GamesProxyModel : public QSortFilterProxyModel {
...
@@ -33,6 +33,7 @@ class GamesProxyModel : public QSortFilterProxyModel {
private:
private:
ServerInfo_User
*
ownUser
;
ServerInfo_User
*
ownUser
;
bool
unavailableGamesVisible
;
bool
unavailableGamesVisible
;
bool
passwordProtectedGamesVisible
;
QString
gameNameFilter
,
creatorNameFilter
;
QString
gameNameFilter
,
creatorNameFilter
;
QSet
<
int
>
gameTypeFilter
;
QSet
<
int
>
gameTypeFilter
;
int
maxPlayersFilterMin
,
maxPlayersFilterMax
;
int
maxPlayersFilterMin
,
maxPlayersFilterMax
;
...
@@ -41,6 +42,8 @@ public:
...
@@ -41,6 +42,8 @@ public:
bool
getUnavailableGamesVisible
()
const
{
return
unavailableGamesVisible
;
}
bool
getUnavailableGamesVisible
()
const
{
return
unavailableGamesVisible
;
}
void
setUnavailableGamesVisible
(
bool
_unavailableGamesVisible
);
void
setUnavailableGamesVisible
(
bool
_unavailableGamesVisible
);
bool
getPasswordProtectedGamesVisible
()
const
{
return
passwordProtectedGamesVisible
;
}
void
setPasswordProtectedGamesVisible
(
bool
_passwordProtectedGamesVisible
);
QString
getGameNameFilter
()
const
{
return
gameNameFilter
;
}
QString
getGameNameFilter
()
const
{
return
gameNameFilter
;
}
void
setGameNameFilter
(
const
QString
&
_gameNameFilter
);
void
setGameNameFilter
(
const
QString
&
_gameNameFilter
);
QString
getCreatorNameFilter
()
const
{
return
creatorNameFilter
;
}
QString
getCreatorNameFilter
()
const
{
return
creatorNameFilter
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment