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
332ca29d
Commit
332ca29d
authored
Jan 29, 2012
by
mbruker
Browse files
Merge pull request #4 from Daenyth/show-unjoinable-checkbox
Change "Show full" "Show running" checkboxes to a single box
parents
c7662999
0c1b6dd9
Changes
7
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/gameselector.cpp
View file @
332ca29d
...
...
@@ -18,7 +18,7 @@ GameSelector::GameSelector(AbstractClient *_client, TabSupervisor *_tabSuperviso
{
gameListView
=
new
QTreeView
;
gameListModel
=
new
GamesModel
(
_rooms
,
_gameTypes
,
this
);
gameListProxyModel
=
new
GamesProxyModel
(
this
);
gameListProxyModel
=
new
GamesProxyModel
(
this
,
tabSupervisor
->
getUserInfo
()
);
gameListProxyModel
->
setSourceModel
(
gameListModel
);
gameListProxyModel
->
setSortCaseSensitivity
(
Qt
::
CaseInsensitive
);
gameListView
->
setModel
(
gameListProxyModel
);
...
...
@@ -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
;
showUnavailableGamesCheckBox
=
new
QCheckBox
;
QVBoxLayout
*
filterLayout
=
new
QVBoxLayout
;
filterLayout
->
addWidget
(
showFullGamesCheckBox
);
filterLayout
->
addWidget
(
showRunningGamesCheckBox
);
filterLayout
->
addWidget
(
showUnavailableGamesCheckBox
);
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
(
showUnavailableGamesCheckBox
,
SIGNAL
(
stateChanged
(
int
)),
this
,
SLOT
(
showUnavailableGamesChanged
(
int
)));
connect
(
createButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
actCreate
()));
connect
(
joinButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
actJoin
()));
connect
(
spectateButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
actJoin
()));
}
void
GameSelector
::
show
Full
GamesChanged
(
int
state
)
void
GameSelector
::
show
Unavailable
GamesChanged
(
int
state
)
{
gameListProxyModel
->
setFullGamesVisible
(
state
);
}
void
GameSelector
::
showRunningGamesChanged
(
int
state
)
{
gameListProxyModel
->
setRunningGamesVisible
(
state
);
gameListProxyModel
->
setUnavailableGamesVisible
(
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"
));
showUnavailableGamesCheckBox
->
setText
(
tr
(
"Show u&navailable games"
));
if
(
createButton
)
createButton
->
setText
(
tr
(
"C&reate"
));
joinButton
->
setText
(
tr
(
"&Join"
));
...
...
cockatrice/src/gameselector.h
View file @
332ca29d
...
...
@@ -18,8 +18,7 @@ class TabRoom;
class
GameSelector
:
public
QGroupBox
{
Q_OBJECT
private
slots
:
void
showFullGamesChanged
(
int
state
);
void
showRunningGamesChanged
(
int
state
);
void
showUnavailableGamesChanged
(
int
state
);
void
actCreate
();
void
actJoin
();
void
checkResponse
(
ResponseCode
response
);
...
...
@@ -34,11 +33,11 @@ private:
GamesModel
*
gameListModel
;
GamesProxyModel
*
gameListProxyModel
;
QPushButton
*
createButton
,
*
joinButton
,
*
spectateButton
;
QCheckBox
*
show
FullGamesCheckBox
,
*
showRunning
GamesCheckBox
;
QCheckBox
*
show
Unavailable
GamesCheckBox
;
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
\ No newline at end of file
#endif
cockatrice/src/gamesmodel.cpp
View file @
332ca29d
...
...
@@ -106,21 +106,15 @@ void GamesModel::updateGameList(ServerInfo_Game *_game)
endInsertRows
();
}
GamesProxyModel
::
GamesProxyModel
(
QObject
*
parent
)
:
QSortFilterProxyModel
(
parent
),
full
GamesVisible
(
false
)
GamesProxyModel
::
GamesProxyModel
(
QObject
*
parent
,
ServerInfo_User
*
_ownUser
)
:
QSortFilterProxyModel
(
parent
),
ownUser
(
_ownUser
),
unavailable
GamesVisible
(
false
)
{
setDynamicSortFilter
(
true
);
}
void
GamesProxyModel
::
set
Full
GamesVisible
(
bool
_
full
GamesVisible
)
void
GamesProxyModel
::
set
Unavailable
GamesVisible
(
bool
_
unavailable
GamesVisible
)
{
fullGamesVisible
=
_fullGamesVisible
;
invalidateFilter
();
}
void
GamesProxyModel
::
setRunningGamesVisible
(
bool
_runningGamesVisible
)
{
runningGamesVisible
=
_runningGamesVisible
;
unavailableGamesVisible
=
_unavailableGamesVisible
;
invalidateFilter
();
}
...
...
@@ -131,10 +125,15 @@ 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
(
!
unavailableGamesVisible
)
{
if
(
game
->
getPlayerCount
()
==
game
->
getMaxPlayers
())
return
false
;
if
(
game
->
getStarted
())
return
false
;
if
(
!
(
ownUser
->
getUserLevel
()
&
ServerInfo_User
::
IsRegistered
))
if
(
game
->
getOnlyRegistered
())
return
false
;
}
return
true
;
}
cockatrice/src/gamesmodel.h
View file @
332ca29d
...
...
@@ -5,6 +5,7 @@
#include
<QSortFilterProxyModel>
#include
<QList>
#include
"gametypemap.h"
#include
"protocol_datastructures.h"
class
ServerInfo_Game
;
...
...
@@ -29,12 +30,11 @@ public:
class
GamesProxyModel
:
public
QSortFilterProxyModel
{
Q_OBJECT
private:
bool
fullGamesVisible
;
bool
r
un
ning
GamesVisible
;
ServerInfo_User
*
ownUser
;
bool
un
available
GamesVisible
;
public:
GamesProxyModel
(
QObject
*
parent
=
0
);
void
setFullGamesVisible
(
bool
_fullGamesVisible
);
void
setRunningGamesVisible
(
bool
_runningGamesVisible
);
GamesProxyModel
(
QObject
*
parent
=
0
,
ServerInfo_User
*
_ownUser
=
0
);
void
setUnavailableGamesVisible
(
bool
_unavailableGamesVisible
);
protected:
bool
filterAcceptsRow
(
int
sourceRow
,
const
QModelIndex
&
sourceParent
)
const
;
};
...
...
cockatrice/src/tab_room.cpp
View file @
332ca29d
...
...
@@ -17,8 +17,8 @@
#include
"chatview.h"
#include
"gameselector.h"
TabRoom
::
TabRoom
(
TabSupervisor
*
_tabSupervisor
,
AbstractClient
*
_client
,
const
QString
&
_ownName
,
ServerInfo_Room
*
info
)
:
Tab
(
_tabSupervisor
),
client
(
_client
),
roomId
(
info
->
getRoomId
()),
roomName
(
info
->
getName
()),
own
Name
(
_own
Name
)
TabRoom
::
TabRoom
(
TabSupervisor
*
_tabSupervisor
,
AbstractClient
*
_client
,
ServerInfo_User
*
_ownUser
,
ServerInfo_Room
*
info
)
:
Tab
(
_tabSupervisor
),
client
(
_client
),
roomId
(
info
->
getRoomId
()),
roomName
(
info
->
getName
()),
own
User
(
_own
User
)
{
const
QList
<
ServerInfo_GameType
*>
gameTypeList
=
info
->
getGameTypeList
();
for
(
int
i
=
0
;
i
<
gameTypeList
.
size
();
++
i
)
...
...
@@ -30,7 +30,7 @@ TabRoom::TabRoom(TabSupervisor *_tabSupervisor, AbstractClient *_client, const Q
userList
=
new
UserList
(
tabSupervisor
,
client
,
UserList
::
RoomList
);
connect
(
userList
,
SIGNAL
(
openMessageDialog
(
const
QString
&
,
bool
)),
this
,
SIGNAL
(
openMessageDialog
(
const
QString
&
,
bool
)));
chatView
=
new
ChatView
(
ownName
,
true
);
chatView
=
new
ChatView
(
own
User
->
get
Name
()
,
true
);
connect
(
chatView
,
SIGNAL
(
showCardInfoPopup
(
QPoint
,
QString
)),
this
,
SLOT
(
showCardInfoPopup
(
QPoint
,
QString
)));
connect
(
chatView
,
SIGNAL
(
deleteCardInfoPopup
(
QString
)),
this
,
SLOT
(
deleteCardInfoPopup
(
QString
)));
sayLabel
=
new
QLabel
;
...
...
cockatrice/src/tab_room.h
View file @
332ca29d
...
...
@@ -2,6 +2,7 @@
#define TAB_ROOM_H
#include
"tab.h"
#include
"protocol_datastructures.h"
#include
<QGroupBox>
#include
<QMap>
...
...
@@ -28,7 +29,7 @@ private:
AbstractClient
*
client
;
int
roomId
;
QString
roomName
;
QString
ownName
;
ServerInfo_User
*
ownUser
;
QMap
<
int
,
QString
>
gameTypes
;
GameSelector
*
gameSelector
;
...
...
@@ -53,7 +54,7 @@ private slots:
void
processLeaveRoomEvent
(
Event_LeaveRoom
*
event
);
void
processSayEvent
(
Event_RoomSay
*
event
);
public:
TabRoom
(
TabSupervisor
*
_tabSupervisor
,
AbstractClient
*
_client
,
const
QString
&
_ownName
,
ServerInfo_Room
*
info
);
TabRoom
(
TabSupervisor
*
_tabSupervisor
,
AbstractClient
*
_client
,
ServerInfo_User
*
_ownUser
,
ServerInfo_Room
*
info
);
~
TabRoom
();
void
retranslateUi
();
void
closeRequest
();
...
...
cockatrice/src/tab_supervisor.cpp
View file @
332ca29d
...
...
@@ -265,7 +265,7 @@ void TabSupervisor::gameLeft(TabGame *tab)
void
TabSupervisor
::
addRoomTab
(
ServerInfo_Room
*
info
,
bool
setCurrent
)
{
TabRoom
*
tab
=
new
TabRoom
(
this
,
client
,
userInfo
->
getName
()
,
info
);
TabRoom
*
tab
=
new
TabRoom
(
this
,
client
,
userInfo
,
info
);
connect
(
tab
,
SIGNAL
(
roomClosing
(
TabRoom
*
)),
this
,
SLOT
(
roomLeft
(
TabRoom
*
)));
connect
(
tab
,
SIGNAL
(
openMessageDialog
(
const
QString
&
,
bool
)),
this
,
SLOT
(
addMessageTab
(
const
QString
&
,
bool
)));
int
tabIndex
=
myAddTab
(
tab
);
...
...
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