Blame view

src/memorymodel/memorymodel.cpp 1.61 KB
25f07764   Peter M. Groen   Implementing the ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
  #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<uint16_t>(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)
  {
  
  }