Fix #14
This commit is contained in:
parent
85c8760bed
commit
64670b9d88
2 changed files with 75 additions and 87 deletions
|
@ -124,7 +124,7 @@ Page {
|
|||
delegate: Button {
|
||||
id: catBt
|
||||
|
||||
width: parent.width
|
||||
width: selectorLv.width
|
||||
height: text !== "" ? selectorLv.delegateHeight:0
|
||||
|
||||
flat: true
|
||||
|
|
|
@ -7,56 +7,56 @@ BRProviderDr::BRProviderDr(QObject *parent) : BRProvider(parent)
|
|||
// - https://github.com/ralfbecker/ranking/blob/master/sitemgr/digitalrock/sac_calendar.php
|
||||
|
||||
this->leagues.insert(
|
||||
BRWidget::DAV,
|
||||
{
|
||||
{
|
||||
{"id", 0},
|
||||
{"name", "Deutsche Meisterschaft"},
|
||||
{"color", "#A8F0A8"},
|
||||
{"leagueIDs", QVariantList({59, 57, 60})}
|
||||
},
|
||||
{
|
||||
{"id", 1},
|
||||
{"name", "Deutscher Jugendcup"},
|
||||
{"color", "#D8FFD8"},
|
||||
{"leagueIDs", QVariantList({58})}
|
||||
},
|
||||
{
|
||||
{"id", 2},
|
||||
{"name", "Landesmeisterschaft"},
|
||||
{"color", "#F0F0F0"},
|
||||
{"leagueIDs", QVariantList({61, 56})}
|
||||
}
|
||||
});
|
||||
BRWidget::DAV,
|
||||
{
|
||||
{
|
||||
{"id", 0},
|
||||
{"name", "Deutsche Meisterschaft"},
|
||||
{"color", "#A8F0A8"},
|
||||
{"leagueIDs", QVariantList({59, 57, 60})}
|
||||
},
|
||||
{
|
||||
{"id", 1},
|
||||
{"name", "Deutscher Jugendcup"},
|
||||
{"color", "#D8FFD8"},
|
||||
{"leagueIDs", QVariantList({58})}
|
||||
},
|
||||
{
|
||||
{"id", 2},
|
||||
{"name", "Landesmeisterschaft"},
|
||||
{"color", "#F0F0F0"},
|
||||
{"leagueIDs", QVariantList({61, 56})}
|
||||
}
|
||||
});
|
||||
|
||||
this->leagues.insert(
|
||||
BRWidget::SAC,
|
||||
{
|
||||
{
|
||||
{"id", 0},
|
||||
{"name", "Erwachsene"},
|
||||
{"color", "#A8F0A8"},
|
||||
{"leagueIDs", QVariantList({57, 59, 60})}
|
||||
},
|
||||
{
|
||||
{"id", 1},
|
||||
{"name", "Jugend"},
|
||||
{"color", "#D8FFD8"},
|
||||
{"leagueIDs", QVariantList({65})}
|
||||
},
|
||||
{
|
||||
{"id", 2},
|
||||
{"name", "RegioCups"},
|
||||
{"color", "#F0F0F0"},
|
||||
{"leagueIDs", QVariantList({64})}
|
||||
},
|
||||
{
|
||||
{"id", 3},
|
||||
{"name", "Iceclimbing"},
|
||||
{"color", "#F0F0F0"},
|
||||
{"leagueIDs", QVariantList({84})}
|
||||
}
|
||||
});
|
||||
BRWidget::SAC,
|
||||
{
|
||||
{
|
||||
{"id", 0},
|
||||
{"name", "Erwachsene"},
|
||||
{"color", "#A8F0A8"},
|
||||
{"leagueIDs", QVariantList({57, 59, 60})}
|
||||
},
|
||||
{
|
||||
{"id", 1},
|
||||
{"name", "Jugend"},
|
||||
{"color", "#D8FFD8"},
|
||||
{"leagueIDs", QVariantList({65})}
|
||||
},
|
||||
{
|
||||
{"id", 2},
|
||||
{"name", "RegioCups"},
|
||||
{"color", "#F0F0F0"},
|
||||
{"leagueIDs", QVariantList({64})}
|
||||
},
|
||||
{
|
||||
{"id", 3},
|
||||
{"name", "Iceclimbing"},
|
||||
{"color", "#F0F0F0"},
|
||||
{"leagueIDs", QVariantList({84})}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
BRWidget::BRWidgetStatusCode BRProviderDr::getWidgetData(BRCalendar::BRCalendarData* calendarData)
|
||||
|
@ -68,7 +68,7 @@ BRWidget::BRWidgetStatusCode BRProviderDr::getWidgetData(BRCalendar::BRCalendarD
|
|||
QString requestUrl = "https://www.digitalrock.de/egroupware/ranking/json.php?nation=" + nationStr + "&year=" + QString::number(year);
|
||||
QVariantMap ret = this->serverRequest(QUrl(requestUrl));
|
||||
|
||||
if(ret["status"] != 200){
|
||||
if(ret["status"] != 200) {
|
||||
// request was a failure
|
||||
return BRWidget::BRWidgetStatusCode(ret["status"].toInt());
|
||||
}
|
||||
|
@ -83,10 +83,10 @@ BRWidget::BRWidgetStatusCode BRProviderDr::getWidgetData(BRCalendar::BRCalendarD
|
|||
for(QVariant seasonVar : seasons) {
|
||||
int seasonId = seasonVar.toString().toInt();
|
||||
BRSeason* season = this->getSeason(
|
||||
calendarData->calendar->getFederation(),
|
||||
seasonId,
|
||||
this->parseSeasonData(seasonId, data)
|
||||
);
|
||||
calendarData->calendar->getFederation(),
|
||||
seasonId,
|
||||
this->parseSeasonData(seasonId, data)
|
||||
);
|
||||
|
||||
calendarData->seasons.append(season);
|
||||
|
||||
|
@ -97,39 +97,30 @@ BRWidget::BRWidgetStatusCode BRProviderDr::getWidgetData(BRCalendar::BRCalendarD
|
|||
return BRWidget::Success;
|
||||
}
|
||||
|
||||
|
||||
|
||||
BRWidget::BRWidgetStatusCode BRProviderDr::getWidgetData(BRSeason::BRSeasonData* seasonData) {
|
||||
if(seasonData->season->getLeagues().length() > 0) {
|
||||
// leagues are already loaded
|
||||
|
||||
// load some data
|
||||
QString nationStr = seasonData->season->getFederation() == BRWidget::SAC ? "SUI":"GER";
|
||||
qDebug() << "Nation str: " << nationStr << " federation: " << seasonData->season->getFederation();
|
||||
int year = seasonData->season->getYear();
|
||||
QString requestUrl = "https://www.digitalrock.de/egroupware/ranking/json.php?nation=" + nationStr + "&year=" + QString::number(year);
|
||||
QVariantMap ret = this->serverRequest(QUrl(requestUrl));
|
||||
// load some data
|
||||
QString nationStr = seasonData->season->getFederation() == BRWidget::SAC ? "SUI":"GER";
|
||||
qDebug() << "Nation str: " << nationStr << " federation: " << seasonData->season->getFederation();
|
||||
int year = seasonData->season->getYear();
|
||||
QString requestUrl = "https://www.digitalrock.de/egroupware/ranking/json.php?nation=" + nationStr + "&year=" + QString::number(year);
|
||||
QVariantMap ret = this->serverRequest(QUrl(requestUrl));
|
||||
|
||||
if(ret["status"] != 200){
|
||||
// request was a failure
|
||||
return BRWidget::BRWidgetStatusCode(ret["status"].toInt());
|
||||
}
|
||||
|
||||
QVariantMap data = QJsonDocument::fromJson(ret["text"].toString().toUtf8()).toVariant().toMap();
|
||||
data.insert("year", year);
|
||||
data.insert("federation", seasonData->season->getFederation());
|
||||
|
||||
// populate season
|
||||
QVariantList seasons = data["years"].toList();
|
||||
|
||||
this->parseSeasonData(seasonData, year, data);
|
||||
|
||||
return BRWidget::Success;
|
||||
}
|
||||
else {
|
||||
// should never happen
|
||||
return BRWidget::NotImplementedError;
|
||||
if(ret["status"] != 200) {
|
||||
// request was a failure
|
||||
return BRWidget::BRWidgetStatusCode(ret["status"].toInt());
|
||||
}
|
||||
|
||||
QVariantMap data = QJsonDocument::fromJson(ret["text"].toString().toUtf8()).toVariant().toMap();
|
||||
data.insert("year", year);
|
||||
data.insert("federation", seasonData->season->getFederation());
|
||||
|
||||
// populate season
|
||||
QVariantList seasons = data["years"].toList();
|
||||
|
||||
this->parseSeasonData(seasonData, year, data);
|
||||
|
||||
return BRWidget::Success;
|
||||
}
|
||||
|
||||
BRSeason::BRSeasonData BRProviderDr::parseSeasonData(int id, QVariantMap rawData) {
|
||||
|
@ -202,7 +193,6 @@ BRLeague::BRLeagueData BRProviderDr::parseLeagueData(QVariantMap leaguePropertie
|
|||
return data;
|
||||
}
|
||||
|
||||
|
||||
BRWidget::BRWidgetStatusCode BRProviderDr::getWidgetData(BRCompetition::BRCompetitionData* competitionData) {
|
||||
|
||||
if(competitionData->competition->getCurrentCategory() == nullptr)
|
||||
|
@ -227,7 +217,7 @@ BRWidget::BRWidgetStatusCode BRProviderDr::getWidgetData(BRCompetition::BRCompet
|
|||
ret = this->serverRequest(QUrl(requestUrl));
|
||||
|
||||
// handle route not found errors
|
||||
if(ret["status"] != 200 && (ret["status"] != 404 || retryCount > 1)){
|
||||
if(ret["status"] != 200 && (ret["status"] != 404 || retryCount > 1)) {
|
||||
// request was a failure
|
||||
return BRWidget::BRWidgetStatusCode(ret["status"].toInt());
|
||||
}
|
||||
|
@ -410,8 +400,6 @@ void BRProviderDr::parseCompetitionData(BRCompetition::BRCompetitionData* compet
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
BRCup::BRCupData BRProviderDr::parseCupData(QVariantList categoriesList, QVariantMap rawData, BRWidget::BRFederation federation) {
|
||||
BRCup::BRCupData data;
|
||||
|
||||
|
|
Loading…
Reference in a new issue