Delete ride function from Ned Harding.

This commit is contained in:
Robert Carlsen
2009-04-14 15:48:13 +00:00
parent 4604f62e23
commit 604c24147f
2 changed files with 26 additions and 0 deletions

View File

@@ -414,6 +414,8 @@ MainWindow::MainWindow(const QDir &home) :
SLOT(findBestIntervals()), tr ("Ctrl+B"));
rideMenu->addAction(tr("Split &ride..."), this,
SLOT(splitRide()));
rideMenu->addAction(tr("D&elete ride..."), this,
SLOT(deleteRide()));
QMenu *optionsMenu = menuBar()->addMenu(tr("&Tools"));
optionsMenu->addAction(tr("&Options..."), this,
SLOT(showOptions()), tr("Ctrl+O"));
@@ -516,6 +518,11 @@ MainWindow::removeCurrentRide()
QFile file(home.absolutePath() + "/" + strOldFileName);
// purposefully don't remove the old ext so the user wouldn't have to figure out what the old file type was
QString strNewName = strOldFileName + ".bak";
// in case there was an existing bak file, delete it
// ignore errors since it probably isn't there.
QFile::remove(home.absolutePath() + "/" + strNewName);
if (!file.rename(home.absolutePath() + "/" + strNewName))
{
QMessageBox::critical(
@@ -1210,3 +1217,21 @@ MainWindow::splitRide()
(new SplitRideDialog(this))->exec();
}
void
MainWindow::deleteRide()
{
QTreeWidgetItem *_item = treeWidget->currentItem();
if (_item==NULL || _item->type() != RIDE_TYPE)
return;
RideItem *item = reinterpret_cast<RideItem*>(_item);
QMessageBox msgBox;
msgBox.setText("Are you sure you want to delete the ride:");
msgBox.setInformativeText(item->fileName);
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
if (msgBox.exec()==QMessageBox::Yes)
removeCurrentRide();
}

View File

@@ -59,6 +59,7 @@ class MainWindow : public QMainWindow
void importTCX();
void findBestIntervals();
void splitRide();
void deleteRide();
void setSmoothingFromSlider();
void setSmoothingFromLineEdit();
void setBinWidthFromSlider();