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

Method color

src/backend/spreadsheet/SpreadsheetModel.cpp:564–595  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

562}
563
564QVariant SpreadsheetModel::color(const AbstractColumn* column, int row, AbstractColumn::Formatting type) const {
565 if (!column->hasHeatmapFormat() || (!column->isNumeric() && column->columnMode() != AbstractColumn::ColumnMode::Text) || !column->isValid(row))
566 return {};
567
568 const auto& format = column->heatmapFormat();
569 if (format.type != type || format.colors.isEmpty())
570 return {};
571
572 int index = 0;
573 if (column->isNumeric()) {
574 double value = column->valueAt(row);
575 double range = (format.max - format.min) / format.colors.count();
576
577 if (value > format.max)
578 index = format.colors.count() - 1;
579 else {
580 for (int i = 0; i < format.colors.count(); ++i) {
581 if (value <= format.min + (i + 1) * range) {
582 index = i;
583 break;
584 }
585 }
586 }
587 } else {
588 index = column->dictionaryIndex(row);
589 }
590
591 if (index < format.colors.count())
592 return {QColor(format.colors.at(index))};
593 else
594 return {QColor(format.colors.constLast())};
595}

Callers 15

setHtmlMethod · 0.45
defaultIconColorMethod · 0.45
paintEventMethod · 0.45
paintEventMethod · 0.45
highlightBlockMethod · 0.45
isDarkModeMethod · 0.45
retranslateUiMethod · 0.45
loadMethod · 0.45
updateAxisColorMethod · 0.45
loadConfigMethod · 0.45
saveConfigAsTemplateMethod · 0.45
updateModelEquationMethod · 0.45

Calls 9

hasHeatmapFormatMethod · 0.80
QColorClass · 0.50
isNumericMethod · 0.45
columnModeMethod · 0.45
isValidMethod · 0.45
isEmptyMethod · 0.45
valueAtMethod · 0.45
countMethod · 0.45
dictionaryIndexMethod · 0.45

Tested by 13

dataMethod · 0.36
setTitleColorMethod · 0.36
setMajorTickColorMethod · 0.36
setMinorTickColorMethod · 0.36
setLineColorMethod · 0.36
setTickLabelColorMethod · 0.36
setTitleColorMethod · 0.36
setMajorTickColorMethod · 0.36
setMinorTickColorMethod · 0.36
setLineColorMethod · 0.36
setTickLabelColorMethod · 0.36
cursorCurveColorMethod · 0.36