removed some old code
This commit is contained in:
parent
64aa68cd26
commit
ace4c37726
4 changed files with 0 additions and 312 deletions
|
@ -39,7 +39,6 @@ HEADERS += src/counter.h \
|
|||
src/abstractgraphicsitem.h \
|
||||
src/dlg_settings.h \
|
||||
src/phasestoolbar.h \
|
||||
src/chatwidget.h \
|
||||
src/gamescene.h \
|
||||
src/arrowitem.h \
|
||||
src/tab_server.h \
|
||||
|
@ -83,7 +82,6 @@ SOURCES += src/counter.cpp \
|
|||
src/abstractgraphicsitem.cpp \
|
||||
src/dlg_settings.cpp \
|
||||
src/phasestoolbar.cpp \
|
||||
src/chatwidget.cpp \
|
||||
src/gamescene.cpp \
|
||||
src/arrowitem.cpp \
|
||||
src/tab_server.cpp \
|
||||
|
|
|
@ -1,250 +0,0 @@
|
|||
#include <QtGui>
|
||||
#include <QApplication>
|
||||
#include "chatwidget.h"
|
||||
#include "client.h"
|
||||
|
||||
ChannelWidget::ChannelWidget(Client *_client, const QString &_name, bool readOnly, bool _virtualChannel, QWidget *parent)
|
||||
: QWidget(parent), client(_client), name(_name), virtualChannel(_virtualChannel)
|
||||
{
|
||||
playerList = new QListWidget;
|
||||
playerList->setFixedWidth(100);
|
||||
|
||||
textEdit = new QTextEdit;
|
||||
textEdit->setReadOnly(true);
|
||||
if (!readOnly) {
|
||||
sayEdit = new QLineEdit;
|
||||
connect(sayEdit, SIGNAL(returnPressed()), this, SLOT(sendMessage()));
|
||||
}
|
||||
|
||||
QVBoxLayout *vbox = new QVBoxLayout;
|
||||
vbox->addWidget(textEdit);
|
||||
if (!readOnly)
|
||||
vbox->addWidget(sayEdit);
|
||||
|
||||
QHBoxLayout *hbox = new QHBoxLayout;
|
||||
hbox->addLayout(vbox);
|
||||
hbox->addWidget(playerList);
|
||||
|
||||
setLayout(hbox);
|
||||
}
|
||||
|
||||
ChannelWidget::~ChannelWidget()
|
||||
{
|
||||
if (!virtualChannel)
|
||||
client->chatLeaveChannel(name);
|
||||
}
|
||||
|
||||
void ChannelWidget::sendMessage()
|
||||
{
|
||||
if (sayEdit->text().isEmpty())
|
||||
return;
|
||||
client->chatSay(name, sayEdit->text());
|
||||
sayEdit->clear();
|
||||
}
|
||||
|
||||
void ChannelWidget::joinEvent(const QString &playerName)
|
||||
{
|
||||
textEdit->append(tr("%1 has joined the channel.").arg(playerName));
|
||||
playerList->addItem(playerName);
|
||||
}
|
||||
|
||||
void ChannelWidget::listPlayersEvent(const QString &playerName)
|
||||
{
|
||||
playerList->addItem(playerName);
|
||||
}
|
||||
|
||||
void ChannelWidget::leaveEvent(const QString &playerName)
|
||||
{
|
||||
textEdit->append(tr("%1 has left the channel.").arg(playerName));
|
||||
for (int i = 0; i < playerList->count(); ++i)
|
||||
if (playerList->item(i)->text() == playerName) {
|
||||
delete playerList->takeItem(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ChannelWidget::sayEvent(const QString &playerName, const QString &s)
|
||||
{
|
||||
textEdit->append(QString("<font color=\"red\">%1:</font> %2").arg(playerName).arg(s));
|
||||
QApplication::alert(this);
|
||||
}
|
||||
|
||||
void ChannelWidget::serverMessageEvent(const QString &s)
|
||||
{
|
||||
textEdit->append(QString("<font color=\"blue\">%1</font>").arg(s));
|
||||
}
|
||||
|
||||
ChatWidget::ChatWidget(Client *_client, QWidget *parent)
|
||||
: QWidget(parent), client(_client)
|
||||
{
|
||||
channelList = new QTreeWidget;
|
||||
channelList->setRootIsDecorated(false);
|
||||
channelList->setFixedWidth(200);
|
||||
|
||||
joinButton = new QPushButton;
|
||||
connect(joinButton, SIGNAL(clicked()), this, SLOT(joinClicked()));
|
||||
QHBoxLayout *buttonLayout = new QHBoxLayout;
|
||||
buttonLayout->addStretch();
|
||||
buttonLayout->addWidget(joinButton);
|
||||
QVBoxLayout *leftLayout = new QVBoxLayout;
|
||||
leftLayout->addWidget(channelList);
|
||||
leftLayout->addLayout(buttonLayout);
|
||||
|
||||
tab = new QTabWidget;
|
||||
|
||||
QHBoxLayout *hbox = new QHBoxLayout;
|
||||
hbox->addLayout(leftLayout);
|
||||
hbox->addWidget(tab, 1);
|
||||
|
||||
retranslateUi();
|
||||
setLayout(hbox);
|
||||
}
|
||||
|
||||
void ChatWidget::retranslateUi()
|
||||
{
|
||||
joinButton->setText(tr("Joi&n"));
|
||||
|
||||
QTreeWidgetItem *header = channelList->headerItem();
|
||||
header->setText(0, tr("Channel"));
|
||||
header->setText(1, tr("Players"));
|
||||
header->setTextAlignment(1, Qt::AlignRight);
|
||||
}
|
||||
|
||||
void ChatWidget::enableChat()
|
||||
{
|
||||
connect(client, SIGNAL(chatEvent(const ChatEventData &)), this, SLOT(chatEvent(const ChatEventData &)));
|
||||
client->chatListChannels();
|
||||
show();
|
||||
}
|
||||
|
||||
void ChatWidget::disableChat()
|
||||
{
|
||||
disconnect(client, 0, this, 0);
|
||||
while (tab->count()) {
|
||||
ChannelWidget *cw = qobject_cast<ChannelWidget *>(tab->widget(0));
|
||||
tab->removeTab(0);
|
||||
delete cw;
|
||||
}
|
||||
channelList->clear();
|
||||
hide();
|
||||
}
|
||||
/*
|
||||
void ChatWidget::chatEvent(const ChatEventData &data)
|
||||
{
|
||||
const QStringList &msg = data.getEventData();
|
||||
switch (data.getEventType()) {
|
||||
case eventChatListChannels: {
|
||||
if (msg.size() != 4)
|
||||
break;
|
||||
for (int i = 0; i < channelList->topLevelItemCount(); ++i) {
|
||||
QTreeWidgetItem *twi = channelList->topLevelItem(i);
|
||||
if (twi->text(0) == msg[0]) {
|
||||
twi->setToolTip(0, msg[1]);
|
||||
twi->setText(1, msg[2]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
QTreeWidgetItem *twi = new QTreeWidgetItem(QStringList() << msg[0] << msg[2]);
|
||||
twi->setTextAlignment(1, Qt::AlignRight);
|
||||
twi->setToolTip(0, msg[1]);
|
||||
channelList->addTopLevelItem(twi);
|
||||
channelList->resizeColumnToContents(0);
|
||||
channelList->resizeColumnToContents(1);
|
||||
if (msg[3] == "1")
|
||||
joinChannel(msg[0]);
|
||||
break;
|
||||
}
|
||||
case eventChatJoinChannel: {
|
||||
if (msg.size() != 2)
|
||||
break;
|
||||
ChannelWidget *w = getChannel(msg[0]);
|
||||
if (!w)
|
||||
break;
|
||||
w->joinEvent(msg[1]);
|
||||
break;
|
||||
}
|
||||
case eventChatListPlayers: {
|
||||
if (msg.size() != 2)
|
||||
break;
|
||||
ChannelWidget *w = getChannel(msg[0]);
|
||||
if (!w)
|
||||
break;
|
||||
w->listPlayersEvent(msg[1]);
|
||||
break;
|
||||
}
|
||||
case eventChatLeaveChannel: {
|
||||
if (msg.size() != 2)
|
||||
break;
|
||||
ChannelWidget *w = getChannel(msg[0]);
|
||||
if (!w)
|
||||
break;
|
||||
w->leaveEvent(msg[1]);
|
||||
break;
|
||||
}
|
||||
case eventChatSay: {
|
||||
if (msg.size() != 3)
|
||||
break;
|
||||
ChannelWidget *w = getChannel(msg[0]);
|
||||
if (!w)
|
||||
break;
|
||||
w->sayEvent(msg[1], msg[2]);
|
||||
break;
|
||||
}
|
||||
case eventChatServerMessage: {
|
||||
if (msg.size() != 2)
|
||||
break;
|
||||
ChannelWidget *w;
|
||||
if (msg[0].isEmpty()) {
|
||||
w = getChannel("Server");
|
||||
if (!w) {
|
||||
w = new ChannelWidget(client, "Server", true, true);
|
||||
tab->addTab(w, "Server");
|
||||
}
|
||||
} else
|
||||
w = getChannel(msg[0]);
|
||||
w->serverMessageEvent(msg[1]);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
void ChatWidget::joinChannel(const QString &channelName)
|
||||
{
|
||||
// PendingCommand_ChatJoinChannel *pc = client->chatJoinChannel(channelName);
|
||||
// connect(pc, SIGNAL(finished(ServerResponse)), this, SLOT(joinFinished(ServerResponse)));
|
||||
}
|
||||
|
||||
void ChatWidget::joinClicked()
|
||||
{
|
||||
QTreeWidgetItem *twi = channelList->currentItem();
|
||||
if (!twi)
|
||||
return;
|
||||
QString channelName = twi->text(0);
|
||||
if (getChannel(channelName))
|
||||
return;
|
||||
|
||||
joinChannel(channelName);
|
||||
}
|
||||
|
||||
void ChatWidget::joinFinished(ResponseCode resp)
|
||||
{
|
||||
if (resp != RespOk)
|
||||
return;
|
||||
|
||||
// PendingCommand_ChatJoinChannel *pc = qobject_cast<PendingCommand_ChatJoinChannel *>(sender());
|
||||
// QString channelName = pc->getChannelName();
|
||||
// ChannelWidget *cw = new ChannelWidget(client, channelName);
|
||||
// tab->addTab(cw, channelName);
|
||||
}
|
||||
|
||||
ChannelWidget *ChatWidget::getChannel(const QString &name)
|
||||
{
|
||||
for (int i = 0; i < tab->count(); ++i) {
|
||||
ChannelWidget *cw = qobject_cast<ChannelWidget *>(tab->widget(i));
|
||||
if (cw->getName() == name)
|
||||
return cw;
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
#ifndef CHATWIDGET_H
|
||||
#define CHATWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "protocol_datastructures.h"
|
||||
|
||||
class QListWidget;
|
||||
class QTextEdit;
|
||||
class QLineEdit;
|
||||
class QTreeWidget;
|
||||
class QTabWidget;
|
||||
class QPushButton;
|
||||
class Client;
|
||||
|
||||
class ChannelWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
private:
|
||||
QListWidget *playerList;
|
||||
QTextEdit *textEdit;
|
||||
QLineEdit *sayEdit;
|
||||
Client *client;
|
||||
QString name;
|
||||
bool virtualChannel;
|
||||
private slots:
|
||||
void sendMessage();
|
||||
public:
|
||||
ChannelWidget(Client *_client, const QString &_name, bool readOnly = false, bool _virtualChannel = false, QWidget *parent = 0);
|
||||
~ChannelWidget();
|
||||
const QString &getName() const { return name; }
|
||||
|
||||
void joinEvent(const QString &playerName);
|
||||
void listPlayersEvent(const QString &playerName);
|
||||
void leaveEvent(const QString &playerName);
|
||||
void sayEvent(const QString &playerName, const QString &s);
|
||||
void serverMessageEvent(const QString &s);
|
||||
};
|
||||
|
||||
class ChatWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
private:
|
||||
QTreeWidget *channelList;
|
||||
QPushButton *joinButton;
|
||||
QTabWidget *tab;
|
||||
Client *client;
|
||||
|
||||
ChannelWidget *getChannel(const QString &name);
|
||||
void joinChannel(const QString &channelName);
|
||||
private slots:
|
||||
// void chatEvent(const ChatEventData &data);
|
||||
void joinClicked();
|
||||
void joinFinished(ResponseCode resp);
|
||||
public:
|
||||
ChatWidget(Client *_client, QWidget *parent = 0);
|
||||
void retranslateUi();
|
||||
void enableChat();
|
||||
void disableChat();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -35,7 +35,6 @@
|
|||
#include "zoneviewzone.h"
|
||||
#include "zoneviewwidget.h"
|
||||
#include "zoneviewlayout.h"
|
||||
#include "chatwidget.h"
|
||||
#include "tab_supervisor.h"
|
||||
|
||||
PingWidget::PingWidget(QWidget *parent)
|
||||
|
|
Loading…
Reference in a new issue