blob: e993294cc819a46f82520427e33f6ab20acc6f3b [file] [log] [blame]
Yingdi Yu348f5ea2014-03-01 14:47:25 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2013, Regents of the University of California
4 * Yingdi Yu
5 *
6 * BSD license, See the LICENSE file for more information
7 *
8 * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
9 * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
10 * Yingdi Yu <yingdi@cs.ucla.edu>
11 */
12
Yingdi Yu0b0a7362014-08-05 16:31:30 -070013#include "chat-dialog.hpp"
Yingdi Yu348f5ea2014-03-01 14:47:25 -080014#include "ui_chat-dialog.h"
15
16#include <QScrollBar>
17#include <QMessageBox>
18#include <QCloseEvent>
19
Yingdi Yud45777b2014-10-16 23:54:11 -070020Q_DECLARE_METATYPE(ndn::Name)
21Q_DECLARE_METATYPE(time_t)
Yingdi Yueb692ac2015-02-10 18:46:18 -080022Q_DECLARE_METATYPE(std::vector<chronochat::NodeInfo>)
Yingdi Yu0b0a7362014-08-05 16:31:30 -070023
Yingdi Yueb692ac2015-02-10 18:46:18 -080024namespace chronochat {
Yingdi Yu0b0a7362014-08-05 16:31:30 -070025
Yingdi Yud45777b2014-10-16 23:54:11 -070026static const Name PRIVATE_PREFIX("/private/local");
27static const uint8_t ROUTING_HINT_SEPARATOR[2] = {0xF0, 0x2E}; // %F0.
Yingdi Yu0b0a7362014-08-05 16:31:30 -070028
Yingdi Yud45777b2014-10-16 23:54:11 -070029ChatDialog::ChatDialog(const Name& chatroomPrefix,
30 const Name& userChatPrefix,
31 const Name& routingPrefix,
32 const std::string& chatroomName,
Yingdi Yu17032f82014-03-25 15:48:23 -070033 const std::string& nick,
Yingdi Yud45777b2014-10-16 23:54:11 -070034 bool isSecured,
Yingdi Yu45da92a2015-02-02 13:17:03 -080035 const Name& signingId,
Yingdi Yufa0b6a02014-04-30 14:26:42 -070036 QWidget* parent)
Yingdi Yu348f5ea2014-03-01 14:47:25 -080037 : QDialog(parent)
38 , ui(new Ui::ChatDialog)
Yingdi Yu45da92a2015-02-02 13:17:03 -080039 , m_backend(chatroomPrefix, userChatPrefix, routingPrefix, chatroomName, nick, signingId)
Yingdi Yud45777b2014-10-16 23:54:11 -070040 , m_chatroomName(chatroomName)
Qiuhan Ding43c8e162015-02-02 15:16:48 -080041 , m_chatroomPrefix(chatroomPrefix)
Yingdi Yud45777b2014-10-16 23:54:11 -070042 , m_nick(nick.c_str())
43 , m_isSecured(isSecured)
Yingdi Yu348f5ea2014-03-01 14:47:25 -080044{
Yingdi Yud45777b2014-10-16 23:54:11 -070045 qRegisterMetaType<ndn::Name>("ndn::Name");
46 qRegisterMetaType<time_t>("time_t");
Yingdi Yueb692ac2015-02-10 18:46:18 -080047 qRegisterMetaType<std::vector<chronochat::NodeInfo> >("std::vector<chronochat::NodeInfo>");
Yingdi Yu348f5ea2014-03-01 14:47:25 -080048
49 m_scene = new DigestTreeScene(this);
Yingdi Yuf4aaa8b2014-03-10 11:24:31 -070050 m_trustScene = new TrustTreeScene(this);
Yingdi Yu348f5ea2014-03-01 14:47:25 -080051 m_rosterModel = new QStringListModel(this);
Yingdi Yu348f5ea2014-03-01 14:47:25 -080052
53 ui->setupUi(this);
Yingdi Yud45777b2014-10-16 23:54:11 -070054
Yingdi Yuf4aaa8b2014-03-10 11:24:31 -070055 ui->syncTreeViewer->setScene(m_scene);
Yingdi Yu348f5ea2014-03-01 14:47:25 -080056 m_scene->setSceneRect(m_scene->itemsBoundingRect());
Yingdi Yuf4aaa8b2014-03-10 11:24:31 -070057 ui->syncTreeViewer->hide();
Yingdi Yud45777b2014-10-16 23:54:11 -070058
Yingdi Yuf4aaa8b2014-03-10 11:24:31 -070059 ui->trustTreeViewer->setScene(m_trustScene);
60 m_trustScene->setSceneRect(m_trustScene->itemsBoundingRect());
61 ui->trustTreeViewer->hide();
Yingdi Yud45777b2014-10-16 23:54:11 -070062
Yingdi Yu348f5ea2014-03-01 14:47:25 -080063 ui->listView->setModel(m_rosterModel);
64
Yingdi Yud45777b2014-10-16 23:54:11 -070065 Name routablePrefix;
Yingdi Yud85e29f2014-09-09 17:20:04 -070066
Yingdi Yud45777b2014-10-16 23:54:11 -070067 if (routingPrefix.isPrefixOf(userChatPrefix))
68 routablePrefix = userChatPrefix;
69 else
70 routablePrefix.append(routingPrefix)
71 .append(ROUTING_HINT_SEPARATOR, 2)
72 .append(userChatPrefix);
Yingdi Yud85e29f2014-09-09 17:20:04 -070073
Yingdi Yud45777b2014-10-16 23:54:11 -070074 updateLabels(routablePrefix);
Yingdi Yu348f5ea2014-03-01 14:47:25 -080075
Yingdi Yud45777b2014-10-16 23:54:11 -070076 QStringList roster;
77 roster << "- " + m_nick;
78 m_rosterModel->setStringList(roster);
79
80 // When backend receives a sync update, notify frontend to update sync tree
Yingdi Yueb692ac2015-02-10 18:46:18 -080081 connect(&m_backend, SIGNAL(syncTreeUpdated(std::vector<chronochat::NodeInfo>, QString)),
82 this, SLOT(updateSyncTree(std::vector<chronochat::NodeInfo>, QString)));
Yingdi Yud45777b2014-10-16 23:54:11 -070083
84 // When backend receives a new chat message, notify frontent to print it out.
85 connect(&m_backend, SIGNAL(chatMessageReceived(QString, QString, time_t)),
86 this, SLOT(receiveChatMessage(QString, QString, time_t)));
87
88 // When backend detects a new session, notify frontend to print the message.
89 connect(&m_backend, SIGNAL(sessionAdded(QString, QString, time_t)),
90 this, SLOT(addSession(QString, QString, time_t)));
91
92 // When backend detects a deleted session, notify frontend to print the message.
93 connect(&m_backend, SIGNAL(sessionRemoved(QString, QString, time_t)),
94 this, SLOT(removeSession(QString, QString, time_t)));
95
96 // When backend detects nick changed, notify frontend to print the new nick
97 connect(&m_backend, SIGNAL(nickUpdated(QString, QString)),
98 this, SLOT(updateNick(QString, QString)));
99
100 // When backend receives a new message, notify frontend to print notification
101 connect(&m_backend, SIGNAL(messageReceived(QString)),
102 this, SLOT(receiveMessage(QString)));
103
104 // When backend updates prefix, notify frontend to update labels.
105 connect(&m_backend, SIGNAL(chatPrefixChanged(ndn::Name)),
106 this, SLOT(updateLabels(ndn::Name)));
107
108 // When frontend gets a message to send, notify backend.
109 connect(this, SIGNAL(msgToSent(QString, time_t)),
110 &m_backend, SLOT(sendChatMessage(QString, time_t)));
111
112 // When frontend gets a shutdown command, notify backend.
113 connect(this, SIGNAL(shutdownBackend()),
114 &m_backend, SLOT(shutdown()));
115
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800116 m_scene->plot("Empty");
117
Yingdi Yufa0b6a02014-04-30 14:26:42 -0700118 connect(ui->lineEdit, SIGNAL(returnPressed()),
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800119 this, SLOT(onReturnPressed()));
Yingdi Yufa0b6a02014-04-30 14:26:42 -0700120 connect(ui->syncTreeButton, SIGNAL(pressed()),
Yingdi Yuf4aaa8b2014-03-10 11:24:31 -0700121 this, SLOT(onSyncTreeButtonPressed()));
Yingdi Yufa0b6a02014-04-30 14:26:42 -0700122 connect(ui->trustTreeButton, SIGNAL(pressed()),
Yingdi Yuf4aaa8b2014-03-10 11:24:31 -0700123 this, SLOT(onTrustTreeButtonPressed()));
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800124
Yingdi Yud45777b2014-10-16 23:54:11 -0700125 disableSyncTreeDisplay();
126 QTimer::singleShot(2200, this, SLOT(enableSyncTreeDisplay()));
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800127
Yingdi Yud45777b2014-10-16 23:54:11 -0700128 m_backend.start();
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800129}
130
131
132ChatDialog::~ChatDialog()
133{
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800134}
135
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800136void
137ChatDialog::closeEvent(QCloseEvent *e)
138{
Yingdi Yud45777b2014-10-16 23:54:11 -0700139 // When close button is clicked, do not close the dialog immediately.
140
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800141 QMessageBox::information(this, tr("ChronoChat"),
142 tr("The chatroom will keep running in the "
143 "system tray. To close the chatroom, "
144 "choose <b>Close chatroom</b> in the "
145 "context memu of the system tray entry."));
Yingdi Yue8323b62014-09-02 17:24:15 -0700146 hide();
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800147 e->ignore();
148}
149
150void
Yingdi Yu233a9722014-03-07 15:47:09 -0800151ChatDialog::changeEvent(QEvent *e)
152{
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700153 switch(e->type()) {
Yingdi Yu233a9722014-03-07 15:47:09 -0800154 case QEvent::ActivationChange:
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700155 if (isActiveWindow()) {
Yingdi Yu233a9722014-03-07 15:47:09 -0800156 emit resetIcon();
157 }
158 break;
159 default:
160 break;
161 }
162}
163
164void
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800165ChatDialog::resizeEvent(QResizeEvent *e)
166{
167 fitView();
168}
169
170void
171ChatDialog::showEvent(QShowEvent *e)
172{
173 fitView();
174}
175
Qiuhan Ding43c8e162015-02-02 15:16:48 -0800176ChatroomInfo
Yingdi Yud45777b2014-10-16 23:54:11 -0700177ChatDialog::getChatroomInfo()
178{
Qiuhan Ding43c8e162015-02-02 15:16:48 -0800179 ChatroomInfo chatroomInfo;
180 chatroomInfo.setName(Name::Component(m_chatroomName));
Yingdi Yud45777b2014-10-16 23:54:11 -0700181 QStringList prefixList = m_scene->getRosterPrefixList();
182 for(QStringList::iterator it = prefixList.begin();
183 it != prefixList.end(); ++it ) {
184 Name participant = Name(it->toStdString()).getPrefix(-3);
Qiuhan Ding43c8e162015-02-02 15:16:48 -0800185 chatroomInfo.addParticipant(participant);
Yingdi Yud45777b2014-10-16 23:54:11 -0700186 }
187
Qiuhan Ding43c8e162015-02-02 15:16:48 -0800188 chatroomInfo.setSyncPrefix(m_chatroomPrefix);
Yingdi Yud45777b2014-10-16 23:54:11 -0700189 if (m_isSecured)
Qiuhan Ding43c8e162015-02-02 15:16:48 -0800190 chatroomInfo.setTrustModel(ChatroomInfo::TRUST_MODEL_HIERARCHICAL);
Yingdi Yud45777b2014-10-16 23:54:11 -0700191 else
Qiuhan Ding43c8e162015-02-02 15:16:48 -0800192 chatroomInfo.setTrustModel(ChatroomInfo::TRUST_MODEL_NONE);
Yingdi Yud45777b2014-10-16 23:54:11 -0700193 return chatroomInfo;
194}
195
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800196// private methods:
Yingdi Yuf4aaa8b2014-03-10 11:24:31 -0700197void ChatDialog::disableSyncTreeDisplay()
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800198{
Yingdi Yuf4aaa8b2014-03-10 11:24:31 -0700199 ui->syncTreeButton->setEnabled(false);
200 ui->syncTreeViewer->hide();
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800201 fitView();
202}
203
204void
Yingdi Yud45777b2014-10-16 23:54:11 -0700205ChatDialog::appendChatMessage(const QString& nick, const QString& text, time_t timestamp)
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800206{
Yingdi Yud45777b2014-10-16 23:54:11 -0700207 QTextCharFormat nickFormat;
208 nickFormat.setForeground(Qt::darkGreen);
209 nickFormat.setFontWeight(QFont::Bold);
210 nickFormat.setFontUnderline(true);
211 nickFormat.setUnderlineColor(Qt::gray);
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800212
Yingdi Yud45777b2014-10-16 23:54:11 -0700213 // Print who & when
214 QTextCursor cursor(ui->textEdit->textCursor());
215 cursor.movePosition(QTextCursor::End);
216 QTextTableFormat tableFormat;
217 tableFormat.setBorder(0);
218 QTextTable *table = cursor.insertTable(1, 2, tableFormat);
219 QString from = QString("%1 ").arg(nick);
220 QTextTableCell fromCell = table->cellAt(0, 0);
221 fromCell.setFormat(nickFormat);
222 fromCell.firstCursorPosition().insertText(from);
223 printTimeInCell(table, timestamp);
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800224
Yingdi Yud45777b2014-10-16 23:54:11 -0700225 // Print what
226 QTextCursor nextCursor(ui->textEdit->textCursor());
227 nextCursor.movePosition(QTextCursor::End);
228 table = nextCursor.insertTable(1, 1, tableFormat);
229 table->cellAt(0, 0).firstCursorPosition().insertText(text);
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800230
Yingdi Yud45777b2014-10-16 23:54:11 -0700231 // Popup notification
232 showMessage(from, text);
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800233
234 QScrollBar *bar = ui->textEdit->verticalScrollBar();
235 bar->setValue(bar->maximum());
236}
237
238void
Yingdi Yud45777b2014-10-16 23:54:11 -0700239ChatDialog::appendControlMessage(const QString& nick,
240 const QString& action,
241 time_t timestamp)
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800242{
Yingdi Yud45777b2014-10-16 23:54:11 -0700243 QTextCharFormat nickFormat;
244 nickFormat.setForeground(Qt::gray);
245 nickFormat.setFontWeight(QFont::Bold);
246 nickFormat.setFontUnderline(true);
247 nickFormat.setUnderlineColor(Qt::gray);
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800248
Yingdi Yud45777b2014-10-16 23:54:11 -0700249 QTextCursor cursor(ui->textEdit->textCursor());
250 cursor.movePosition(QTextCursor::End);
251 QTextTableFormat tableFormat;
252 tableFormat.setBorder(0);
253 QTextTable *table = cursor.insertTable(1, 2, tableFormat);
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800254
Yingdi Yud45777b2014-10-16 23:54:11 -0700255 QString controlMsg = QString("%1 %2 ").arg(nick).arg(action);
256 QTextTableCell fromCell = table->cellAt(0, 0);
257 fromCell.setFormat(nickFormat);
258 fromCell.firstCursorPosition().insertText(controlMsg);
259 printTimeInCell(table, timestamp);
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800260}
261
262QString
263ChatDialog::formatTime(time_t timestamp)
264{
Qiuhan Ding4b8cfaa2015-03-10 17:03:48 -0700265 struct tm* localTime = localtime(&timestamp);
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800266
Qiuhan Ding4b8cfaa2015-03-10 17:03:48 -0700267 return QString("%1:%2:%3")
268 .arg(localTime->tm_hour, 2, 10, QChar('0'))
269 .arg(localTime->tm_min, 2, 10, QChar('0'))
270 .arg(localTime->tm_sec, 2, 10, QChar('0'));
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800271}
272
273void
274ChatDialog::printTimeInCell(QTextTable *table, time_t timestamp)
275{
276 QTextCharFormat timeFormat;
277 timeFormat.setForeground(Qt::gray);
278 timeFormat.setFontUnderline(true);
279 timeFormat.setUnderlineColor(Qt::gray);
280 QTextTableCell timeCell = table->cellAt(0, 1);
281 timeCell.setFormat(timeFormat);
282 timeCell.firstCursorPosition().insertText(formatTime(timestamp));
283}
284
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800285void
286ChatDialog::showMessage(const QString& from, const QString& data)
287{
288 if (!isActiveWindow())
289 emit showChatMessage(QString::fromStdString(m_chatroomName),
290 from, data);
291}
292
293void
294ChatDialog::fitView()
295{
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800296 QRectF rect = m_scene->itemsBoundingRect();
297 m_scene->setSceneRect(rect);
Yingdi Yuf4aaa8b2014-03-10 11:24:31 -0700298 ui->syncTreeViewer->fitInView(m_scene->itemsBoundingRect(), Qt::KeepAspectRatio);
299
300 QRectF trustRect = m_trustScene->itemsBoundingRect();
301 m_trustScene->setSceneRect(trustRect);
302 ui->trustTreeViewer->fitInView(m_trustScene->itemsBoundingRect(), Qt::KeepAspectRatio);
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800303}
304
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800305// public slots:
306void
Yingdi Yue8323b62014-09-02 17:24:15 -0700307ChatDialog::onShow()
308{
309 this->show();
310 this->raise();
311 this->activateWindow();
312}
313
314void
Yingdi Yud45777b2014-10-16 23:54:11 -0700315ChatDialog::shutdown()
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800316{
Yingdi Yud45777b2014-10-16 23:54:11 -0700317 if (m_backend.isRunning()) {
318 emit shutdownBackend();
319 m_backend.wait();
320 }
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800321 hide();
322 emit closeChatDialog(QString::fromStdString(m_chatroomName));
323}
324
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800325// private slots:
326void
Yingdi Yueb692ac2015-02-10 18:46:18 -0800327ChatDialog::updateSyncTree(std::vector<chronochat::NodeInfo> updates, QString rootDigest)
Yingdi Yud45777b2014-10-16 23:54:11 -0700328{
329 m_scene->processSyncUpdate(updates, rootDigest);
330}
331
332void
333ChatDialog::receiveChatMessage(QString nick, QString text, time_t timestamp)
334{
335 appendChatMessage(nick, text, timestamp);
336}
337
338void
339ChatDialog::addSession(QString sessionPrefix, QString nick, time_t timestamp)
340{
341 appendControlMessage(nick, "enters room", timestamp);
342 m_scene->updateNick(sessionPrefix, nick);
343 m_rosterModel->setStringList(m_scene->getRosterList());
Qiuhan Ding112ee482015-03-11 11:54:11 -0700344 fitView();
Yingdi Yud45777b2014-10-16 23:54:11 -0700345}
346
347void
348ChatDialog::removeSession(QString sessionPrefix, QString nick, time_t timestamp)
349{
350 appendControlMessage(nick, "leaves room", timestamp);
351 m_scene->removeNode(sessionPrefix);
352 m_rosterModel->setStringList(m_scene->getRosterList());
Qiuhan Ding112ee482015-03-11 11:54:11 -0700353 fitView();
Yingdi Yud45777b2014-10-16 23:54:11 -0700354}
355
356void
357ChatDialog::updateNick(QString sessionPrefix, QString nick)
358{
359 m_scene->updateNick(sessionPrefix, nick);
360 m_rosterModel->setStringList(m_scene->getRosterList());
361}
362
363void
364ChatDialog::receiveMessage(QString sessionPrefix)
365{
366 m_scene->messageReceived(sessionPrefix);
367}
368
369void
370ChatDialog::updateLabels(Name newChatPrefix)
371{
372 // Reset DigestTree
373 m_scene->clearAll();
374 m_scene->plot("Empty");
375
376 // Display chatroom name
377 QString chatroomName = QString("Chatroom: %1").arg(QString::fromStdString(m_chatroomName));
378 ui->infoLabel->setStyleSheet("QLabel {color: #630; font-size: 16px; font: bold \"Verdana\";}");
379 ui->infoLabel->setText(chatroomName);
380
381 // Display chat message prefix
382 QString chatPrefix;
383 if (PRIVATE_PREFIX.isPrefixOf(newChatPrefix)) {
384 chatPrefix =
385 QString("<Warning: no connection to hub or hub does not support prefix autoconfig.>\n"
386 "<Prefix = %1>")
387 .arg(QString::fromStdString(newChatPrefix.toUri()));
388 ui->prefixLabel->setStyleSheet(
389 "QLabel {color: red; font-size: 12px; font: bold \"Verdana\";}");
390 }
391 else {
392 chatPrefix = QString("<Prefix = %1>")
393 .arg(QString::fromStdString(newChatPrefix.toUri()));
394 ui->prefixLabel->setStyleSheet(
395 "QLabel {color: Green; font-size: 12px; font: bold \"Verdana\";}");
396 }
397 ui->prefixLabel->setText(chatPrefix);
Qiuhan Ding112ee482015-03-11 11:54:11 -0700398 fitView();
Yingdi Yud45777b2014-10-16 23:54:11 -0700399}
400
401void
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800402ChatDialog::onReturnPressed()
403{
404 QString text = ui->lineEdit->text();
Yingdi Yud45777b2014-10-16 23:54:11 -0700405
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800406 if (text.isEmpty())
407 return;
408
409 ui->lineEdit->clear();
410
Yingdi Yud45777b2014-10-16 23:54:11 -0700411 time_t timestamp =
412 static_cast<time_t>(time::toUnixTimestamp(time::system_clock::now()).count() / 1000);
413 // appendChatMessage(m_nick, text, timestamp);
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800414
Yingdi Yud45777b2014-10-16 23:54:11 -0700415 emit msgToSent(text, timestamp);
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800416
417 fitView();
418}
419
Yingdi Yufa0b6a02014-04-30 14:26:42 -0700420void
Yingdi Yuf4aaa8b2014-03-10 11:24:31 -0700421ChatDialog::onSyncTreeButtonPressed()
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800422{
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700423 if (ui->syncTreeViewer->isVisible()) {
Yingdi Yuf4aaa8b2014-03-10 11:24:31 -0700424 ui->syncTreeViewer->hide();
425 ui->syncTreeButton->setText("Show ChronoSync Tree");
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800426 }
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700427 else {
Yingdi Yuf4aaa8b2014-03-10 11:24:31 -0700428 ui->syncTreeViewer->show();
429 ui->syncTreeButton->setText("Hide ChronoSync Tree");
430 }
431
432 fitView();
433}
434
435void
436ChatDialog::onTrustTreeButtonPressed()
437{
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700438 if (ui->trustTreeViewer->isVisible()) {
Yingdi Yuf4aaa8b2014-03-10 11:24:31 -0700439 ui->trustTreeViewer->hide();
440 ui->trustTreeButton->setText("Show Trust Tree");
441 }
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700442 else {
Yingdi Yuf4aaa8b2014-03-10 11:24:31 -0700443 ui->trustTreeViewer->show();
444 ui->trustTreeButton->setText("Hide Trust Tree");
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800445 }
446
447 fitView();
448}
449
Yingdi Yuf4aaa8b2014-03-10 11:24:31 -0700450void ChatDialog::enableSyncTreeDisplay()
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800451{
Yingdi Yuf4aaa8b2014-03-10 11:24:31 -0700452 ui->syncTreeButton->setEnabled(true);
Yingdi Yud45777b2014-10-16 23:54:11 -0700453 ui->syncTreeViewer->show();
454 fitView();
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800455}
456
Yingdi Yueb692ac2015-02-10 18:46:18 -0800457} // namespace chronochat
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800458
Mengjin Yanaec70742014-08-25 10:37:45 -0700459
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800460#if WAF
461#include "chat-dialog.moc"
Yingdi Yu42125862014-08-07 17:04:28 -0700462// #include "chat-dialog.cpp.moc"
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800463#endif