diff options
Diffstat (limited to 'utils/regtools/qeditor/utils.cpp')
-rw-r--r-- | utils/regtools/qeditor/utils.cpp | 48 |
1 files changed, 21 insertions, 27 deletions
diff --git a/utils/regtools/qeditor/utils.cpp b/utils/regtools/qeditor/utils.cpp index 448ed92c3e..036f1595a3 100644 --- a/utils/regtools/qeditor/utils.cpp +++ b/utils/regtools/qeditor/utils.cpp | |||
@@ -331,22 +331,7 @@ QString SocFieldCachedItemDelegate::displayText(const QVariant& value, const QLo | |||
331 | { | 331 | { |
332 | const SocFieldCachedValue& v = value.value< SocFieldCachedValue >(); | 332 | const SocFieldCachedValue& v = value.value< SocFieldCachedValue >(); |
333 | int bitcount = v.field().last_bit - v.field().first_bit; | 333 | int bitcount = v.field().last_bit - v.field().first_bit; |
334 | QString name = v.value_name(); | 334 | return QString("0x%1").arg(v.value(), (bitcount + 3) / 4, 16, QChar('0')); |
335 | QString strval = QString("0x%1").arg(v.value(), (bitcount + 3) / 4, 16, QChar('0')); | ||
336 | switch(m_mode) | ||
337 | { | ||
338 | case DisplayName: | ||
339 | if(name.size() > 0) | ||
340 | return name; | ||
341 | /* fallthrough */ | ||
342 | case DisplayValueAndName: | ||
343 | if(name.size() > 0) | ||
344 | return QString("%1 (%2)").arg(strval).arg(name); | ||
345 | /* fallthrough */ | ||
346 | case DisplayValue: | ||
347 | default: | ||
348 | return strval; | ||
349 | } | ||
350 | } | 335 | } |
351 | else | 336 | else |
352 | return QStyledItemDelegate::displayText(value, locale); | 337 | return QStyledItemDelegate::displayText(value, locale); |
@@ -543,25 +528,34 @@ void RegSexyDisplay::paintEvent(QPaintEvent *event) | |||
543 | } | 528 | } |
544 | 529 | ||
545 | /** | 530 | /** |
546 | * GrowingTableView | 531 | * GrowingTextEdit |
547 | */ | 532 | */ |
548 | GrowingTableView::GrowingTableView(QWidget *parent) | 533 | GrowingTextEdit::GrowingTextEdit(QWidget *parent) |
549 | :QTableView(parent) | 534 | :QTextEdit(parent) |
550 | { | 535 | { |
536 | connect(this, SIGNAL(textChanged()), this, SLOT(TextChanged())); | ||
537 | setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); | ||
538 | setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | ||
551 | } | 539 | } |
552 | 540 | ||
553 | void GrowingTableView::setModel(QAbstractItemModel *m) | 541 | void GrowingTextEdit::TextChanged() |
542 | { | ||
543 | int content_size = document()->documentLayout()->documentSize().height(); | ||
544 | content_size = qMax(content_size, fontMetrics().height()); | ||
545 | setFixedHeight(content_size + contentsMargins().top() + contentsMargins().bottom()); | ||
546 | } | ||
547 | |||
548 | /** | ||
549 | * GrowingTableWidget | ||
550 | */ | ||
551 | GrowingTableWidget::GrowingTableWidget(QWidget *parent) | ||
552 | :QTableWidget(parent) | ||
554 | { | 553 | { |
555 | if(model()) | ||
556 | disconnect(model(), SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), | ||
557 | this, SLOT(DataChanged(const QModelIndex&, const QModelIndex&))); | ||
558 | QTableView::setModel(m); | ||
559 | connect(model(), SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), | 554 | connect(model(), SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), |
560 | this, SLOT(DataChanged(const QModelIndex&, const QModelIndex&))); | 555 | this, SLOT(DataChanged(const QModelIndex&, const QModelIndex&))); |
561 | DataChanged(QModelIndex(), QModelIndex()); | ||
562 | } | 556 | } |
563 | 557 | ||
564 | void GrowingTableView::DataChanged(const QModelIndex& tl, const QModelIndex& br) | 558 | void GrowingTableWidget::DataChanged(const QModelIndex& tl, const QModelIndex& br) |
565 | { | 559 | { |
566 | Q_UNUSED(tl); | 560 | Q_UNUSED(tl); |
567 | Q_UNUSED(br); | 561 | Q_UNUSED(br); |
@@ -569,7 +563,7 @@ void GrowingTableView::DataChanged(const QModelIndex& tl, const QModelIndex& br) | |||
569 | resizeColumnsToContents(); | 563 | resizeColumnsToContents(); |
570 | int h = contentsMargins().top() + contentsMargins().bottom(); | 564 | int h = contentsMargins().top() + contentsMargins().bottom(); |
571 | h += horizontalHeader()->height(); | 565 | h += horizontalHeader()->height(); |
572 | for(int i = 0; i < model()->rowCount(); i++) | 566 | for(int i = 0; i < rowCount(); i++) |
573 | h += rowHeight(i); | 567 | h += rowHeight(i); |
574 | setMinimumHeight(h); | 568 | setMinimumHeight(h); |
575 | } | 569 | } |