MCPcopy Create free account
hub / github.com/KDE/labplot / SpreadsheetModel

Method SpreadsheetModel

src/backend/spreadsheet/SpreadsheetModel.cpp:41–77  ·  view source on GitHub ↗

! \class SpreadsheetModel \brief Model for the access to a Spreadsheet This is a model in the sense of Qt4 model/view framework which is used to access a Spreadsheet object from any of Qt4s view classes, typically a QTableView. Its main purposes are translating Spreadsheet signals into QAbstractItemModel signals and translating calls to the QAbstractItemModel read/write API into calls in

Source from the content-addressed store, hash-verified

39 \ingroup backend
40*/
41SpreadsheetModel::SpreadsheetModel(Spreadsheet* spreadsheet)
42 : QAbstractItemModel(nullptr)
43 , m_spreadsheet(spreadsheet)
44 , m_rowCount(spreadsheet->rowCount())
45 , m_verticalHeaderCount(spreadsheet->rowCount())
46 , m_columnCount(spreadsheet->columnCount()) {
47 updateVerticalHeader();
48 updateHorizontalHeader(false);
49 connect(m_spreadsheet, &Spreadsheet::aspectDescriptionChanged, this, &SpreadsheetModel::handleDescriptionChange);
50
51 // Used when single column gets deleted or added
52 connect(m_spreadsheet,
53 QOverload<const AbstractAspect*, int, const AbstractAspect*>::of(&Spreadsheet::childAspectAboutToBeAdded),
54 this,
55 &SpreadsheetModel::handleAspectAboutToBeAdded);
56 connect(m_spreadsheet, &Spreadsheet::childAspectAdded, this, &SpreadsheetModel::handleAspectAdded);
57 connect(m_spreadsheet, &Spreadsheet::childAspectAboutToBeRemoved, this, &SpreadsheetModel::handleAspectAboutToBeRemoved);
58 connect(m_spreadsheet, &Spreadsheet::childAspectRemoved, this, &SpreadsheetModel::handleAspectRemoved);
59
60 // Used when changing the column count
61 connect(m_spreadsheet, &Spreadsheet::aspectsAboutToBeInserted, this, &SpreadsheetModel::handleAspectsAboutToBeInserted);
62 connect(m_spreadsheet, &Spreadsheet::aspectsAboutToBeRemoved, this, &SpreadsheetModel::handleAspectsAboutToBeRemoved);
63 connect(m_spreadsheet, &Spreadsheet::aspectsInserted, this, &SpreadsheetModel::handleAspectsInserted);
64 connect(m_spreadsheet, &Spreadsheet::aspectsRemoved, this, &SpreadsheetModel::handleAspectsRemoved);
65
66 connect(m_spreadsheet, &Spreadsheet::rowsAboutToBeInserted, this, &SpreadsheetModel::handleRowsAboutToBeInserted);
67 connect(m_spreadsheet, &Spreadsheet::rowsAboutToBeRemoved, this, &SpreadsheetModel::handleRowsAboutToBeRemoved);
68 connect(m_spreadsheet, &Spreadsheet::rowsInserted, this, &SpreadsheetModel::handleRowsInserted);
69 connect(m_spreadsheet, &Spreadsheet::rowsRemoved, this, &SpreadsheetModel::handleRowsRemoved);
70
71 m_suppressSignals = true;
72 handleAspectsAboutToBeInserted(0, spreadsheet->columnCount() - 1);
73 handleAspectsInserted(0, spreadsheet->columnCount() - 1); // make connections
74 m_suppressSignals = false;
75
76 m_spreadsheet->setModel(this);
77}
78
79void SpreadsheetModel::suppressSignals(bool value) {
80 m_suppressSignals = value;

Callers

nothing calls this directly

Calls 3

rowCountMethod · 0.45
columnCountMethod · 0.45
setModelMethod · 0.45

Tested by

no test coverage detected