Merge pull request #810 from stigbd/master

Made the fault handling in TPDownload a little more user friendly
This commit is contained in:
Mark Liversedge
2014-02-25 14:05:04 +00:00
4 changed files with 17 additions and 8 deletions

View File

@@ -63,9 +63,13 @@ TPAthlete::list(int type, QString user, QString pass)
void TPAthlete::getResponse(const QtSoapMessage &message)
{
waiting = false;
QString resultStr;
QList< QMap<QString, QString> > athletelist;
if (!message.isFault()) {
if (message.isFault()) {
resultStr = tr("Error:") + qPrintable(message.faultString().toString());
}
else {
const QtSoapType &response = message.returnValue();
if (response.isValid()) {
@@ -97,8 +101,8 @@ void TPAthlete::getResponse(const QtSoapMessage &message)
}
}
// return what we got (empty if failed)
completed(athletelist);
// return what we got (empty if non-valid response)
completed(resultStr, athletelist);
}
//

View File

@@ -34,7 +34,7 @@ public:
void list(int type, QString user, QString pass);
signals:
void completed(QList<QMap<QString,QString> >);
void completed(QString, QList<QMap<QString,QString> >);
private slots:
void getResponse(const QtSoapMessage &);

View File

@@ -33,7 +33,7 @@ TPDownloadDialog::TPDownloadDialog(Context *context) : QDialog(context->mainWind
athleter = new TPAthlete(this);
connect (athleter, SIGNAL(completed(QList<QMap<QString,QString> >)), this, SLOT(completedAthlete(QList<QMap<QString,QString> >)));
connect (athleter, SIGNAL(completed(QString, QList<QMap<QString,QString> >)), this, SLOT(completedAthlete(QString, QList<QMap<QString,QString> >)));
athleter->list(appsettings->cvalue(context->athlete->cyclist, GC_TPTYPE, "0").toInt(),
appsettings->cvalue(context->athlete->cyclist, GC_TPUSER, "null").toString(),
appsettings->cvalue(context->athlete->cyclist, GC_TPPASS, "null").toString());
@@ -42,7 +42,7 @@ TPDownloadDialog::TPDownloadDialog(Context *context) : QDialog(context->mainWind
}
void
TPDownloadDialog::completedAthlete(QList<QMap<QString, QString> >athletes)
TPDownloadDialog::completedAthlete(QString errorStr, QList<QMap<QString, QString> >athletes)
{
// did we get any athletes?
if (athletes.count() == 0) {
@@ -50,7 +50,12 @@ TPDownloadDialog::completedAthlete(QList<QMap<QString, QString> >athletes)
QMessageBox msgBox;
msgBox.setWindowTitle(tr("Download from TrainingPeaks.com"));
msgBox.setText(tr("You must be a premium member to download from TrainingPeaks. Please check your cyclist configurations are correct on the Passwords tab."));
if (errorStr.size() != 0) { // Something went wrong, so there should be a fault message
msgBox.setText(errorStr);
}
else {
msgBox.setText(tr("You must be a premium member to download from TrainingPeaks. Please check your cyclist configurations are correct on the Passwords tab."));
}
msgBox.setIcon(QMessageBox::Critical);
msgBox.exec();
reject();

View File

@@ -48,7 +48,7 @@ class TPDownloadDialog : public QDialog
bool useMetricUnits;
public slots:
void completedAthlete(QList<QMap<QString,QString> >);
void completedAthlete(QString, QList<QMap<QString,QString> >);
void completedWorkout(QList<QMap<QString,QString> >);
void completedDownload(QDomDocument);
void completedUpload(QString);