key viewer
diff --git a/src/cert-tree-model.cpp b/src/cert-tree-model.cpp
new file mode 100644
index 0000000..6af6e4e
--- /dev/null
+++ b/src/cert-tree-model.cpp
@@ -0,0 +1,60 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2014, Regents of the University of California,
+ *
+ * This file is part of NFD Control Center.  See AUTHORS.md for complete list of NFD
+ * authors and contributors.
+ *
+ * NFD Control Center is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * NFD Control Center is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with NFD
+ * Control Center, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "cert-tree-model.hpp"
+
+#ifdef WAF
+#include "cert-tree-model.moc"
+#endif
+
+namespace ndn {
+namespace ncc {
+
+CertTreeModel::CertTreeModel(int row, int column, QObject* parent)
+  : QStandardItemModel(row, column, parent)
+{
+}
+
+QVariant
+CertTreeModel::data(const QModelIndex& index, int role) const
+{
+  switch (role) {
+  case Qt::FontRole:
+    {
+      QFont font;
+      if (index.column() == 0) {
+        font.setBold(true);
+      }
+      return font;
+    }
+  case Qt::BackgroundRole:
+    {
+      QBrush brush(Qt::white, Qt::SolidPattern);
+      if (index.row() % 2 == 0) {
+        brush.setColor(Qt::lightGray);
+      }
+      return brush;
+    }
+  default:
+    return QStandardItemModel::data(index, role);
+  }
+}
+
+} // namespace ncc
+} // namespace ndn
diff --git a/src/cert-tree-model.hpp b/src/cert-tree-model.hpp
new file mode 100644
index 0000000..38693ad
--- /dev/null
+++ b/src/cert-tree-model.hpp
@@ -0,0 +1,43 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2014, Regents of the University of California,
+ *
+ * This file is part of NFD Control Center.  See AUTHORS.md for complete list of NFD
+ * authors and contributors.
+ *
+ * NFD Control Center is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * NFD Control Center is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with NFD
+ * Control Center, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef NDN_NCC_CERT_TREE_MODEL_HPP
+#define NDN_NCC_CERT_TREE_MODEL_HPP
+
+#include <QStandardItemModel>
+
+namespace ndn {
+namespace ncc {
+
+class CertTreeModel : public QStandardItemModel
+{
+  Q_OBJECT
+
+public:
+  explicit
+  CertTreeModel(int row, int column, QObject* parent = 0);
+
+  QVariant
+  data(const QModelIndex& index, int role) const Q_DECL_OVERRIDE;
+};
+
+} // namespace ncc
+} // namespace ndn
+
+#endif // NDN_NCC_CERT_TREE_MODEL_HPP
diff --git a/src/key-tree-item.cpp b/src/key-tree-item.cpp
index 070537e..bfc5788 100644
--- a/src/key-tree-item.cpp
+++ b/src/key-tree-item.cpp
@@ -24,10 +24,12 @@
 namespace ndn {
 namespace ncc {
 
-KeyTreeItem::KeyTreeItem(const QVariant& name, const QVariant& data, Type type, KeyTreeItem* parent)
+KeyTreeItem::KeyTreeItem(const QVariant& name, const QVariant& data,
+                         Type type, KeyTreeItem* parent)
   : m_name(name)
   , m_data(data)
   , m_type(type)
+  , m_isDefault(false)
   , m_parentItem(parent)
 {
 }
@@ -38,6 +40,12 @@
 }
 
 void
+KeyTreeItem::setDefault(bool isDefault)
+{
+  m_isDefault = isDefault;
+}
+
+void
 KeyTreeItem::setParent(KeyTreeItem* parent)
 {
   m_parentItem = parent;
diff --git a/src/key-tree-item.hpp b/src/key-tree-item.hpp
index 6d7a02a..aa21c9c 100644
--- a/src/key-tree-item.hpp
+++ b/src/key-tree-item.hpp
@@ -47,6 +47,15 @@
   ~KeyTreeItem();
 
   void
+  setDefault(bool isDefault);
+
+  bool
+  isDefault()
+  {
+    return m_isDefault;
+  }
+
+  void
   setParent(KeyTreeItem* parent);
 
   void
@@ -81,6 +90,7 @@
   QVariant m_name;
   QVariant m_data;
   Type m_type;
+  bool m_isDefault;
   KeyTreeItem* m_parentItem;
 };
 
diff --git a/src/key-tree-model.cpp b/src/key-tree-model.cpp
index ec4fc02..56c4ec1 100644
--- a/src/key-tree-model.cpp
+++ b/src/key-tree-model.cpp
@@ -21,6 +21,9 @@
 #include "key-tree-item.hpp"
 
 #include <QStringList>
+#include <QFont>
+#include <QBrush>
+#include <iostream>
 
 
 #ifdef WAF
@@ -84,12 +87,33 @@
   if (!index.isValid())
     return QVariant();
 
-  if (role != Qt::DisplayRole)
-    return QVariant();
 
   KeyTreeItem* item = static_cast<KeyTreeItem*>(index.internalPointer());
-
-  return item->data();
+  switch (role) {
+  case Qt::DisplayRole:
+    {
+      return item->data();
+    }
+  case Qt::FontRole:
+    {
+      QFont font;
+      if (item->isDefault()) {
+        font.setBold(true);
+      }
+      return font;
+    }
+  // case Qt::BackgroundRole:
+  //   {
+  //     std::cerr << "brush" << std::endl;
+  //     QBrush brush(Qt::white, Qt::SolidPattern);
+  //     if (index.row() % 2 == 0) {
+  //       brush.setColor(Qt::cyan);
+  //     }
+  //     return brush;
+  //   }
+  default:
+    return QVariant();
+  }
 }
 
 Qt::ItemFlags
diff --git a/src/key-viewer-dialog.cpp b/src/key-viewer-dialog.cpp
index 9a95bbd..530fdb2 100644
--- a/src/key-viewer-dialog.cpp
+++ b/src/key-viewer-dialog.cpp
@@ -23,6 +23,8 @@
 
 #include <iostream>
 
+#include <Qt>
+
 
 #ifdef WAF
 #include "key-viewer-dialog.moc"
@@ -31,6 +33,8 @@
 namespace ndn {
 namespace ncc {
 
+static int N_ROWS = 30;
+
 KeyViewerDialog::KeyViewerDialog(QWidget *parent)
   : QDialog(parent)
   , ui(new Ui::KeyViewerDialog)
@@ -41,6 +45,12 @@
   ui->treeView->setModel(m_model.get());
   ui->treeView->show();
 
+  m_tableModel = make_shared<CertTreeModel>(N_ROWS, 2);
+  m_tableModel->setHeaderData(0, Qt::Horizontal,"Field");
+  m_tableModel->setHeaderData(1, Qt::Horizontal,"Value");
+  ui->certView->setModel(m_tableModel.get());
+  ui->certView->show();
+
   connect(ui->treeView, SIGNAL(clicked(const QModelIndex&)), this, SLOT(displayCert(const QModelIndex&)));
 }
 
@@ -62,7 +72,9 @@
   std::vector<Name> defaultIdentities;
   m_keyChain->getAllIdentities(defaultIdentities, true);
   for (const auto& identity : defaultIdentities) {
-    newModel->addChild(createIdentityNode(identity));
+    auto idItem = createIdentityNode(identity);
+    idItem->setDefault(true);
+    newModel->addChild(idItem);
   }
 
   std::vector<Name> otherIdentities;
@@ -97,7 +109,10 @@
     parent = m_model->index(0, 0, parent);
   }
 
-  shared_ptr<QStandardItemModel> tableModel;
+  shared_ptr<CertTreeModel> tableModel = make_shared<CertTreeModel>(N_ROWS, 2);
+  tableModel->setHeaderData(0, Qt::Horizontal,"Field");
+  tableModel->setHeaderData(1, Qt::Horizontal,"Value");
+
   item = static_cast<KeyTreeItem*>(parent.internalPointer());
   if (item->type() == KeyTreeItem::Type::CERT) {
     std::cerr << item->name().toString().toStdString() << std::endl;
@@ -105,9 +120,9 @@
     shared_ptr<IdentityCertificate> cert =
       m_keyChain->getCertificate(Name(item->name().toString().toStdString()));
 
-    tableModel = make_shared<QStandardItemModel>(5, 2);
     tableModel->setItem(0, 0, new QStandardItem(QString("Name")));
     tableModel->setItem(0, 1, new QStandardItem(item->name().toString()));
+    // tableModel->setData(tableModel->index(0, 0), Qt::red, Qt::BackgroundRole);
 
     tableModel->setItem(1, 0, new QStandardItem(QString("NotBefore")));
     tableModel->setItem(1, 1, new QStandardItem(QString::fromStdString(time::toIsoString(cert->getNotBefore()))));
@@ -123,14 +138,11 @@
     tableModel->setItem(4, 1, new QStandardItem(QString::fromStdString(signerName.toUri())));
   }
   else {
-    tableModel = make_shared<QStandardItemModel>(5, 2);
+    tableModel->setItem(0, 0, new QStandardItem(QString("")));
+    tableModel->setItem(0, 1, new QStandardItem(QString("")));
   }
-  ui->tableView->setModel(tableModel.get());
-  ui->tableView->resizeColumnsToContents();
-  QHeaderView* header = ui->tableView->horizontalHeader();
-  header->setStretchLastSection(true);
-  ui->tableView->setHorizontalHeader(header);
-  ui->tableView->show();
+  ui->certView->setModel(tableModel.get());
+  ui->certView->show();
   m_tableModel = tableModel;
 }
 
@@ -144,7 +156,9 @@
   std::vector<Name> defaultKeys;
   m_keyChain->getAllKeyNamesOfIdentity(identity, defaultKeys, true);
   for (const auto& keyName : defaultKeys) {
-    idItem->appendChild(createKeyNode(keyName, idItem));
+    auto keyItem = createKeyNode(keyName, idItem);
+    keyItem->setDefault(true);
+    idItem->appendChild(keyItem);
   }
 
   std::vector<ndn::Name> otherKeys;
@@ -167,10 +181,12 @@
   std::vector<Name> defaultCertificates;
   m_keyChain->getAllCertificateNamesOfKey(keyName, defaultCertificates, true);
   for (const auto& certName : defaultCertificates) {
-    keyItem->appendChild(new KeyTreeItem(QVariant(QString::fromStdString(certName.toUri())),
-                                         QVariant(QString::fromStdString(certName[-1].toUri())),
-                                         KeyTreeItem::Type::CERT,
-                                         keyItem));
+    auto certItem = new KeyTreeItem(QVariant(QString::fromStdString(certName.toUri())),
+                                    QVariant(QString::fromStdString(certName[-1].toUri())),
+                                    KeyTreeItem::Type::CERT,
+                                    keyItem);
+    certItem->setDefault(true);
+    keyItem->appendChild(certItem);
   }
 
   std::vector<ndn::Name> otherCertificates;
diff --git a/src/key-viewer-dialog.hpp b/src/key-viewer-dialog.hpp
index 60996af..01261a5 100644
--- a/src/key-viewer-dialog.hpp
+++ b/src/key-viewer-dialog.hpp
@@ -21,10 +21,11 @@
 #define NDN_NCC_KEY_VIEWER_DIALOG_HPP
 
 #include "key-tree-model.hpp"
+#include "cert-tree-model.hpp"
 #include <ndn-cxx/security/key-chain.hpp>
 
 #include <QDialog>
-#include <QStandardItemModel>
+
 
 namespace Ui {
 class KeyViewerDialog;
@@ -76,7 +77,7 @@
   shared_ptr<KeyTreeModel> m_model;
   shared_ptr<KeyChain> m_keyChain;
 
-  shared_ptr<QStandardItemModel> m_tableModel;
+  shared_ptr<CertTreeModel> m_tableModel;
 };
 
 } // namespace ncc
diff --git a/src/key-viewer-dialog.ui b/src/key-viewer-dialog.ui
index e3b6e38..44e02b4 100644
--- a/src/key-viewer-dialog.ui
+++ b/src/key-viewer-dialog.ui
@@ -27,7 +27,7 @@
   </property>
   <layout class="QHBoxLayout" name="horizontalLayout_2">
    <item>
-    <layout class="QHBoxLayout" name="horizontalLayout" stretch="1,1">
+    <layout class="QHBoxLayout" name="horizontalLayout" stretch="3,2">
      <property name="sizeConstraint">
       <enum>QLayout::SetMaximumSize</enum>
      </property>
@@ -35,7 +35,11 @@
       <widget class="QTreeView" name="treeView"/>
      </item>
      <item>
-      <widget class="QTableView" name="tableView"/>
+      <widget class="QTreeView" name="certView">
+       <property name="indentation">
+        <number>0</number>
+       </property>
+      </widget>
      </item>
     </layout>
    </item>