plotting
diff --git a/demo/chatdialog.cpp b/demo/chatdialog.cpp
index 34f5682..b7edf20 100644
--- a/demo/chatdialog.cpp
+++ b/demo/chatdialog.cpp
@@ -17,7 +17,7 @@
DigestTreeScene *scene = new DigestTreeScene();
treeViewer->setScene(scene);
- scene->plot();
+ //scene->plot();
connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(returnPressed()));
connect(setButton, SIGNAL(pressed()), this, SLOT(buttonPressed()));
@@ -53,8 +53,8 @@
void
ChatDialog::formChatMessage(const QString &text, SyncDemo::ChatMessage &msg) {
- msg.set_from(m_nick.toStdString());
- msg.set_to(m_chatroom.toStdString());
+ msg.set_from(m_user.getNick().toStdString());
+ msg.set_to(m_user.getChatroom().toStdString());
msg.set_data(text.toStdString());
time_t seconds = time(NULL);
msg.set_timestamp(seconds);
@@ -64,29 +64,34 @@
ChatDialog::readSettings()
{
QSettings s(ORGANIZATION, APPLICATION);
- m_nick = s.value("nick", "").toString();
- m_chatroom = s.value("chatroom", "").toString();
- m_prefix = s.value("prefix", "").toString();
- if (m_nick == "" || m_chatroom == "" || m_prefix == "") {
+ QString nick = s.value("nick", "").toString();
+ QString chatroom = s.value("chatroom", "").toString();
+ QString prefix = s.value("prefix", "").toString();
+ if (nick == "" || chatroom == "" || prefix == "") {
QTimer::singleShot(500, this, SLOT(buttonPressed()));
}
+ else {
+ m_user.setNick(nick);
+ m_user.setChatroom(chatroom);
+ m_user.setPrefix(prefix);
+ }
}
void
ChatDialog::writeSettings()
{
QSettings s(ORGANIZATION, APPLICATION);
- s.setValue("nick", m_nick);
- s.setValue("chatroom", m_chatroom);
- s.setValue("prefix", m_prefix);
+ s.setValue("nick", m_user.getNick());
+ s.setValue("chatroom", m_user.getChatroom());
+ s.setValue("prefix", m_user.getPrefix());
}
void
ChatDialog::updateLabels()
{
- QString settingDisp = QString("<User: %1>, <Chatroom: %2>").arg(m_nick).arg(m_chatroom);
+ QString settingDisp = QString("<User: %1>, <Chatroom: %2>").arg(m_user.getNick()).arg(m_user.getChatroom());
infoLabel->setText(settingDisp);
- QString prefixDisp = QString("<Prefix: %1>").arg(m_prefix);
+ QString prefixDisp = QString("<Prefix: %1>").arg(m_user.getPrefix());
prefixLabel->setText(prefixDisp);
}
@@ -111,7 +116,7 @@
void
ChatDialog::buttonPressed()
{
- SettingDialog dialog(this, m_nick, m_chatroom, m_prefix);
+ SettingDialog dialog(this, m_user.getNick(), m_user.getChatroom(), m_user.getPrefix());
connect(&dialog, SIGNAL(updated(QString, QString, QString)), this, SLOT(settingUpdated(QString, QString, QString)));
dialog.exec();
}
@@ -120,17 +125,17 @@
ChatDialog::settingUpdated(QString nick, QString chatroom, QString prefix)
{
bool needWrite = false;
- if (!nick.isEmpty() && nick != m_nick) {
- m_nick = nick;
+ if (!nick.isEmpty() && nick != m_user.getNick()) {
+ m_user.setNick(nick);
needWrite = true;
}
- if (!prefix.isEmpty() && prefix != m_prefix) {
- m_prefix = prefix;
+ if (!prefix.isEmpty() && prefix != m_user.getPrefix()) {
+ m_user.setPrefix(prefix);
needWrite = true;
// TODO: set the previous prefix as left?
}
- if (!chatroom.isEmpty() && chatroom != m_chatroom) {
- m_chatroom = chatroom;
+ if (!chatroom.isEmpty() && chatroom != m_user.getChatroom()) {
+ m_user.setChatroom(chatroom);
needWrite = true;
// TODO: perhaps need to do a lot. e.g. use a new SyncAppSokcet
}