This commit is contained in:
Dorian Zedler 2021-03-07 20:39:07 +01:00
parent 85c8760bed
commit 64670b9d88
Signed by: dorian
GPG key ID: 989DE36109AFA354
2 changed files with 75 additions and 87 deletions

View file

@ -124,7 +124,7 @@ Page {
delegate: Button { delegate: Button {
id: catBt id: catBt
width: parent.width width: selectorLv.width
height: text !== "" ? selectorLv.delegateHeight:0 height: text !== "" ? selectorLv.delegateHeight:0
flat: true flat: true

View file

@ -7,56 +7,56 @@ BRProviderDr::BRProviderDr(QObject *parent) : BRProvider(parent)
// - https://github.com/ralfbecker/ranking/blob/master/sitemgr/digitalrock/sac_calendar.php // - https://github.com/ralfbecker/ranking/blob/master/sitemgr/digitalrock/sac_calendar.php
this->leagues.insert( this->leagues.insert(
BRWidget::DAV, BRWidget::DAV,
{ {
{ {
{"id", 0}, {"id", 0},
{"name", "Deutsche Meisterschaft"}, {"name", "Deutsche Meisterschaft"},
{"color", "#A8F0A8"}, {"color", "#A8F0A8"},
{"leagueIDs", QVariantList({59, 57, 60})} {"leagueIDs", QVariantList({59, 57, 60})}
}, },
{ {
{"id", 1}, {"id", 1},
{"name", "Deutscher Jugendcup"}, {"name", "Deutscher Jugendcup"},
{"color", "#D8FFD8"}, {"color", "#D8FFD8"},
{"leagueIDs", QVariantList({58})} {"leagueIDs", QVariantList({58})}
}, },
{ {
{"id", 2}, {"id", 2},
{"name", "Landesmeisterschaft"}, {"name", "Landesmeisterschaft"},
{"color", "#F0F0F0"}, {"color", "#F0F0F0"},
{"leagueIDs", QVariantList({61, 56})} {"leagueIDs", QVariantList({61, 56})}
} }
}); });
this->leagues.insert( this->leagues.insert(
BRWidget::SAC, BRWidget::SAC,
{ {
{ {
{"id", 0}, {"id", 0},
{"name", "Erwachsene"}, {"name", "Erwachsene"},
{"color", "#A8F0A8"}, {"color", "#A8F0A8"},
{"leagueIDs", QVariantList({57, 59, 60})} {"leagueIDs", QVariantList({57, 59, 60})}
}, },
{ {
{"id", 1}, {"id", 1},
{"name", "Jugend"}, {"name", "Jugend"},
{"color", "#D8FFD8"}, {"color", "#D8FFD8"},
{"leagueIDs", QVariantList({65})} {"leagueIDs", QVariantList({65})}
}, },
{ {
{"id", 2}, {"id", 2},
{"name", "RegioCups"}, {"name", "RegioCups"},
{"color", "#F0F0F0"}, {"color", "#F0F0F0"},
{"leagueIDs", QVariantList({64})} {"leagueIDs", QVariantList({64})}
}, },
{ {
{"id", 3}, {"id", 3},
{"name", "Iceclimbing"}, {"name", "Iceclimbing"},
{"color", "#F0F0F0"}, {"color", "#F0F0F0"},
{"leagueIDs", QVariantList({84})} {"leagueIDs", QVariantList({84})}
} }
}); });
} }
BRWidget::BRWidgetStatusCode BRProviderDr::getWidgetData(BRCalendar::BRCalendarData* calendarData) 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); QString requestUrl = "https://www.digitalrock.de/egroupware/ranking/json.php?nation=" + nationStr + "&year=" + QString::number(year);
QVariantMap ret = this->serverRequest(QUrl(requestUrl)); QVariantMap ret = this->serverRequest(QUrl(requestUrl));
if(ret["status"] != 200){ if(ret["status"] != 200) {
// request was a failure // request was a failure
return BRWidget::BRWidgetStatusCode(ret["status"].toInt()); return BRWidget::BRWidgetStatusCode(ret["status"].toInt());
} }
@ -83,10 +83,10 @@ BRWidget::BRWidgetStatusCode BRProviderDr::getWidgetData(BRCalendar::BRCalendarD
for(QVariant seasonVar : seasons) { for(QVariant seasonVar : seasons) {
int seasonId = seasonVar.toString().toInt(); int seasonId = seasonVar.toString().toInt();
BRSeason* season = this->getSeason( BRSeason* season = this->getSeason(
calendarData->calendar->getFederation(), calendarData->calendar->getFederation(),
seasonId, seasonId,
this->parseSeasonData(seasonId, data) this->parseSeasonData(seasonId, data)
); );
calendarData->seasons.append(season); calendarData->seasons.append(season);
@ -97,39 +97,30 @@ BRWidget::BRWidgetStatusCode BRProviderDr::getWidgetData(BRCalendar::BRCalendarD
return BRWidget::Success; return BRWidget::Success;
} }
BRWidget::BRWidgetStatusCode BRProviderDr::getWidgetData(BRSeason::BRSeasonData* seasonData) { BRWidget::BRWidgetStatusCode BRProviderDr::getWidgetData(BRSeason::BRSeasonData* seasonData) {
if(seasonData->season->getLeagues().length() > 0) {
// leagues are already loaded
// load some data // load some data
QString nationStr = seasonData->season->getFederation() == BRWidget::SAC ? "SUI":"GER"; QString nationStr = seasonData->season->getFederation() == BRWidget::SAC ? "SUI":"GER";
qDebug() << "Nation str: " << nationStr << " federation: " << seasonData->season->getFederation(); qDebug() << "Nation str: " << nationStr << " federation: " << seasonData->season->getFederation();
int year = seasonData->season->getYear(); int year = seasonData->season->getYear();
QString requestUrl = "https://www.digitalrock.de/egroupware/ranking/json.php?nation=" + nationStr + "&year=" + QString::number(year); QString requestUrl = "https://www.digitalrock.de/egroupware/ranking/json.php?nation=" + nationStr + "&year=" + QString::number(year);
QVariantMap ret = this->serverRequest(QUrl(requestUrl)); QVariantMap ret = this->serverRequest(QUrl(requestUrl));
if(ret["status"] != 200){ if(ret["status"] != 200) {
// request was a failure // request was a failure
return BRWidget::BRWidgetStatusCode(ret["status"].toInt()); 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;
} }
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) { BRSeason::BRSeasonData BRProviderDr::parseSeasonData(int id, QVariantMap rawData) {
@ -202,7 +193,6 @@ BRLeague::BRLeagueData BRProviderDr::parseLeagueData(QVariantMap leaguePropertie
return data; return data;
} }
BRWidget::BRWidgetStatusCode BRProviderDr::getWidgetData(BRCompetition::BRCompetitionData* competitionData) { BRWidget::BRWidgetStatusCode BRProviderDr::getWidgetData(BRCompetition::BRCompetitionData* competitionData) {
if(competitionData->competition->getCurrentCategory() == nullptr) if(competitionData->competition->getCurrentCategory() == nullptr)
@ -227,7 +217,7 @@ BRWidget::BRWidgetStatusCode BRProviderDr::getWidgetData(BRCompetition::BRCompet
ret = this->serverRequest(QUrl(requestUrl)); ret = this->serverRequest(QUrl(requestUrl));
// handle route not found errors // 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 // request was a failure
return BRWidget::BRWidgetStatusCode(ret["status"].toInt()); 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 BRProviderDr::parseCupData(QVariantList categoriesList, QVariantMap rawData, BRWidget::BRFederation federation) {
BRCup::BRCupData data; BRCup::BRCupData data;