]> git.siccegge.de Git - frida/frida.git/blobdiff - src/gui/widgets/BasicBlockWidget.hxx
Move to table widget -- looks nicer and matches better
[frida/frida.git] / src / gui / widgets / BasicBlockWidget.hxx
index 7f4a0a36dfb791aff828b98e79f60bf741f4f4cf..98d3e6301b266b5d4c51663b08b7e57cd26a9844 100644 (file)
@@ -7,20 +7,55 @@ public:
                : x(-5), y(-20)
                , dx(270), dy(45)
                , name(name) {
-               _widget.setMinimumWidth(_widget.sizeHintForColumn(0) + 10);
+               _widget.setMinimumHeight(_widget.rowHeight(0) + 10);
                _widget.setMaximumHeight(20);
-               dx = _widget.sizeHintForColumn(0) + 20;
+               _widget.setColumnCount(3);
+               _widget.verticalHeader()->hide();
+               _widget.horizontalHeader()->hide();
+               dx = _widget.rowHeight(0) + 20;
                if (dx < 270) dx = 270;
     }
 
-       void addItem(const QString& line) {
-               _widget.addItem(line);
+       void addItem(uint8_t* bytes, size_t num_bytes,
+                                const QString& line) {
+               size_t current_row = _widget.rowCount();
+               int column_width;
+
+               QString bytestring;
+
+               for (size_t i(0); i < num_bytes; ++i) {
+                       const char * hexdigits = "0123456789ABCDEF";
+                       bytestring += hexdigits[(bytes[i] >> 4) & 0xF];
+                       bytestring += hexdigits[bytes[i] & 0xF];
+                       bytestring += ' ';
+               }
+
+               _widget.setRowCount(current_row + 1);
+
+               _widget.setItem(current_row, 0, new QTableWidgetItem(bytestring));
+               _widget.setItem(current_row, 1, new QTableWidgetItem(line));
+               _widget.setItem(current_row, 2, new QTableWidgetItem(""));
                _widget.updateGeometry();
-               _widget.setMinimumWidth(_widget.sizeHintForColumn(0) + 10);
-               _widget.setMinimumHeight(_widget.sizeHintForRow(0) * (1 + _widget.count()));
-               _widget.setMaximumHeight(_widget.sizeHintForRow(0) * (1 + _widget.count()));
-               dy = _widget.sizeHintForRow(0) * (1 + _widget.count()) + 25;
-               dx = _widget.sizeHintForColumn(0) + 20;
+
+               _widget.resizeColumnToContents(0);
+               _widget.resizeColumnToContents(1);
+               _widget.resizeColumnToContents(2);
+
+               _widget.resizeRowToContents(current_row);
+
+               column_width =
+                       _widget.columnWidth(0) +
+                       _widget.columnWidth(1) +
+                       _widget.columnWidth(2) +
+                       2;
+
+               _widget.setMinimumWidth(column_width);
+               _widget.setMinimumHeight(_widget.rowHeight(1) * (_widget.rowCount()) + 2);
+               _widget.setMaximumHeight(_widget.rowHeight(1) * (_widget.rowCount()) + 2);
+
+
+               dy = _widget.rowHeight(0) * (_widget.rowCount()) + 25;
+               dx = column_width + 10;
                if (dx < 270) dx = 270;
        }
 
@@ -42,6 +77,6 @@ public:
     }
 private:
     int x, y, dx, dy;
-    QListWidget _widget;
+    QTableWidget _widget;
        QString name;
 };