1. Alec Brooks
  2. trehe

Commits

Zenchreal  committed 3957f2f

Inspector window small improvements

  • Participants
  • Parent commits 4c62340
  • Branches default

Comments (0)

Files changed (4)

File src/ui/InspectorMoreDialog.cpp

View file
 #include "ui_InspectorMoreDialog.h"
 #include <QStandardItemModel>
 #include <QStandardItem>
+#include <QSortFilterProxyModel>
 
 
 InspectorMoreDialog::InspectorMoreDialog(QWidget* parent) :
 	// Set up the tree view
 	model = new QStandardItemModel();
 	model->setHorizontalHeaderLabels(QStringList() << tr("Type") << tr("Value"));
-	ui->tree->setModel(model);
+	
+	QSortFilterProxyModel* proxy = new QSortFilterProxyModel();
+	proxy->setSourceModel(model);
+
+	ui->tree->setModel(proxy);
+	ui->tree->setSortingEnabled(true);
 	ui->tree->setIndentation(0);
 	ui->tree->setDragEnabled(false);
 	ui->tree->setAcceptDrops(false);
 	{
 		// Correct endian for the interp
 		interp->setEndian(defaultEndianValue);
+
+		std::string valueString;
+		Interpretation::Result result;
+		
+		result = interp->bytesToStringBounded(
+			(const uint8_t*) bytes.data(),
+			bytes.size(),
+			valueString,
+			64
+		);
+		
+		if (result != Interpretation::SUCCESS)
+		{
+			valueString = "oops";
+		}
 		
 		QStandardItem* name = new QStandardItem(interp->name().c_str()); // TODO
-		QStandardItem* value = new QStandardItem("...");
+		QStandardItem* value = new QStandardItem(valueString.c_str());
 
 		// Type name should be bold
 		QFont font = name->font();
 
 		model->appendRow(QList<QStandardItem*>() << name << value);
 	}
+
+	ui->tree->setSortingEnabled(true);
 }
 
 size_t InspectorMoreDialog::result() const

File src/ui/InspectorWindow.cpp

View file
 
 void InspectorWindow::updateValues(QByteArray bytes)
 {
+	lastBytes = bytes;
+
 	for (int i = 0; i < model->rowCount(); i++)
 	{
 		QStandardItem* valueItem = model->item(i, 1);
 	std::vector<shared_ptr<Interpretation>> list;
 	
 	Interpretation::listAll(list);
-	dlg.updateList(list, QByteArray());
+	dlg.updateList(list, lastBytes);
 	dlg.exec();
 }
 

File src/ui/InspectorWindow.hpp

View file
 
 	bool blockItemChanged;
 
+	// This is a hack for now. We store the last bytes sent to updateValues so
+	// we have then for the more dialog.
+	QByteArray lastBytes;
+
 	// Context menu actions
 	QAction* hideAct;
 	QAction* moreAct;

File src/ui/MarksWindow.cpp

View file
 	setWindowTitle(tr("Marks"));
 	createContextMenu();
 	
-	tree->setItemDelegateForColumn(1, new ComboDelegate());
+	//tree->setItemDelegateForColumn(1, new ComboDelegate());
 
 	connect(model, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(itemChanged(QStandardItem*)));
 	connect(tree, SIGNAL(clicked(const QModelIndex&)), this, SLOT(itemClicked(const QModelIndex&)));