blob: 65204dfe8b7a78a0c6a7f6c7df64d3ed23002bbc [file] [log] [blame]
Yingdi Yu7989eb22013-10-31 17:38:22 -07001/* -*- 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 */
11
Yingdi Yu0b0a7362014-08-05 16:31:30 -070012#include "digest-tree-scene.hpp"
Alexander Afanasyevf829f4d2013-05-07 15:59:36 -070013
Zhenkai Zhuf474a0a2012-05-30 15:06:29 -070014#include <QtGui>
Alexander Afanasyevf829f4d2013-05-07 15:59:36 -070015
16#ifndef Q_MOC_RUN
Zhenkai Zhuf474a0a2012-05-30 15:06:29 -070017#include <vector>
18#include <iostream>
19#include <assert.h>
Zhenkai Zhu71b42cb2012-06-04 09:42:53 -070020#include <boost/lexical_cast.hpp>
Zhenkai Zhu21d75f92012-06-04 21:23:34 -070021#include <memory>
Alexander Afanasyevf829f4d2013-05-07 15:59:36 -070022#endif
Zhenkai Zhuf474a0a2012-05-30 15:06:29 -070023
Yingdi Yu0b0a7362014-08-05 16:31:30 -070024namespace chronos {
25
Zhenkai Zhuf474a0a2012-05-30 15:06:29 -070026static const double Pi = 3.14159265358979323846264338327950288419717;
Zhenkai Zhuf474a0a2012-05-30 15:06:29 -070027
Zhenkai Zhu7f52e1b2012-10-09 11:45:36 -070028//DisplayUserPtr DisplayUserNullPtr;
Zhenkai Zhud13acd02012-06-04 15:25:20 -070029
Yingdi Yu348f5ea2014-03-01 14:47:25 -080030DigestTreeScene::DigestTreeScene(QWidget *parent)
Zhenkai Zhuf474a0a2012-05-30 15:06:29 -070031 : QGraphicsScene(parent)
32{
Zhenkai Zhud13acd02012-06-04 15:25:20 -070033 previouslyUpdatedUser = DisplayUserNullPtr;
Zhenkai Zhu6fcdee42012-05-30 17:02:49 -070034}
35
36void
Zhenkai Zhu82a62752012-06-04 17:11:04 -070037DigestTreeScene::processUpdate(const std::vector<Sync::MissingDataInfo> &v, QString digest)
Zhenkai Zhu71b42cb2012-06-04 09:42:53 -070038{
39 int n = v.size();
Yingdi Yufa0b6a02014-04-30 14:26:42 -070040 bool rePlot = false;
Yingdi Yu0b0a7362014-08-05 16:31:30 -070041 for (int i = 0; i < n; i++) {
Yingdi Yu5a5ff202014-03-17 10:03:02 -070042 QString routablePrefix(v[i].prefix.c_str());
43 QString prefix = trimRoutablePrefix(routablePrefix);
44
45 Roster_iterator it = m_roster.find(prefix);
Yingdi Yu0b0a7362014-08-05 16:31:30 -070046 if (it == m_roster.end()) {
Yingdi Yu5a5ff202014-03-17 10:03:02 -070047 // std::cout << "processUpdate v[" << i << "]: " << prefix.toStdString() << std::endl;
Yingdi Yufa0b6a02014-04-30 14:26:42 -070048 rePlot = true;
Zhenkai Zhu71b42cb2012-06-04 09:42:53 -070049 DisplayUserPtr p(new DisplayUser());
Yingdi Yu0b0a7362014-08-05 16:31:30 -070050 time_t tempTime = ::time(NULL) - FRESHNESS + 1;
Zhenkai Zhu86df7412012-09-27 16:30:20 -070051 p->setReceived(tempTime);
Yingdi Yu5a5ff202014-03-17 10:03:02 -070052 p->setPrefix(prefix);
Zhenkai Zhu71b42cb2012-06-04 09:42:53 -070053 p->setSeq(v[i].high);
54 m_roster.insert(p->getPrefix(), p);
55 }
Yingdi Yu0b0a7362014-08-05 16:31:30 -070056 else {
Zhenkai Zhud1c5a972012-06-05 14:07:41 -070057 it.value()->setSeq(v[i].high);
58 }
Zhenkai Zhu71b42cb2012-06-04 09:42:53 -070059 }
60
Yingdi Yu0b0a7362014-08-05 16:31:30 -070061 if (rePlot) {
Zhenkai Zhu71b42cb2012-06-04 09:42:53 -070062 plot(digest);
Yingdi Yu348f5ea2014-03-01 14:47:25 -080063 QTimer::singleShot(2100, this, SLOT(emitReplot()));
Zhenkai Zhu71b42cb2012-06-04 09:42:53 -070064 }
Yingdi Yu0b0a7362014-08-05 16:31:30 -070065 else {
66 for (int i = 0; i < n; i++) {
Yingdi Yu5a5ff202014-03-17 10:03:02 -070067 QString routablePrefix(v[i].prefix.c_str());
68 QString prefix = trimRoutablePrefix(routablePrefix);
Yingdi Yufa0b6a02014-04-30 14:26:42 -070069
Yingdi Yu5a5ff202014-03-17 10:03:02 -070070 Roster_iterator it = m_roster.find(prefix);
Zhenkai Zhu71b42cb2012-06-04 09:42:53 -070071 if (it != m_roster.end()) {
72 DisplayUserPtr p = it.value();
73 QGraphicsTextItem *item = p->getSeqTextItem();
Zhenkai Zhud13acd02012-06-04 15:25:20 -070074 QGraphicsRectItem *rectItem = p->getInnerRectItem();
Zhenkai Zhu71b42cb2012-06-04 09:42:53 -070075 std::string s = boost::lexical_cast<std::string>(p->getSeqNo().getSeq());
76 item->setPlainText(s.c_str());
Zhenkai Zhud13acd02012-06-04 15:25:20 -070077 QRectF textBR = item->boundingRect();
78 QRectF rectBR = rectItem->boundingRect();
Yingdi Yu0b0a7362014-08-05 16:31:30 -070079 item->setPos(rectBR.x() + (rectBR.width() - textBR.width())/2,
80 rectBR.y() + (rectBR.height() - textBR.height())/2);
Zhenkai Zhu71b42cb2012-06-04 09:42:53 -070081 }
82 }
83 m_rootDigest->setPlainText(digest);
84 }
85}
86
87void
Zhenkai Zhu86df7412012-09-27 16:30:20 -070088DigestTreeScene::emitReplot()
89{
90 emit replot();
91}
92
Zhenkai Zhu9036e032012-09-27 20:59:33 -070093QStringList
Zhenkai Zhu6082ede2012-09-27 17:28:46 -070094DigestTreeScene::getRosterList()
95{
Zhenkai Zhu9036e032012-09-27 20:59:33 -070096 QStringList rosterList;
97 RosterIterator it(m_roster);
Yingdi Yu0b0a7362014-08-05 16:31:30 -070098 while (it.hasNext()) {
Zhenkai Zhu9036e032012-09-27 20:59:33 -070099 it.next();
100 DisplayUserPtr p = it.value();
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700101 if (p != DisplayUserNullPtr) {
Zhenkai Zhu9036e032012-09-27 20:59:33 -0700102 rosterList << "- " + p->getNick();
103 }
104 }
105 return rosterList;
Zhenkai Zhu6082ede2012-09-27 17:28:46 -0700106}
107
108void
Yingdi Yu5a5ff202014-03-17 10:03:02 -0700109DigestTreeScene::msgReceived(QString routablePrefix, QString nick)
Zhenkai Zhu71b42cb2012-06-04 09:42:53 -0700110{
Yingdi Yu5a5ff202014-03-17 10:03:02 -0700111 QString prefix = trimRoutablePrefix(routablePrefix);
Zhenkai Zhu71b42cb2012-06-04 09:42:53 -0700112 Roster_iterator it = m_roster.find(prefix);
Yingdi Yu5a5ff202014-03-17 10:03:02 -0700113 // std::cout << "msgReceived prefix: " << prefix.toStdString() << std::endl;
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700114 if (it != m_roster.end()) {
115 // std::cout << "Updating for prefix = " << prefix.toStdString() <<
116 // " nick = " << nick.toStdString() << std::endl;
117 DisplayUserPtr p = it.value();
118 p->setReceived(::time(NULL));
119 if (nick != p->getNick()) {
120 // std::cout << "old nick = " << p->getNick().toStdString() << std::endl;
121 p->setNick(nick);
122 QGraphicsTextItem *nickItem = p->getNickTextItem();
123 QGraphicsRectItem *nickRectItem = p->getNickRectItem();
124 nickItem->setPlainText(p->getNick());
125 QRectF rectBR = nickRectItem->boundingRect();
126 QRectF nickBR = nickItem->boundingRect();
127 nickItem->setPos(rectBR.x() + (rectBR.width() - nickBR.width())/2, rectBR.y() + 5);
128 emit rosterChanged(QStringList());
Yingdi Yuf4aaa8b2014-03-10 11:24:31 -0700129 }
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700130
131 reDrawNode(p, Qt::red);
132
133 if (previouslyUpdatedUser != DisplayUserNullPtr && previouslyUpdatedUser != p) {
134 reDrawNode(previouslyUpdatedUser, Qt::darkBlue);
135 }
136
137 previouslyUpdatedUser = p;
138 }
Zhenkai Zhu71b42cb2012-06-04 09:42:53 -0700139}
140
141void
Zhenkai Zhu82a62752012-06-04 17:11:04 -0700142DigestTreeScene::clearAll()
143{
144 clear();
Zhenkai Zhu82a62752012-06-04 17:11:04 -0700145 m_roster.clear();
146}
147
Zhenkai Zhu591e8c32012-09-26 11:57:50 -0700148bool
149DigestTreeScene::removeNode(const QString prefix)
150{
151 int removedCount = m_roster.remove(prefix);
152 return (removedCount > 0);
153}
154
Zhenkai Zhu82a62752012-06-04 17:11:04 -0700155void
Zhenkai Zhu71b42cb2012-06-04 09:42:53 -0700156DigestTreeScene::plot(QString digest)
157{
Yingdi Yufa4ce792014-02-06 18:09:22 -0800158#ifdef _DEBUG
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700159 std::cout << "Plotting at time: " << ::time(NULL) << std::endl;
Zhenkai Zhu86df7412012-09-27 16:30:20 -0700160#endif
Zhenkai Zhu6fcdee42012-05-30 17:02:49 -0700161 clear();
Zhenkai Zhu71b42cb2012-06-04 09:42:53 -0700162
Zhenkai Zhud13acd02012-06-04 15:25:20 -0700163 int nodeSize = 40;
Zhenkai Zhu21d75f92012-06-04 21:23:34 -0700164
Zhenkai Zhu71b42cb2012-06-04 09:42:53 -0700165 int siblingDistance = 100, levelDistance = 100;
Zhenkai Zhu21d75f92012-06-04 21:23:34 -0700166 std::auto_ptr<TreeLayout> layout(new OneLevelTreeLayout());
167 layout->setSiblingDistance(siblingDistance);
168 layout->setLevelDistance(levelDistance);
Zhenkai Zhuf474a0a2012-05-30 15:06:29 -0700169
Zhenkai Zhu86df7412012-09-27 16:30:20 -0700170 // do some cleaning, get rid of stale member info
171 Roster_iterator it = m_roster.begin();
Zhenkai Zhu25e33e52012-09-28 13:00:07 -0700172 QStringList staleUserList;
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700173 while (it != m_roster.end()) {
Zhenkai Zhu86df7412012-09-27 16:30:20 -0700174 DisplayUserPtr p = it.value();
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700175 if (p != DisplayUserNullPtr) {
176 time_t now = ::time(NULL);
177 if (now - p->getReceived() >= FRESHNESS) {
Yingdi Yufa4ce792014-02-06 18:09:22 -0800178#ifdef _DEBUG
Zhenkai Zhu86df7412012-09-27 16:30:20 -0700179 std::cout << "Removing user: " << p->getNick().toStdString() << std::endl;
180 std::cout << "now - last = " << now - p->getReceived() << std::endl;
181#endif
Zhenkai Zhu25e33e52012-09-28 13:00:07 -0700182 staleUserList << p->getNick();
Zhenkai Zhu86df7412012-09-27 16:30:20 -0700183 p = DisplayUserNullPtr;
184 it = m_roster.erase(it);
185 }
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700186 else {
187 if (!m_currentPrefix.startsWith("/private/local") &&
188 p->getPrefix().startsWith("/private/local")) {
Yingdi Yufa4ce792014-02-06 18:09:22 -0800189#ifdef _DEBUG
Zhenkai Zhu716fe852012-10-08 18:27:55 -0700190 std::cout << "erasing: " << p->getPrefix().toStdString() << std::endl;
191#endif
192 staleUserList << p->getNick();
193 p = DisplayUserNullPtr;
194 it = m_roster.erase(it);
195 continue;
196 }
Zhenkai Zhu86df7412012-09-27 16:30:20 -0700197 ++it;
198 }
199 }
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700200 else {
Zhenkai Zhu86df7412012-09-27 16:30:20 -0700201 it = m_roster.erase(it);
202 }
203 }
204
Zhenkai Zhu6082ede2012-09-27 17:28:46 -0700205 // for simpicity here, whenever we replot, we also redo the roster list
Zhenkai Zhu25e33e52012-09-28 13:00:07 -0700206 emit rosterChanged(staleUserList);
Zhenkai Zhu6082ede2012-09-27 17:28:46 -0700207
Zhenkai Zhu21d75f92012-06-04 21:23:34 -0700208 int n = m_roster.size();
Zhenkai Zhu716fe852012-10-08 18:27:55 -0700209
Zhenkai Zhu21d75f92012-06-04 21:23:34 -0700210 std::vector<TreeLayout::Coordinate> childNodesCo(n);
Zhenkai Zhuf474a0a2012-05-30 15:06:29 -0700211
Zhenkai Zhu21d75f92012-06-04 21:23:34 -0700212 layout->setOneLevelLayout(childNodesCo);
213
214 plotEdge(childNodesCo, nodeSize);
215 plotNode(childNodesCo, digest, nodeSize);
Zhenkai Zhu71b42cb2012-06-04 09:42:53 -0700216
Zhenkai Zhud13acd02012-06-04 15:25:20 -0700217 previouslyUpdatedUser = DisplayUserNullPtr;
218
Zhenkai Zhu71b42cb2012-06-04 09:42:53 -0700219}
220
221void
Zhenkai Zhu21d75f92012-06-04 21:23:34 -0700222DigestTreeScene::plotEdge(const std::vector<TreeLayout::Coordinate> &childNodesCo, int nodeSize)
Zhenkai Zhu71b42cb2012-06-04 09:42:53 -0700223{
Zhenkai Zhu21d75f92012-06-04 21:23:34 -0700224 int n = childNodesCo.size();
225 for (int i = 0; i < n; i++) {
226 double x1 = 0.0, y1 = 0.0;
227 double x2 = childNodesCo[i].x, y2 = childNodesCo[i].y;
Zhenkai Zhu71b42cb2012-06-04 09:42:53 -0700228 QPointF src(x1 + nodeSize/2, y1 + nodeSize/2);
229 QPointF dest(x2 + nodeSize/2, y2 + nodeSize/2);
Zhenkai Zhuf474a0a2012-05-30 15:06:29 -0700230 QLineF line(src, dest);
Zhenkai Zhuf474a0a2012-05-30 15:06:29 -0700231 double angle = ::acos(line.dx() / line.length());
232
233 double arrowSize = 10;
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700234 QPointF sourceArrowP0 = src + QPointF((nodeSize/2 + 10) * line.dx() / line.length(),
235 (nodeSize/2 +10) * line.dy() / line.length());
Zhenkai Zhu71b42cb2012-06-04 09:42:53 -0700236 QPointF sourceArrowP1 = sourceArrowP0 + QPointF(cos(angle + Pi / 3 - Pi/2) * arrowSize,
Zhenkai Zhuf474a0a2012-05-30 15:06:29 -0700237 sin(angle + Pi / 3 - Pi/2) * arrowSize);
Zhenkai Zhu71b42cb2012-06-04 09:42:53 -0700238 QPointF sourceArrowP2 = sourceArrowP0 + QPointF(cos(angle + Pi - Pi / 3 - Pi/2) * arrowSize,
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700239 sin(angle + Pi - Pi / 3 - Pi/2) * arrowSize);
Zhenkai Zhuf474a0a2012-05-30 15:06:29 -0700240
Zhenkai Zhu71b42cb2012-06-04 09:42:53 -0700241 addLine(QLineF(sourceArrowP0, dest), QPen(Qt::black));
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700242 addPolygon(QPolygonF() << sourceArrowP0<< sourceArrowP1 <<
243 sourceArrowP2, QPen(Qt::black), QBrush(Qt::black));
Zhenkai Zhu71b42cb2012-06-04 09:42:53 -0700244 }
245}
246
247void
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700248DigestTreeScene::plotNode(const std::vector<TreeLayout::Coordinate>& childNodesCo,
249 QString digest, int nodeSize)
Zhenkai Zhu71b42cb2012-06-04 09:42:53 -0700250{
Zhenkai Zhu71b42cb2012-06-04 09:42:53 -0700251 RosterIterator it(m_roster);
Zhenkai Zhu21d75f92012-06-04 21:23:34 -0700252 int n = childNodesCo.size();
253 int rim = 3;
Zhenkai Zhu71b42cb2012-06-04 09:42:53 -0700254
Zhenkai Zhu21d75f92012-06-04 21:23:34 -0700255 // plot root node
256 QRectF rootBoundingRect(0, 0, nodeSize, nodeSize);
257 QRectF rootInnerBoundingRect(rim, rim, nodeSize - rim * 2, nodeSize - rim * 2);
258 addRect(rootBoundingRect, QPen(Qt::black), QBrush(Qt::darkRed));
259 addRect(rootInnerBoundingRect, QPen(Qt::black), QBrush(Qt::lightGray));
Zhenkai Zhuc5470612012-06-05 12:28:59 -0700260 QRectF digestRect(- 5.5 * nodeSize , - nodeSize, 12 * nodeSize, 30);
Zhenkai Zhu21d75f92012-06-04 21:23:34 -0700261 addRect(digestRect, QPen(Qt::darkCyan), QBrush(Qt::darkCyan));
Zhenkai Zhu27df8d42012-06-05 12:04:04 -0700262
Zhenkai Zhu21d75f92012-06-04 21:23:34 -0700263 QGraphicsTextItem *digestItem = addText(digest);
264 QRectF digestBoundingRect = digestItem->boundingRect();
Zhenkai Zhu27df8d42012-06-05 12:04:04 -0700265 digestItem->setDefaultTextColor(Qt::black);
Zhenkai Zhu21d75f92012-06-04 21:23:34 -0700266 digestItem->setFont(QFont("Cursive", 12, QFont::Bold));
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700267 digestItem->setPos(- 4.5 * nodeSize + (12 * nodeSize - digestBoundingRect.width()) / 2,
268 - nodeSize + 5);
Zhenkai Zhu21d75f92012-06-04 21:23:34 -0700269 m_rootDigest = digestItem;
270
271 // plot child nodes
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700272 for (int i = 0; i < n; i++) {
Yingdi Yufa0b6a02014-04-30 14:26:42 -0700273 if (it.hasNext())
Zhenkai Zhu21d75f92012-06-04 21:23:34 -0700274 it.next();
Yingdi Yufa0b6a02014-04-30 14:26:42 -0700275 else
Zhenkai Zhu21d75f92012-06-04 21:23:34 -0700276 abort();
Zhenkai Zhud13acd02012-06-04 15:25:20 -0700277
Zhenkai Zhu21d75f92012-06-04 21:23:34 -0700278 double x = childNodesCo[i].x;
279 double y = childNodesCo[i].y;
280 QRectF boundingRect(x, y, nodeSize, nodeSize);
281 QRectF innerBoundingRect(x + rim, y + rim, nodeSize - rim * 2, nodeSize - rim * 2);
282 DisplayUserPtr p = it.value();
283 QGraphicsRectItem *rectItem = addRect(boundingRect, QPen(Qt::black), QBrush(Qt::darkBlue));
284 p->setRimRectItem(rectItem);
285
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700286 QGraphicsRectItem *innerRectItem = addRect(innerBoundingRect,
287 QPen(Qt::black),
288 QBrush(Qt::lightGray));
Zhenkai Zhu21d75f92012-06-04 21:23:34 -0700289 p->setInnerRectItem(innerRectItem);
290
291 std::string s = boost::lexical_cast<std::string>(p->getSeqNo().getSeq());
292 QGraphicsTextItem *seqItem = addText(s.c_str());
293 seqItem->setFont(QFont("Cursive", 12, QFont::Bold));
Yingdi Yufa0b6a02014-04-30 14:26:42 -0700294 QRectF seqBoundingRect = seqItem->boundingRect();
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700295 seqItem->setPos(x + nodeSize / 2 - seqBoundingRect.width() / 2,
296 y + nodeSize / 2 - seqBoundingRect.height() / 2);
Zhenkai Zhu21d75f92012-06-04 21:23:34 -0700297 p->setSeqTextItem(seqItem);
298
299 QRectF textRect(x - nodeSize / 2, y + nodeSize, 2 * nodeSize, 30);
300 QGraphicsRectItem *nickRectItem = addRect(textRect, QPen(Qt::darkCyan), QBrush(Qt::darkCyan));
301 p->setNickRectItem(nickRectItem);
302 QGraphicsTextItem *nickItem = addText(p->getNick());
303 QRectF textBoundingRect = nickItem->boundingRect();
304 nickItem->setDefaultTextColor(Qt::white);
305 nickItem->setFont(QFont("Cursive", 12, QFont::Bold));
306 nickItem->setPos(x + nodeSize / 2 - textBoundingRect.width() / 2, y + nodeSize + 5);
307 p->setNickTextItem(nickItem);
Zhenkai Zhuf474a0a2012-05-30 15:06:29 -0700308 }
Zhenkai Zhu21d75f92012-06-04 21:23:34 -0700309
Zhenkai Zhuf474a0a2012-05-30 15:06:29 -0700310}
311
Zhenkai Zhu82a62752012-06-04 17:11:04 -0700312void
313DigestTreeScene::reDrawNode(DisplayUserPtr p, QColor rimColor)
314{
315 QGraphicsRectItem *rimItem = p->getRimRectItem();
316 rimItem->setBrush(QBrush(rimColor));
317 QGraphicsRectItem *innerItem = p->getInnerRectItem();
318 innerItem->setBrush(QBrush(Qt::lightGray));
319 QGraphicsTextItem *seqTextItem = p->getSeqTextItem();
320 std::string s = boost::lexical_cast<std::string>(p->getSeqNo().getSeq());
321 seqTextItem->setPlainText(s.c_str());
322 QRectF textBR = seqTextItem->boundingRect();
323 QRectF innerBR = innerItem->boundingRect();
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700324 seqTextItem->setPos(innerBR.x() + (innerBR.width() - textBR.width())/2,
325 innerBR.y() + (innerBR.height() - textBR.height())/2);
Zhenkai Zhu82a62752012-06-04 17:11:04 -0700326}
327
Yingdi Yufa0b6a02014-04-30 14:26:42 -0700328QString
Yingdi Yu5a5ff202014-03-17 10:03:02 -0700329DigestTreeScene::trimRoutablePrefix(QString prefix)
330{
331 bool encaped = false;
332 ndn::Name prefixName(prefix.toStdString());
333
Yingdi Yu5a5ff202014-03-17 10:03:02 -0700334 size_t offset = 0;
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700335 for (ndn::Name::const_iterator it = prefixName.begin(); it != prefixName.end(); it++, offset++) {
336 if (it->toUri() == "%F0.") {
337 encaped = true;
338 break;
Yingdi Yu5a5ff202014-03-17 10:03:02 -0700339 }
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700340 }
Yingdi Yu5a5ff202014-03-17 10:03:02 -0700341
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700342 if (!encaped)
Yingdi Yu5a5ff202014-03-17 10:03:02 -0700343 return prefix;
344 else
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700345 return QString(prefixName.getSubName(offset+1).toUri().c_str());
Yingdi Yu5a5ff202014-03-17 10:03:02 -0700346}
347
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700348} // namespace chronos
349
Alexander Afanasyevb4b92292013-07-09 13:54:59 -0700350#if WAF
Yingdi Yuf4aaa8b2014-03-10 11:24:31 -0700351#include "digest-tree-scene.moc"
352#include "digest-tree-scene.cpp.moc"
Alexander Afanasyevb4b92292013-07-09 13:54:59 -0700353#endif