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

Method updateProperties

src/backend/core/column/ColumnPrivate.cpp:3092–3276  ·  view source on GitHub ↗

! * Updates the properties. Will be called, when data in the column changed. * The properties will be used to speed up some algorithms. * See where variable properties will be used. */

Source from the content-addressed store, hash-verified

3090 * See where variable properties will be used.
3091 */
3092void ColumnPrivate::updateProperties() {
3093 PERFTRACE(name() + QLatin1String(Q_FUNC_INFO));
3094
3095 // TODO: for double Properties::Constant will never be used. Use an epsilon (difference smaller than epsilon is zero)
3096 const int rows = rowCount();
3097 if (rows == 0 || m_columnMode == AbstractColumn::ColumnMode::Text) {
3098 properties = AbstractColumn::Properties::No;
3099 available.properties = true;
3100 return;
3101 }
3102
3103 double prevValue = NAN;
3104 int prevValueInt = 0;
3105 qint64 prevValueBigInt = 0;
3106 qint64 prevValueDatetime = 0;
3107
3108 if (m_columnMode == AbstractColumn::ColumnMode::Integer)
3109 prevValueInt = integerAt(0);
3110 else if (m_columnMode == AbstractColumn::ColumnMode::BigInt)
3111 prevValueBigInt = bigIntAt(0);
3112 else if (m_columnMode == AbstractColumn::ColumnMode::Double)
3113 prevValue = doubleAt(0);
3114 else if (m_columnMode == AbstractColumn::ColumnMode::DateTime || m_columnMode == AbstractColumn::ColumnMode::Month
3115 || m_columnMode == AbstractColumn::ColumnMode::Day)
3116 prevValueDatetime = dateTimeAt(0).toMSecsSinceEpoch();
3117 else {
3118 properties = AbstractColumn::Properties::No;
3119 available.properties = true;
3120 return;
3121 }
3122
3123 int monotonic_decreasing = -1;
3124 int monotonic_increasing = -1;
3125
3126 double value;
3127 int valueInt;
3128 qint64 valueBigInt;
3129 qint64 valueDateTime;
3130 for (int row = 1; row < rows; row++) {
3131 if (!q->isValid(row) || q->isMasked(row)) {
3132 // if there is one invalid or masked value, the property is No, because
3133 // otherwise it's difficult to find the correct index in indexForValue().
3134 // You don't know if you should increase the index or decrease it when
3135 // you hit an invalid value
3136 properties = AbstractColumn::Properties::No;
3137 available.properties = true;
3138 return;
3139 }
3140
3141 switch (m_columnMode) {
3142 case AbstractColumn::ColumnMode::Integer: {
3143 valueInt = integerAt(row);
3144
3145 if (valueInt > prevValueInt) {
3146 monotonic_decreasing = 0;
3147 if (monotonic_increasing < 0)
3148 monotonic_increasing = 1;
3149 else if (monotonic_increasing == 0)

Callers 1

propertiesMethod · 0.45

Calls 3

rowCountFunction · 0.85
isValidMethod · 0.45
isMaskedMethod · 0.45

Tested by

no test coverage detected