diff --git a/src/CriticalPowerWindow.cpp b/src/CriticalPowerWindow.cpp index 3c44bd944..a165d7b9a 100644 --- a/src/CriticalPowerWindow.cpp +++ b/src/CriticalPowerWindow.cpp @@ -205,11 +205,11 @@ CriticalPowerWindow::CriticalPowerWindow(const QDir &home, Context *context, boo // model config // 2 or 3 point model ? modelCombo= new QComboBox(this); - modelCombo->addItem("None"); - modelCombo->addItem("2 parameter"); - modelCombo->addItem("3 parameter"); - modelCombo->addItem("Extended CP"); - modelCombo->addItem("Multicomponent"); + modelCombo->addItem(tr("None")); + modelCombo->addItem(tr("2 parameter")); + modelCombo->addItem(tr("3 parameter")); + modelCombo->addItem(tr("Extended CP")); + modelCombo->addItem(tr("Multicomponent")); modelCombo->setCurrentIndex(1); mcl->addRow(new QLabel(tr("CP Model")), modelCombo); diff --git a/src/DataFilter.cpp b/src/DataFilter.cpp index 8a7d8b3cf..245a6b6ea 100644 --- a/src/DataFilter.cpp +++ b/src/DataFilter.cpp @@ -137,7 +137,7 @@ void Leaf::validateFilter(DataFilter *df, Leaf *leaf) // a lookup at execution time QString lookup = df->lookupMap.value(*(leaf->lvalue.n), ""); if (lookup == "") { - DataFiltererrors << QString("%1 is unknown").arg(*(leaf->lvalue.n)); + DataFiltererrors << QString(QObject::tr("%1 is unknown")).arg(*(leaf->lvalue.n)); } } break; @@ -150,10 +150,10 @@ void Leaf::validateFilter(DataFilter *df, Leaf *leaf) QString symbol = *(leaf->series->lvalue.n); if (leaf->function == "best" && !bestValidSymbols.exactMatch(symbol)) - DataFiltererrors << QString("invalid data series for best(): %1").arg(symbol); + DataFiltererrors << QString(QObject::tr("invalid data series for best(): %1")).arg(symbol); if (leaf->function == "tiz" && !tizValidSymbols.exactMatch(symbol)) - DataFiltererrors << QString("invalid data series for tiz(): %1").arg(symbol); + DataFiltererrors << QString(QObject::tr("invalid data series for tiz(): %1")).arg(symbol); // now set the series type leaf->seriesType = nameToSeries(symbol); @@ -167,13 +167,13 @@ void Leaf::validateFilter(DataFilter *df, Leaf *leaf) bool lhsType = Leaf::isNumber(df, leaf->lvalue.l); bool rhsType = Leaf::isNumber(df, leaf->rvalue.l); if (lhsType != rhsType) { - DataFiltererrors << QString("comparing strings with numbers"); + DataFiltererrors << QString(QObject::tr("comparing strings with numbers")); } // what about using string operations on a lhs/rhs that // are numeric? if ((lhsType || rhsType) && leaf->op >= MATCHES && leaf->op <= CONTAINS) { - DataFiltererrors << "using a string operations with a number"; + DataFiltererrors << QObject::tr("using a string operations with a number"); } validateFilter(df, leaf->lvalue.l); @@ -222,7 +222,7 @@ QStringList DataFilter::parseFilter(QString query, QStringList *list) if (!treeRoot || DataFiltererrors.count() > 0) { // nope // no errors just failed to finish - if (!treeRoot) DataFiltererrors << "malformed expression."; + if (!treeRoot) DataFiltererrors << tr("malformed expression."); // Bzzzt, malformed emit parseBad(DataFiltererrors); @@ -269,12 +269,16 @@ void DataFilter::configUpdate() lookupMap.clear(); lookupType.clear(); - // create lookup map from 'friendly name' to name used in smmaryMetrics + // create lookup map from 'friendly name' to INTERNAL-name used in summaryMetrics // to enable a quick lookup && the lookup for the field type (number, text) const RideMetricFactory &factory = RideMetricFactory::instance(); for (int i=0; iname(); + QString name = context->specialFields.internalName(factory.rideMetric(symbol)->name()); + + //special Treatment for BikeScore + if (name.startsWith("BikeScore")) name = "BikeScore™"; + lookupMap.insert(name.replace(" ","_"), symbol); lookupType.insert(name.replace(" ","_"), true); } @@ -283,10 +287,16 @@ void DataFilter::configUpdate() foreach(FieldDefinition field, context->athlete->rideMetadata()->getFields()) { QString underscored = field.name; if (!context->specialFields.isMetric(underscored)) { + + // translate to internal name if name has non Latin1 characters + underscored = context->specialFields.internalName(underscored); + field.name = context->specialFields.internalName((field.name)); + lookupMap.insert(underscored.replace(" ","_"), field.name); lookupType.insert(underscored.replace(" ","_"), (field.type > 2)); // true if is number } } + } double Leaf::eval(DataFilter *df, Leaf *leaf, SummaryMetrics m, QString f) diff --git a/src/DataFilter.l b/src/DataFilter.l index 2cbb30086..0fd6885c6 100644 --- a/src/DataFilter.l +++ b/src/DataFilter.l @@ -61,7 +61,11 @@ "TRIMP(100)_Points" return SYMBOL; /* special case */ "Left/Right_Balance" return SYMBOL; /* special case */ -"Minimum_W'_bal" return SYMBOL; /* special case */ +"Minimum_W'bal" return SYMBOL; /* special case */ +"Maximum_W'bal_Match" return SYMBOL; /* special case */ +"Max_W'_Expended" return SYMBOL; /* special case */ +"W'_Work" return SYMBOL; /* special case */ +"W'bal_TAU" return SYMBOL; /* special case */ [a-zA-Z0-9][a-zA-Z0-9_%™]+ return SYMBOL; /* symbols can start with 0-9 */ diff --git a/src/RideNavigator.cpp b/src/RideNavigator.cpp index 492d780bb..4aed06ec5 100644 --- a/src/RideNavigator.cpp +++ b/src/RideNavigator.cpp @@ -907,9 +907,6 @@ void RideNavigator::dropEvent(QDropEvent *event) { QString name = event->mimeData()->data("application/x-columnchooser"); - // fugly, but it works for BikeScore with the (TM) in it... - // when MIME object is UTF-8 and not Latin-1 - this seems not to be required any more - // if (name == "BikeScore?") name = QTextEdit("BikeScore™").toPlainText(); tableView->setColumnHidden(logicalHeadings.indexOf(name), false); tableView->setColumnWidth(logicalHeadings.indexOf(name), 50); tableView->header()->moveSection(tableView->header()->visualIndex(logicalHeadings.indexOf(name)), 1); @@ -1182,8 +1179,8 @@ ColumnChooser::buttonClicked(QString name) // setup the drag data QMimeData *mimeData = new QMimeData; QByteArray empty; -// mimeData->setData("application/x-columnchooser", name.toLatin1()); -// Use UTF-8 in Mime Date to cover also special characters + // Use UTF-8 in Mime Date to cover also special characters, + // but the Receiver of the mimeData has to be able to handle Utf8() or translate mimeData->setData("application/x-columnchooser", name.toUtf8()); // create a drag event diff --git a/src/SearchBox.cpp b/src/SearchBox.cpp index 3a71407d5..bf40467a5 100644 --- a/src/SearchBox.cpp +++ b/src/SearchBox.cpp @@ -231,7 +231,7 @@ void SearchBox::setBad(QStringList errors) pal.setColor(QPalette::Text, Qt::red); setPalette(pal); - setToolTip(errors.join(" and ")); + setToolTip(errors.join(tr(" and "))); } void SearchBox::setGood() @@ -259,8 +259,13 @@ void SearchBox::dropEvent(QDropEvent *event) { QString name = event->mimeData()->data("application/x-columnchooser"); - // fugly, but it works for BikeScore with the (TM) in it... - if (name == "BikeScore?") name = QString("BikeScore™").replace("™", QChar(0x2122)); + // fugly, but it works for BikeScore with the (TM) in it... so... + // independent of Latin1 or UTF-8 coming from "Column Chooser" the "TM" is not recognized by the parser, + // when stripping it of, all works fine (Parser add's it internally to find the right metrics) + if (name.startsWith("BikeScore")) name = QString("BikeScore"); + // Always use the "internalNames" in Filter expressions + SpecialFields sp; + name = sp.internalName(name); // we do very little to the name, just space to _ and lower case it for now... name.replace(' ', '_');