[MDBViz] Switch from a QListView to a QTreeView for the ops

This lets us open & close groups and automates the hierarchy.

Change-Id: Ib6f0850a49b793d824fc25aa16be78e6a1a93d9e
Reviewed-on: https://skia-review.googlesource.com/43280
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/tools/mdbviz/Model.cpp b/tools/mdbviz/Model.cpp
index a3f8e1a..c292956 100644
--- a/tools/mdbviz/Model.cpp
+++ b/tools/mdbviz/Model.cpp
@@ -61,10 +61,25 @@
     return kStrings[(int)err];
 }
 
-const char* Model::getOpName(int index) {
+const char* Model::getOpName(int index) const {
     return SkDrawCommand::GetCommandString(fOps[index]->getType());
 }
 
+bool Model::isHierarchyPush(int index) const {
+    SkDrawCommand::OpType type = fOps[index]->getType();
+
+    return SkDrawCommand::kSave_OpType == type ||
+           SkDrawCommand::kSaveLayer_OpType == type ||
+           SkDrawCommand::kBeginDrawPicture_OpType == type;
+}
+
+bool Model::isHierarchyPop(int index) const {
+    SkDrawCommand::OpType type = fOps[index]->getType();
+
+    return SkDrawCommand::kRestore_OpType == type ||
+           SkDrawCommand::kEndDrawPicture_OpType == type;
+}
+
 void Model::setCurOp(int curOp) {
     SkASSERT(curOp < fOps.count());
 
@@ -96,5 +111,6 @@
     for (int i = 0; i < fOps.count(); ++i) {
         delete fOps[i];
     }
+    fOps.reset();
     fCurOp = 0;
 }