#include "memorymodel.h" MemoryModel::MemoryModel(int segments, int registers_per_segment, QObject *parent) : QAbstractItemModel(parent) , m_memoryData() { for(int nCount = 0; nCount < segments; nCount++) { m_memoryData.insert( nCount, QVector(registers_per_segment, 0x00) ); } } int MemoryModel::columnCount(const QModelIndex &parent) const { if(rowCount(parent) > 0) { return m_memoryData.value(0).count(); } return 0; } QVariant MemoryModel::data(const QModelIndex &index, int role) const { int segment = index.row(); int reg = index.column(); switch(role) { case Qt::DisplayRole: return QVariant(m_memoryData.value(segment).at(reg)); default: return QVariant(); } } QVariant MemoryModel::headerData(int section, Qt::Orientation orientation, int role) const { // Make sure we stay within the header boundaries... // ColumnNames if(role == Qt::DisplayRole && orientation == Qt::Horizontal && section < m_headers.size()) { return m_headers.at(section); } return QVariant(); } QModelIndex MemoryModel::index(int row, int column, const QModelIndex &parent) const { } QModelIndex MemoryModel::parent(const QModelIndex &index) const { Q_UNUSED(index) return QModelIndex(); } int MemoryModel::rowCount(const QModelIndex &parent) const { return m_memoryData.count(); } bool MemoryModel::setData(const QModelIndex &index, const QVariant &value, int role) { } bool MemoryModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role) { }