some hack to make the init smooth
diff --git a/chatdialog.cpp b/chatdialog.cpp
index 6fdc657..f677b43 100644
--- a/chatdialog.cpp
+++ b/chatdialog.cpp
@@ -27,13 +27,13 @@
qRegisterMetaType<size_t>("size_t");
setupUi(this);
m_session = time(NULL);
+ m_scene = new DigestTreeScene(this);
readSettings();
updateLabels();
lineEdit->setFocusPolicy(Qt::StrongFocus);
- m_scene = new DigestTreeScene(this);
treeViewer->setScene(m_scene);
m_scene->plot("Empty");
@@ -627,6 +627,7 @@
m_user.setChatroom(chatroom);
m_user.setOriginPrefix(originPrefix);
m_user.setPrefix(originPrefix + "/" + chatroom + "/" + getRandomString());
+ m_scene->setCurrentPrefix(originPrefix + "/" + chatroom + "/" + getRandomString());
return true;
}
@@ -810,12 +811,14 @@
if (!originPrefix.isEmpty() && originPrefix != m_user.getOriginPrefix()) {
m_user.setOriginPrefix(originPrefix);
m_user.setPrefix(originPrefix + "/" + m_user.getChatroom() + "/" + randString);
+ m_scene->setCurrentPrefix(originPrefix + "/" + m_user.getChatroom() + "/" + randString);
needWrite = true;
needFresh = true;
}
if (!chatroom.isEmpty() && chatroom != m_user.getChatroom()) {
m_user.setChatroom(chatroom);
m_user.setPrefix(m_user.getOriginPrefix() + "/" + chatroom + "/" + randString);
+ m_scene->setCurrentPrefix(m_user.getOriginPrefix() + "/" + chatroom + "/" + randString);
needWrite = true;
needFresh = true;
}
diff --git a/digesttreescene.cpp b/digesttreescene.cpp
index 64f6949..b876a17 100644
--- a/digesttreescene.cpp
+++ b/digesttreescene.cpp
@@ -94,9 +94,11 @@
Roster_iterator it = m_roster.find(prefix);
if (it != m_roster.end())
{
+ std::cout << "Updating for prefix = " << prefix.toStdString() << " nick = " << nick.toStdString() << std::endl;
DisplayUserPtr p = it.value();
p->setReceived(time(NULL));
if (nick != p->getNick()) {
+ std::cout << "old nick = " << p->getNick().toStdString() << std::endl;
p->setNick(nick);
QGraphicsTextItem *nickItem = p->getNickTextItem();
QGraphicsRectItem *nickRectItem = p->getNickRectItem();
@@ -150,6 +152,9 @@
// do some cleaning, get rid of stale member info
Roster_iterator it = m_roster.begin();
QStringList staleUserList;
+#ifdef __DEBUG
+ std::cout << "------------------------------------------------------" << std::endl;
+#endif
while (it != m_roster.end())
{
DisplayUserPtr p = it.value();
@@ -168,6 +173,20 @@
}
else
{
+#ifdef __DEBUG
+ std::cout << "having user: " << p->getNick().toStdString() << std::endl;
+ std::cout << "prefix: " << p->getPrefix().toStdString() << std::endl;
+#endif
+ if (!m_currentPrefix.startsWith("/private/local") && p->getPrefix().startsWith("/private/local"))
+ {
+#ifdef __DEBUG
+ std::cout << "erasing: " << p->getPrefix().toStdString() << std::endl;
+#endif
+ staleUserList << p->getNick();
+ p = DisplayUserNullPtr;
+ it = m_roster.erase(it);
+ continue;
+ }
++it;
}
}
@@ -175,12 +194,16 @@
{
it = m_roster.erase(it);
}
+#ifdef __DEBUG
+ std::cout << "------------------------------------------------------" << std::endl;
+#endif
}
// for simpicity here, whenever we replot, we also redo the roster list
emit rosterChanged(staleUserList);
int n = m_roster.size();
+
std::vector<TreeLayout::Coordinate> childNodesCo(n);
layout->setOneLevelLayout(childNodesCo);
diff --git a/digesttreescene.h b/digesttreescene.h
index 29d9177..9d9dee4 100644
--- a/digesttreescene.h
+++ b/digesttreescene.h
@@ -36,6 +36,7 @@
bool removeNode(const QString prefix);
void plot(QString digest);
QStringList getRosterList();
+ void setCurrentPrefix(QString prefix) {m_currentPrefix = prefix;}
signals:
void replot();
@@ -52,6 +53,7 @@
Roster m_roster;
QGraphicsTextItem *m_rootDigest;
DisplayUserPtr previouslyUpdatedUser;
+ QString m_currentPrefix;
};