a bit of gui. Not working yet.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4760 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2012-01-07 21:01:43 +00:00
parent 485c394e2b
commit 30411659e0
4 changed files with 96 additions and 1 deletions

View File

@ -412,6 +412,7 @@ FORMS += gui/StartDialog.ui \
gui/chat/PopupChatWindow.ui \ gui/chat/PopupChatWindow.ui \
gui/chat/PopupChatDialog.ui \ gui/chat/PopupChatDialog.ui \
gui/chat/CreateLobbyDialog.ui \ gui/chat/CreateLobbyDialog.ui \
gui/ChatLobbyWidget.ui \
gui/connect/ConfCertDialog.ui \ gui/connect/ConfCertDialog.ui \
gui/msgs/MessageComposer.ui \ gui/msgs/MessageComposer.ui \
gui/msgs/MessageWindow.ui\ gui/msgs/MessageWindow.ui\

View File

@ -1,9 +1,32 @@
#include <QTableWidget>
#include <retroshare/rsmsgs.h> #include <retroshare/rsmsgs.h>
#include "ChatLobbyWidget.h" #include "ChatLobbyWidget.h"
#define COL_LOBBY_NAME 0
#define COL_LOBBY_ID 1
#define COL_LOBBY_TYPE 2
#define COL_LOBBY_STATE 3
#define COL_LOBBY_COUNT 4
ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WFlags flags) ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WFlags flags)
: RsAutoUpdatePage(5000,parent) : RsAutoUpdatePage(5000,parent)
{ {
setupUi(this) ;
_lobby_table_TW->setColumnCount(5) ;
QStringList list ;
list.push_back(tr("Lobby name")) ;
list.push_back(tr("Lobby ID")) ;
list.push_back(tr("Lobby type")) ;
list.push_back(tr("Subscribed")) ;
list.push_back(tr("Count")) ;
_lobby_table_TW->setHorizontalHeaderLabels(list) ;
QObject::connect(this,SIGNAL(cellDoubleClicked(int,int)),this,SLOT(doubleClickCell(int,int))) ;
updateDisplay() ;
} }
ChatLobbyWidget::~ChatLobbyWidget() ChatLobbyWidget::~ChatLobbyWidget()
{ {
@ -11,11 +34,43 @@ ChatLobbyWidget::~ChatLobbyWidget()
void ChatLobbyWidget::updateDisplay() void ChatLobbyWidget::updateDisplay()
{ {
std::cerr << "updating chat lobby display!" << std::endl;
std::vector<PublicChatLobbyRecord> public_lobbies ; std::vector<PublicChatLobbyRecord> public_lobbies ;
rsMsgs->getListOfNearbyChatLobbies(public_lobbies) ; rsMsgs->getListOfNearbyChatLobbies(public_lobbies) ;
std::list<ChatLobbyInfo> linfos ;
rsMsgs->getChatLobbyList(linfos) ;
// now, do a nice display of public lobbies. // now, do a nice display of public lobbies.
_lobby_table_TW->clear() ;
int n=0 ;
for(uint32_t i=0;i<public_lobbies.size();++i,++n)
{
_lobby_table_TW->setItem(n,COL_LOBBY_NAME,new QTableWidgetItem(QString::fromUtf8(public_lobbies[i].lobby_name.c_str()))) ;
_lobby_table_TW->setItem(n,COL_LOBBY_ID ,new QTableWidgetItem(QString::number(public_lobbies[i].lobby_id,16))) ;
_lobby_table_TW->setItem(n,COL_LOBBY_TYPE,new QTableWidgetItem(tr("Public"))) ;
_lobby_table_TW->setItem(n,COL_LOBBY_COUNT,new QTableWidgetItem(QString::number(public_lobbies[i].total_number_of_peers))) ;
std::string vpid ;
if(rsMsgs->getVirtualPeerId(public_lobbies[i].lobby_id,vpid))
_lobby_table_TW->setItem(n,COL_LOBBY_STATE,new QTableWidgetItem(tr("subscribed"))) ;
else
_lobby_table_TW->setItem(n,COL_LOBBY_STATE,new QTableWidgetItem("")) ;
}
for(std::list<ChatLobbyInfo>::const_iterator it(linfos.begin());it!=linfos.end();++it,++n)
if((*it).lobby_privacy_level == RS_CHAT_LOBBY_PRIVACY_LEVEL_PRIVATE)
{
_lobby_table_TW->setItem(n,COL_LOBBY_NAME,new QTableWidgetItem(QString::fromUtf8((*it).lobby_name.c_str()))) ;
_lobby_table_TW->setItem(n,COL_LOBBY_ID ,new QTableWidgetItem(QString::number((*it).lobby_id,16))) ;
_lobby_table_TW->setItem(n,COL_LOBBY_TYPE,new QTableWidgetItem(tr("Private"))) ;
_lobby_table_TW->setItem(n,COL_LOBBY_COUNT,new QTableWidgetItem(QString::number((*it).nick_names.size()))) ;
_lobby_table_TW->setItem(n,COL_LOBBY_STATE,new QTableWidgetItem(tr("subscribed"))) ;
}
// Each lobby can be joined directly, by calling // Each lobby can be joined directly, by calling
// rsMsgs->joinPublicLobby(chatLobbyId) ; // rsMsgs->joinPublicLobby(chatLobbyId) ;

View File

@ -1,8 +1,9 @@
#pragma once #pragma once
#include "ui_ChatLobbyWidget.h"
#include "RsAutoUpdatePage.h" #include "RsAutoUpdatePage.h"
class ChatLobbyWidget : public RsAutoUpdatePage class ChatLobbyWidget : public RsAutoUpdatePage, public Ui::ChatLobbyWidget
{ {
Q_OBJECT Q_OBJECT

View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ChatLobbyWidget</class>
<widget class="QWidget" name="ChatLobbyWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>608</width>
<height>397</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QTableWidget" name="_lobby_table_TW">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QTabWidget" name="_lobby_tab_TW">
<property name="currentIndex">
<number>-1</number>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>