Move back to QTableWidget so we get proper programmatic access to rows/cells
authorChristoph Egger <siccegge@faui49man12.informatik.uni-erlangen.de>
Thu, 15 Jan 2015 16:39:05 +0000 (17:39 +0100)
committerChristoph Egger <siccegge@faui49man12.informatik.uni-erlangen.de>
Thu, 15 Jan 2015 16:39:05 +0000 (17:39 +0100)
src/gui/widgets/BasicBlockWidget.cxx
src/gui/widgets/BasicBlockWidget.hxx

index cceb2ffd26a064d57464b0b4b0df9d93bfe95abf..c434c46949f6a4cede34ea28652ba2f1c5c2c61f 100644 (file)
@@ -5,12 +5,20 @@ BasicBlockWidget::BasicBlockWidget(const QString& name, BasicBlock * block)
        , name(name), block(block)
        , _proxy(this) {
        next[0] = NULL; next[1] = NULL;
+       _widget.setStyleSheet("QTableWidget { background-color : #ddddff; }");
+       _widget.setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
+       _widget.verticalHeader()->setDefaultSectionSize(18);
+       _widget.setColumnCount(3);
+       _widget.verticalHeader()->hide();
+       _widget.horizontalHeader()->hide();
+       _widget.setShowGrid(false);
+       _widget.setWordWrap(false);
+       _widget.setMinimumSize(210, 40);
+
        _proxy.setWidget(&_widget);
-       _widget.setTextInteractionFlags(Qt::TextSelectableByMouse|Qt::LinksAccessibleByMouse);
-       _widget.setStyleSheet("QLabel { background-color : #ddddff; }");
        _proxy.setPos(5, 20);
 
-       if (width < 270) width = 270;
+       if (width < 250) width = 250;
 }
 
 void BasicBlockWidget::addItem(uint8_t* bytes, size_t num_bytes,
@@ -24,24 +32,16 @@ void BasicBlockWidget::addItem(uint8_t* bytes, size_t num_bytes,
                bytestring += ' ';
        }
 
-       QString old_text = _widget.text();
-       if (old_text == "") {
-               old_text = "<table>";
-       }
-
-       line = line.toHtmlEscaped();
-       if (href != "") {
-               line = "<a href=\"" + href + "\">" + line + "</a>";
-       }
+       int current_row = _widget.rowCount();
+       _widget.setRowCount(1 + current_row);
+       _widget.setItem(current_row, 0, new QTableWidgetItem(bytestring));
+       _widget.setItem(current_row, 1, new QTableWidgetItem(line.replace('\t', ' ')));
+//     _widget.setItem(current_row, 2, new QTableWidgetItem(href));
 
-       QString new_text =
-               old_text.remove("</table>") +
-               "<tr><td>" + bytestring +
-               "</td><td>" + line +
-               "</td><td>" + "" +
-               "</td></tr></table>";
+       _widget.resizeColumnToContents(0);
+       _widget.resizeColumnToContents(1);
+       _widget.resizeColumnToContents(2);
 
-       _widget.setText(new_text);
        width = 12 + _widget.sizeHint().width();
        height = 25 + _widget.sizeHint().height();
 
index 0087e05011d6d93bdbe7758779cb80a06342cc73..30f2babce3ff260d84b0152b9987423739304408 100644 (file)
@@ -64,7 +64,7 @@ public:
 private:
        uint32_t width, height;
        QGraphicsProxyWidget _proxy;
-       QLabel _widget;
+       QTableWidget _widget;
        QString name;
        BasicBlock * block;
        std::vector<BasicBlockWidget*> previous;