roster done
diff --git a/chatdialog.cpp b/chatdialog.cpp
index 89e1710..636ba1a 100644
--- a/chatdialog.cpp
+++ b/chatdialog.cpp
@@ -38,6 +38,7 @@
QRectF rect = m_scene->itemsBoundingRect();
m_scene->setSceneRect(rect);
+ listView->setStyleSheet("QListView { alternate-background-color: white; background: #F0F0F0; color: darkGreen; font: bold large; }");
m_rosterModel = new QStringListModel(this);
listView->setModel(m_rosterModel);
@@ -89,14 +90,14 @@
void
ChatDialog::replot()
{
- boost::mutex::scoped_lock lock(m_sceneMutex);
+ boost::recursive_mutex::scoped_lock lock(m_sceneMutex);
m_scene->plot(m_sock->getRootDigest().c_str());
}
void
ChatDialog::updateRosterList()
{
- boost::mutex::scoped_lock lock(m_sceneMutex);
+ boost::recursive_mutex::scoped_lock lock(m_sceneMutex);
QStringList rosterList = m_scene->getRosterList();
m_rosterModel->setStringList(rosterList);
}
@@ -144,7 +145,7 @@
void
ChatDialog::appendMessage(const SyncDemo::ChatMessage msg)
{
- boost::mutex::scoped_lock lock(m_msgMutex);
+ boost::recursive_mutex::scoped_lock lock(m_msgMutex);
if (msg.type() != SyncDemo::ChatMessage::CHAT) {
return;
@@ -237,7 +238,7 @@
// reflect the changes on digest tree
{
- boost::mutex::scoped_lock lock(m_sceneMutex);
+ boost::recursive_mutex::scoped_lock lock(m_sceneMutex);
m_scene->processUpdate(v, m_sock->getRootDigest().c_str());
}
@@ -313,7 +314,7 @@
std::cout <<"<<< updating scene for" << prefix << ": " << msg.from() << std::endl;
#endif
{
- boost::mutex::scoped_lock lock(m_sceneMutex);
+ boost::recursive_mutex::scoped_lock lock(m_sceneMutex);
m_scene->msgReceived(prefix.c_str(), msg.from().c_str());
}
fitView();
@@ -334,7 +335,7 @@
bool removed = m_scene->removeNode(prefix);
if (removed)
{
- boost::mutex::scoped_lock lock(m_sceneMutex);
+ boost::recursive_mutex::scoped_lock lock(m_sceneMutex);
m_scene->plot(m_sock->getRootDigest().c_str());
}
}
@@ -460,7 +461,7 @@
std::vector<Sync::MissingDataInfo> v;
v.push_back(mdi);
{
- boost::mutex::scoped_lock lock(m_sceneMutex);
+ boost::recursive_mutex::scoped_lock lock(m_sceneMutex);
m_scene->processUpdate(v, m_sock->getRootDigest().c_str());
m_scene->msgReceived(m_user.getPrefix(), m_user.getNick());
}
@@ -520,7 +521,7 @@
needWrite = true;
{
- boost::mutex::scoped_lock lock(m_sceneMutex);
+ boost::recursive_mutex::scoped_lock lock(m_sceneMutex);
m_scene->clearAll();
m_scene->plot("Empty");
}
@@ -637,7 +638,7 @@
void
ChatDialog::fitView()
{
- boost::mutex::scoped_lock lock(m_sceneMutex);
+ boost::recursive_mutex::scoped_lock lock(m_sceneMutex);
QRectF rect = m_scene->itemsBoundingRect();
m_scene->setSceneRect(rect);
treeViewer->fitInView(m_scene->itemsBoundingRect(), Qt::KeepAspectRatio);
diff --git a/chatdialog.h b/chatdialog.h
index dc7b390..902316f 100644
--- a/chatdialog.h
+++ b/chatdialog.h
@@ -1,7 +1,7 @@
#ifndef CHATDIALOG_H
#define CHATDIALOG_H
#include <boost/function.hpp>
-#include <boost/thread/mutex.hpp>
+#include <boost/thread/recursive_mutex.hpp>
#include <vector>
#include "digesttreescene.h"
#include "ui_chatdialog.h"
@@ -80,8 +80,8 @@
Sync::SyncAppSocket *m_sock;
uint32_t m_session;
DigestTreeScene *m_scene;
- boost::mutex m_msgMutex;
- boost::mutex m_sceneMutex;
+ boost::recursive_mutex m_msgMutex;
+ boost::recursive_mutex m_sceneMutex;
time_t m_lastMsgTime;
int m_randomizedInterval;
QTimer *m_timer;
diff --git a/chatdialog.ui b/chatdialog.ui
index 517e105..e36ed32 100644
--- a/chatdialog.ui
+++ b/chatdialog.ui
@@ -5,7 +5,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>600</width>
+ <width>800</width>
<height>600</height>
</rect>
</property>
@@ -105,38 +105,41 @@
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
+ <property name="minimumWidth">
+ <number>600</number>
+ </property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
+ <!-- start of input line widget -->
+ <item>
+ <layout class="QHBoxLayout">
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Message:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="lineEdit" />
+ </item>
+ </layout>
+ </item>
+ <!-- end of input line widget -->
</layout>
</item>
</layout>
</item>
<!-- end of display area -->
- <!-- start of input line widget -->
- <item>
- <layout class="QHBoxLayout">
- <property name="margin">
- <number>0</number>
- </property>
- <property name="spacing">
- <number>6</number>
- </property>
- <item>
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Message:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="lineEdit" />
- </item>
- </layout>
- </item>
- <!-- end of input line widget -->
</layout>
</widget>
<resources/>
diff --git a/digesttreescene.cpp b/digesttreescene.cpp
index b79962e..5364f0f 100644
--- a/digesttreescene.cpp
+++ b/digesttreescene.cpp
@@ -71,9 +71,21 @@
emit replot();
}
-void
+QStringList
DigestTreeScene::getRosterList()
{
+ QStringList rosterList;
+ RosterIterator it(m_roster);
+ while(it.hasNext())
+ {
+ it.next();
+ DisplayUserPtr p = it.value();
+ if (p != DisplayUserNullPtr)
+ {
+ rosterList << "- " + p->getNick();
+ }
+ }
+ return rosterList;
}
void
@@ -95,6 +107,7 @@
QRectF rectBR = nickRectItem->boundingRect();
QRectF nickBR = nickItem->boundingRect();
nickItem->setPos(rectBR.x() + (rectBR.width() - nickBR.width())/2, rectBR.y() + 5);
+ emit rosterChanged();
}
reDrawNode(p, Qt::red);
diff --git a/sync-demo.pro b/sync-demo.pro
index c82c20b..8c5d1b8 100644
--- a/sync-demo.pro
+++ b/sync-demo.pro
@@ -20,7 +20,7 @@
QMAKE_CXXFLAGS *= -g
QMAKE_CFLAGS *= -g
-LIBS += -lboost_system-mt -lboost_random
+LIBS += -lboost_system-mt -lboost_random-mt
CONFIG += console