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
a64ea173
Commit
a64ea173
authored
Aug 18, 2015
by
Jeff
Browse files
Add LineEditCompleter to Tab_Game
parent
8c072295
Changes
7
Hide whitespace changes
Inline
Side-by-side
cockatrice/CMakeLists.txt
View file @
a64ea173
...
...
@@ -94,6 +94,7 @@ SET(cockatrice_SOURCES
src/qt-json/json.cpp
src/soundengine.cpp
src/pending_command.cpp
src/lineeditcompleter.cpp
${
VERSION_STRING_CPP
}
)
...
...
cockatrice/src/lineeditcompleter.cpp
0 → 100644
View file @
a64ea173
#include
<QStringListModel>
#include
<QLineEdit>
#include
<QCompleter>
#include
<QWidget>
#include
<QTextCursor>
#include
<QAbstractItemView>
#include
<QScrollBar>
#include
<QStringListModel>
#include
<QKeyEvent>
#include
<QFocusEvent>
#include
"lineeditcompleter.h"
LineEditCompleter
::
LineEditCompleter
(
QWidget
*
parent
)
:
QLineEdit
(
parent
)
{
}
void
LineEditCompleter
::
focusOutEvent
(
QFocusEvent
*
e
){
QLineEdit
::
focusOutEvent
(
e
);
if
(
c
->
popup
()
->
isVisible
()){
//Remove Popup
c
->
popup
()
->
hide
();
//Truncate the line to last space or whole string
QString
textValue
=
text
();
int
lastIndex
=
textValue
.
length
();
int
lastWordStartIndex
=
textValue
.
lastIndexOf
(
" "
)
+
1
;
int
leftShift
=
qMin
(
lastIndex
,
lastWordStartIndex
);
setText
(
textValue
.
left
(
leftShift
));
//Insert highlighted line from popup
insert
(
c
->
completionModel
()
->
index
(
c
->
popup
()
->
currentIndex
().
row
(),
0
).
data
().
toString
()
+
" "
);
//Set focus back to the textbox since tab was pressed
setFocus
();
}
}
void
LineEditCompleter
::
keyPressEvent
(
QKeyEvent
*
event
)
{
switch
(
event
->
key
()){
case
Qt
::
Key_Return
:
case
Qt
::
Key_Enter
:
case
Qt
::
Key_Escape
:
if
(
c
->
popup
()
->
isVisible
()){
event
->
ignore
();
//Remove Popup
c
->
popup
()
->
hide
();
//Truncate the line to last space or whole string
QString
textValue
=
text
();
int
lastIndexof
=
textValue
.
lastIndexOf
(
" "
);
QString
finalString
=
textValue
.
left
(
lastIndexof
);
//Add a space if there's a word
if
(
finalString
!=
""
)
finalString
+=
" "
;
setText
(
finalString
);
return
;
}
break
;
case
Qt
::
Key_Space
:
if
(
c
->
popup
()
->
isVisible
()){
event
->
ignore
();
//Remove Popup
c
->
popup
()
->
hide
();
//Truncate the line to last space or whole string
QString
textValue
=
text
();
int
lastIndex
=
textValue
.
length
();
int
lastWordStartIndex
=
textValue
.
lastIndexOf
(
" "
)
+
1
;
int
leftShift
=
qMin
(
lastIndex
,
lastWordStartIndex
);
setText
(
textValue
.
left
(
leftShift
));
//Insert highlighted line from popup
insert
(
c
->
completionModel
()
->
index
(
c
->
popup
()
->
currentIndex
().
row
(),
0
).
data
().
toString
()
+
" "
);
return
;
}
break
;
default:
break
;
}
QLineEdit
::
keyPressEvent
(
event
);
QString
textValue
=
text
();
//Wait until the first character after @
if
(
!
c
||
text
().
right
(
1
).
contains
(
"@"
))
return
;
//Set new completion prefix
c
->
setCompletionPrefix
(
cursorWord
(
text
()));
if
(
c
->
completionPrefix
().
length
()
<
1
){
c
->
popup
()
->
hide
();
return
;
}
//Draw completion box
QRect
cr
=
cursorRect
();
cr
.
setWidth
(
c
->
popup
()
->
sizeHintForColumn
(
0
)
+
c
->
popup
()
->
verticalScrollBar
()
->
sizeHint
().
width
());
c
->
complete
(
cr
);
//Select first item in the completion popup
QItemSelectionModel
*
sm
=
new
QItemSelectionModel
(
c
->
completionModel
());
c
->
popup
()
->
setSelectionModel
(
sm
);
sm
->
select
(
c
->
completionModel
()
->
index
(
0
,
0
),
QItemSelectionModel
::
ClearAndSelect
);
sm
->
setCurrentIndex
(
c
->
completionModel
()
->
index
(
0
,
0
),
QItemSelectionModel
::
NoUpdate
);
}
QString
LineEditCompleter
::
cursorWord
(
const
QString
&
line
)
const
{
return
line
.
mid
(
line
.
left
(
cursorPosition
()).
lastIndexOf
(
" "
)
+
1
,
cursorPosition
()
-
line
.
left
(
cursorPosition
()).
lastIndexOf
(
" "
)
-
1
);
}
void
LineEditCompleter
::
insertCompletion
(
QString
arg
)
{
QString
s_arg
=
arg
+
" "
;
setText
(
text
().
replace
(
text
().
left
(
cursorPosition
()).
lastIndexOf
(
" "
)
+
1
,
cursorPosition
()
-
text
().
left
(
cursorPosition
()).
lastIndexOf
(
" "
)
-
1
,
s_arg
));
}
void
LineEditCompleter
::
setCompleter
(
QCompleter
*
completer
)
{
c
=
completer
;
c
->
setWidget
(
this
);
connect
(
c
,
SIGNAL
(
activated
(
QString
)),
this
,
SLOT
(
insertCompletion
(
QString
)));
}
void
LineEditCompleter
::
setCompletionList
(
QStringList
completionList
)
{
if
(
!
c
||
c
->
popup
()
->
isVisible
())
return
;
QStringListModel
*
model
;
model
=
(
QStringListModel
*
)(
c
->
model
());
if
(
model
==
NULL
)
model
=
new
QStringListModel
();
model
->
setStringList
(
completionList
);
}
\ No newline at end of file
cockatrice/src/lineeditcompleter.h
0 → 100644
View file @
a64ea173
#ifndef LINEEDITCOMPLETER_H
#define LINEEDITCOMPLETER_H
#include
<QLineEdit>
#include
<QKeyEvent>
#include
<QFocusEvent>
#include
<QStringList>
class
LineEditCompleter
:
public
QLineEdit
{
Q_OBJECT
private:
QString
cursorWord
(
const
QString
&
line
)
const
;
QCompleter
*
c
;
private
slots
:
void
insertCompletion
(
QString
);
protected:
void
keyPressEvent
(
QKeyEvent
*
event
);
void
focusOutEvent
(
QFocusEvent
*
e
);
public:
explicit
LineEditCompleter
(
QWidget
*
parent
=
0
);
void
setCompleter
(
QCompleter
*
);
void
setCompletionList
(
QStringList
);
};
#endif
\ No newline at end of file
cockatrice/src/tab_game.cpp
View file @
a64ea173
...
...
@@ -8,6 +8,8 @@
#include
<QTimer>
#include
<QToolButton>
#include
<QDebug>
#include
<QCompleter>
#include
<QWidget>
#include
"dlg_creategame.h"
#include
"tab_game.h"
...
...
@@ -31,6 +33,7 @@
#include
"settingscache.h"
#include
"carddatabase.h"
#include
"replay_timeline_widget.h"
#include
"lineeditcompleter.h"
#include
<google/protobuf/descriptor.h>
#include
"pending_command.h"
...
...
@@ -409,8 +412,9 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_client
connect
(
messageLog
,
SIGNAL
(
showCardInfoPopup
(
QPoint
,
QString
)),
this
,
SLOT
(
showCardInfoPopup
(
QPoint
,
QString
)));
connect
(
messageLog
,
SIGNAL
(
deleteCardInfoPopup
(
QString
)),
this
,
SLOT
(
deleteCardInfoPopup
(
QString
)));
connect
(
messageLog
,
SIGNAL
(
addMentionTag
(
QString
)),
this
,
SLOT
(
addMentionTag
(
QString
)));
connect
(
settingsCache
,
SIGNAL
(
chatMentionCompleterChanged
()),
this
,
SLOT
(
actCompleterChanged
()));
sayLabel
=
new
QLabel
;
sayEdit
=
new
Q
LineEdit
;
sayEdit
=
new
LineEdit
Completer
;
sayLabel
->
setBuddy
(
sayEdit
);
QHBoxLayout
*
hLayout
=
new
QHBoxLayout
;
...
...
@@ -507,6 +511,17 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_client
for
(
int
i
=
gameInfo
.
game_types_size
()
-
1
;
i
>=
0
;
i
--
)
gameTypes
.
append
(
roomGameTypes
.
find
(
gameInfo
.
game_types
(
i
)).
value
());
completer
=
new
QCompleter
(
autocompleteUserList
,
sayEdit
);
completer
->
setCaseSensitivity
(
Qt
::
CaseInsensitive
);
completer
->
setMaxVisibleItems
(
5
);
#if QT_VERSION >= 0x050000
completer
->
setFilterMode
(
Qt
::
MatchStartsWith
);
#endif
sayEdit
->
setCompleter
(
completer
);
actCompleterChanged
();
}
void
TabGame
::
addMentionTag
(
QString
value
)
{
...
...
@@ -681,6 +696,9 @@ void TabGame::actLeaveGame()
void
TabGame
::
actSay
()
{
if
(
completer
->
popup
()
->
isVisible
())
return
;
if
(
!
sayEdit
->
text
().
isEmpty
())
{
Command_GameSay
cmd
;
cmd
.
set_message
(
sayEdit
->
text
().
toStdString
());
...
...
@@ -739,11 +757,21 @@ void TabGame::actRotateViewCCW()
scene
->
adjustPlayerRotation
(
1
);
}
void
TabGame
::
actCompleterChanged
()
{
settingsCache
->
getChatMentionCompleter
()
?
completer
->
setCompletionRole
(
2
)
:
completer
->
setCompletionRole
(
1
);
}
Player
*
TabGame
::
addPlayer
(
int
playerId
,
const
ServerInfo_User
&
info
)
{
bool
local
=
((
clients
.
size
()
>
1
)
||
(
playerId
==
localPlayerId
));
Player
*
newPlayer
=
new
Player
(
info
,
playerId
,
local
,
this
);
connect
(
newPlayer
,
SIGNAL
(
openDeckEditor
(
const
DeckLoader
*
)),
this
,
SIGNAL
(
openDeckEditor
(
const
DeckLoader
*
)));
QString
newPlayerName
=
"@"
+
newPlayer
->
getName
();
if
(
!
autocompleteUserList
.
contains
(
newPlayerName
)){
autocompleteUserList
<<
newPlayerName
;
sayEdit
->
setCompletionList
(
autocompleteUserList
);
}
scene
->
addPlayer
(
newPlayer
);
connect
(
newPlayer
,
SIGNAL
(
newCardAdded
(
AbstractCardItem
*
)),
this
,
SLOT
(
newCardAdded
(
AbstractCardItem
*
)));
...
...
@@ -763,7 +791,6 @@ Player *TabGame::addPlayer(int playerId, const ServerInfo_User &info)
players
.
insert
(
playerId
,
newPlayer
);
emit
playerAdded
(
newPlayer
);
return
newPlayer
;
}
...
...
@@ -938,6 +965,9 @@ void TabGame::eventSpectatorSay(const Event_GameSay &event, int eventPlayerId, c
void
TabGame
::
eventSpectatorLeave
(
const
Event_Leave
&
/*event*/
,
int
eventPlayerId
,
const
GameEventContext
&
/*context*/
)
{
QString
playerName
=
"@"
+
QString
::
fromStdString
(
spectators
.
value
(
eventPlayerId
).
name
());
if
(
autocompleteUserList
.
removeOne
(
playerName
))
sayEdit
->
setCompletionList
(
autocompleteUserList
);
messageLog
->
logLeaveSpectator
(
QString
::
fromStdString
(
spectators
.
value
(
eventPlayerId
).
name
()));
playerListWidget
->
removePlayer
(
eventPlayerId
);
spectators
.
remove
(
eventPlayerId
);
...
...
@@ -952,6 +982,11 @@ void TabGame::eventGameStateChanged(const Event_GameStateChanged &event, int /*e
const
ServerInfo_Player
&
playerInfo
=
event
.
player_list
(
i
);
const
ServerInfo_PlayerProperties
&
prop
=
playerInfo
.
properties
();
const
int
playerId
=
prop
.
player_id
();
QString
playerName
=
"@"
+
QString
::
fromStdString
(
prop
.
user_info
().
name
());
if
(
!
autocompleteUserList
.
contains
(
playerName
)){
autocompleteUserList
<<
playerName
;
sayEdit
->
setCompletionList
(
autocompleteUserList
);
}
if
(
prop
.
spectator
())
{
if
(
!
spectators
.
contains
(
playerId
))
{
spectators
.
insert
(
playerId
,
prop
.
user_info
());
...
...
@@ -1059,11 +1094,18 @@ void TabGame::eventJoin(const Event_Join &event, int /*eventPlayerId*/, const Ga
{
const
ServerInfo_PlayerProperties
&
playerInfo
=
event
.
player_properties
();
const
int
playerId
=
playerInfo
.
player_id
();
QString
playerName
=
QString
::
fromStdString
(
playerInfo
.
user_info
().
name
());
if
(
!
autocompleteUserList
.
contains
(
"@"
+
playerName
)){
autocompleteUserList
<<
"@"
+
playerName
;
sayEdit
->
setCompletionList
(
autocompleteUserList
);
}
if
(
players
.
contains
(
playerId
))
return
;
if
(
playerInfo
.
spectator
())
{
spectators
.
insert
(
playerId
,
playerInfo
.
user_info
());
messageLog
->
logJoinSpectator
(
QString
::
fromStdString
(
playerInfo
.
user_info
().
name
())
);
messageLog
->
logJoinSpectator
(
playerName
);
}
else
{
Player
*
newPlayer
=
addPlayer
(
playerId
,
playerInfo
.
user_info
());
messageLog
->
logJoin
(
newPlayer
);
...
...
@@ -1078,6 +1120,10 @@ void TabGame::eventLeave(const Event_Leave & /*event*/, int eventPlayerId, const
if
(
!
player
)
return
;
QString
playerName
=
"@"
+
player
->
getName
();
if
(
autocompleteUserList
.
removeOne
(
playerName
))
sayEdit
->
setCompletionList
(
autocompleteUserList
);
messageLog
->
logLeave
(
player
);
playerListWidget
->
removePlayer
(
eventPlayerId
);
players
.
remove
(
eventPlayerId
);
...
...
cockatrice/src/tab_game.h
View file @
a64ea173
...
...
@@ -3,6 +3,7 @@
#include
<QMap>
#include
<QPushButton>
#include
<QCompleter>
#include
"tab.h"
#include
"pb/serverinfo_game.pb.h"
...
...
@@ -54,6 +55,7 @@ class QHBoxLayout;
class
GameReplay
;
class
ServerInfo_User
;
class
PendingCommand
;
class
LineEditCompleter
;
class
ToggleButton
:
public
QPushButton
{
Q_OBJECT
...
...
@@ -116,6 +118,8 @@ private:
CardItem
*
activeCard
;
bool
gameClosed
;
QStringList
gameTypes
;
QCompleter
*
completer
;
QStringList
autocompleteUserList
;
// Replay related members
GameReplay
*
replay
;
...
...
@@ -130,7 +134,7 @@ private:
QLabel
*
timeElapsedLabel
;
MessageLogWidget
*
messageLog
;
QLabel
*
sayLabel
;
Q
LineEdit
*
sayEdit
;
LineEdit
Completer
*
sayEdit
;
PhasesToolbar
*
phasesToolbar
;
GameScene
*
scene
;
GameView
*
gameView
;
...
...
@@ -199,6 +203,8 @@ private slots:
void
addMentionTag
(
QString
value
);
void
commandFinished
(
const
Response
&
response
);
void
actCompleterChanged
();
public:
TabGame
(
TabSupervisor
*
_tabSupervisor
,
QList
<
AbstractClient
*>
&
_clients
,
const
Event_GameJoined
&
event
,
const
QMap
<
int
,
QString
>
&
_roomGameTypes
);
TabGame
(
TabSupervisor
*
_tabSupervisor
,
GameReplay
*
replay
);
...
...
cockatrice/src/tab_room.cpp
View file @
a64ea173
...
...
@@ -13,12 +13,6 @@
#include
<QSystemTrayIcon>
#include
<QCompleter>
#include
<QWidget>
#include
<QTextCursor>
#include
<QAbstractItemView>
#include
<QScrollBar>
#include
<QStringListModel>
#include
<QKeyEvent>
#include
<QFocusEvent>
#include
"tab_supervisor.h"
#include
"tab_room.h"
#include
"tab_userlists.h"
...
...
@@ -28,6 +22,7 @@
#include
"gameselector.h"
#include
"settingscache.h"
#include
"main.h"
#include
"lineeditcompleter.h"
#include
"get_pb_extension.h"
#include
"pb/room_commands.pb.h"
...
...
@@ -61,7 +56,7 @@ TabRoom::TabRoom(TabSupervisor *_tabSupervisor, AbstractClient *_client, ServerI
connect
(
chatView
,
SIGNAL
(
addMentionTag
(
QString
)),
this
,
SLOT
(
addMentionTag
(
QString
)));
connect
(
settingsCache
,
SIGNAL
(
chatMentionCompleterChanged
()),
this
,
SLOT
(
actCompleterChanged
()));
sayLabel
=
new
QLabel
;
sayEdit
=
new
Custom
LineEdit
;
sayEdit
=
new
LineEdit
Completer
;
sayLabel
->
setBuddy
(
sayEdit
);
connect
(
sayEdit
,
SIGNAL
(
returnPressed
()),
this
,
SLOT
(
sendMessage
()));
...
...
@@ -255,7 +250,7 @@ void TabRoom::processJoinRoomEvent(const Event_JoinRoom &event)
userList
->
sortItems
();
if
(
!
autocompleteUserList
.
contains
(
"@"
+
QString
::
fromStdString
(
event
.
user_info
().
name
()))){
autocompleteUserList
<<
"@"
+
QString
::
fromStdString
(
event
.
user_info
().
name
());
sayEdit
->
update
Complet
erModel
(
autocompleteUserList
);
sayEdit
->
set
Complet
ionList
(
autocompleteUserList
);
}
}
...
...
@@ -263,7 +258,7 @@ void TabRoom::processLeaveRoomEvent(const Event_LeaveRoom &event)
{
userList
->
deleteUser
(
QString
::
fromStdString
(
event
.
name
()));
autocompleteUserList
.
removeOne
(
"@"
+
QString
::
fromStdString
(
event
.
name
()));
sayEdit
->
update
Complet
erModel
(
autocompleteUserList
);
sayEdit
->
set
Complet
ionList
(
autocompleteUserList
);
}
void
TabRoom
::
processRoomSayEvent
(
const
Event_RoomSay
&
event
)
...
...
@@ -295,125 +290,4 @@ PendingCommand *TabRoom::prepareRoomCommand(const ::google::protobuf::Message &c
void
TabRoom
::
sendRoomCommand
(
PendingCommand
*
pend
)
{
client
->
sendCommand
(
pend
);
}
CustomLineEdit
::
CustomLineEdit
(
QWidget
*
parent
)
:
QLineEdit
(
parent
)
{
}
void
CustomLineEdit
::
focusOutEvent
(
QFocusEvent
*
e
){
QLineEdit
::
focusOutEvent
(
e
);
if
(
c
->
popup
()
->
isVisible
()){
//Remove Popup
c
->
popup
()
->
hide
();
//Truncate the line to last space or whole string
QString
textValue
=
text
();
int
lastIndex
=
textValue
.
length
();
int
lastWordStartIndex
=
textValue
.
lastIndexOf
(
" "
)
+
1
;
int
leftShift
=
qMin
(
lastIndex
,
lastWordStartIndex
);
setText
(
textValue
.
left
(
leftShift
));
//Insert highlighted line from popup
insert
(
c
->
completionModel
()
->
index
(
c
->
popup
()
->
currentIndex
().
row
(),
0
).
data
().
toString
()
+
" "
);
//Set focus back to the textbox since tab was pressed
setFocus
();
}
}
void
CustomLineEdit
::
keyPressEvent
(
QKeyEvent
*
event
)
{
switch
(
event
->
key
()){
case
Qt
::
Key_Return
:
case
Qt
::
Key_Enter
:
case
Qt
::
Key_Escape
:
if
(
c
->
popup
()
->
isVisible
()){
event
->
ignore
();
//Remove Popup
c
->
popup
()
->
hide
();
//Truncate the line to last space or whole string
QString
textValue
=
text
();
int
lastIndexof
=
textValue
.
lastIndexOf
(
" "
);
QString
finalString
=
textValue
.
left
(
lastIndexof
);
//Add a space if there's a word
if
(
finalString
!=
""
)
finalString
+=
" "
;
setText
(
finalString
);
return
;
}
break
;
case
Qt
::
Key_Space
:
if
(
c
->
popup
()
->
isVisible
()){
event
->
ignore
();
//Remove Popup
c
->
popup
()
->
hide
();
//Truncate the line to last space or whole string
QString
textValue
=
text
();
int
lastIndex
=
textValue
.
length
();
int
lastWordStartIndex
=
textValue
.
lastIndexOf
(
" "
)
+
1
;
int
leftShift
=
qMin
(
lastIndex
,
lastWordStartIndex
);
setText
(
textValue
.
left
(
leftShift
));
//Insert highlighted line from popup
insert
(
c
->
completionModel
()
->
index
(
c
->
popup
()
->
currentIndex
().
row
(),
0
).
data
().
toString
()
+
" "
);
return
;
}
break
;
default:
break
;
}
QLineEdit
::
keyPressEvent
(
event
);
//Wait until the first character after @
if
(
!
c
||
text
().
right
(
1
).
contains
(
"@"
))
return
;
//Set new completion prefix
c
->
setCompletionPrefix
(
cursorWord
(
text
()));
if
(
c
->
completionPrefix
().
length
()
<
1
){
c
->
popup
()
->
hide
();
return
;
}
//Draw completion box
QRect
cr
=
cursorRect
();
cr
.
setWidth
(
c
->
popup
()
->
sizeHintForColumn
(
0
)
+
c
->
popup
()
->
verticalScrollBar
()
->
sizeHint
().
width
());
c
->
complete
(
cr
);
//Select first item in the completion popup
QItemSelectionModel
*
sm
=
new
QItemSelectionModel
(
c
->
completionModel
());
c
->
popup
()
->
setSelectionModel
(
sm
);
sm
->
select
(
c
->
completionModel
()
->
index
(
0
,
0
),
QItemSelectionModel
::
ClearAndSelect
);
sm
->
setCurrentIndex
(
c
->
completionModel
()
->
index
(
0
,
0
),
QItemSelectionModel
::
NoUpdate
);
}
QString
CustomLineEdit
::
cursorWord
(
const
QString
&
line
)
const
{
return
line
.
mid
(
line
.
left
(
cursorPosition
()).
lastIndexOf
(
" "
)
+
1
,
cursorPosition
()
-
line
.
left
(
cursorPosition
()).
lastIndexOf
(
" "
)
-
1
);
}
void
CustomLineEdit
::
insertCompletion
(
QString
arg
)
{
QString
s_arg
=
arg
+
" "
;
setText
(
text
().
replace
(
text
().
left
(
cursorPosition
()).
lastIndexOf
(
" "
)
+
1
,
cursorPosition
()
-
text
().
left
(
cursorPosition
()).
lastIndexOf
(
" "
)
-
1
,
s_arg
));
}
void
CustomLineEdit
::
setCompleter
(
QCompleter
*
completer
)
{
c
=
completer
;
c
->
setWidget
(
this
);
connect
(
c
,
SIGNAL
(
activated
(
QString
)),
this
,
SLOT
(
insertCompletion
(
QString
)));
}
void
CustomLineEdit
::
updateCompleterModel
(
QStringList
completionList
)
{
if
(
!
c
||
c
->
popup
()
->
isVisible
())
return
;
QStringListModel
*
model
;
model
=
(
QStringListModel
*
)(
c
->
model
());
if
(
model
==
NULL
)
model
=
new
QStringListModel
();
QStringList
updatedList
=
completionList
;
model
->
setStringList
(
updatedList
);
}
\ No newline at end of file
cockatrice/src/tab_room.h
View file @
a64ea173
...
...
@@ -2,6 +2,7 @@
#define TAB_ROOM_H
#include
"tab.h"
#include
"lineeditcompleter.h"
#include
<QGroupBox>
#include
<QMap>
#include
<QLineEdit>
...
...
@@ -28,7 +29,7 @@ class GameSelector;
class
Response
;
class
PendingCommand
;
class
ServerInfo_User
;
class
Custom
LineEdit
;
class
LineEdit
Completer
;
class
TabRoom
:
public
Tab
{
Q_OBJECT
...
...
@@ -43,7 +44,7 @@ private:
UserList
*
userList
;
ChatView
*
chatView
;
QLabel
*
sayLabel
;
Custom
LineEdit
*
sayEdit
;
LineEdit
Completer
*
sayEdit
;
QGroupBox
*
chatGroupBox
;
QMenu
*
roomMenu
;
...
...
@@ -90,21 +91,4 @@ public:
void
sendRoomCommand
(
PendingCommand
*
pend
);
};
class
CustomLineEdit
:
public
QLineEdit
{
Q_OBJECT
private:
QString
cursorWord
(
const
QString
&
line
)
const
;
QCompleter
*
c
;
private
slots
:
void
insertCompletion
(
QString
);
protected:
void
keyPressEvent
(
QKeyEvent
*
event
);
void
focusOutEvent
(
QFocusEvent
*
e
);
public:
explicit
CustomLineEdit
(
QWidget
*
parent
=
0
);
void
setCompleter
(
QCompleter
*
);
void
updateCompleterModel
(
QStringList
);
};
#endif
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