aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFanda Vacek <fanda.vacek@gmail.com>2019-02-09 20:06:55 +0100
committerPavel Pisa <pisa@cmp.felk.cvut.cz>2019-02-09 21:55:54 +0100
commitfa867875a15faf61ceef4bbc7b6e4f281fa91954 (patch)
tree4a24652616541618a3513faaa23f9d9f5f940ca3
parent3e505068b88edb726dcc16969fdd86c479f49022 (diff)
downloadqtmips-fa867875a15faf61ceef4bbc7b6e4f281fa91954.tar.gz
qtmips-fa867875a15faf61ceef4bbc7b6e4f281fa91954.tar.bz2
qtmips-fa867875a15faf61ceef4bbc7b6e4f281fa91954.zip
Correct MemoryDock header fields values.
-rw-r--r--qtmips_gui/memorymodel.cpp29
-rw-r--r--qtmips_gui/memorymodel.h6
2 files changed, 22 insertions, 13 deletions
diff --git a/qtmips_gui/memorymodel.cpp b/qtmips_gui/memorymodel.cpp
index 5596b35..71df4ce 100644
--- a/qtmips_gui/memorymodel.cpp
+++ b/qtmips_gui/memorymodel.cpp
@@ -40,20 +40,10 @@ MemoryModel::MemoryModel(QObject *parent)
cell_size = CELLSIZE_WORD;
cells_per_row = 1;
index0_offset = 0;
- updateHeaderLabels();
-}
-
-void MemoryModel::updateHeaderLabels() {
- setHeaderData(0, Qt::Horizontal, QString("Address"));
- for (unsigned int i = 0; i < cells_per_row; i++) {
- std::uint32_t addr = i * cellSizeBytes();
- setHeaderData(i + 1, Qt::Horizontal, QString("+0x") +
- QString::number(addr, 16));
- }
}
int MemoryModel::rowCount(const QModelIndex & /*parent*/) const {
- std::uint64_t rows = (0x10000000 + cells_per_row - 1) / cells_per_row;
+ std::uint64_t rows = (0x100 + cells_per_row - 1) / cells_per_row;
return rows;
}
@@ -61,6 +51,23 @@ int MemoryModel::columnCount(const QModelIndex & /*parent*/) const {
return 2;
}
+QVariant MemoryModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ if(orientation == Qt::Horizontal) {
+ if(role == Qt::DisplayRole) {
+ if(section == 0) {
+ return tr("Address");
+ }
+ else {
+ std::uint32_t addr = (section - 1) * cellSizeBytes();
+ QString ret = "+0x" + QString::number(addr, 16);
+ return ret;
+ }
+ }
+ }
+ return Super::headerData(section, orientation, role);
+}
+
QVariant MemoryModel::data(const QModelIndex &index, int role) const {
if (role == Qt::DisplayRole)
{
diff --git a/qtmips_gui/memorymodel.h b/qtmips_gui/memorymodel.h
index badb224..8a01531 100644
--- a/qtmips_gui/memorymodel.h
+++ b/qtmips_gui/memorymodel.h
@@ -41,6 +41,8 @@
class MemoryModel : public QAbstractTableModel
{
Q_OBJECT
+
+ using Super = QAbstractTableModel;
public:
enum MemoryCellSize {
CELLSIZE_BYTE,
@@ -51,10 +53,10 @@ public:
MemoryModel(QObject *parent);
int rowCount(const QModelIndex &parent = QModelIndex()) const override ;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
private:
- void updateHeaderLabels();
- inline unsigned int cellSizeBytes() {
+ inline unsigned int cellSizeBytes() const {
switch (cell_size) {
case CELLSIZE_BYTE:
return 1;