| 209 | } |
| 210 | |
| 211 | QVariant SpreadsheetModel::headerData(int section, Qt::Orientation orientation, int role) const { |
| 212 | if ((orientation == Qt::Horizontal && section > m_columnCount - 1) || (orientation == Qt::Vertical && section > m_rowCount - 1)) |
| 213 | return {}; |
| 214 | |
| 215 | // If a column in the spreadsheet gets remove, because of an import. It can happen, that MainWindow activates a different dockwidget, which |
| 216 | // leads to a redraw of the Spreadsheetview. During this import, the spreadsheetmodel m_columnCount and the spreadsheet column count are not in sync |
| 217 | if (m_suppressSignals) |
| 218 | return {}; |
| 219 | |
| 220 | switch (orientation) { |
| 221 | case Qt::Horizontal: |
| 222 | switch (role) { |
| 223 | case Qt::DisplayRole: |
| 224 | case Qt::ToolTipRole: |
| 225 | case Qt::EditRole: |
| 226 | return m_horizontal_header_data.at(section); |
| 227 | case Qt::DecorationRole: |
| 228 | return m_spreadsheet->child<Column>(section)->icon(); |
| 229 | case static_cast<int>(CustomDataRole::CommentRole): |
| 230 | // Return the comment associated with the column |
| 231 | return m_spreadsheet->child<Column>(section)->comment(); |
| 232 | |
| 233 | case static_cast<int>(CustomDataRole::SparkLineRole): { |
| 234 | // Return the sparkline associated with the column |
| 235 | return m_spreadsheet->child<Column>(section)->sparkline(); |
| 236 | } |
| 237 | } |
| 238 | break; |
| 239 | case Qt::Vertical: |
| 240 | switch (role) { |
| 241 | case Qt::DisplayRole: |
| 242 | case Qt::ToolTipRole: |
| 243 | return section + 1; |
| 244 | } |
| 245 | } |
| 246 | |
| 247 | return {}; |
| 248 | } |
| 249 | |
| 250 | int SpreadsheetModel::rowCount(const QModelIndex& /*parent*/) const { |
| 251 | return m_rowCount; |
no test coverage detected