From f5c3009d23291f17be708ddcd38b5e9b1eb2fd7d Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Tue, 1 Nov 2005 05:36:28 +0000 Subject: [PATCH 1/1] Agrego posibilidad de ir al nodo anterior. --- viewer/view_btree.cpp | 19 ++++++++++++++++++- viewer/view_btree.h | 4 ++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/viewer/view_btree.cpp b/viewer/view_btree.cpp index 6a1fd16..eb2e067 100644 --- a/viewer/view_btree.cpp +++ b/viewer/view_btree.cpp @@ -16,10 +16,27 @@ ViewBTree::ViewBTree (Canvas::Group *parent, std::string filename, uint block_si byte_to_pixels = node_width/block_size; last_selected = NULL; + last_visited = 0; +} + +void ViewBTree::GoBack () +{ + uint l = back.top (); + back.pop (); + + Clear (); + AddNode (l, 1); } void ViewBTree::AddNode (uint num, uint padre) { + /* Hack de ultima hora :P */ + if (padre == 0) + /* evito quedar en circulo :D */ + back.push (last_visited); + + last_visited = num; + uchar *node = ReadBlock (num); BTreeNodeHeader node_h; @@ -45,7 +62,7 @@ void ViewBTree::on_item_activated (BTreeData *data, uint num, ViewNode *vnode) delete vnode; std::cout << next << std::endl; - AddNode (next, num); + AddNode (next, 0); } void ViewBTree::on_item_selected (BTreeData *data, uint num, ViewNode *vnode) diff --git a/viewer/view_btree.h b/viewer/view_btree.h index 894bf5d..18f4df7 100644 --- a/viewer/view_btree.h +++ b/viewer/view_btree.h @@ -4,6 +4,7 @@ #include #include +#include #include "btree.h" #include "view_node.h" @@ -18,6 +19,7 @@ class ViewBTree : public Canvas::Group, public BTree { void Clear (); void HighliteKey (Clave &k); + void GoBack (); static double byte_to_pixels; static double node_width; @@ -33,6 +35,8 @@ class ViewBTree : public Canvas::Group, public BTree { /* Control para no poner 2 veces un nodo */ /* Un nodo que quiera ser puesto 2 veces es un bug :) */ std::map node_placed; + std::stack back; + uint last_visited; public: void AddNode (uint num, uint padre = 0); -- 2.43.0