diff options
| author | Amaury Pouly <amaury.pouly@gmail.com> | 2014-12-15 22:44:17 +0100 |
|---|---|---|
| committer | Amaury Pouly <amaury.pouly@gmail.com> | 2014-12-15 22:44:17 +0100 |
| commit | 94c4834bbbcda9ef71ec8d5ff080b41374d8e7c0 (patch) | |
| tree | a424068bce4a0374335f77bbf74a2d5c052118ca /utils/regtools/qeditor/utils.cpp | |
| parent | 3b3d9bf725a5b04e4cd9bc4254fbd2594b518e89 (diff) | |
| download | rockbox-94c4834bbbcda9ef71ec8d5ff080b41374d8e7c0.zip rockbox-94c4834bbbcda9ef71ec8d5ff080b41374d8e7c0.tar.gz rockbox-94c4834bbbcda9ef71ec8d5ff080b41374d8e7c0.tar.bz2 rockbox-94c4834bbbcda9ef71ec8d5ff080b41374d8e7c0.tar.xz | |
Revert "regtools/qeditor: use the new model, drop unused code"
This reverts commit 3b3d9bf725a5b04e4cd9bc4254fbd2594b518e89.
Gerrit did crap on this one.
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 448ed92..036f159 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 { const SocFieldCachedValue& v = value.value< SocFieldCachedValue >(); int bitcount = v.field().last_bit - v.field().first_bit; - QString name = v.value_name(); - QString strval = QString("0x%1").arg(v.value(), (bitcount + 3) / 4, 16, QChar('0')); - switch(m_mode) - { - case DisplayName: - if(name.size() > 0) - return name; - /* fallthrough */ - case DisplayValueAndName: - if(name.size() > 0) - return QString("%1 (%2)").arg(strval).arg(name); - /* fallthrough */ - case DisplayValue: - default: - return strval; - } + return QString("0x%1").arg(v.value(), (bitcount + 3) / 4, 16, QChar('0')); } else return QStyledItemDelegate::displayText(value, locale); @@ -543,25 +528,34 @@ void RegSexyDisplay::paintEvent(QPaintEvent *event) } /** - * GrowingTableView + * GrowingTextEdit */ -GrowingTableView::GrowingTableView(QWidget *parent) - :QTableView(parent) +GrowingTextEdit::GrowingTextEdit(QWidget *parent) + :QTextEdit(parent) { + connect(this, SIGNAL(textChanged()), this, SLOT(TextChanged())); + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); } -void GrowingTableView::setModel(QAbstractItemModel *m) +void GrowingTextEdit::TextChanged() +{ + int content_size = document()->documentLayout()->documentSize().height(); + content_size = qMax(content_size, fontMetrics().height()); + setFixedHeight(content_size + contentsMargins().top() + contentsMargins().bottom()); +} + +/** + * GrowingTableWidget + */ +GrowingTableWidget::GrowingTableWidget(QWidget *parent) + :QTableWidget(parent) { - if(model()) - disconnect(model(), SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), - this, SLOT(DataChanged(const QModelIndex&, const QModelIndex&))); - QTableView::setModel(m); connect(model(), SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), this, SLOT(DataChanged(const QModelIndex&, const QModelIndex&))); - DataChanged(QModelIndex(), QModelIndex()); } -void GrowingTableView::DataChanged(const QModelIndex& tl, const QModelIndex& br) +void GrowingTableWidget::DataChanged(const QModelIndex& tl, const QModelIndex& br) { Q_UNUSED(tl); Q_UNUSED(br); @@ -569,7 +563,7 @@ void GrowingTableView::DataChanged(const QModelIndex& tl, const QModelIndex& br) resizeColumnsToContents(); int h = contentsMargins().top() + contentsMargins().bottom(); h += horizontalHeader()->height(); - for(int i = 0; i < model()->rowCount(); i++) + for(int i = 0; i < rowCount(); i++) h += rowHeight(i); setMinimumHeight(h); } |