mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-14 08:38:45 +00:00
The new powercontrols have a lot more memory and they allow you to selectively download the recorded "rides". Looking at srmwin, this seems to be the suggested way of operation. (i.e. record multiple workouts, download only the "new" ones). Furthermore, the SRM file format has some limits (timespan, total number of records), that make it inapropriate to store "all rides" into one file and split it later. So download now - tries to get a list of rides of the device - if it gets any, the user can get prompted to choose which to download. - let device download (selected/all) rides, split if necessary and return a list with tmp filename, start time, file extension. - download dialog builds new filename based on time, prompts user for overwriting when file exists and renames file. The download Dialog now stays open, so user can read the status messages and click "cleanup". This avoids many of the anoying message boxes we had in the Srm download. Cleanup's user interaction (confirmation, errors) was moved from the individual device to DownloadDialog, as well.
87 lines
1.8 KiB
C++
87 lines
1.8 KiB
C++
/*
|
|
* Copyright (c) 2008 Sean C. Rhea (srhea@srhea.net)
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU General Public License as published by the Free
|
|
* Software Foundation; either version 2 of the License, or (at your option)
|
|
* any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
* more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along
|
|
* with this program; if not, write to the Free Software Foundation, Inc., 51
|
|
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
#include "Device.h"
|
|
|
|
#define tr(s) QObject::tr(s)
|
|
|
|
typedef QMap<QString,DevicesPtr> DevicesMap;
|
|
|
|
static DevicesMap *devicesPtr;
|
|
|
|
inline DevicesMap &
|
|
devices()
|
|
{
|
|
if (devicesPtr == NULL)
|
|
devicesPtr = new QMap<QString,DevicesPtr>;
|
|
return *devicesPtr;
|
|
}
|
|
|
|
Device::~Device()
|
|
{
|
|
if( dev->isOpen() )
|
|
dev->close();
|
|
}
|
|
|
|
bool
|
|
Device::preview( StatusCallback statusCallback, QString &err )
|
|
{
|
|
(void) statusCallback;
|
|
(void) err;
|
|
|
|
return true;
|
|
}
|
|
|
|
QList<DeviceRideItemPtr> &Device::rides()
|
|
{
|
|
return rideList;
|
|
}
|
|
|
|
bool
|
|
Device::cleanup( QString &err )
|
|
{
|
|
(void) dev;
|
|
|
|
err = tr("cleanup is not supported");
|
|
|
|
return false;
|
|
}
|
|
|
|
|
|
QList<QString>
|
|
Devices::typeNames()
|
|
{
|
|
return devices().keys();
|
|
}
|
|
|
|
DevicesPtr
|
|
Devices::getType(const QString &deviceTypeName )
|
|
{
|
|
assert(devices().contains(deviceTypeName));
|
|
return devices().value(deviceTypeName);
|
|
}
|
|
|
|
bool
|
|
Devices::addType(const QString &deviceTypeName, DevicesPtr p )
|
|
{
|
|
assert(!devices().contains(deviceTypeName));
|
|
devices().insert(deviceTypeName, p);
|
|
return true;
|
|
}
|
|
|