wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
SignalModel.cpp
Go to the documentation of this file.
1// Copyright 2015 - 2026, GIBIS-UNIFESP and the wiRedPanda contributors
2// SPDX-License-Identifier: GPL-3.0-or-later
3
5
6SignalModel::SignalModel(const int rows, const int columns, QObject *parent)
7 : QStandardItemModel(rows, columns, parent)
8{
9}
10
11Qt::ItemFlags SignalModel::flags(const QModelIndex &index) const
12{
13 Q_UNUSED(index)
14 // Cells are read-only in the model; editing is done programmatically via setCellValue()
15 return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
16}
17
18void SignalModel::setValue(const int row, const int col, const int value)
19{
20 setData(index(row, col), value, Qt::DisplayRole);
21}
22
23int SignalModel::value(const int row, const int col) const
24{
25 return index(row, col).data(Qt::DisplayRole).toInt();
26}
27
29{
30 m_inputRows = inputRows;
31}
32
33void SignalModel::notifyBulkChanged()
34{
35 emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
36}
37
39 : m_model(model)
40{
41 m_model.blockSignals(true);
42}
43
45{
46 m_model.blockSignals(false);
47 m_model.notifyBulkChanged();
48}
SignalModel for the beWavedDolphin waveform table.
BulkEditGuard(SignalModel &model)
void setValue(int row, int col, int value)
Sets the logic value (0/1) of the cell at (row, col).
int value(int row, int col) const
Returns the logic value (0/1) of the cell at (row, col).
void setInputRows(int inputRows)
Records how many leading rows are inputs (the rest are outputs).
int inputRows() const
Returns the number of input rows (the output rows follow them).
Definition SignalModel.h:55
SignalModel(int rows, int columns, QObject *parent=nullptr)
Constructs the model.
Qt::ItemFlags flags(const QModelIndex &index) const override