Start moving to players list model.
--- a/QTfrontend/hwform.cpp Wed Oct 03 12:04:29 2012 +0400
+++ b/QTfrontend/hwform.cpp Sat Oct 06 01:09:41 2012 +0400
@@ -93,6 +93,7 @@
#include "mouseoverfilter.h"
#include "roomslistmodel.h"
#include "recorder.h"
+#include "playerslistmodel.h"
#include "DataManager.h"
@@ -1091,6 +1092,9 @@
connect(hwnet, SIGNAL(AuthFailed()), this, SLOT(NetAuthFailed()), Qt::QueuedConnection);
//connect(ui.pageNetGame->BtnBack, SIGNAL(clicked()), hwnet, SLOT(partRoom()));
+ ui.pageRoomsList->chatWidget->setUsersModel(hwnet->lobbyPlayersModel());
+ ui.pageNetGame->pChatWidget->setUsersModel(hwnet->roomPlayersModel());
+
// rooms list page stuff
ui.pageRoomsList->setModel(hwnet->roomsListModel());
connect(hwnet, SIGNAL(adminAccess(bool)),
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/model/playerslistmodel.cpp Sat Oct 06 01:09:41 2012 +0400
@@ -0,0 +1,14 @@
+#include "playerslistmodel.h"
+
+PlayersListModel::PlayersListModel(QObject *parent) :
+ QStringListModel(parent)
+{
+
+}
+
+void PlayersListModel::addPlayer(const QString & nickname)
+{
+ insertRows(rowCount(), 1);
+
+ setData(index(rowCount() - 1), nickname);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/model/playerslistmodel.h Sat Oct 06 01:09:41 2012 +0400
@@ -0,0 +1,19 @@
+#ifndef PLAYERSLISTMODEL_H
+#define PLAYERSLISTMODEL_H
+
+#include <QStringListModel>
+
+class PlayersListModel : public QStringListModel
+{
+ Q_OBJECT
+public:
+ explicit PlayersListModel(QObject *parent = 0);
+
+signals:
+
+public slots:
+ void addPlayer(const QString & nickname);
+
+};
+
+#endif // PLAYERSLISTMODEL_H
--- a/QTfrontend/net/newnetclient.cpp Wed Oct 03 12:04:29 2012 +0400
+++ b/QTfrontend/net/newnetclient.cpp Sat Oct 06 01:09:41 2012 +0400
@@ -26,6 +26,7 @@
#include "proto.h"
#include "game.h"
#include "roomslistmodel.h"
+#include "playerslistmodel.h"
char delimeter='\n';
@@ -36,6 +37,8 @@
netClientState(Disconnected)
{
m_roomsListModel = new RoomsListModel(this);
+ m_lobbyPlayersModel = new PlayersListModel(this);
+ m_roomPlayersModel = new PlayersListModel(this);
// socket stuff
connect(&NetSocket, SIGNAL(readyRead()), this, SLOT(ClientRead()));
connect(&NetSocket, SIGNAL(connected()), this, SLOT(OnConnect()));
@@ -444,6 +447,7 @@
emit nickAddedLobby(lst[i], false);
emit chatStringLobby(lst[i], tr("%1 *** %2 has joined").arg('\x03').arg("|nick|"));
+ m_lobbyPlayersModel->addPlayer(lst[i]);
}
return;
}
@@ -920,3 +924,13 @@
{
return m_roomsListModel;
}
+
+PlayersListModel * HWNewNet::lobbyPlayersModel()
+{
+ return m_lobbyPlayersModel;
+}
+
+PlayersListModel * HWNewNet::roomPlayersModel()
+{
+ return m_roomPlayersModel;
+}
--- a/QTfrontend/net/newnetclient.h Wed Oct 03 12:04:29 2012 +0400
+++ b/QTfrontend/net/newnetclient.h Sat Oct 06 01:09:41 2012 +0400
@@ -32,6 +32,8 @@
class GameCFGWidget;
class TeamSelWidget;
class RoomsListModel;
+class PlayersListModel;
+class QSortFilterModel;
extern char delimeter;
@@ -55,6 +57,8 @@
QString getRoom();
QString getHost();
RoomsListModel * roomsListModel();
+ PlayersListModel * lobbyPlayersModel();
+ PlayersListModel * roomPlayersModel();
private:
bool isChief;
@@ -65,6 +69,8 @@
QString seed;
bool m_game_connected;
RoomsListModel * m_roomsListModel;
+ PlayersListModel * m_lobbyPlayersModel;
+ PlayersListModel * m_roomPlayersModel;
template <typename T>
void SendCfgStrNet(T a)
--- a/QTfrontend/ui/widget/chatwidget.cpp Wed Oct 03 12:04:29 2012 +0400
+++ b/QTfrontend/ui/widget/chatwidget.cpp Sat Oct 06 01:09:41 2012 +0400
@@ -34,6 +34,7 @@
#include <QDateTime>
#include <QTime>
#include <QPainter>
+#include <QListView>
#include <QMessageBox>
@@ -121,7 +122,7 @@
QPainter painter(&result);
if(data(Ready).toBool())
- painter.drawPixmap(8, 0, 16, 16, QPixmap(":/res/chat/lamp.png"));
+ painter.drawPixmap(0, 0, 16, 16, QPixmap(":/res/chat/lamp.png"));
QString mainIconName(":/res/chat/");
@@ -135,13 +136,13 @@
if(!data(Registered).toBool())
mainIconName += "_gray";
- painter.drawPixmap(0, 0, 16, 16, QPixmap(mainIconName + ".png"));
+ painter.drawPixmap(8, 0, 16, 16, QPixmap(mainIconName + ".png"));
if(data(Ignore).toBool())
- painter.drawPixmap(0, 0, 16, 16, QPixmap(":/res/chat/ignore.png"));
+ painter.drawPixmap(8, 0, 16, 16, QPixmap(":/res/chat/ignore.png"));
else
if(data(Friend).toBool())
- painter.drawPixmap(0, 0, 16, 16, QPixmap(":/res/chat/friend.png"));
+ painter.drawPixmap(8, 0, 16, 16, QPixmap(":/res/chat/friend.png"));
painter.end();
@@ -354,11 +355,11 @@
this, SLOT(linkClicked(const QUrl&)));
mainLayout.addWidget(chatText, 0, 0, 2, 1);
- chatNicks = new QListWidget(this);
+ chatNicks = new QListView(this);
chatNicks->setIconSize(QSize(24, 16));
chatNicks->setMinimumHeight(10);
chatNicks->setMinimumWidth(10);
- chatNicks->setSortingEnabled(true);
+ //chatNicks->setSortingEnabled(true);
chatNicks->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
chatNicks->setContextMenuPolicy(Qt::ActionsContextMenu);
connect(chatNicks, SIGNAL(itemDoubleClicked(QListWidgetItem *)),
@@ -414,7 +415,7 @@
{
// decode nick
QString nick = QString::fromUtf8(QByteArray::fromBase64(link.encodedQuery()));
- QList<QListWidgetItem *> items = chatNicks->findItems(nick, Qt::MatchExactly);
+ /*QList<QListWidgetItem *> items = chatNicks->findItems(nick, Qt::MatchExactly);
bool isOffline = (items.size() < 1);
@@ -447,7 +448,7 @@
}
// display menu popup at mouse cursor position
- popup->popup(QCursor::pos());
+ popup->popup(QCursor::pos());*/
}
}
@@ -531,10 +532,10 @@
void HWChatWidget::updateNickItems()
{
- for(int i = 0; i < chatNicks->count(); i++)
+ /*for(int i = 0; i < chatNicks->count(); i++)
updateNickItem(chatNicks->item(i));
- chatNicks->sortItems();
+ chatNicks->sortItems();*/
}
void HWChatWidget::loadLists(const QString & nick)
@@ -700,12 +701,12 @@
QListWidgetItem * item = new ListWidgetNickItem(nick, friendsList.contains(nick, Qt::CaseInsensitive), isIgnored);
updateNickItem(item);
- chatNicks->addItem(item);
+ /*chatNicks->addItem(item);*/
if ((!isIgnored) && (nick != m_userNick)) // don't auto-complete own name
chatEditLine->addNickname(nick);
- emit nickCountUpdate(chatNicks->count());
+ //emit nickCountUpdate(chatNicks->count());
if(notifyNick && notify && gameSettings->value("frontend/sound", true).toBool())
{
@@ -718,10 +719,10 @@
{
chatEditLine->removeNickname(nick);
- foreach(QListWidgetItem * item, chatNicks->findItems(nick, Qt::MatchExactly))
- chatNicks->takeItem(chatNicks->row(item));
+ /*foreach(QListWidgetItem * item, chatNicks->findItems(nick, Qt::MatchExactly))
+ chatNicks->takeItem(chatNicks->row(item));*/
- emit nickCountUpdate(chatNicks->count());
+ //emit nickCountUpdate(chatNicks->count());
}
void HWChatWidget::clear()
@@ -735,7 +736,7 @@
chatText->clear();
chatStrings.clear();
- chatNicks->clear();
+ //chatNicks->clear();
// clear and re compile regexp for highlighting
m_highlights.clear();
@@ -782,35 +783,35 @@
void HWChatWidget::onKick()
{
- QListWidgetItem * curritem = chatNicks->currentItem();
+ /*QListWidgetItem * curritem = chatNicks->currentItem();
if (curritem)
- emit kick(curritem->text());
+ emit kick(curritem->text());*/
}
void HWChatWidget::onBan()
{
- QListWidgetItem * curritem = chatNicks->currentItem();
+ /*QListWidgetItem * curritem = chatNicks->currentItem();
if (curritem)
- emit ban(curritem->text());
+ emit ban(curritem->text());*/
}
void HWChatWidget::onInfo()
{
- QListWidgetItem * curritem = chatNicks->currentItem();
+ /*QListWidgetItem * curritem = chatNicks->currentItem();
if (curritem)
- emit info(curritem->text());
+ emit info(curritem->text());*/
}
void HWChatWidget::onFollow()
{
- QListWidgetItem * curritem = chatNicks->currentItem();
+ /*QListWidgetItem * curritem = chatNicks->currentItem();
if (curritem)
- emit follow(curritem->text());
+ emit follow(curritem->text());*/
}
void HWChatWidget::onIgnore()
{
- QListWidgetItem * curritem = chatNicks->currentItem();
+ /*QListWidgetItem * curritem = chatNicks->currentItem();
QString nick = "";
if(curritem != NULL)
nick = curritem->text();
@@ -843,12 +844,12 @@
updateNickItem(curritem); // update icon/sort order/etc
chatNicks->sortItems();
chatNickSelected(0); // update context menu
- }
+ }*/
}
void HWChatWidget::onFriend()
{
- QListWidgetItem * curritem = chatNicks->currentItem();
+ /*QListWidgetItem * curritem = chatNicks->currentItem();
QString nick = "";
if(curritem != NULL)
nick = curritem->text();
@@ -879,7 +880,7 @@
updateNickItem(curritem); // update icon/sort order/etc
chatNicks->sortItems();
chatNickSelected(0); // update context menu
- }
+ }*/
}
void HWChatWidget::chatNickDoubleClicked(QListWidgetItem * item)
@@ -896,7 +897,7 @@
{
Q_UNUSED(index);
- QListWidgetItem* item = chatNicks->currentItem();
+ /*QListWidgetItem* item = chatNicks->currentItem();
QString nick = "";
if (item != NULL)
nick = item->text();
@@ -937,18 +938,18 @@
{
acKick->setVisible(!isSelf);
acBan->setVisible(!isSelf);
- }
+ }*/
}
void HWChatWidget::setStatus(const QString & nick, ListWidgetNickItem::StateFlag flag, bool status)
{
- QList<QListWidgetItem *> items = chatNicks->findItems(nick, Qt::MatchExactly);
+ /*QList<QListWidgetItem *> items = chatNicks->findItems(nick, Qt::MatchExactly);
if (items.size() == 1)
{
items[0]->setData(flag, status);
updateNickItem(items[0]);
- }
+ }*/
}
void HWChatWidget::setReadyStatus(const QString & nick, bool isReady)
@@ -1103,3 +1104,10 @@
nickRemoved(nickname);
clear();
}
+
+
+void HWChatWidget::setUsersModel(QAbstractListModel * model)
+{
+ chatNicks->setModel(model);
+ chatNicks->setModelColumn(0);
+}
--- a/QTfrontend/ui/widget/chatwidget.h Wed Oct 03 12:04:29 2012 +0400
+++ b/QTfrontend/ui/widget/chatwidget.h Sat Oct 06 01:09:41 2012 +0400
@@ -21,23 +21,23 @@
#define _CHAT_WIDGET_INCLUDED
#include <QWidget>
-#include <QListWidget>
#include <QString>
#include <QGridLayout>
#include <QList>
#include <QPair>
#include <QRegExp>
#include <QHash>
+#include <QListWidgetItem>
#include "SDLInteraction.h"
#include "SmartLineEdit.h"
-class ListWidgetNickItem;
class QTextBrowser;
class QLineEdit;
-class QListWidget;
+class QListView;
class QSettings;
+class QAbstractListModel;
/// Class for custom nickname sorting
class ListWidgetNickItem : public QListWidgetItem
@@ -87,6 +87,7 @@
void displayNotice(const QString & message);
void displayWarning(const QString & message);
void setUser(const QString & nickname);
+ void setUsersModel(QAbstractListModel * model);
protected:
virtual void dragEnterEvent(QDragEnterEvent * event);
@@ -137,7 +138,7 @@
QGridLayout mainLayout;
QTextBrowser* chatText;
QStringList chatStrings;
- QListWidget* chatNicks;
+ QListView* chatNicks;
SmartLineEdit* chatEditLine;
QAction * acInfo;
QAction * acKick;
--- a/project_files/hedgewars.pro Wed Oct 03 12:04:29 2012 +0400
+++ b/project_files/hedgewars.pro Sat Oct 06 01:09:41 2012 +0400
@@ -110,7 +110,8 @@
../QTfrontend/net/recorder.h \
../QTfrontend/ui/dialog/ask_quit.h \
../QTfrontend/ui/dialog/upload_video.h \
- ../QTfrontend/campaign.h
+ ../QTfrontend/campaign.h \
+ ../QTfrontend/model/playerslistmodel.h
SOURCES += ../QTfrontend/model/ammoSchemeModel.cpp \
../QTfrontend/model/MapModel.cpp \
@@ -198,7 +199,8 @@
../QTfrontend/net/recorder.cpp \
../QTfrontend/ui/dialog/ask_quit.cpp \
../QTfrontend/ui/dialog/upload_video.cpp \
- ../QTfrontend/campaign.cpp
+ ../QTfrontend/campaign.cpp \
+ ../QTfrontend/model/playerslistmodel.cpp
win32 {