tweak prefix and origin prefix
diff --git a/chatdialog.cpp b/chatdialog.cpp
index 031189e..291d2a0 100644
--- a/chatdialog.cpp
+++ b/chatdialog.cpp
@@ -382,7 +382,7 @@
QSettings s(ORGANIZATION, APPLICATION);
QString nick = s.value("nick", "").toString();
QString chatroom = s.value("chatroom", "").toString();
- QString prefix = s.value("prefix", "").toString();
+ QString originPrefix = s.value("originPrefix", "").toString();
if (nick == "" || chatroom == "" || prefix == "") {
QTimer::singleShot(500, this, SLOT(buttonPressed()));
return false;
@@ -390,7 +390,8 @@
else {
m_user.setNick(nick);
m_user.setChatroom(chatroom);
- m_user.setPrefix(prefix);
+ m_user.setOriginPrefix(originPrefix);
+ m_user.setPrefix(origin_prefix + "/" + chatroom + "/" + getRandomString());
return true;
}
#else
@@ -406,7 +407,7 @@
QSettings s(ORGANIZATION, APPLICATION);
s.setValue("nick", m_user.getNick());
s.setValue("chatroom", m_user.getChatroom());
- s.setValue("prefix", m_user.getPrefix());
+ s.setValue("originPrefix", m_user.getOriginPrefix());
#endif
}
@@ -416,8 +417,8 @@
QString settingDisp = QString("Chatroom: %1").arg(m_user.getChatroom());
infoLabel->setStyleSheet("QLabel {color: #630; font-size: 16px; font: bold \"Verdana\";}");
infoLabel->setText(settingDisp);
- //QString prefixDisp = QString("<Prefix: %1>").arg(m_user.getPrefix());
- //prefixLabel->setText(prefixDisp);
+ QString prefixDisp = QString("<Prefix: %1>").arg(m_user.getPrefix());
+ prefixLabel->setText(prefixDisp);
}
void
@@ -490,7 +491,7 @@
void
ChatDialog::buttonPressed()
{
- SettingDialog dialog(this, m_user.getNick(), m_user.getChatroom(), m_user.getPrefix());
+ SettingDialog dialog(this, m_user.getNick(), m_user.getChatroom(), m_user.getOriginPrefix());
connect(&dialog, SIGNAL(updated(QString, QString, QString)), this, SLOT(settingUpdated(QString, QString, QString)));
dialog.exec();
QTimer::singleShot(100, this, SLOT(checkSetting()));
@@ -499,28 +500,37 @@
void
ChatDialog::checkSetting()
{
- if (m_user.getPrefix().isEmpty() || m_user.getNick().isEmpty() || m_user.getChatroom().isEmpty())
+ if (m_user.getOriginPrefix().isEmpty() || m_user.getNick().isEmpty() || m_user.getChatroom().isEmpty())
{
buttonPressed();
}
}
void
-ChatDialog::settingUpdated(QString nick, QString chatroom, QString prefix)
+ChatDialog::settingUpdated(QString nick, QString chatroom, QString originPrefix)
{
+ QString randString = getRandomString();
bool needWrite = false;
+ bool needFresh = false;
if (!nick.isEmpty() && nick != m_user.getNick()) {
m_user.setNick(nick);
needWrite = true;
}
- if (!prefix.isEmpty() && prefix != m_user.getPrefix()) {
- m_user.setPrefix(prefix + "/" + getRandomString());
+ if (!originPrefix.isEmpty() && originPrefix != m_user.getOriginPrefix()) {
+ m_user.setOriginPrefix(originPrefix);
+ m_user.setPrefix(originPrefix + "/" + m_user.getChatroom() + "/" + randString);
needWrite = true;
- // TODO: set the previous prefix as left?
+ needFresh = true;
}
if (!chatroom.isEmpty() && chatroom != m_user.getChatroom()) {
m_user.setChatroom(chatroom);
+ m_user.setPrefix(m_user.getOriginPrefix() + "/" + chatroom + "/" + randString);
needWrite = true;
+ needFresh = true;
+ }
+
+ if (needFresh)
+ {
{
boost::recursive_mutex::scoped_lock lock(m_sceneMutex);
@@ -555,6 +565,7 @@
fitView();
}
+
if (needWrite) {
writeSettings();
updateLabels();
diff --git a/chatdialog.ui b/chatdialog.ui
index be648e1..e36ed32 100644
--- a/chatdialog.ui
+++ b/chatdialog.ui
@@ -41,7 +41,6 @@
</property>
</widget>
</item>
- <!--
<item>
<widget class="QLabel" name="prefixLabel">
<property name="focusPolicy">
@@ -49,7 +48,6 @@
</property>
</widget>
</item>
- -->
</layout>
</item>
<item>
diff --git a/digesttreescene.h b/digesttreescene.h
index 7d30bac..0e2e0f7 100644
--- a/digesttreescene.h
+++ b/digesttreescene.h
@@ -65,15 +65,18 @@
void setChatroom(QString chatroom) {m_chatroom = chatroom;}
void setSeq(Sync::SeqNo seq) {m_seq = seq;}
void setReceived(time_t t) {m_received = t;}
+ void setOriginPrefix(QString originPrefix) { m_originPrefix = originPrefix;}
QString getNick() { return m_nick;}
QString getPrefix() { return m_prefix;}
QString getChatroom() { return m_chatroom;}
+ QString getOriginPrefix() { return m_originPrefix;}
Sync::SeqNo getSeqNo() { return m_seq;}
time_t getReceived() { return m_received;}
private:
QString m_nick;
QString m_prefix;
QString m_chatroom;
+ QString m_originPrefix;
Sync::SeqNo m_seq;
time_t m_received;
};