Remove RideSummaryWindow configuration pages

.. now the RideSummaryWindow is deprecated we no longer need
   to configure the metrics / bests being displayed on it.
This commit is contained in:
Mark Liversedge
2021-07-09 11:20:29 +01:00
parent 9d6e08547f
commit 722588f1db
4 changed files with 0 additions and 475 deletions

View File

@@ -332,9 +332,7 @@ MetricConfig::MetricConfig(QDir home, Context *context) :
home(home), context(context)
{
// the widgets
bestsPage = new BestsMetricsPage(this);
intervalsPage = new IntervalMetricsPage(this);
summaryPage = new SummaryMetricsPage(this);
customPage = new CustomMetricsPage(this, context);
setContentsMargins(0,0,0,0);
@@ -344,8 +342,6 @@ MetricConfig::MetricConfig(QDir home, Context *context) :
QTabWidget *tabs = new QTabWidget(this);
tabs->addTab(customPage, tr("Custom"));
tabs->addTab(bestsPage, tr("Bests"));
tabs->addTab(summaryPage, tr("Summary"));
tabs->addTab(intervalsPage, tr("Intervals"));
mainLayout->addWidget(tabs);
}
@@ -354,8 +350,6 @@ qint32 MetricConfig::saveClicked()
{
qint32 state = 0;
state |= bestsPage->saveClicked();
state |= summaryPage->saveClicked();
state |= intervalsPage->saveClicked();
state |= customPage->saveClicked();

View File

@@ -104,9 +104,7 @@ class MetricConfig : public QWidget
QDir home;
Context *context;
BestsMetricsPage *bestsPage;
IntervalMetricsPage *intervalsPage;
SummaryMetricsPage *summaryPage;
CustomMetricsPage *customPage;
};

View File

@@ -1755,203 +1755,6 @@ IntervalMetricsPage::saveClicked()
return 0;
}
BestsMetricsPage::BestsMetricsPage(QWidget *parent) :
QWidget(parent), changed(false)
{
HelpWhatsThis *help = new HelpWhatsThis(this);
this->setWhatsThis(help->getWhatsThisText(HelpWhatsThis::Preferences_Metrics_Best));
availList = new QListWidget;
availList->setSortingEnabled(true);
availList->setSelectionMode(QAbstractItemView::SingleSelection);
QVBoxLayout *availLayout = new QVBoxLayout;
availLayout->addWidget(new QLabel(tr("Available Metrics")));
availLayout->addWidget(availList);
selectedList = new QListWidget;
selectedList->setSelectionMode(QAbstractItemView::SingleSelection);
QVBoxLayout *selectedLayout = new QVBoxLayout;
selectedLayout->addWidget(new QLabel(tr("Selected Metrics")));
selectedLayout->addWidget(selectedList);
#ifndef Q_OS_MAC
upButton = new QToolButton(this);
downButton = new QToolButton(this);
leftButton = new QToolButton(this);
rightButton = new QToolButton(this);
upButton->setArrowType(Qt::UpArrow);
downButton->setArrowType(Qt::DownArrow);
leftButton->setArrowType(Qt::LeftArrow);
rightButton->setArrowType(Qt::RightArrow);
upButton->setFixedSize(20*dpiXFactor,20*dpiYFactor);
downButton->setFixedSize(20*dpiXFactor,20*dpiYFactor);
leftButton->setFixedSize(20*dpiXFactor,20*dpiYFactor);
rightButton->setFixedSize(20*dpiXFactor,20*dpiYFactor);
#else
upButton = new QPushButton(tr("Up"));
downButton = new QPushButton(tr("Down"));
leftButton = new QPushButton("<");
rightButton = new QPushButton(">");
#endif
QVBoxLayout *buttonGrid = new QVBoxLayout;
QHBoxLayout *upLayout = new QHBoxLayout;
QHBoxLayout *inexcLayout = new QHBoxLayout;
QHBoxLayout *downLayout = new QHBoxLayout;
upLayout->addStretch();
upLayout->addWidget(upButton);
upLayout->addStretch();
inexcLayout->addStretch();
inexcLayout->addWidget(leftButton);
inexcLayout->addWidget(rightButton);
inexcLayout->addStretch();
downLayout->addStretch();
downLayout->addWidget(downButton);
downLayout->addStretch();
buttonGrid->addStretch();
buttonGrid->addLayout(upLayout);
buttonGrid->addLayout(inexcLayout);
buttonGrid->addLayout(downLayout);
buttonGrid->addStretch();
QHBoxLayout *hlayout = new QHBoxLayout;
hlayout->addLayout(availLayout);
hlayout->addLayout(buttonGrid);
hlayout->addLayout(selectedLayout);
setLayout(hlayout);
QString s;
if (appsettings->contains(GC_SETTINGS_BESTS_METRICS))
s = appsettings->value(this, GC_SETTINGS_BESTS_METRICS).toString();
else
s = GC_SETTINGS_BESTS_METRICS_DEFAULT;
QStringList selectedMetrics = s.split(",");
const RideMetricFactory &factory = RideMetricFactory::instance();
for (int i = 0; i < factory.metricCount(); ++i) {
QString symbol = factory.metricName(i);
if (selectedMetrics.contains(symbol) || symbol.startsWith("compatibility_"))
continue;
QSharedPointer<RideMetric> m(factory.newMetric(symbol));
QListWidgetItem *item = new QListWidgetItem(Utils::unprotect(m->name()));
item->setData(Qt::UserRole, symbol);
item->setToolTip(m->description());
availList->addItem(item);
}
foreach (QString symbol, selectedMetrics) {
if (!factory.haveMetric(symbol))
continue;
QSharedPointer<RideMetric> m(factory.newMetric(symbol));
QListWidgetItem *item = new QListWidgetItem(Utils::unprotect(m->name()));
item->setData(Qt::UserRole, symbol);
item->setToolTip(m->description());
selectedList->addItem(item);
}
upButton->setEnabled(false);
downButton->setEnabled(false);
leftButton->setEnabled(false);
rightButton->setEnabled(false);
connect(upButton, SIGNAL(clicked()), this, SLOT(upClicked()));
connect(downButton, SIGNAL(clicked()), this, SLOT(downClicked()));
connect(leftButton, SIGNAL(clicked()), this, SLOT(leftClicked()));
connect(rightButton, SIGNAL(clicked()), this, SLOT(rightClicked()));
connect(availList, SIGNAL(itemSelectionChanged()),
this, SLOT(availChanged()));
connect(selectedList, SIGNAL(itemSelectionChanged()),
this, SLOT(selectedChanged()));
}
void
BestsMetricsPage::upClicked()
{
assert(!selectedList->selectedItems().isEmpty());
QListWidgetItem *item = selectedList->selectedItems().first();
int row = selectedList->row(item);
assert(row > 0);
selectedList->takeItem(row);
selectedList->insertItem(row - 1, item);
selectedList->setCurrentItem(item);
changed = true;
}
void
BestsMetricsPage::downClicked()
{
assert(!selectedList->selectedItems().isEmpty());
QListWidgetItem *item = selectedList->selectedItems().first();
int row = selectedList->row(item);
assert(row < selectedList->count() - 1);
selectedList->takeItem(row);
selectedList->insertItem(row + 1, item);
selectedList->setCurrentItem(item);
changed = true;
}
void
BestsMetricsPage::leftClicked()
{
assert(!selectedList->selectedItems().isEmpty());
QListWidgetItem *item = selectedList->selectedItems().first();
selectedList->takeItem(selectedList->row(item));
availList->addItem(item);
changed = true;
selectedChanged();
}
void
BestsMetricsPage::rightClicked()
{
assert(!availList->selectedItems().isEmpty());
QListWidgetItem *item = availList->selectedItems().first();
availList->takeItem(availList->row(item));
selectedList->addItem(item);
changed = true;
}
void
BestsMetricsPage::availChanged()
{
rightButton->setEnabled(!availList->selectedItems().isEmpty());
}
void
BestsMetricsPage::selectedChanged()
{
if (selectedList->selectedItems().isEmpty()) {
upButton->setEnabled(false);
downButton->setEnabled(false);
leftButton->setEnabled(false);
return;
}
QListWidgetItem *item = selectedList->selectedItems().first();
int row = selectedList->row(item);
if (row == 0)
upButton->setEnabled(false);
else
upButton->setEnabled(true);
if (row == selectedList->count() - 1)
downButton->setEnabled(false);
else
downButton->setEnabled(true);
leftButton->setEnabled(true);
}
qint32
BestsMetricsPage::saveClicked()
{
if (!changed) return 0;
QStringList metrics;
for (int i = 0; i < selectedList->count(); ++i)
metrics << selectedList->item(i)->data(Qt::UserRole).toString();
appsettings->setValue(GC_SETTINGS_BESTS_METRICS, metrics.join(","));
return 0;
}
static quint16 userMetricsCRC(QList<UserMetricSettings> userMetrics)
{
// run through metrics and compute a CRC to detect changes
@@ -2355,199 +2158,6 @@ CustomMetricsPage::saveClicked()
return returning;
}
SummaryMetricsPage::SummaryMetricsPage(QWidget *parent) :
QWidget(parent), changed(false)
{
HelpWhatsThis *help = new HelpWhatsThis(this);
this->setWhatsThis(help->getWhatsThisText(HelpWhatsThis::Preferences_Metrics_Summary));
availList = new QListWidget;
availList->setSortingEnabled(true);
availList->setSelectionMode(QAbstractItemView::SingleSelection);
QVBoxLayout *availLayout = new QVBoxLayout;
availLayout->addWidget(new QLabel(tr("Available Metrics")));
availLayout->addWidget(availList);
selectedList = new QListWidget;
selectedList->setSelectionMode(QAbstractItemView::SingleSelection);
QVBoxLayout *selectedLayout = new QVBoxLayout;
selectedLayout->addWidget(new QLabel(tr("Selected Metrics")));
selectedLayout->addWidget(selectedList);
#ifndef Q_OS_MAC
upButton = new QToolButton(this);
downButton = new QToolButton(this);
leftButton = new QToolButton(this);
rightButton = new QToolButton(this);
upButton->setArrowType(Qt::UpArrow);
downButton->setArrowType(Qt::DownArrow);
leftButton->setArrowType(Qt::LeftArrow);
rightButton->setArrowType(Qt::RightArrow);
upButton->setFixedSize(20*dpiXFactor,20*dpiYFactor);
downButton->setFixedSize(20*dpiXFactor,20*dpiYFactor);
leftButton->setFixedSize(20*dpiXFactor,20*dpiYFactor);
rightButton->setFixedSize(20*dpiXFactor,20*dpiYFactor);
#else
upButton = new QPushButton(tr("Up"));
downButton = new QPushButton(tr("Down"));
leftButton = new QPushButton("<");
rightButton = new QPushButton(">");
#endif
QVBoxLayout *buttonGrid = new QVBoxLayout;
QHBoxLayout *upLayout = new QHBoxLayout;
QHBoxLayout *inexcLayout = new QHBoxLayout;
QHBoxLayout *downLayout = new QHBoxLayout;
upLayout->addStretch();
upLayout->addWidget(upButton);
upLayout->addStretch();
inexcLayout->addStretch();
inexcLayout->addWidget(leftButton);
inexcLayout->addWidget(rightButton);
inexcLayout->addStretch();
downLayout->addStretch();
downLayout->addWidget(downButton);
downLayout->addStretch();
buttonGrid->addStretch();
buttonGrid->addLayout(upLayout);
buttonGrid->addLayout(inexcLayout);
buttonGrid->addLayout(downLayout);
buttonGrid->addStretch();
QHBoxLayout *hlayout = new QHBoxLayout;
hlayout->addLayout(availLayout);
hlayout->addLayout(buttonGrid);
hlayout->addLayout(selectedLayout);
setLayout(hlayout);
QString s = appsettings->value(this, GC_SETTINGS_SUMMARY_METRICS, GC_SETTINGS_SUMMARY_METRICS_DEFAULT).toString();
QStringList selectedMetrics = s.split(",");
const RideMetricFactory &factory = RideMetricFactory::instance();
for (int i = 0; i < factory.metricCount(); ++i) {
QString symbol = factory.metricName(i);
if (selectedMetrics.contains(symbol) || symbol.startsWith("compatibility_"))
continue;
QSharedPointer<RideMetric> m(factory.newMetric(symbol));
QListWidgetItem *item = new QListWidgetItem(Utils::unprotect(m->name()));
item->setData(Qt::UserRole, symbol);
item->setToolTip(m->description());
availList->addItem(item);
}
foreach (QString symbol, selectedMetrics) {
if (!factory.haveMetric(symbol))
continue;
QSharedPointer<RideMetric> m(factory.newMetric(symbol));
QListWidgetItem *item = new QListWidgetItem(Utils::unprotect(m->name()));
item->setData(Qt::UserRole, symbol);
item->setToolTip(m->description());
selectedList->addItem(item);
}
upButton->setEnabled(false);
downButton->setEnabled(false);
leftButton->setEnabled(false);
rightButton->setEnabled(false);
connect(upButton, SIGNAL(clicked()), this, SLOT(upClicked()));
connect(downButton, SIGNAL(clicked()), this, SLOT(downClicked()));
connect(leftButton, SIGNAL(clicked()), this, SLOT(leftClicked()));
connect(rightButton, SIGNAL(clicked()), this, SLOT(rightClicked()));
connect(availList, SIGNAL(itemSelectionChanged()),
this, SLOT(availChanged()));
connect(selectedList, SIGNAL(itemSelectionChanged()),
this, SLOT(selectedChanged()));
}
void
SummaryMetricsPage::upClicked()
{
assert(!selectedList->selectedItems().isEmpty());
QListWidgetItem *item = selectedList->selectedItems().first();
int row = selectedList->row(item);
assert(row > 0);
selectedList->takeItem(row);
selectedList->insertItem(row - 1, item);
selectedList->setCurrentItem(item);
changed = true;
}
void
SummaryMetricsPage::downClicked()
{
assert(!selectedList->selectedItems().isEmpty());
QListWidgetItem *item = selectedList->selectedItems().first();
int row = selectedList->row(item);
assert(row < selectedList->count() - 1);
selectedList->takeItem(row);
selectedList->insertItem(row + 1, item);
selectedList->setCurrentItem(item);
changed = true;
}
void
SummaryMetricsPage::leftClicked()
{
assert(!selectedList->selectedItems().isEmpty());
QListWidgetItem *item = selectedList->selectedItems().first();
selectedList->takeItem(selectedList->row(item));
availList->addItem(item);
changed = true;
selectedChanged();
}
void
SummaryMetricsPage::rightClicked()
{
assert(!availList->selectedItems().isEmpty());
QListWidgetItem *item = availList->selectedItems().first();
availList->takeItem(availList->row(item));
selectedList->addItem(item);
changed = true;
}
void
SummaryMetricsPage::availChanged()
{
rightButton->setEnabled(!availList->selectedItems().isEmpty());
}
void
SummaryMetricsPage::selectedChanged()
{
if (selectedList->selectedItems().isEmpty()) {
upButton->setEnabled(false);
downButton->setEnabled(false);
leftButton->setEnabled(false);
return;
}
QListWidgetItem *item = selectedList->selectedItems().first();
int row = selectedList->row(item);
if (row == 0)
upButton->setEnabled(false);
else
upButton->setEnabled(true);
if (row == selectedList->count() - 1)
downButton->setEnabled(false);
else
downButton->setEnabled(true);
leftButton->setEnabled(true);
}
qint32
SummaryMetricsPage::saveClicked()
{
if (!changed) return 0;
QStringList metrics;
for (int i = 0; i < selectedList->count(); ++i)
metrics << selectedList->item(i)->data(Qt::UserRole).toString();
appsettings->setValue(GC_SETTINGS_SUMMARY_METRICS, metrics.join(","));
return 0;
}
MetadataPage::MetadataPage(Context *context) : context(context)
{
QVBoxLayout *layout = new QVBoxLayout(this);

View File

@@ -57,11 +57,9 @@ class QGroupBox;
class QHBoxLayout;
class QVBoxLayout;
class ColorsPage;
class IntervalMetricsPage;
class ZonePage;
class HrZonePage;
class PaceZonePage;
class SummaryMetricsPage;
class MetadataPage;
class KeywordsPage;
class FieldsPage;
@@ -317,44 +315,6 @@ private:
QLabel *m_StatsLabelArr[StatsLastPart];
};
class BestsMetricsPage : public QWidget
{
Q_OBJECT
G_OBJECT
public:
BestsMetricsPage(QWidget *parent = NULL);
public slots:
void upClicked();
void downClicked();
void leftClicked();
void rightClicked();
void availChanged();
void selectedChanged();
qint32 saveClicked();
protected:
bool changed;
QListWidget *availList;
QListWidget *selectedList;
#ifndef Q_OS_MAC
QToolButton *upButton;
QToolButton *downButton;
QToolButton *leftButton;
QToolButton *rightButton;
#else
QPushButton *upButton;
QPushButton *downButton;
QPushButton *leftButton;
QPushButton *rightButton;
#endif
};
class CustomMetricsPage : public QWidget
{
Q_OBJECT
@@ -440,43 +400,6 @@ class IntervalMetricsPage : public QWidget
#endif
};
class SummaryMetricsPage : public QWidget
{
Q_OBJECT
public:
SummaryMetricsPage(QWidget *parent = NULL);
public slots:
void upClicked();
void downClicked();
void leftClicked();
void rightClicked();
void availChanged();
void selectedChanged();
qint32 saveClicked();
protected:
bool changed;
QListWidget *availList;
QListWidget *selectedList;
#ifndef Q_OS_MAC
QToolButton *upButton;
QToolButton *downButton;
QToolButton *leftButton;
QToolButton *rightButton;
#else
QPushButton *upButton;
QPushButton *downButton;
QPushButton *leftButton;
QPushButton *rightButton;
#endif
};
class KeywordsPage : public QWidget
{
Q_OBJECT