summaryrefslogtreecommitdiff
path: root/utils/regtools/qeditor/utils.cpp
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2014-10-22 18:00:59 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2014-12-15 22:57:20 +0100
commit5dab7688380fdb2beccaca47091ebcc85042fab6 (patch)
tree8534394d85bda0499407a84deb1f6e133db3ac40 /utils/regtools/qeditor/utils.cpp
parentabed208efbba78b502c94408b0c9b97c8ab61e14 (diff)
downloadrockbox-5dab7688380fdb2beccaca47091ebcc85042fab6.zip
rockbox-5dab7688380fdb2beccaca47091ebcc85042fab6.tar.gz
rockbox-5dab7688380fdb2beccaca47091ebcc85042fab6.tar.bz2
rockbox-5dab7688380fdb2beccaca47091ebcc85042fab6.tar.xz
regtools/qeditor: use the new model, drop unused code
Change-Id: Ic4e2e201f6d055c85d52b7fe15d25980386df5b8 Reviewed-on: http://gerrit.rockbox.org/1023 Reviewed-by: Amaury Pouly <amaury.pouly@gmail.com>
Diffstat (limited to 'utils/regtools/qeditor/utils.cpp')
-rw-r--r--utils/regtools/qeditor/utils.cpp48
1 files changed, 27 insertions, 21 deletions
diff --git a/utils/regtools/qeditor/utils.cpp b/utils/regtools/qeditor/utils.cpp
index df7f714..5aef241 100644
--- a/utils/regtools/qeditor/utils.cpp
+++ b/utils/regtools/qeditor/utils.cpp
@@ -371,7 +371,22 @@ QString SocFieldCachedItemDelegate::displayText(const QVariant& value, const QLo
{
const SocFieldCachedValue& v = value.value< SocFieldCachedValue >();
int bitcount = v.field().last_bit - v.field().first_bit;
- return QString("0x%1").arg(v.value(), (bitcount + 3) / 4, 16, QChar('0'));
+ 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;
+ }
}
else
return QStyledItemDelegate::displayText(value, locale);
@@ -791,34 +806,25 @@ void RegSexyDisplay::paintEvent(QPaintEvent *event)
}
/**
- * GrowingTextEdit
+ * GrowingTableView
*/
-GrowingTextEdit::GrowingTextEdit(QWidget *parent)
- :QTextEdit(parent)
-{
- connect(this, SIGNAL(textChanged()), this, SLOT(TextChanged()));
- setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
- setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-}
-
-void GrowingTextEdit::TextChanged()
+GrowingTableView::GrowingTableView(QWidget *parent)
+ :QTableView(parent)
{
- 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)
+void GrowingTableView::setModel(QAbstractItemModel *m)
{
+ 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 GrowingTableWidget::DataChanged(const QModelIndex& tl, const QModelIndex& br)
+void GrowingTableView::DataChanged(const QModelIndex& tl, const QModelIndex& br)
{
Q_UNUSED(tl);
Q_UNUSED(br);
@@ -826,7 +832,7 @@ void GrowingTableWidget::DataChanged(const QModelIndex& tl, const QModelIndex& b
resizeColumnsToContents();
int h = contentsMargins().top() + contentsMargins().bottom();
h += horizontalHeader()->height();
- for(int i = 0; i < rowCount(); i++)
+ for(int i = 0; i < model()->rowCount(); i++)
h += rowHeight(i);
setMinimumHeight(h);
}