mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
DataFilter - better error feedback
.. when editing programs the syntax errors were not being shared with the user, just a wavy red line. .. this commit adds the errors to the two main dialogs for editing user metrics and user charts. .. in addition a completer was added to the user chart series editor to help (it already existed on the metric editor).
This commit is contained in:
@@ -2725,8 +2725,8 @@ DataFilterEdit::checkErrors()
|
||||
QStringList errors = checker.check(toPlainText());
|
||||
checker.colorSyntax(document(), textCursor().position()); // syntax + error highlighting
|
||||
|
||||
// need to fixup for errors!
|
||||
// XXX next commit
|
||||
// even if no errors need to tell folks
|
||||
emit syntaxErrors(errors);
|
||||
}
|
||||
|
||||
bool
|
||||
|
||||
@@ -265,6 +265,9 @@ protected:
|
||||
void keyPressEvent(QKeyEvent *e);
|
||||
void focusInEvent(QFocusEvent *e);
|
||||
|
||||
Q_SIGNALS:
|
||||
void syntaxErrors(QStringList&);
|
||||
|
||||
public slots:
|
||||
void setText(const QString&);
|
||||
void insertCompletion(const QString &completion);
|
||||
|
||||
@@ -22,7 +22,9 @@
|
||||
#include "TabView.h"
|
||||
#include "RideFileCommand.h"
|
||||
#include "Utils.h"
|
||||
#include "Tab.h"
|
||||
#include "LTMTool.h"
|
||||
#include "RideNavigator.h"
|
||||
#include "ColorButton.h"
|
||||
#include "MainWindow.h"
|
||||
#include "UserChartData.h"
|
||||
@@ -828,6 +830,10 @@ UserChartSettings::refreshAxesTab()
|
||||
//if (selected) seriesTable->setCurrentItem(selected);
|
||||
}
|
||||
|
||||
static bool insensitiveLessThan(const QString &a, const QString &b)
|
||||
{
|
||||
return a.toLower() < b.toLower();
|
||||
}
|
||||
//
|
||||
// Data series settings
|
||||
//
|
||||
@@ -862,10 +868,84 @@ EditUserSeriesDialog::EditUserSeriesDialog(Context *context, bool rangemode, Gen
|
||||
|
||||
cf->addRow(tr("Series Name"), zz);
|
||||
|
||||
QList<QString> list;
|
||||
QString last;
|
||||
SpecialFields sp;
|
||||
|
||||
// get sorted list
|
||||
QStringList names = context->tab->rideNavigator()->logicalHeadings;
|
||||
|
||||
// start with just a list of functions
|
||||
list = DataFilter::builtins();
|
||||
|
||||
// ridefile data series symbols
|
||||
list += RideFile::symbols();
|
||||
|
||||
// add special functions (older code needs fixing !)
|
||||
list << "config(cranklength)";
|
||||
list << "config(cp)";
|
||||
list << "config(ftp)";
|
||||
list << "config(w')";
|
||||
list << "config(pmax)";
|
||||
list << "config(cv)";
|
||||
list << "config(scv)";
|
||||
list << "config(height)";
|
||||
list << "config(weight)";
|
||||
list << "config(lthr)";
|
||||
list << "config(maxhr)";
|
||||
list << "config(rhr)";
|
||||
list << "config(units)";
|
||||
list << "const(e)";
|
||||
list << "const(pi)";
|
||||
list << "daterange(start)";
|
||||
list << "daterange(stop)";
|
||||
list << "ctl";
|
||||
list << "tsb";
|
||||
list << "atl";
|
||||
list << "sb(BikeStress)";
|
||||
list << "lts(BikeStress)";
|
||||
list << "sts(BikeStress)";
|
||||
list << "rr(BikeStress)";
|
||||
list << "tiz(power, 1)";
|
||||
list << "tiz(hr, 1)";
|
||||
list << "best(power, 3600)";
|
||||
list << "best(hr, 3600)";
|
||||
list << "best(cadence, 3600)";
|
||||
list << "best(speed, 3600)";
|
||||
list << "best(torque, 3600)";
|
||||
list << "best(isopower, 3600)";
|
||||
list << "best(xpower, 3600)";
|
||||
list << "best(vam, 3600)";
|
||||
list << "best(wpk, 3600)";
|
||||
|
||||
qSort(names.begin(), names.end(), insensitiveLessThan);
|
||||
|
||||
foreach(QString name, names) {
|
||||
|
||||
// handle dups
|
||||
if (last == name) continue;
|
||||
last = name;
|
||||
|
||||
// Handle bikescore tm
|
||||
if (name.startsWith("BikeScore")) name = QString("BikeScore");
|
||||
|
||||
// Always use the "internalNames" in Filter expressions
|
||||
name = sp.internalName(name);
|
||||
|
||||
// we do very little to the name, just space to _ and lower case it for now...
|
||||
name.replace(' ', '_');
|
||||
list << name;
|
||||
}
|
||||
program = new DataFilterEdit(this, context);
|
||||
program->setMinimumHeight(250 * dpiXFactor); // give me some space!
|
||||
DataFilterCompleter *completer = new DataFilterCompleter(list, this);
|
||||
program->setCompleter(completer);
|
||||
cf->addRow(tr("Program"), (QWidget *)NULL);
|
||||
cf->addRow(program);
|
||||
errors = new QLabel(this);
|
||||
errors->setStyleSheet("color: red;");
|
||||
cf->addRow(errors); //
|
||||
|
||||
|
||||
yname = new QLineEdit(this);
|
||||
zz = new QHBoxLayout();
|
||||
@@ -1016,8 +1096,15 @@ EditUserSeriesDialog::EditUserSeriesDialog(Context *context, bool rangemode, Gen
|
||||
// connect up slots
|
||||
connect(okButton, SIGNAL(clicked()), this, SLOT(okClicked()));
|
||||
connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancelClicked()));
|
||||
connect(program, SIGNAL(syntaxErrors(QStringList&)), this, SLOT(setErrors(QStringList&)));
|
||||
}
|
||||
|
||||
void
|
||||
EditUserSeriesDialog::setErrors(QStringList &list)
|
||||
{
|
||||
errors->setText(list.join(";"));
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
EditUserSeriesDialog::cancelClicked()
|
||||
|
||||
@@ -171,6 +171,8 @@ class EditUserSeriesDialog : public QDialog
|
||||
void okClicked();
|
||||
void cancelClicked();
|
||||
|
||||
void setErrors(QStringList &errors);
|
||||
|
||||
private:
|
||||
Context *context;
|
||||
GenericSeriesInfo &original;
|
||||
@@ -178,6 +180,7 @@ class EditUserSeriesDialog : public QDialog
|
||||
// series page
|
||||
QLineEdit *name, *xname, *yname, *groupname;
|
||||
DataFilterEdit *program;
|
||||
QLabel *errors;
|
||||
|
||||
QComboBox *line, *symbol;
|
||||
QDoubleSpinBox *size;
|
||||
|
||||
@@ -182,6 +182,9 @@ EditUserMetricDialog::EditUserMetricDialog(QWidget *parent, Context *context, Us
|
||||
// create an empty completer, configchanged will fix it
|
||||
DataFilterCompleter *completer = new DataFilterCompleter(list, this);
|
||||
formulaEdit->setCompleter(completer);
|
||||
errors= new QLabel(this);
|
||||
errors->setStyleSheet("color: red");
|
||||
connect(formulaEdit, SIGNAL(syntaxErrors(QStringList&)), this, SLOT(setErrors(QStringList&)));
|
||||
|
||||
QLabel *eval = new QLabel(tr("Evaluates"), this);
|
||||
QLabel *metric = new QLabel(tr("Metric"), this);
|
||||
@@ -234,7 +237,8 @@ EditUserMetricDialog::EditUserMetricDialog(QWidget *parent, Context *context, Us
|
||||
head->addWidget(formulaEditLabel, 6,0);
|
||||
|
||||
// 8 - 16 row; program editor
|
||||
head->addWidget(formulaEdit, 7,0, 8, 5);
|
||||
head->addWidget(formulaEdit, 7,0, 7, 5);
|
||||
head->addWidget(errors, 15,0,1,5);
|
||||
|
||||
// 17th row; labels for estimates
|
||||
head->addWidget(test, 16, 0);
|
||||
@@ -269,6 +273,12 @@ EditUserMetricDialog::EditUserMetricDialog(QWidget *parent, Context *context, Us
|
||||
enableOk();
|
||||
}
|
||||
|
||||
void
|
||||
EditUserMetricDialog::setErrors(QStringList &list)
|
||||
{
|
||||
errors->setText(list.join(";"));
|
||||
}
|
||||
|
||||
void
|
||||
EditUserMetricDialog::enableOk()
|
||||
{
|
||||
|
||||
@@ -49,6 +49,7 @@ class RideTreeView;
|
||||
class EditMetricDetailDialog;
|
||||
class EditUserDataDialog;
|
||||
class EditUserMetricDialog;
|
||||
class EditUserSeriesDialog;
|
||||
|
||||
//
|
||||
// The RideNavigator
|
||||
@@ -78,6 +79,7 @@ class RideNavigator : public GcChartWindow
|
||||
friend class ::EditMetricDetailDialog;
|
||||
friend class ::EditUserDataDialog;
|
||||
friend class ::EditUserMetricDialog;
|
||||
friend class ::EditUserSeriesDialog;
|
||||
|
||||
public:
|
||||
RideNavigator(Context *, bool mainwindow = false);
|
||||
|
||||
@@ -99,6 +99,8 @@ class EditUserMetricDialog : public QDialog {
|
||||
void okClicked();
|
||||
void enableOk();
|
||||
|
||||
void setErrors(QStringList&);
|
||||
|
||||
private:
|
||||
|
||||
bool validSettings();
|
||||
@@ -122,6 +124,7 @@ class EditUserMetricDialog : public QDialog {
|
||||
*precision;
|
||||
|
||||
DataFilterEdit *formulaEdit; // edit your formula
|
||||
QLabel *errors; // for highlighting errors
|
||||
|
||||
QLabel *mValue, *iValue, *elapsed;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user