Compare commits

...

3 Commits

Author SHA1 Message Date
Joachim Kohlhammer
5a13b7d6a4 Userchart: New action to duplicate a series (#4841)
On User Charts
2026-03-14 18:33:03 -03:00
Joachim Kohlhammer
5b10ab1288 Using real path (/activities / /planned) for batch export (#4840)
Otherwise export of planned activities fail.
2026-03-14 14:40:45 -03:00
Joachim Kohlhammer
d7167b1cbf Plan activity: Allow to enter Workout Code (#4842)
Similar to "Log activity".
2026-03-14 12:38:42 -03:00
5 changed files with 82 additions and 5 deletions

View File

@@ -83,6 +83,43 @@ class GenericSeriesInfo {
color("red"), opacity(100.0), opengl(true), legend(true), datalabels(false), fill(false)
{}
GenericSeriesInfo(const GenericSeriesInfo &other) {
*this = other;
}
GenericSeriesInfo &operator=(const GenericSeriesInfo &other) {
if (this == &other) return *this;
name = other.name;
group = other.group;
xseries = other.xseries;
yseries = other.yseries;
fseries = other.fseries;
xname = other.xname;
yname = other.yname;
labels = other.labels;
colors = other.colors;
line = other.line;
symbol = other.symbol;
size = other.size;
color = other.color;
opacity = other.opacity;
opengl = other.opengl;
legend = other.legend;
datalabels = other.datalabels;
fill = other.fill;
aggregateby = other.aggregateby;
annotations = other.annotations;
string1 = other.string1;
string2 = other.string2;
string3 = other.string3;
string4 = other.string4;
user1 = user2 = user3 = user4 = nullptr;
return *this;
}
// available for use (e.g. UserChartSettings)
void *user1, *user2, *user3, *user4;
QString string1, string2, string3, string4;

View File

@@ -869,6 +869,15 @@ UserChartSettings::UserChartSettings(Context *context, bool rangemode, GenericCh
// custom buttons
ActionButtonBox *seriesActionButtons = new ActionButtonBox(ActionButtonBox::UpDownGroup | ActionButtonBox::EditGroup | ActionButtonBox::AddDeleteGroup);
seriesActionButtons->defaultConnect(seriesTable);
QPushButton *duplicateButton = seriesActionButtons->addButton(tr("Duplicate"), ActionButtonBox::Right);
QModelIndex index = seriesTable->selectionModel()->currentIndex();
duplicateButton->setEnabled(index.isValid());
connect(seriesTable->selectionModel(), &QItemSelectionModel::currentChanged, this, [this, duplicateButton]() {
QModelIndex index = this->seriesTable->selectionModel()->currentIndex();
duplicateButton->setEnabled(index.isValid());
});
connect(duplicateButton, &QPushButton::clicked, this, &UserChartSettings::duplicateSeries);
connect(seriesActionButtons, &ActionButtonBox::editRequested, this, &UserChartSettings::editSeries);
connect(seriesActionButtons, &ActionButtonBox::addRequested, this, &UserChartSettings::addSeries);
connect(seriesActionButtons, &ActionButtonBox::deleteRequested, this, &UserChartSettings::deleteSeries);
@@ -1058,6 +1067,33 @@ UserChartSettings::seriesClicked(int row,int)
}
}
void
UserChartSettings::duplicateSeries()
{
QList<QTableWidgetItem*> items = seriesTable->selectedItems();
if (items.count() < 1) return;
int index = seriesTable->row(items.first());
GenericSeriesInfo seriesInfo = seriesinfo[index];
bool duplicate = false;
QString name = seriesInfo.name;
int dup = 1;
do {
duplicate = false;
for (const GenericSeriesInfo &info : seriesinfo) {
if (info.name == seriesInfo.name) {
duplicate = true;
seriesInfo.name = name + QString("_%1").arg(dup);
++dup;
break;
}
}
} while (duplicate);
seriesinfo.append(seriesInfo);
refreshSeriesTab();
emit chartConfigChanged();
}
void
UserChartSettings::editSeries()
{

View File

@@ -165,6 +165,7 @@ class UserChartSettings : public QWidget {
// configuration - data series
void refreshSeriesTab(); // update gui with current config
void duplicateSeries();
void editSeries();
void seriesClicked(int,int);
void addSeries();

View File

@@ -102,6 +102,7 @@ processed(0), fails(0), numFilesToProcess(0), metadataCompleter(nullptr) {
files->setItemWidget(add, 0, checkBox);
add->setText(1, rideItem->fileName);
add->setData(1, Qt::UserRole, rideItem->planned);
add->setText(2, rideItem->dateTime.toString(tr("dd MMM yyyy")));
add->setText(3, rideItem->dateTime.toString(tr("hh:mm:ss")));
add->setText(4, tr(""));
@@ -635,7 +636,13 @@ BatchProcessingDialog::exportFiles()
// open it..
QStringList errors;
QList<RideFile*> rides;
QFile thisfile(QString(context->athlete->home->activities().absolutePath()+"/"+current->text(1)));
QString rideFileName;
if (current->data(1, Qt::UserRole).toBool()) {
rideFileName = context->athlete->home->planned().absolutePath()+"/"+current->text(1);
} else {
rideFileName = context->athlete->home->activities().absolutePath()+"/"+current->text(1);
}
QFile thisfile(rideFileName);
RideFile *rideF = RideFileFactory::instance().openRideFile(context, thisfile, errors, &rides);
// open success?

View File

@@ -303,9 +303,7 @@ ManualActivityPageBasics::ManualActivityPageBasics
woTypeEdit->addItem(tr("Manual Entry"));
woTypeEdit->setCurrentIndex(1);
if (plan) {
connect(woTypeEdit, &QComboBox::currentIndexChanged, this, [sportEdit](int index) {
sportEdit->setEnabled(index != 0);
if (index == 0) {
sportEdit->setText("Bike");
@@ -331,8 +329,6 @@ ManualActivityPageBasics::ManualActivityPageBasics
}
}
workoutCodeLabel->setVisible(! plan);
workoutCodeEdit->setVisible(! plan);
rpeLabel->setVisible(! plan);
rpeEdit->setVisible(! plan);
woTypeLabel->setVisible(plan);