first steps integrating chattools in mainwindow chat
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
using namespace std;
|
||||
|
||||
|
||||
ChatTools::ChatTools(QLineEdit* l, QTreeWidget *t, QStringList *s) : nickAutoCompletitionCounter(0), myLineEdit(l), myNickTreeWidget(t), myNickStringList(s)
|
||||
ChatTools::ChatTools(QLineEdit* l, QTreeWidget *t) : nickAutoCompletitionCounter(0), myLineEdit(l), myNickTreeWidget(t), myNickStringList(NULL)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -63,6 +63,7 @@ void ChatTools::nickAutoCompletition() {
|
||||
if(nickAutoCompletitionCounter == 0) {
|
||||
|
||||
if(myNickTreeWidget) {
|
||||
cout << "use Treewidget niclist" << endl;
|
||||
QTreeWidgetItemIterator it(myNickTreeWidget);
|
||||
while (*it) {
|
||||
if ((*it)->text(0).startsWith(myChatStringList.last(), Qt::CaseInsensitive) && myChatStringList.last() != "")
|
||||
@@ -71,7 +72,12 @@ void ChatTools::nickAutoCompletition() {
|
||||
}
|
||||
}
|
||||
|
||||
if(myNickStringList) {
|
||||
if(!myNickStringList.isEmpty()) {
|
||||
cout << "use static nickList" << endl;
|
||||
|
||||
QStringListIterator it(myNickStringList);
|
||||
while (it.hasNext())
|
||||
cout << it.next().toLocal8Bit().constData() << endl;
|
||||
//TODO code for static nickList
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class ChatTools : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ChatTools(QLineEdit* l, QTreeWidget *t = NULL, QStringList *s = NULL);
|
||||
ChatTools(QLineEdit* l, QTreeWidget *t = NULL);
|
||||
|
||||
~ChatTools();
|
||||
|
||||
@@ -42,6 +42,8 @@ public slots:
|
||||
void nickAutoCompletition();
|
||||
void setChatTextEdited();
|
||||
|
||||
void setPlayerNicksList(QStringList value) { myNickStringList = value; }
|
||||
|
||||
private:
|
||||
QStringList chatLinesHistory;
|
||||
QString lastChatString;
|
||||
@@ -50,7 +52,7 @@ private:
|
||||
|
||||
QLineEdit* myLineEdit;
|
||||
QTreeWidget *myNickTreeWidget;
|
||||
QStringList *myNickStringList;
|
||||
QStringList myNickStringList;
|
||||
// friend class GuiWrapper;
|
||||
};
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
#include "mainwindowimpl.h"
|
||||
#include "session.h"
|
||||
#include "chattools.h"
|
||||
#include "configfile.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -28,6 +30,7 @@ Chat::Chat(mainWindowImpl* w, ConfigFile *c) : myW(w), myConfig(c)
|
||||
{
|
||||
myW->setChat(this);
|
||||
|
||||
myChatTools = new ChatTools(myW->lineEdit_ChatInput);
|
||||
connect(this, SIGNAL(signalChatMessage(QString, QString)), this, SLOT(receiveMessage(QString, QString)));
|
||||
}
|
||||
|
||||
@@ -69,12 +72,15 @@ void Chat::checkInputLength(QString string) {
|
||||
void Chat::clearNewGame() {
|
||||
|
||||
myW->textBrowser_Chat->clear();
|
||||
/* QStringList wordList;
|
||||
wordList << "alpha" << "omega" << "omicron" << "zeta";*/
|
||||
|
||||
// QCompleter *completer = new QCompleter(wordList, this);
|
||||
// completer->setCaseSensitivity(Qt::CaseInsensitive);
|
||||
// completer->setCompletionMode(QCompleter::InlineCompletion);
|
||||
// // lineEdit_ChatInput->setCompleter(completer);
|
||||
|
||||
}
|
||||
|
||||
void Chat::setPlayerNicksList(QStringList nickList) {
|
||||
//fill playerNicksList for nick-autocompletition
|
||||
myChatTools->setPlayerNicksList(nickList);
|
||||
}
|
||||
|
||||
void Chat::fillChatLinesHistory(QString fillString) { myChatTools->fillChatLinesHistory(fillString); }
|
||||
int Chat::getChatLinesHistorySize() { return myChatTools->getChatLinesHistorySize(); }
|
||||
void Chat::showChatHistoryIndex(int index) { myChatTools->showChatHistoryIndex(index); }
|
||||
void Chat::nickAutoCompletition() { myChatTools->nickAutoCompletition(); }
|
||||
void Chat::setChatTextEdited() { myChatTools->setChatTextEdited(); }
|
||||
|
||||
@@ -21,13 +21,12 @@
|
||||
#define CHAT_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "configfile.h"
|
||||
|
||||
#include <QtCore>
|
||||
|
||||
|
||||
class mainWindowImpl;
|
||||
class ChatTools;
|
||||
class ConfigFile;
|
||||
|
||||
class Chat : public QObject
|
||||
{
|
||||
@@ -48,12 +47,21 @@ public slots:
|
||||
void checkInvisible();
|
||||
void checkInputLength(QString);
|
||||
void clearNewGame();
|
||||
|
||||
ChatTools* getMyChatTools() const { return myChatTools; }
|
||||
|
||||
void fillChatLinesHistory(QString fillString);
|
||||
void showChatHistoryIndex(int index);
|
||||
int getChatLinesHistorySize();
|
||||
void nickAutoCompletition();
|
||||
void setChatTextEdited();
|
||||
void setPlayerNicksList(QStringList);
|
||||
|
||||
private:
|
||||
|
||||
mainWindowImpl *myW;
|
||||
ConfigFile *myConfig;
|
||||
|
||||
ChatTools *myChatTools;
|
||||
|
||||
|
||||
friend class GuiWrapper;
|
||||
|
||||
@@ -541,6 +541,7 @@ mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent)
|
||||
// QShortcut *quitPokerTHKeys = new QShortcut(QKeySequence(Qt::Key_Control + Qt::Key_Q), this);
|
||||
// connect( quitPokerTHKeys, SIGNAL(activated() ), actionQuit, SLOT( trigger() ) );
|
||||
|
||||
lineEdit_ChatInput->installEventFilter(this);
|
||||
|
||||
//Connects
|
||||
connect(dealFlopCards0Timer, SIGNAL(timeout()), this, SLOT( dealFlopCards1() ));
|
||||
@@ -1344,6 +1345,19 @@ void mainWindowImpl::refreshPlayerName() {
|
||||
|
||||
}
|
||||
|
||||
QStringList mainWindowImpl::getPlayerNicksList() {
|
||||
|
||||
QStringList list;
|
||||
HandInterface *currentHand = mySession->getCurrentGame()->getCurrentHand();
|
||||
PlayerListConstIterator it_c;
|
||||
|
||||
for (it_c=currentHand->getSeatsList()->begin(); it_c!=currentHand->getSeatsList()->end(); it_c++) {
|
||||
list << QString::fromUtf8((*it_c)->getMyName().c_str());
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
void mainWindowImpl::refreshPlayerAvatar() {
|
||||
|
||||
QPixmap onePix(myAppDataPath +"gfx/gui/misc/1px.png");
|
||||
@@ -3575,6 +3589,9 @@ void mainWindowImpl::networkNotification(int notificationId)
|
||||
void mainWindowImpl::networkStart(boost::shared_ptr<Game> game)
|
||||
{
|
||||
mySession->startClientGame(game);
|
||||
|
||||
//send playerNicksList to chat for nick-autocompletition
|
||||
myChat->setPlayerNicksList(getPlayerNicksList());
|
||||
}
|
||||
|
||||
void mainWindowImpl::keyPressEvent ( QKeyEvent * event ) {
|
||||
@@ -3611,24 +3628,41 @@ void mainWindowImpl::keyPressEvent ( QKeyEvent * event ) {
|
||||
playingMode = 2;
|
||||
statusBar()->showMessage(tr("Auto mode set: Check or fold."), 5000);
|
||||
}
|
||||
// if (event->key() == Qt::Key_S) { setLabelArray[0]->startTimeOutAnimation(myConfig->readConfigInt("NetTimeOutPlayerAction"),TRUE); } //s
|
||||
if (event->key() == 16777249) {
|
||||
if (event->key() == 16777249) { //CTRL
|
||||
pushButton_break->click();
|
||||
ctrlPressed = TRUE;
|
||||
// QTimer::SingleShot
|
||||
} //CTRL
|
||||
// if (event->key() == 65) { pixmapLabel_card0a->setUpdatesEnabled(FALSE); }
|
||||
// if (event->key() == 66) { label_logo->hide(); }
|
||||
|
||||
}
|
||||
if (event->key() == Qt::Key_Escape && (myActionIsBet || myActionIsRaise)) {
|
||||
meInAction();
|
||||
}
|
||||
if (event->key() == Qt::Key_Up && lineEdit_ChatInput->hasFocus()) {
|
||||
if((keyUpDownChatCounter + 1) <= myChat->getChatLinesHistorySize()) { keyUpDownChatCounter++; }
|
||||
// std::cout << "Up keyUpDownChatCounter: " << keyUpDownChatCounter << "\n";
|
||||
myChat->showChatHistoryIndex(keyUpDownChatCounter);
|
||||
}
|
||||
else if(event->key() == Qt::Key_Down && lineEdit_ChatInput->hasFocus()) {
|
||||
if((keyUpDownChatCounter - 1) >= 0) { keyUpDownChatCounter--; }
|
||||
// std::cout << "Down keyUpDownChatCounter: " << keyUpDownChatCounter << "\n";
|
||||
myChat->showChatHistoryIndex(keyUpDownChatCounter);
|
||||
}
|
||||
else { keyUpDownChatCounter = 0; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
// bool mainWindowImpl::event ( QEvent * event ) {
|
||||
bool mainWindowImpl::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
|
||||
|
||||
// if(event->type() == QEvent::MouseMove) { event->setAccepted ( FALSE ); }
|
||||
// }
|
||||
if (obj == lineEdit_ChatInput && lineEdit_ChatInput->text() != "" && event->type() == QEvent::KeyPress && keyEvent->key() == Qt::Key_Tab)
|
||||
{
|
||||
myChat->nickAutoCompletition();
|
||||
return true;
|
||||
} else {
|
||||
// pass the event on to the parent class
|
||||
return QMainWindow::eventFilter(obj, event);
|
||||
}
|
||||
}
|
||||
|
||||
void mainWindowImpl::switchChatWindow() {
|
||||
|
||||
|
||||
@@ -167,6 +167,7 @@ public slots:
|
||||
void refreshGroupbox(int =-1, int =-1);
|
||||
void refreshAll();
|
||||
void refreshPlayerName();
|
||||
QStringList getPlayerNicksList();
|
||||
void refreshGameLabels(int);
|
||||
void refreshButton();
|
||||
void refreshPlayerAvatar();
|
||||
@@ -278,7 +279,7 @@ public slots:
|
||||
void breakButtonClicked();
|
||||
|
||||
void keyPressEvent ( QKeyEvent*);
|
||||
// bool event ( QEvent * );
|
||||
bool eventFilter(QObject *obj, QEvent *event);
|
||||
|
||||
void switchChatWindow();
|
||||
void switchHelpWindow();
|
||||
@@ -446,6 +447,9 @@ private:
|
||||
|
||||
QSemaphore guiUpdateSemaphore;
|
||||
|
||||
int keyUpDownChatCounter;
|
||||
|
||||
|
||||
friend class GuiWrapper;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user