Skip to content
Permalink
Browse files

Import Workouts from WebPageWindow

.. so we can open ergdb as a chart window and browse and
   select workouts to import.
  • Loading branch information...
liversedge committed Apr 15, 2019
1 parent 4083be3 commit fc9fb7ba24462949aeba4fd168e95b51222eb5c6
Showing with 28 additions and 15 deletions.
  1. +10 −10 src/Gui/MainWindow.cpp
  2. +2 −2 src/Train/Library.cpp
  3. +1 −1 src/Train/Library.h
  4. +15 −2 src/Train/WebPageWindow.cpp
@@ -1212,10 +1212,11 @@ MainWindow::dropEvent(QDropEvent *event)
// is this a chart file ?
QStringList filenames;
QList<LTMSettings> imported;
QStringList list;
QStringList list, workouts;
for(int i=0; i<urls.count(); i++) {

QString filename = QFileInfo(urls.value(i).toLocalFile()).absoluteFilePath();
fprintf(stderr, "%s\n", filename.toStdString().c_str()); fflush(stderr);

if (filename.endsWith(".gchart", Qt::CaseInsensitive)) {
// add to the list of charts to import
@@ -1236,6 +1237,8 @@ MainWindow::dropEvent(QDropEvent *event)
xmlReader.parse(source);
imported += handler.getSettings();

} else if (ErgFile::isWorkout(filename)) {
workouts << filename;
} else {
filenames.append(filename);
}
@@ -1263,18 +1266,15 @@ MainWindow::dropEvent(QDropEvent *event)
// are there any .gcharts to import?
if (list.count()) importCharts(list);

// import workouts
if (workouts.count()) Library::importFiles(currentTab->context, filenames, true);

// if there is anything left, process based upon view...
if (filenames.count()) {

if (currentTab->currentView() != 3) { // we're not on train view

// We have something to process then
RideImportWizard *dialog = new RideImportWizard (filenames, currentTab->context);
dialog->process(); // do it!

} else {
Library::importFiles(currentTab->context, filenames);
}
// We have something to process then
RideImportWizard *dialog = new RideImportWizard (filenames, currentTab->context);
dialog->process(); // do it!
}
return;
}
@@ -91,7 +91,7 @@ Library::initialise(QDir home)
}

void
Library::importFiles(Context *context, QStringList files)
Library::importFiles(Context *context, QStringList files, bool forcedialog)
{
QStringList videos, workouts, videosyncs;
MediaHelper helper;
@@ -133,7 +133,7 @@ Library::importFiles(Context *context, QStringList files)

// with only 1 of each max, lets import without any
// fuss and select the items imported
if (videos.count()<=1 && workouts.count() <= 1 && videosyncs.count() <= 1) {
if (!forcedialog && videos.count()<=1 && workouts.count() <= 1 && videosyncs.count() <= 1) {

trainDB->startLUW();

@@ -42,7 +42,7 @@ class Library : QObject

static void initialise(QDir); // init
static Library *findLibrary(QString);
static void importFiles(Context *context, QStringList files);
static void importFiles(Context *context, QStringList files, bool forcedialog=false);
void removeRef(Context *context, QString ref);
};

@@ -33,6 +33,8 @@
#include "Units.h"
#include "TimeUtils.h"
#include "HelpWhatsThis.h"
#include "Library.h"
#include "ErgFile.h"

#ifdef NOWEBKIT
#include <QtWebChannel>
@@ -312,8 +314,19 @@ WebPageWindow::downloadFinished()
{
// now try and import it (if download failed file won't exist)
// dialog is self deleting
RideImportWizard *dialog = new RideImportWizard(filenames, context);
dialog->process(); // do it!
QStringList rides, workouts;
foreach(QString filename, filenames) {
if (ErgFile::isWorkout(filename)) workouts << filename;
else rides << filename;
}

if (rides.count()) {
RideImportWizard *dialog = new RideImportWizard(rides, context);
dialog->process(); // do it!
}
if (workouts.count()) {
Library::importFiles(context, filenames, true);
}
}

void

0 comments on commit fc9fb7b

Please sign in to comment.
You can’t perform that action at this time.