Add Planned to DataFilter

Including 2 defaults filters for Planned and Actual activities.
Part 2 of #4670
This commit is contained in:
Alejandro Martinez
2025-07-18 19:21:07 -03:00
parent 5e7fdca415
commit 72961b6558
2 changed files with 15 additions and 0 deletions

View File

@@ -867,6 +867,7 @@ DataFilter::colorSyntax(QTextDocument *document, int pos)
// isRun isa special, we may add more later (e.g. date) // isRun isa special, we may add more later (e.g. date)
if (!sym.compare("Date", Qt::CaseInsensitive) || if (!sym.compare("Date", Qt::CaseInsensitive) ||
!sym.compare("Time", Qt::CaseInsensitive) || !sym.compare("Time", Qt::CaseInsensitive) ||
!sym.compare("Planned", Qt::CaseInsensitive) ||
!sym.compare("banister", Qt::CaseInsensitive) || !sym.compare("banister", Qt::CaseInsensitive) ||
!sym.compare("best", Qt::CaseInsensitive) || !sym.compare("best", Qt::CaseInsensitive) ||
!sym.compare("tiz", Qt::CaseInsensitive) || !sym.compare("tiz", Qt::CaseInsensitive) ||
@@ -1628,6 +1629,7 @@ bool Leaf::isNumber(DataFilterRuntime *df, Leaf *leaf)
if (symbol == "x" || symbol == "i") return true; if (symbol == "x" || symbol == "i") return true;
else if (!symbol.compare("Date", Qt::CaseInsensitive)) return true; else if (!symbol.compare("Date", Qt::CaseInsensitive)) return true;
else if (!symbol.compare("Time", Qt::CaseInsensitive)) return true; else if (!symbol.compare("Time", Qt::CaseInsensitive)) return true;
else if (!symbol.compare("Planned", Qt::CaseInsensitive)) return true;
else if (!symbol.compare("Today", Qt::CaseInsensitive)) return true; else if (!symbol.compare("Today", Qt::CaseInsensitive)) return true;
else if (!symbol.compare("Current", Qt::CaseInsensitive)) return true; else if (!symbol.compare("Current", Qt::CaseInsensitive)) return true;
else if (!symbol.compare("RECINTSECS", Qt::CaseInsensitive)) return true; else if (!symbol.compare("RECINTSECS", Qt::CaseInsensitive)) return true;
@@ -1726,6 +1728,7 @@ void Leaf::validateFilter(Context *context, DataFilterRuntime *df, Leaf *leaf)
// isRun isa special, we may add more later (e.g. date) // isRun isa special, we may add more later (e.g. date)
if (symbol.compare("Date", Qt::CaseInsensitive) && if (symbol.compare("Date", Qt::CaseInsensitive) &&
symbol.compare("Time", Qt::CaseInsensitive) && symbol.compare("Time", Qt::CaseInsensitive) &&
symbol.compare("Planned", Qt::CaseInsensitive) &&
symbol.compare("x", Qt::CaseInsensitive) && // used by which and [lexpr] symbol.compare("x", Qt::CaseInsensitive) && // used by which and [lexpr]
symbol.compare("i", Qt::CaseInsensitive) && // used by which and [lexpr] symbol.compare("i", Qt::CaseInsensitive) && // used by which and [lexpr]
symbol.compare("Today", Qt::CaseInsensitive) && symbol.compare("Today", Qt::CaseInsensitive) &&
@@ -2925,6 +2928,7 @@ void Leaf::validateFilter(Context *context, DataFilterRuntime *df, Leaf *leaf)
// some specials are not allowed // some specials are not allowed
if (!symbol.compare("Date", Qt::CaseInsensitive) || if (!symbol.compare("Date", Qt::CaseInsensitive) ||
!symbol.compare("Time", Qt::CaseInsensitive) || !symbol.compare("Time", Qt::CaseInsensitive) ||
!symbol.compare("Planned", Qt::CaseInsensitive) ||
!symbol.compare("x", Qt::CaseInsensitive) || // used by which !symbol.compare("x", Qt::CaseInsensitive) || // used by which
!symbol.compare("i", Qt::CaseInsensitive) || // used by which !symbol.compare("i", Qt::CaseInsensitive) || // used by which
!symbol.compare("Today", Qt::CaseInsensitive) || !symbol.compare("Today", Qt::CaseInsensitive) ||
@@ -7778,6 +7782,11 @@ Result Leaf::eval(DataFilterRuntime *df, Leaf *leaf, const Result &x, long it, R
lhsdouble = QTime(0,0,0).secsTo(m->dateTime.time()); lhsdouble = QTime(0,0,0).secsTo(m->dateTime.time());
lhsisNumber = true; lhsisNumber = true;
} else if (!symbol.compare("Planned", Qt::CaseInsensitive)) {
lhsdouble = m->planned;
lhsisNumber = true;
} else if (isCoggan(symbol)) { } else if (isCoggan(symbol)) {
// a coggan PMC metric // a coggan PMC metric
PMCData *pmcData = m->context->athlete->getPMCFor("coggan_tss"); PMCData *pmcData = m->context->athlete->getPMCFor("coggan_tss");

View File

@@ -90,6 +90,12 @@ NamedSearches::read()
if (list.isEmpty()) { if (list.isEmpty()) {
NamedSearch namedSearch; NamedSearch namedSearch;
namedSearch.type = NamedSearch::filter; namedSearch.type = NamedSearch::filter;
namedSearch.name = tr("Planned");
namedSearch.text = "Planned";
list.append(namedSearch);
namedSearch.name = tr("Actual");
namedSearch.text = "!Planned";
list.append(namedSearch);
namedSearch.name = tr("Swim"); namedSearch.name = tr("Swim");
namedSearch.text = "isSwim"; namedSearch.text = "isSwim";
list.append(namedSearch); list.append(namedSearch);