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

Method data

src/backend/spreadsheet/SpreadsheetModel.cpp:123–209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121}
122
123QVariant SpreadsheetModel::data(const QModelIndex& index, int role) const {
124 if (!index.isValid())
125 return {};
126
127 const int row = index.row();
128 const int col = index.column();
129 const Column* col_ptr = m_spreadsheet->column(col);
130
131 if (!col_ptr)
132 return {};
133
134 switch (role) {
135 case Qt::ToolTipRole:
136 if (col_ptr->isValid(row)) {
137 if (col_ptr->isMasked(row))
138 return {i18n("%1, masked (ignored in all operations)", col_ptr->asStringColumn()->textAt(row))};
139 else
140 return {col_ptr->asStringColumn()->textAt(row)};
141 } else {
142 if (col_ptr->isMasked(row))
143 return {i18n("invalid cell, masked (ignored in all operations)")};
144 else
145 return {i18n("invalid cell (ignored in all operations)")};
146 }
147 case Qt::EditRole:
148 if (col_ptr->columnMode() == AbstractColumn::ColumnMode::Double) {
149 double value = col_ptr->valueAt(row);
150 if (std::isnan(value))
151 return {QStringLiteral("-")};
152 else if (std::isinf(value))
153 return {QStringLiteral("inf")};
154 else
155 return {col_ptr->asStringColumn()->textAt(row)};
156 }
157
158 if (col_ptr->isValid(row))
159 return {col_ptr->asStringColumn()->textAt(row)};
160
161 // m_formula_mode is not used at the moment
162 // if (m_formula_mode)
163 // return QVariant(col_ptr->formula(row));
164
165 break;
166 case Qt::DisplayRole:
167 if (col_ptr->columnMode() == AbstractColumn::ColumnMode::Double) {
168 double value = col_ptr->valueAt(row);
169 if (std::isnan(value))
170 return {QStringLiteral("-")};
171 else if (std::isinf(value))
172 return {UTF8_QSTRING("∞")};
173 else
174 return {col_ptr->asStringColumn()->textAt(row)};
175 }
176
177 if (!col_ptr->isValid(row))
178 return {QStringLiteral("-")};
179
180 // m_formula_mode is not used at the moment

Callers 1

prepareImportMethod · 0.45

Calls 13

asStringColumnMethod · 0.80
QBrushClass · 0.50
isValidMethod · 0.45
rowMethod · 0.45
columnMethod · 0.45
isMaskedMethod · 0.45
textAtMethod · 0.45
columnModeMethod · 0.45
valueAtMethod · 0.45
isEmptyMethod · 0.45
indexOfMethod · 0.45
colorMethod · 0.45

Tested by

no test coverage detected