From eb54db85888d61ef72fb6dc6b8964360635faa60 Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Mon, 26 Sep 2005 05:57:58 +0000 Subject: [PATCH] Agrego vista de debugging. --- viewer/Makefile | 2 +- viewer/view_debug.cpp | 38 ++++++++++++++++++++++++++++++++++++++ viewer/view_debug.h | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 viewer/view_debug.cpp create mode 100644 viewer/view_debug.h diff --git a/viewer/Makefile b/viewer/Makefile index f3603ed..dd7bd7d 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 +OBJECTS=main.o view_btree.o view_btree_data.o view_properties.o view_node.o new_tree_dialog.o view_debug.o all: $(TARGET) diff --git a/viewer/view_debug.cpp b/viewer/view_debug.cpp new file mode 100644 index 0000000..60d4ca4 --- /dev/null +++ b/viewer/view_debug.cpp @@ -0,0 +1,38 @@ + +#include "view_debug.h" + +ViewDebug::ViewDebug (BTree *t):Gtk::VBox (), + testkeys ("Comprobar") +{ + btree = t; + list_store = Gtk::ListStore::create (columns); + list.set_model (list_store); + + list.append_column ("Clave", columns.col_key_string); + list.append_column ("Encontrada", columns.col_key_verified); + + pack_start (list, true, true, 8); + pack_end (testkeys, false, true, 8); + + testkeys.signal_clicked().connect( sigc::mem_fun(*this, &ViewDebug::on_test_clicked) ); +} + +void ViewDebug::AddKey (const Clave &k) +{ + Gtk::TreeModel::Row row = *(list_store->append()); + row[columns.col_key_string] = k; + row[columns.col_key_verified] = false; + row[columns.col_key] = k.Clone (); +} + +void ViewDebug::on_test_clicked () +{ + Gtk::TreeModel::Children rows = list_store->children (); + for(Gtk::TreeModel::Children::iterator iter = rows.begin(); iter != rows.end(); ++iter) + { + Gtk::TreeModel::Row row = *iter; + if (btree->FindKey (*row[columns.col_key])) + row[columns.col_key_verified] = true; + } +} + diff --git a/viewer/view_debug.h b/viewer/view_debug.h new file mode 100644 index 0000000..5f400bc --- /dev/null +++ b/viewer/view_debug.h @@ -0,0 +1,39 @@ + +#ifndef _VIEW_DEBUG_H_ +#define _VIEW_DEBUG_H_ + +#include +#include "btree.h" + +class ViewDebug:public Gtk::VBox { + public: + ViewDebug (BTree *); + + void AddKey (const Clave &k); + private: + /* Slots */ + void on_test_clicked (); + + BTree *btree; + + Gtk::Button testkeys; + Gtk::TreeView list; + Glib::RefPtr list_store; + + class ModelColumns : public Gtk::TreeModel::ColumnRecord { + public: + ModelColumns(){ + add (col_key_string); + add (col_key_verified); + add (col_key); + } + Gtk::TreeModelColumn col_key_string; + Gtk::TreeModelColumn col_key_verified; + Gtk::TreeModelColumn col_key; + }; + + ModelColumns columns; +}; + +#endif + -- 2.43.0