Made the fault handling in TPDownload a little more user friendly

If something goes wrong, we try to display the fault message to the
user.
This commit is contained in:
Stig B. Dørmænen
2014-02-25 14:23:37 +01:00
committed by Gareth Coco
parent 0457d826ec
commit 9d8a7a59a2
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

@@ -31,7 +31,7 @@ TPDownloadDialog::TPDownloadDialog(MainWindow *main) : QDialog(main, Qt::Dialog)
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(main->cyclist, GC_TPTYPE, "0").toInt(),
appsettings->cvalue(main->cyclist, GC_TPUSER, "null").toString(),
appsettings->cvalue(main->cyclist, GC_TPPASS, "null").toString());
@@ -40,7 +40,7 @@ TPDownloadDialog::TPDownloadDialog(MainWindow *main) : QDialog(main, Qt::Dialog)
}
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) {
@@ -48,7 +48,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

@@ -44,7 +44,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);