mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-04-13 12:42:20 +00:00
committed by
GitHub
parent
5b10ab1288
commit
5a13b7d6a4
@@ -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;
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user