remove node when one leaves
diff --git a/.gitignore b/.gitignore
index a8568fd..fd68882 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,4 @@
moc_*
*.pb.*
qrc*
+gdb-target
diff --git a/chatdialog.cpp b/chatdialog.cpp
index 322c947..58bdd90 100644
--- a/chatdialog.cpp
+++ b/chatdialog.cpp
@@ -85,6 +85,7 @@
{
if (m_sock != NULL)
{
+ m_sock->remove(m_user.getPrefix().toStdString());
delete m_sock;
m_sock = NULL;
}
@@ -261,6 +262,14 @@
void
ChatDialog::processRemove(std::string prefix)
{
+#ifdef __DEBUG
+ std::cout << "<<< remove node for prefix" << prefix << std::endl;
+#endif
+ bool removed = m_scene->removeNode(QString(prefix.c_str()));
+ if (removed)
+ {
+ m_scene->plot(m_sock->getRootDigest().c_str());
+ }
}
void
diff --git a/digesttreescene.cpp b/digesttreescene.cpp
index 30c087e..50d170b 100644
--- a/digesttreescene.cpp
+++ b/digesttreescene.cpp
@@ -113,6 +113,13 @@
m_roster.clear();
}
+bool
+DigestTreeScene::removeNode(const QString prefix)
+{
+ int removedCount = m_roster.remove(prefix);
+ return (removedCount > 0);
+}
+
void
DigestTreeScene::plot(QString digest)
{
diff --git a/digesttreescene.h b/digesttreescene.h
index f041b11..6a30e18 100644
--- a/digesttreescene.h
+++ b/digesttreescene.h
@@ -32,6 +32,7 @@
void msgReceived(QString prefix, QString nick);
void clearAll();
void plot(QString digest);
+ bool removeNode(const QString prefix);
private:
void plotEdge(const std::vector<TreeLayout::Coordinate> &v, int nodeSize);
void plotNode(const std::vector<TreeLayout::Coordinate> &v, QString digest, int nodeSize);
diff --git a/sync-demo.pro b/sync-demo.pro
index a12f970..f65fbdd 100644
--- a/sync-demo.pro
+++ b/sync-demo.pro
@@ -20,6 +20,7 @@
QMAKE_CXXFLAGS *= -g
QMAKE_CFLAGS *= -g
+LIBS += -lboost_system-mt
CONFIG += console