bug+codestyle: Fix compile bugs and adjust code style

Change-Id: I008bb538441c099fa25b8b967fbf23ffce13a220
diff --git a/src/trust-tree-scene.cpp b/src/trust-tree-scene.cpp
index d3f84b5..73643f2 100644
--- a/src/trust-tree-scene.cpp
+++ b/src/trust-tree-scene.cpp
@@ -8,23 +8,23 @@
  * Author: Yingdi Yu <yingdi@cs.ucla.edu>
  */
 
-#include "trust-tree-scene.h"
+#include "trust-tree-scene.hpp"
 
 #include <QtGui>
 
 #ifndef Q_MOC_RUN
-#include <vector>
-#include <iostream>
 #include <assert.h>
-#include <boost/lexical_cast.hpp>
 #include <memory>
 #endif
 
+namespace chronos {
+
 static const double Pi = 3.14159265358979323846264338327950288419717;
 
-TrustTreeScene::TrustTreeScene(QWidget *parent)
+TrustTreeScene::TrustTreeScene(QWidget* parent)
   : QGraphicsScene(parent)
-{}
+{
+}
 
 void
 TrustTreeScene::plotTrustTree(TrustTreeNodeList& nodeList)
@@ -32,9 +32,10 @@
   clear();
 
   int nodeSize = 40;
-  int siblingDistance = 100, levelDistance = 100;
+  int siblingDistance = 100;
+  int levelDistance = 100;
 
-  boost::shared_ptr<MultipleLevelTreeLayout> layout(new MultipleLevelTreeLayout());
+  shared_ptr<MultipleLevelTreeLayout> layout(new MultipleLevelTreeLayout());
   layout->setSiblingDistance(siblingDistance);
   layout->setLevelDistance(levelDistance);
   layout->setMultipleLevelTreeLayout(nodeList);
@@ -46,41 +47,37 @@
 void
 TrustTreeScene::plotEdge(const TrustTreeNodeList& nodeList, int nodeSize)
 {
-  TrustTreeNodeList::const_iterator it  = nodeList.begin();
-  TrustTreeNodeList::const_iterator end = nodeList.end();
-  for(; it != end; it++)
-    {
-      TrustTreeNodeList& introducees = (*it)->getIntroducees();
-      TrustTreeNodeList::iterator eeIt  = introducees.begin();
-      TrustTreeNodeList::iterator eeEnd = introducees.end();
+  for (TrustTreeNodeList::const_iterator it = nodeList.begin(); it != nodeList.end(); it++) {
+    TrustTreeNodeList& introducees = (*it)->getIntroducees();
+    for (TrustTreeNodeList::iterator eeIt = introducees.begin();
+         eeIt != introducees.end(); eeIt++) {
+      if ((*it)->level() >= (*eeIt)->level())
+        continue;
 
-      for(; eeIt != eeEnd; eeIt++)
-        {
-          if((*it)->level() >= (*eeIt)->level())
-            continue;
+      double x1 = (*it)->x;
+      double y1 = (*it)->y;
+      double x2 = (*eeIt)->x;
+      double y2 = (*eeIt)->y;
 
-          double x1 = (*it)->x;
-          double y1 = (*it)->y;
-          double x2 = (*eeIt)->x;
-          double y2 = (*eeIt)->y;
+      QPointF src(x1 + nodeSize/2, y1 + nodeSize/2);
+      QPointF dest(x2 + nodeSize/2, y2 + nodeSize/2);
+      QLineF line(src, dest);
+      double angle = ::acos(line.dx() / line.length());
 
-          QPointF src(x1 + nodeSize/2, y1 + nodeSize/2);
-          QPointF dest(x2 + nodeSize/2, y2 + nodeSize/2);
-          QLineF line(src, dest);
-          double angle = ::acos(line.dx() / line.length());
+      double arrowSize = 10;
+      QPointF endP0 = src + QPointF((nodeSize/2) * line.dx() / line.dy(), nodeSize/2);
+      QPointF sourceArrowP0 = dest + QPointF((-nodeSize/2) * line.dx() / line.dy(),
+                                             -nodeSize/2);
+      QPointF sourceArrowP1 = sourceArrowP0 + QPointF(-cos(angle - Pi / 6) * arrowSize,
+                                                      -sin(angle - Pi / 6) * arrowSize);
+      QPointF sourceArrowP2 = sourceArrowP0 + QPointF(-cos(angle + Pi / 6) * arrowSize,
+                                                      -sin(angle + Pi / 6) * arrowSize);
 
-          double arrowSize = 10;
-          QPointF endP0 = src + QPointF((nodeSize/2) * line.dx() / line.dy(), nodeSize/2);
-          QPointF sourceArrowP0 = dest + QPointF((-nodeSize/2) * line.dx() / line.dy(), -nodeSize/2);
-          QPointF sourceArrowP1 = sourceArrowP0 + QPointF(-cos(angle - Pi / 6) * arrowSize,
-                                                          -sin(angle - Pi / 6) * arrowSize);
-          QPointF sourceArrowP2 = sourceArrowP0 + QPointF(-cos(angle + Pi / 6) * arrowSize,
-                                                          -sin(angle + Pi / 6) * arrowSize);
-
-          addLine(QLineF(sourceArrowP0, endP0), QPen(Qt::black));
-          addPolygon(QPolygonF() << sourceArrowP0 << sourceArrowP1 << sourceArrowP2, QPen(Qt::black), QBrush(Qt::black));
-        }
+      addLine(QLineF(sourceArrowP0, endP0), QPen(Qt::black));
+      addPolygon(QPolygonF() << sourceArrowP0 << sourceArrowP1 << sourceArrowP2,
+                 QPen(Qt::black), QBrush(Qt::black));
     }
+  }
 }
 
 void
@@ -89,10 +86,7 @@
   int rim = 3;
 
   // plot nodes
-  TrustTreeNodeList::const_iterator it  = nodeList.begin();
-  TrustTreeNodeList::const_iterator end = nodeList.end();
-  for(; it != end; it++)
-  {
+  for (TrustTreeNodeList::const_iterator it = nodeList.begin(); it != nodeList.end(); it++) {
     double x = (*it)->x;
     double y = (*it)->y;
     QRectF boundingRect(x, y, nodeSize, nodeSize);
@@ -108,9 +102,10 @@
     nickItem->setFont(QFont("Cursive", 8, QFont::Bold));
     nickItem->setPos(x - nodeSize / 2 + 10, y + nodeSize + 5);
   }
-
 }
 
+} //namespace chronos
+
 #if WAF
 #include "trust-tree-scene.moc"
 #include "trust-tree-scene.cpp.moc"