From 274c2c5a714d1490d4e5d49e37ea99668093c868 Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Mon, 24 Dec 2012 16:05:07 +0000 Subject: [PATCH 1/3] Workout Library fixups Remember the selected video or workout when refreshing list on data change. This is particularly relevant when dragging and dropping in videos and workouts. --- src/TrainTool.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/TrainTool.cpp b/src/TrainTool.cpp index 6e3515fe0..298ec3b06 100644 --- a/src/TrainTool.cpp +++ b/src/TrainTool.cpp @@ -384,10 +384,26 @@ TrainTool::TrainTool(MainWindow *parent, const QDir &home) : GcWindow(parent), h void TrainTool::refresh() { + // remember selection + int row = mediaTree->currentIndex().row(); + QString videoPath = mediaTree->model()->data(mediaTree->model()->index(row,0)).toString(); + + // refresh data videoModel->select(); while (videoModel->canFetchMore(QModelIndex())) videoModel->fetchMore(QModelIndex()); + + // restore selection + selectVideo(videoPath); + + + row = workoutTree->currentIndex().row(); + QString workoutPath = workoutTree->model()->data(workoutTree->model()->index(row,0)).toString(); + workoutModel->select(); while (workoutModel->canFetchMore(QModelIndex())) workoutModel->fetchMore(QModelIndex()); + + // restore selection + selectWorkout(workoutPath); } void From 4915d2e21ab9e5c146b80763bfb3698713c1f2ce Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Mon, 24 Dec 2012 16:23:16 +0000 Subject: [PATCH 2/3] CP Calculator is really and Estimator .. and the dialog was a bit ugly too. --- src/MainWindow.cpp | 2 +- src/ToolsDialog.cpp | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 6656cf9e0..30620301e 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -797,7 +797,7 @@ MainWindow::MainWindow(const QDir &home) : QMenu *optionsMenu = menuBar()->addMenu(tr("&Tools")); optionsMenu->addAction(tr("&Options..."), this, SLOT(showOptions())); - optionsMenu->addAction(tr("Critical Power Calculator..."), this, SLOT(showTools())); + optionsMenu->addAction(tr("Critical Power Estimator..."), this, SLOT(showTools())); optionsMenu->addAction(tr("Air Density (Rho) Estimator..."), this, SLOT(showRhoEstimator())); optionsMenu->addSeparator(); diff --git a/src/ToolsDialog.cpp b/src/ToolsDialog.cpp index 77823e7c4..1dffc661a 100644 --- a/src/ToolsDialog.cpp +++ b/src/ToolsDialog.cpp @@ -59,9 +59,11 @@ QHBoxLayout *setupMinsSecs(ToolsDialog *dialog, ToolsDialog::ToolsDialog(QWidget *parent) : QDialog(parent) { - setWindowTitle(tr("Critical Power Calculator")); + setWindowTitle(tr("Critical Power Estimator")); setAttribute(Qt::WA_DeleteOnClose); + setFixedSize(300, 240); + QVBoxLayout *mainVBox = new QVBoxLayout(this); mainVBox->addWidget(new QLabel(tr("Your best short effort (3-5 min):"))); @@ -71,18 +73,22 @@ ToolsDialog::ToolsDialog(QWidget *parent) : QDialog(parent) mainVBox->addWidget(new QLabel(tr("Your best long effort (15-60 min):"))); mainVBox->addLayout(setupMinsSecs(this, longMinsSpinBox, longSecsSpinBox, longWattsSpinBox, 60.0, 20.0)); + mainVBox->addStretch(); QHBoxLayout *cpHBox = new QHBoxLayout; cpHBox->addWidget(new QLabel(tr("Your critical power:"))); txtCP = new QLineEdit(this); txtCP->setAlignment(Qt::AlignRight); txtCP->setReadOnly(true); - cpHBox->addWidget(txtCP); + cpHBox->addWidget(txtCP, Qt::AlignLeft); mainVBox->addLayout(cpHBox); + mainVBox->addStretch(); + QHBoxLayout *buttonHBox = new QHBoxLayout; btnCalculate = new QPushButton(this); - btnCalculate->setText(tr("Calculate CP")); + btnCalculate->setText(tr("Estimate CP")); + buttonHBox->addStretch(); buttonHBox->addWidget(btnCalculate); btnOK = new QPushButton(this); btnOK->setText(tr("Done")); From ea174a758e1e58b2debc7e7c3727bab8e380609b Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Mon, 24 Dec 2012 16:45:44 +0000 Subject: [PATCH 3/3] VLC is Optional - don't SEGV Ugh. Fixed a couple of SEGV when library importing is used with video but no video support is compiled in. --- src/Library.cpp | 2 +- src/TrainTool.cpp | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Library.cpp b/src/Library.cpp index b7191c78c..2e4356d9f 100644 --- a/src/Library.cpp +++ b/src/Library.cpp @@ -120,7 +120,7 @@ Library::importFiles(MainWindow *mainWindow, QStringList files) if (!videos.count() && !workouts.count()) { QMessageBox::warning(NULL, tr("Import Videos and Workouts"), - "No valid videos or workouts were found to import"); + "No supported videos or workouts were found to import"); return; } diff --git a/src/TrainTool.cpp b/src/TrainTool.cpp index 298ec3b06..74c86ef34 100644 --- a/src/TrainTool.cpp +++ b/src/TrainTool.cpp @@ -324,10 +324,10 @@ TrainTool::TrainTool(MainWindow *parent, const QDir &home) : GcWindow(parent), h #if defined Q_OS_MAC || defined GC_HAVE_VLC connect(mediaTree->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(mediaTreeWidgetSelectionChanged())); + connect(main, SIGNAL(selectMedia(QString)), this, SLOT(selectVideo(QString))); #endif connect(main, SIGNAL(configChanged()), this, SLOT(configChanged())); connect(main, SIGNAL(selectWorkout(QString)), this, SLOT(selectWorkout(QString))); - connect(main, SIGNAL(selectMedia(QString)), this, SLOT(selectVideo(QString))); connect(trainDB, SIGNAL(dataChanged()), this, SLOT(refresh())); connect(workoutTree->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(workoutTreeWidgetSelectionChanged())); @@ -384,8 +384,11 @@ TrainTool::TrainTool(MainWindow *parent, const QDir &home) : GcWindow(parent), h void TrainTool::refresh() { + int row; + +#if defined Q_OS_MAC || defined GC_HAVE_VLC // remember selection - int row = mediaTree->currentIndex().row(); + row = mediaTree->currentIndex().row(); QString videoPath = mediaTree->model()->data(mediaTree->model()->index(row,0)).toString(); // refresh data @@ -394,7 +397,7 @@ TrainTool::refresh() // restore selection selectVideo(videoPath); - +#endif row = workoutTree->currentIndex().row(); QString workoutPath = workoutTree->model()->data(workoutTree->model()->index(row,0)).toString();