From 354f66865d010a90b1d81c83bcaf55115e5859e1 Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Mon, 5 Dec 2005 01:38:05 +0000 Subject: [PATCH] Muestro los datos borrados y que son recuperables. --- viewer/Makefile | 2 +- viewer/list_dialog.cpp | 28 ++++++++++++++++++++++++++++ viewer/list_dialog.h | 28 ++++++++++++++++++++++++++++ viewer/main.cpp | 1 + viewer/view_properties.cpp | 32 +++++++++++++++++++++++++++++++- viewer/view_properties.h | 12 +++++++++++- 6 files changed, 100 insertions(+), 3 deletions(-) create mode 100644 viewer/list_dialog.cpp create mode 100644 viewer/list_dialog.h diff --git a/viewer/Makefile b/viewer/Makefile index dd7bd7d..72b76b7 100644 --- a/viewer/Makefile +++ b/viewer/Makefile @@ -1,6 +1,6 @@ TARGET=viewer CXXFLAGS=-Wall -g `pkg-config gtkmm-2.4 libgnomecanvasmm-2.6 --cflags` -I../src -OBJECTS=main.o view_btree.o view_btree_data.o view_properties.o view_node.o new_tree_dialog.o view_debug.o +OBJECTS=main.o view_btree.o view_btree_data.o view_properties.o view_node.o new_tree_dialog.o key_dialog.o view_debug.o list_dialog.o all: $(TARGET) diff --git a/viewer/list_dialog.cpp b/viewer/list_dialog.cpp new file mode 100644 index 0000000..5eb0f98 --- /dev/null +++ b/viewer/list_dialog.cpp @@ -0,0 +1,28 @@ + +#include "list_dialog.h" + +#include + +ListDialog::ListDialog(const Glib::ustring& title, std::list &l): + Gtk::Dialog(title, true, true) +{ + list_store = Gtk::ListStore::create (columns); + list.set_model (list_store); + + list.append_column ("Valor", columns.col_key); + + std::list::iterator it = l.begin (); + while (it != l.end ()) { + Gtk::TreeModel::iterator iter = list_store->append(); + Gtk::TreeModel::Row row = *iter; + row[columns.col_key] = *it; + it++; + } + + get_vbox()->add (list); + + add_button(Gtk::StockID("gtk-ok"), Gtk::RESPONSE_OK); + set_size_request (200, 300); + show_all (); +} + diff --git a/viewer/list_dialog.h b/viewer/list_dialog.h new file mode 100644 index 0000000..1efabb1 --- /dev/null +++ b/viewer/list_dialog.h @@ -0,0 +1,28 @@ + +#ifndef _LIST_DIALOG_ +#define _LIST_DIALOG_ + +#include +#include + +class ListDialog : public Gtk::Dialog { + public: + ListDialog (const Glib::ustring& title, std::list &l); + private: + Gtk::ScrolledWindow area; + Gtk::TreeView list; + Glib::RefPtr list_store; + + class ModelColumns : public Gtk::TreeModel::ColumnRecord { + public: + ModelColumns(){ + add (col_key); + } + Gtk::TreeModelColumn col_key; + }; + + ModelColumns columns; +}; + +#endif + diff --git a/viewer/main.cpp b/viewer/main.cpp index 59f34f7..e6a7a86 100644 --- a/viewer/main.cpp +++ b/viewer/main.cpp @@ -150,6 +150,7 @@ void nuevo_arbol () int type = d.getKeyType (); int atype = d.getTreeType (); tree = Glib::RefPtr(new ViewBTree (real_canvas->root(), "test.idx", d.getBlockSize (), atype, type)); + real_frame->SetTree (tree); tree->signal_selected ().connect ( sigc::mem_fun (*real_frame, &ViewProperties::ShowItem) ); if (type == BTree::KEY_FIXED) { std::list lst; diff --git a/viewer/view_properties.cpp b/viewer/view_properties.cpp index 0e789df..b7be8dd 100644 --- a/viewer/view_properties.cpp +++ b/viewer/view_properties.cpp @@ -1,7 +1,8 @@ #include "view_properties.h" -ViewProperties::ViewProperties ():Frame () +ViewProperties::ViewProperties ():Frame (), + view_deleted_nodes ("Nodos\nRecuperables"),view_deleted_data ("Datos\nRecuperables") { lnode_num.set_use_markup (true); lnode_level.set_use_markup (true); @@ -46,13 +47,20 @@ ViewProperties::ViewProperties ():Frame () table.property_column_spacing () = 8; table.property_row_spacing () = 8; + bbox.pack_start (view_deleted_nodes, true, false, 8); + bbox.pack_start (view_deleted_data, true, false, 8); + hbox.pack_start (table, false, true, 8); hbox.pack_start (raw_view, true, true, 8); + hbox.pack_end (bbox, false, true, 8); table.set_size_request (250, 0); add (hbox); + view_deleted_nodes.signal_clicked ().connect ( sigc::mem_fun (*this, &ViewProperties::ViewDeletedNodes) ); + view_deleted_data.signal_clicked ().connect ( sigc::mem_fun (*this, &ViewProperties::ViewDeletedDatas) ); + property_label_xalign () = 0; set_label ("Propiedades"); set_shadow_type(Gtk::SHADOW_NONE); @@ -138,3 +146,25 @@ std::string ViewProperties::ToRaw (BTreeData *p) return ss.str (); } +void ViewProperties::ViewDeletedNodes (void) +{ + ListDialog *l = new ListDialog ("Nodos Borrados", tree->deleted_nodes); + + l->run (); + + delete l; +} + +void ViewProperties::ViewDeletedDatas (void) +{ + ListDialog *l = new ListDialog ("Datos Borrados", tree->deleted_block_data); + + l->run (); + + delete l; +} + +void ViewProperties::SetTree (Glib::RefPtr _tree) +{ + tree = _tree; +} diff --git a/viewer/view_properties.h b/viewer/view_properties.h index 2036513..8026c1b 100644 --- a/viewer/view_properties.h +++ b/viewer/view_properties.h @@ -5,19 +5,29 @@ #include #include "btree.h" #include "btree_data.h" +#include "list_dialog.h" +#include "view_btree.h" class ViewProperties:public Gtk::Frame { public: ViewProperties (); + + void SetTree (Glib::RefPtr tree); void ShowItem (BTreeData *, BTreeNodeHeader &header); private: + Glib::RefPtr tree; + void ViewProperties::ViewDeletedNodes (void); + void ViewProperties::ViewDeletedDatas (void); std::string ToRaw (BTreeData *); Gtk::Table table; Gtk::HBox hbox; Gtk::TextView raw_view; - + Gtk::VButtonBox bbox; + Gtk::Button view_deleted_nodes; + Gtk::Button view_deleted_data; + /* Node Info */ Gtk::Label node_num; Gtk::Label node_level; -- 2.43.0