mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-04-15 05:32:21 +00:00
Ride Editor Remove XDATA by closing tab
.. get ride of the xdata by closing its tab at the bottom of the chart. This is similar to how worksheets are removed in Excel and should be intuitive to most people. .. a warning is issued before removing the data, but it can be undone as all data commands are performed on the command stack
This commit is contained in:
@@ -134,6 +134,7 @@ RideEditor::RideEditor(Context *context) : GcChartWindow(context), data(NULL), r
|
||||
tabbar = new EditorTabBar(this);
|
||||
tabbar->setShape(QTabBar::RoundedSouth);
|
||||
tabbar->setCurrentIndex(0);
|
||||
tabbar->setTabsClosable(true);
|
||||
tabbar->hide();
|
||||
|
||||
// stack of standard + other editors
|
||||
@@ -183,6 +184,7 @@ RideEditor::RideEditor(Context *context) : GcChartWindow(context), data(NULL), r
|
||||
connect(context, SIGNAL(rideClean(RideItem*)), this, SLOT(rideClean()));
|
||||
connect(context, SIGNAL(configChanged(qint32)), this, SLOT(configChanged(qint32)));
|
||||
connect(tabbar, SIGNAL(currentChanged(int)), this, SLOT(tabbarSelected(int)));
|
||||
connect(tabbar, SIGNAL(tabCloseRequested(int)), this, SLOT(removeTabRequested(int)));
|
||||
|
||||
// put find tool and anomaly list in the controls
|
||||
findTool = new FindDialog(this);
|
||||
@@ -217,7 +219,8 @@ RideEditor::configChanged(qint32)
|
||||
tabbar->setPalette(palette);
|
||||
QColor faded = GCColor::invertColor(GColor(CPLOTBACKGROUND));
|
||||
tabbar->setStyleSheet(QString("QTabBar::tab { background-color: %1; border: 0.5px solid %1; color: rgba(%3,%4,%5,50%) }"
|
||||
"QTabBar::tab:selected { background-color: %1; color: %2; border: 2px solid %1; border-bottom-color: %6 }")
|
||||
"QTabBar::tab:selected { background-color: %1; color: %2; border: 2px solid %1; border-bottom-color: %6 }"
|
||||
"QTabBar::close-button:!selected { background-color: %1; }")
|
||||
.arg(GColor(CPLOTBACKGROUND).name())
|
||||
.arg(GCColor::invertColor(GColor(CPLOTBACKGROUND)).name())
|
||||
.arg(faded.red()).arg(faded.green()).arg(faded.blue())
|
||||
@@ -1531,6 +1534,25 @@ RideEditor::tabbarSelected(int index)
|
||||
if (index > -1 && index < stack->count()) stack->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
void
|
||||
RideEditor::removeTabRequested(int index)
|
||||
{
|
||||
// close tab is one way of removing the data from the ride
|
||||
QMessageBox confirm(QMessageBox::Warning, tr("Delete XDATA Series"),
|
||||
QString(tr("You are about to permanently remove the XDATA "
|
||||
"series '%1' from the activity\n\n"
|
||||
"Do you want to continue?")).arg(tabbar->tabText(index)),
|
||||
QMessageBox::Ok | QMessageBox::Cancel);
|
||||
|
||||
if ((confirm.exec() & QMessageBox::Cancel) != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ok then lets remove it !
|
||||
ride->ride()->command->removeXData(tabbar->tabText(index));
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
RideEditor::setTabBar()
|
||||
{
|
||||
@@ -1547,6 +1569,11 @@ RideEditor::setTabBar()
|
||||
while(tabbar->count()) tabbar->removeTab(0);
|
||||
tabbar->hide();
|
||||
tabbar->addTab(tr("STANDARD"));
|
||||
|
||||
// disable close button on STANDARD tab
|
||||
tabbar->setTabButton(0, QTabBar::RightSide, 0);
|
||||
tabbar->setTabButton(0, QTabBar::LeftSide, 0);
|
||||
|
||||
if (ride->ride()->xdata().count()) {
|
||||
|
||||
// we need xdata editing too
|
||||
|
||||
@@ -131,6 +131,7 @@ class RideEditor : public GcChartWindow
|
||||
void rideSelected();
|
||||
void setTabBar();
|
||||
void tabbarSelected(int);
|
||||
void removeTabRequested(int);
|
||||
void intervalSelected();
|
||||
void rideDirty();
|
||||
void rideClean();
|
||||
|
||||
Reference in New Issue
Block a user