From 459e107cb0f6fcf17618e06837fc8ff5b3f0ce8d Mon Sep 17 00:00:00 2001 From: Christoph Egger Date: Thu, 15 Jan 2015 17:39:05 +0100 Subject: [PATCH] Move back to QTableWidget so we get proper programmatic access to rows/cells --- src/gui/widgets/BasicBlockWidget.cxx | 38 ++++++++++++++-------------- src/gui/widgets/BasicBlockWidget.hxx | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/gui/widgets/BasicBlockWidget.cxx b/src/gui/widgets/BasicBlockWidget.cxx index cceb2ff..c434c46 100644 --- a/src/gui/widgets/BasicBlockWidget.cxx +++ b/src/gui/widgets/BasicBlockWidget.cxx @@ -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 = ""; - } - - line = line.toHtmlEscaped(); - if (href != "") { - line = "" + line + ""; - } + 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("
") + - "" + bytestring + - "" + line + - "" + "" + - ""; + _widget.resizeColumnToContents(0); + _widget.resizeColumnToContents(1); + _widget.resizeColumnToContents(2); - _widget.setText(new_text); width = 12 + _widget.sizeHint().width(); height = 25 + _widget.sizeHint().height(); diff --git a/src/gui/widgets/BasicBlockWidget.hxx b/src/gui/widgets/BasicBlockWidget.hxx index 0087e05..30f2bab 100644 --- a/src/gui/widgets/BasicBlockWidget.hxx +++ b/src/gui/widgets/BasicBlockWidget.hxx @@ -64,7 +64,7 @@ public: private: uint32_t width, height; QGraphicsProxyWidget _proxy; - QLabel _widget; + QTableWidget _widget; QString name; BasicBlock * block; std::vector previous; -- 2.39.5