Compare commits
13 commits
main
...
internal_m
Author | SHA1 | Date | |
---|---|---|---|
bef407ebc3 | |||
d2a0c9a2d5 | |||
2ffbd09afc | |||
64670b9d88 | |||
85c8760bed | |||
9d8e1c7c42 | |||
035a2edcdf | |||
252f8dbfdd | |||
9b762ea246 | |||
c44380d1bf | |||
0c7f5a42e4 | |||
77070aa98b | |||
92caac3309 |
60 changed files with 5094 additions and 248 deletions
40
NewStructure.md
Normal file
40
NewStructure.md
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
# Layer 1:
|
||||||
|
- Server Conector -> gets data as QVariant
|
||||||
|
- One class: BRServerConnector
|
||||||
|
- URL has to be given as string
|
||||||
|
|
||||||
|
# Layer 2:
|
||||||
|
- Translation layer
|
||||||
|
- classes:
|
||||||
|
- BRController
|
||||||
|
- BRProvider
|
||||||
|
- BRProvderDr
|
||||||
|
|
||||||
|
|
||||||
|
# Layer 3
|
||||||
|
- Consisten data layer
|
||||||
|
- classes:
|
||||||
|
- BRWidget -> gets a provider, has an int load() function
|
||||||
|
- BRCalendar
|
||||||
|
- BRCompetition
|
||||||
|
- BRCategory
|
||||||
|
- BRResult
|
||||||
|
- BRBoulderResult
|
||||||
|
- BRLeadResult
|
||||||
|
- BRSpeedResult
|
||||||
|
# layer 4
|
||||||
|
- QML
|
||||||
|
- Will call functions from Layer 2 and get Objects from Layer 3
|
||||||
|
|
||||||
|
|
||||||
|
# Season and Leagues handling
|
||||||
|
1. Calendar loads
|
||||||
|
-> Calendar gets available seasons (which get available leagues)
|
||||||
|
-> Data loader decides on default season and default league(s)
|
||||||
|
-> Data loader loads default competitions
|
||||||
|
2. Calendar displays competitions
|
||||||
|
3. Current season is changed:
|
||||||
|
-> calendar reloads
|
||||||
|
-> Data loader sees that the availableSeasons are already
|
||||||
|
4. Current League is changed:
|
||||||
|
-> calendar reloads
|
74
android-sources/AndroidManifest.old.xml
Normal file
74
android-sources/AndroidManifest.old.xml
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<manifest package="com.itsblue.blueROCKtest" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.03.1" android:versionCode="13" android:installLocation="auto">
|
||||||
|
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="blueROCK" android:icon="@drawable/icon">
|
||||||
|
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="blueROCK" android:screenOrientation="unspecified" android:launchMode="singleTop">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
|
<category android:name="android.intent.category.LAUNCHER"/>
|
||||||
|
</intent-filter>
|
||||||
|
<!-- Application arguments -->
|
||||||
|
<!-- meta-data android:name="android.app.arguments" android:value="arg1 arg2 arg3"/ -->
|
||||||
|
<!-- Application arguments -->
|
||||||
|
<meta-data android:name="android.app.lib_name" android:value="blueROCK"/>
|
||||||
|
<meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
|
||||||
|
<meta-data android:name="android.app.repository" android:value="default"/>
|
||||||
|
<meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
|
||||||
|
<meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
|
||||||
|
<!-- Deploy Qt libs as part of package -->
|
||||||
|
<meta-data android:name="android.app.bundle_local_qt_libs" android:value="1"/>
|
||||||
|
<meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/>
|
||||||
|
<meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/>
|
||||||
|
<!-- Run with local libs -->
|
||||||
|
<meta-data android:name="android.app.use_local_qt_libs" android:value="1"/>
|
||||||
|
<meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
|
||||||
|
<meta-data android:name="android.app.load_local_libs" android:value="plugins/platforms/android/libqtforandroid.so:plugins/bearer/libqandroidbearer.so:lib/libQt5QuickParticles.so"/>
|
||||||
|
<meta-data android:name="android.app.load_local_jars" android:value="jar/QtAndroid.jar:jar/QtAndroidBearer.jar:jar/QtAndroidExtras.jar"/>
|
||||||
|
<meta-data android:name="android.app.static_init_classes" android:value=""/>
|
||||||
|
<!-- Used to specify custom system library path to run with local system libs -->
|
||||||
|
<!-- <meta-data android:name="android.app.system_libs_prefix" android:value="/system/lib/"/> -->
|
||||||
|
<!-- Messages maps -->
|
||||||
|
<meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/>
|
||||||
|
<meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/>
|
||||||
|
<meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
|
||||||
|
<!-- Messages maps -->
|
||||||
|
<!-- Splash screen -->
|
||||||
|
<!-- meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/ -->
|
||||||
|
<!-- meta-data android:name="android.app.splash_screen_sticky" android:value="true"/ -->
|
||||||
|
<!-- Splash screen -->
|
||||||
|
<!-- Background running -->
|
||||||
|
<!-- Warning: changing this value to true may cause unexpected crashes if the
|
||||||
|
application still try to draw after
|
||||||
|
"applicationStateChanged(Qt::ApplicationSuspended)"
|
||||||
|
signal is sent! -->
|
||||||
|
<meta-data android:name="android.app.background_running" android:value="false"/>
|
||||||
|
<!-- Background running -->
|
||||||
|
<!-- auto screen scale factor -->
|
||||||
|
<meta-data android:name="android.app.auto_screen_scale_factor" android:value="false"/>
|
||||||
|
<!-- auto screen scale factor -->
|
||||||
|
<!-- extract android style -->
|
||||||
|
<!-- available android:values :
|
||||||
|
* full - useful QWidget & Quick Controls 1 apps
|
||||||
|
* minimal - useful for Quick Controls 2 apps, it is much faster than "full"
|
||||||
|
* none - useful for apps that don't use any of the above Qt modules
|
||||||
|
-->
|
||||||
|
<meta-data android:name="android.app.extract_android_style" android:value="full"/>
|
||||||
|
<!-- extract android style -->
|
||||||
|
</activity>
|
||||||
|
<!-- For adding service(s) please check: https://wiki.qt.io/AndroidServices -->
|
||||||
|
</application>
|
||||||
|
|
||||||
|
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
|
||||||
|
|
||||||
|
<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
|
||||||
|
Remove the comment if you do not require these default permissions. -->
|
||||||
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
|
||||||
|
Remove the comment if you do not require these default features. -->
|
||||||
|
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
|
||||||
|
|
||||||
|
<uses-permission android:name="com.android.vending.BILLING"/>
|
||||||
|
</manifest>
|
|
@ -1,44 +1,54 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<manifest package="com.itsblue.blueROCKtest" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.03.1" android:versionCode="13" android:installLocation="auto">
|
<manifest package="com.itsblue.blueROCKtest" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="-- %%INSERT_VERSION_NAME%% --" android:versionCode="-- %%INSERT_VERSION_CODE%% --" android:installLocation="auto">
|
||||||
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="blueROCK" android:icon="@drawable/icon">
|
<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
|
||||||
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="blueROCK" android:screenOrientation="unspecified" android:launchMode="singleTop">
|
Remove the comment if you do not require these default permissions. -->
|
||||||
|
<!-- %%INSERT_PERMISSIONS -->
|
||||||
|
|
||||||
|
<!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
|
||||||
|
Remove the comment if you do not require these default features. -->
|
||||||
|
<!-- %%INSERT_FEATURES -->
|
||||||
|
|
||||||
|
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
|
||||||
|
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="-- %%INSERT_APP_NAME%% --" android:extractNativeLibs="true" android:icon="@drawable/icon">
|
||||||
|
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="-- %%INSERT_APP_NAME%% --" android:screenOrientation="unspecified" android:launchMode="singleTop">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN"/>
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
<category android:name="android.intent.category.LAUNCHER"/>
|
<category android:name="android.intent.category.LAUNCHER"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
<!-- Application arguments -->
|
<!-- Application arguments -->
|
||||||
<!-- meta-data android:name="android.app.arguments" android:value="arg1 arg2 arg3"/ -->
|
<!-- meta-data android:name="android.app.arguments" android:value="arg1 arg2 arg3"/ -->
|
||||||
<!-- Application arguments -->
|
<!-- Application arguments -->
|
||||||
|
<meta-data android:name="android.app.lib_name" android:value="-- %%INSERT_APP_LIB_NAME%% --"/>
|
||||||
<meta-data android:name="android.app.lib_name" android:value="blueROCK"/>
|
|
||||||
<meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
|
<meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
|
||||||
<meta-data android:name="android.app.repository" android:value="default"/>
|
<meta-data android:name="android.app.repository" android:value="default"/>
|
||||||
<meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
|
<meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
|
||||||
<meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
|
<meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
|
||||||
<!-- Deploy Qt libs as part of package -->
|
<!-- Deploy Qt libs as part of package -->
|
||||||
<meta-data android:name="android.app.bundle_local_qt_libs" android:value="1"/>
|
<meta-data android:name="android.app.bundle_local_qt_libs" android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --"/>
|
||||||
<meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/>
|
|
||||||
<meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/>
|
|
||||||
<!-- Run with local libs -->
|
<!-- Run with local libs -->
|
||||||
<meta-data android:name="android.app.use_local_qt_libs" android:value="1"/>
|
<meta-data android:name="android.app.use_local_qt_libs" android:value="-- %%USE_LOCAL_QT_LIBS%% --"/>
|
||||||
<meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
|
<meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
|
||||||
<meta-data android:name="android.app.load_local_libs" android:value="plugins/platforms/android/libqtforandroid.so:plugins/bearer/libqandroidbearer.so:lib/libQt5QuickParticles.so"/>
|
<meta-data android:name="android.app.load_local_libs_resource_id" android:resource="@array/load_local_libs"/>
|
||||||
<meta-data android:name="android.app.load_local_jars" android:value="jar/QtAndroid.jar:jar/QtAndroidBearer.jar:jar/QtAndroidExtras.jar"/>
|
<meta-data android:name="android.app.load_local_jars" android:value="-- %%INSERT_LOCAL_JARS%% --"/>
|
||||||
<meta-data android:name="android.app.static_init_classes" android:value=""/>
|
<meta-data android:name="android.app.static_init_classes" android:value="-- %%INSERT_INIT_CLASSES%% --"/>
|
||||||
<!-- Used to specify custom system library path to run with local system libs -->
|
<!-- Used to specify custom system library path to run with local system libs -->
|
||||||
<!-- <meta-data android:name="android.app.system_libs_prefix" android:value="/system/lib/"/> -->
|
<!-- <meta-data android:name="android.app.system_libs_prefix" android:value="/system/lib/"/> -->
|
||||||
<!-- Messages maps -->
|
<!-- Messages maps -->
|
||||||
<meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/>
|
<meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/>
|
||||||
<meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/>
|
<meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/>
|
||||||
<meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
|
<meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
|
||||||
|
<meta-data android:value="@string/unsupported_android_version" android:name="android.app.unsupported_android_version"/>
|
||||||
<!-- Messages maps -->
|
<!-- Messages maps -->
|
||||||
|
|
||||||
<!-- Splash screen -->
|
<!-- Splash screen -->
|
||||||
|
<!-- Orientation-specific (portrait/landscape) data is checked first. If not available for current orientation,
|
||||||
|
then android.app.splash_screen_drawable. For best results, use together with splash_screen_sticky and
|
||||||
|
use hideSplashScreen() with a fade-out animation from Qt Android Extras to hide the splash screen when you
|
||||||
|
are done populating your window with content. -->
|
||||||
|
<!-- meta-data android:name="android.app.splash_screen_drawable_portrait" android:resource="@drawable/logo_portrait" / -->
|
||||||
|
<!-- meta-data android:name="android.app.splash_screen_drawable_landscape" android:resource="@drawable/logo_landscape" / -->
|
||||||
<!-- meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/ -->
|
<!-- meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/ -->
|
||||||
<!-- meta-data android:name="android.app.splash_screen_sticky" android:value="true"/ -->
|
<!-- meta-data android:name="android.app.splash_screen_sticky" android:value="true"/ -->
|
||||||
<!-- Splash screen -->
|
<!-- Splash screen -->
|
||||||
|
|
||||||
<!-- Background running -->
|
<!-- Background running -->
|
||||||
<!-- Warning: changing this value to true may cause unexpected crashes if the
|
<!-- Warning: changing this value to true may cause unexpected crashes if the
|
||||||
application still try to draw after
|
application still try to draw after
|
||||||
|
@ -46,38 +56,21 @@
|
||||||
signal is sent! -->
|
signal is sent! -->
|
||||||
<meta-data android:name="android.app.background_running" android:value="false"/>
|
<meta-data android:name="android.app.background_running" android:value="false"/>
|
||||||
<!-- Background running -->
|
<!-- Background running -->
|
||||||
|
|
||||||
<!-- auto screen scale factor -->
|
<!-- auto screen scale factor -->
|
||||||
<meta-data android:name="android.app.auto_screen_scale_factor" android:value="false"/>
|
<meta-data android:name="android.app.auto_screen_scale_factor" android:value="false"/>
|
||||||
<!-- auto screen scale factor -->
|
<!-- auto screen scale factor -->
|
||||||
|
|
||||||
<!-- extract android style -->
|
<!-- extract android style -->
|
||||||
<!-- available android:values :
|
<!-- available android:values :
|
||||||
|
* default - In most cases this will be the same as "full", but it can also be something else if needed, e.g., for compatibility reasons
|
||||||
* full - useful QWidget & Quick Controls 1 apps
|
* full - useful QWidget & Quick Controls 1 apps
|
||||||
* minimal - useful for Quick Controls 2 apps, it is much faster than "full"
|
* minimal - useful for Quick Controls 2 apps, it is much faster than "full"
|
||||||
* none - useful for apps that don't use any of the above Qt modules
|
* none - useful for apps that don't use any of the above Qt modules
|
||||||
-->
|
-->
|
||||||
<meta-data android:name="android.app.extract_android_style" android:value="full"/>
|
<meta-data android:name="android.app.extract_android_style" android:value="default"/>
|
||||||
<!-- extract android style -->
|
<!-- extract android style -->
|
||||||
</activity>
|
</activity>
|
||||||
|
<!-- For adding service(s) please check: https://wiki.qt.io/AndroidServices -->
|
||||||
<!-- For adding service(s) please check: https://wiki.qt.io/AndroidServices -->
|
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28"/>
|
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="29"/>
|
||||||
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
|
|
||||||
|
|
||||||
<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
|
|
||||||
Remove the comment if you do not require these default permissions. -->
|
|
||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
|
|
||||||
Remove the comment if you do not require these default features. -->
|
|
||||||
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
|
|
||||||
|
|
||||||
<uses-permission android:name="com.android.vending.BILLING"/>
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|
68
android-sources/build.gradle
Normal file
68
android-sources/build.gradle
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
classpath 'com.android.tools.build:gradle:3.6.0'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
/*******************************************************
|
||||||
|
* The following variables:
|
||||||
|
* - androidBuildToolsVersion,
|
||||||
|
* - androidCompileSdkVersion
|
||||||
|
* - qt5AndroidDir - holds the path to qt android files
|
||||||
|
* needed to build any Qt application
|
||||||
|
* on Android.
|
||||||
|
*
|
||||||
|
* are defined in gradle.properties file. This file is
|
||||||
|
* updated by QtCreator and androiddeployqt tools.
|
||||||
|
* Changing them manually might break the compilation!
|
||||||
|
*******************************************************/
|
||||||
|
|
||||||
|
compileSdkVersion androidCompileSdkVersion.toInteger()
|
||||||
|
|
||||||
|
buildToolsVersion '28.0.3'
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
main {
|
||||||
|
manifest.srcFile 'AndroidManifest.xml'
|
||||||
|
java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java']
|
||||||
|
aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl']
|
||||||
|
res.srcDirs = [qt5AndroidDir + '/res', 'res']
|
||||||
|
resources.srcDirs = ['resources']
|
||||||
|
renderscript.srcDirs = ['src']
|
||||||
|
assets.srcDirs = ['assets']
|
||||||
|
jniLibs.srcDirs = ['libs']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lintOptions {
|
||||||
|
abortOnError false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do not compress Qt binary resources file
|
||||||
|
aaptOptions {
|
||||||
|
noCompress 'rcc'
|
||||||
|
}
|
||||||
|
defaultConfig {
|
||||||
|
resConfig "en"
|
||||||
|
minSdkVersion = qtMinSdkVersion
|
||||||
|
targetSdkVersion = 29
|
||||||
|
//qtTargetSdkVersion
|
||||||
|
}
|
||||||
|
}
|
BIN
android-sources/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
android-sources/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
5
android-sources/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
5
android-sources/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
172
android-sources/gradlew
vendored
Executable file
172
android-sources/gradlew
vendored
Executable file
|
@ -0,0 +1,172 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
##
|
||||||
|
## Gradle start up script for UN*X
|
||||||
|
##
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
PRG="$0"
|
||||||
|
# Need this for relative symlinks.
|
||||||
|
while [ -h "$PRG" ] ; do
|
||||||
|
ls=`ls -ld "$PRG"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
PRG="$link"
|
||||||
|
else
|
||||||
|
PRG=`dirname "$PRG"`"/$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
SAVED="`pwd`"
|
||||||
|
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
|
APP_NAME="Gradle"
|
||||||
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS=""
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD="maximum"
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "`uname`" in
|
||||||
|
CYGWIN* )
|
||||||
|
cygwin=true
|
||||||
|
;;
|
||||||
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
NONSTOP* )
|
||||||
|
nonstop=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
|
else
|
||||||
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD="java"
|
||||||
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||||
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
|
if [ $? -eq 0 ] ; then
|
||||||
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
|
MAX_FD="$MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
ulimit -n $MAX_FD
|
||||||
|
if [ $? -ne 0 ] ; then
|
||||||
|
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Darwin, add options to specify how the application appears in the dock
|
||||||
|
if $darwin; then
|
||||||
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Cygwin, switch paths to Windows format before running java
|
||||||
|
if $cygwin ; then
|
||||||
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
|
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||||
|
SEP=""
|
||||||
|
for dir in $ROOTDIRSRAW ; do
|
||||||
|
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||||
|
SEP="|"
|
||||||
|
done
|
||||||
|
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||||
|
# Add a user-defined pattern to the cygpath arguments
|
||||||
|
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||||
|
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||||
|
fi
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
i=0
|
||||||
|
for arg in "$@" ; do
|
||||||
|
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||||
|
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||||
|
|
||||||
|
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||||
|
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||||
|
else
|
||||||
|
eval `echo args$i`="\"$arg\""
|
||||||
|
fi
|
||||||
|
i=$((i+1))
|
||||||
|
done
|
||||||
|
case $i in
|
||||||
|
(0) set -- ;;
|
||||||
|
(1) set -- "$args0" ;;
|
||||||
|
(2) set -- "$args0" "$args1" ;;
|
||||||
|
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
|
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
|
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
|
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
|
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
|
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
|
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Escape application args
|
||||||
|
save () {
|
||||||
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
|
echo " "
|
||||||
|
}
|
||||||
|
APP_ARGS=$(save "$@")
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
|
|
||||||
|
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||||
|
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
84
android-sources/gradlew.bat
vendored
Normal file
84
android-sources/gradlew.bat
vendored
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
@if "%DEBUG%" == "" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS=
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if "%ERRORLEVEL%" == "0" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:init
|
||||||
|
@rem Get command-line arguments, handling Windows variants
|
||||||
|
|
||||||
|
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||||
|
|
||||||
|
:win9xME_args
|
||||||
|
@rem Slurp the command line arguments.
|
||||||
|
set CMD_LINE_ARGS=
|
||||||
|
set _SKIP=2
|
||||||
|
|
||||||
|
:win9xME_args_slurp
|
||||||
|
if "x%~1" == "x" goto execute
|
||||||
|
|
||||||
|
set CMD_LINE_ARGS=%*
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
@rem Execute Gradle
|
||||||
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||||
|
|
||||||
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
|
rem the _cmd.exe /c_ return code!
|
||||||
|
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||||
|
exit /b 1
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
Binary file not shown.
Before Width: | Height: | Size: 150 KiB After Width: | Height: | Size: 124 KiB |
Binary file not shown.
Before Width: | Height: | Size: 150 KiB After Width: | Height: | Size: 124 KiB |
Binary file not shown.
Before Width: | Height: | Size: 150 KiB After Width: | Height: | Size: 124 KiB |
22
android-sources/res/values/libs.xml
Normal file
22
android-sources/res/values/libs.xml
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<resources>
|
||||||
|
<array name="qt_sources">
|
||||||
|
<item>https://download.qt.io/ministro/android/qt5/qt-5.14</item>
|
||||||
|
</array>
|
||||||
|
|
||||||
|
<!-- The following is handled automatically by the deployment tool. It should
|
||||||
|
not be edited manually. -->
|
||||||
|
|
||||||
|
<array name="bundled_libs">
|
||||||
|
<!-- %%INSERT_EXTRA_LIBS%% -->
|
||||||
|
</array>
|
||||||
|
|
||||||
|
<array name="qt_libs">
|
||||||
|
<!-- %%INSERT_QT_LIBS%% -->
|
||||||
|
</array>
|
||||||
|
|
||||||
|
<array name="load_local_libs">
|
||||||
|
<!-- %%INSERT_LOCAL_LIBS%% -->
|
||||||
|
</array>
|
||||||
|
|
||||||
|
</resources>
|
68
blueROCK.pro
68
blueROCK.pro
|
@ -5,6 +5,7 @@ VERSION = 0.04
|
||||||
|
|
||||||
android {
|
android {
|
||||||
QT += androidextras
|
QT += androidextras
|
||||||
|
android: include(/home/dorian/Android/Sdk/android_openssl/openssl.pri)
|
||||||
ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android-sources
|
ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android-sources
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,9 +26,55 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
||||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
|
sources/brathlete.cpp \
|
||||||
|
sources/brleague.cpp \
|
||||||
sources/appsettings.cpp \
|
sources/appsettings.cpp \
|
||||||
sources/main.cpp \
|
sources/brcalendar.cpp \
|
||||||
sources/serverconn.cpp
|
sources/competition/brround.cpp \
|
||||||
|
sources/brseason.cpp \
|
||||||
|
sources/brserverconnector.cpp \
|
||||||
|
sources/brwidget.cpp \
|
||||||
|
sources/competition/result/brresultdetailsgeneralresult.cpp \
|
||||||
|
sources/main.cpp \
|
||||||
|
sources/brcontroller.cpp \
|
||||||
|
sources/provider/brprovider.cpp \
|
||||||
|
sources/provider/brproviderdr.cpp \
|
||||||
|
sources/provider/brprovidervl.cpp \
|
||||||
|
sources/competition/brcategory.cpp \
|
||||||
|
sources/competition/brcompetition.cpp \
|
||||||
|
sources/competition/result/brresult.cpp \
|
||||||
|
sources/competition/result/brresultdetails.cpp \
|
||||||
|
sources/competition/result/brresultdetailsunknown.cpp \
|
||||||
|
sources/cup/brcup.cpp
|
||||||
|
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
headers/brathlete.h \
|
||||||
|
headers/brleague.h \
|
||||||
|
headers/appsettings.h \
|
||||||
|
headers/brcalendar.h \
|
||||||
|
headers/competition/brcategory.h \
|
||||||
|
headers/competition/brcompetition.h \
|
||||||
|
headers/brcontroller.h \
|
||||||
|
headers/brseason.h \
|
||||||
|
headers/brserverconnector.h \
|
||||||
|
headers/brwidget.h \
|
||||||
|
headers/competition/result/brresultdetailsgeneralresult.h \
|
||||||
|
headers/provider/brprovider.h \
|
||||||
|
headers/provider/brproviderdr.h \
|
||||||
|
headers/provider/brprovidervl.h \
|
||||||
|
headers/competition/brround.h \
|
||||||
|
headers/competition/result/brresult.h \
|
||||||
|
headers/competition/result/brresultdetails.h \
|
||||||
|
headers/competition/result/brresultdetailsunknown.h \
|
||||||
|
headers/cup/brcup.h
|
||||||
|
|
||||||
|
INCLUDEPATH += \
|
||||||
|
headers \
|
||||||
|
headers/provider \
|
||||||
|
headers/competition \
|
||||||
|
headers/competition/result \
|
||||||
|
headers/cup
|
||||||
|
|
||||||
RESOURCES += resources/qml/qml.qrc \
|
RESOURCES += resources/qml/qml.qrc \
|
||||||
resources/shared/shared.qrc \
|
resources/shared/shared.qrc \
|
||||||
|
@ -46,12 +93,21 @@ qnx: target.path = /tmp/$${TARGET}/bin
|
||||||
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||||
!isEmpty(target.path): INSTALLS += target
|
!isEmpty(target.path): INSTALLS += target
|
||||||
|
|
||||||
HEADERS += \
|
|
||||||
headers/appsettings.h \
|
|
||||||
headers/serverconn.h
|
|
||||||
|
|
||||||
DISTFILES += \
|
DISTFILES += \
|
||||||
CHANGELOG.md \
|
CHANGELOG.md \
|
||||||
android-sources/AndroidManifest.xml \
|
android-sources/AndroidManifest.xml \
|
||||||
|
android-sources/build.gradle \
|
||||||
|
android-sources/gradle/wrapper/gradle-wrapper.jar \
|
||||||
|
android-sources/gradle/wrapper/gradle-wrapper.properties \
|
||||||
|
android-sources/gradlew \
|
||||||
|
android-sources/gradlew.bat \
|
||||||
|
android-sources/res/values/libs.xml \
|
||||||
resources/shared/icons/bluerock/index.theme \
|
resources/shared/icons/bluerock/index.theme \
|
||||||
$$files(resources/shared/icons/*.png, true)
|
$$files(resources/shared/icons/*.png, true)
|
||||||
|
|
||||||
|
ANDROID_ABIS = armeabi-v7a
|
||||||
|
|
||||||
|
contains(ANDROID_TARGET_ARCH,armeabi-v7a) {
|
||||||
|
ANDROID_ABIS = \
|
||||||
|
armeabi-v7a
|
||||||
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ class AppSettings : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY(NOTIFY themeChanged)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit AppSettings(QObject *parent = nullptr);
|
explicit AppSettings(QObject *parent = nullptr);
|
||||||
|
|
73
headers/brathlete.h
Normal file
73
headers/brathlete.h
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
#ifndef BRATHLETE_H
|
||||||
|
#define BRATHLETE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QUrl>
|
||||||
|
#include "brwidget.h"
|
||||||
|
|
||||||
|
class BRAthlete : public BRWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QString firstName READ getFirstName NOTIFY metadataChanged)
|
||||||
|
Q_PROPERTY(QString lastName READ getLastName NOTIFY metadataChanged)
|
||||||
|
Q_PROPERTY(QString city READ getCity NOTIFY metadataChanged)
|
||||||
|
Q_PROPERTY(QString federation READ getFederation NOTIFY metadataChanged)
|
||||||
|
Q_PROPERTY(QUrl federationUrl READ getFederationUrl NOTIFY metadataChanged)
|
||||||
|
Q_PROPERTY(int yearOfBirth READ getYearOfBirth NOTIFY metadataChanged)
|
||||||
|
Q_PROPERTY(BRAthleteGender gender READ getGender NOTIFY metadataChanged)
|
||||||
|
Q_PROPERTY(QString nation READ getNation NOTIFY metadataChanged)
|
||||||
|
Q_PROPERTY(int age READ getAge NOTIFY metadataChanged)
|
||||||
|
public:
|
||||||
|
friend class BRProvider;
|
||||||
|
|
||||||
|
enum BRAthleteGender {
|
||||||
|
Unknown = -1,
|
||||||
|
Male,
|
||||||
|
Female
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const BRAthlete* athlete;
|
||||||
|
|
||||||
|
QString firstName;
|
||||||
|
QString lastName;
|
||||||
|
QString city;
|
||||||
|
QString federation;
|
||||||
|
QUrl federationUrl;
|
||||||
|
int yearOfBirth;
|
||||||
|
BRAthleteGender gender;
|
||||||
|
QString nation;
|
||||||
|
int age;
|
||||||
|
} BRAthleteData;
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode load() override;
|
||||||
|
|
||||||
|
QString getFirstName();
|
||||||
|
QString getLastName();
|
||||||
|
QString getCity();
|
||||||
|
QString getFederation();
|
||||||
|
QUrl getFederationUrl();
|
||||||
|
int getYearOfBirth();
|
||||||
|
BRAthleteGender getGender();
|
||||||
|
QString getNation();
|
||||||
|
int getAge();
|
||||||
|
|
||||||
|
private:
|
||||||
|
BRAthlete(BRProvider* provider, BRWidget::BRFederation federation, int id, BRAthleteData initialData);
|
||||||
|
void setData(BRAthleteData data);
|
||||||
|
|
||||||
|
QString firstName;
|
||||||
|
QString lastName;
|
||||||
|
QString city;
|
||||||
|
QString federation;
|
||||||
|
QUrl federationUrl;
|
||||||
|
int yearOfBirth;
|
||||||
|
BRAthleteGender gender;
|
||||||
|
QString nation;
|
||||||
|
int age;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void metadataChanged();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BRATHLETE_H
|
48
headers/brcalendar.h
Normal file
48
headers/brcalendar.h
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
#ifndef BRCALENDAR_H
|
||||||
|
#define BRCALENDAR_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "brwidget.h"
|
||||||
|
#include "brseason.h"
|
||||||
|
#include "brcompetition.h"
|
||||||
|
#include "brcategory.h"
|
||||||
|
#include "brcup.h"
|
||||||
|
|
||||||
|
class BRCalendar : public BRWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QString title READ getTitle NOTIFY titleChanged)
|
||||||
|
Q_PROPERTY(QList<QObject*> seasons READ getSeasonsQML NOTIFY seasonsChanged)
|
||||||
|
Q_PROPERTY(BRSeason* currentSeason READ getCurrentSeason WRITE setCurrentSeason NOTIFY currentSeasonChanged)
|
||||||
|
|
||||||
|
public:
|
||||||
|
friend class BRProvider;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
BRCalendar* calendar;
|
||||||
|
BRSeason* currentSeason;
|
||||||
|
QList<BRSeason*> seasons;
|
||||||
|
} BRCalendarData;
|
||||||
|
|
||||||
|
Q_INVOKABLE BRWidget::BRWidgetStatusCode load() override;
|
||||||
|
|
||||||
|
Q_INVOKABLE QString getTitle();
|
||||||
|
Q_INVOKABLE QList<QObject*> getSeasonsQML();
|
||||||
|
Q_INVOKABLE BRSeason* getCurrentSeason();
|
||||||
|
Q_INVOKABLE void setCurrentSeason(BRSeason* season);
|
||||||
|
|
||||||
|
private:
|
||||||
|
explicit BRCalendar(BRProvider* provider, BRFederation federation);
|
||||||
|
void setData(BRCalendarData data);
|
||||||
|
|
||||||
|
QList<BRSeason*> seasons;
|
||||||
|
BRSeason* currentSeason;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void titleChanged();
|
||||||
|
void seasonsChanged();
|
||||||
|
void currentSeasonChanged();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BRCALENDAR_H
|
28
headers/brcontroller.h
Normal file
28
headers/brcontroller.h
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
#ifndef BRCONTROLLER_H
|
||||||
|
#define BRCONTROLLER_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "brproviderdr.h"
|
||||||
|
#include "brprovidervl.h"
|
||||||
|
#include "brwidget.h"
|
||||||
|
|
||||||
|
class BRCalendar;
|
||||||
|
|
||||||
|
class BRController : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit BRController(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
Q_INVOKABLE BRCalendar* getCalendar(BRWidget::BRFederation federation);
|
||||||
|
|
||||||
|
private:
|
||||||
|
BRProvider* providerDr;
|
||||||
|
BRProvider* providerVl;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BRCONTROLLER_H
|
62
headers/brleague.h
Normal file
62
headers/brleague.h
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
#ifndef BRLEAGUE_H
|
||||||
|
#define BRLEAGUE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QColor>
|
||||||
|
|
||||||
|
#include "brwidget.h"
|
||||||
|
#include "brcompetition.h"
|
||||||
|
#include "brcategory.h"
|
||||||
|
#include "brcup.h"
|
||||||
|
|
||||||
|
class BRLeague : public BRWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QString name READ getName NOTIFY metadataChanged)
|
||||||
|
Q_PROPERTY(QColor color READ getColor NOTIFY metadataChanged)
|
||||||
|
Q_PROPERTY(bool enabled READ getEnabled WRITE setEnabled NOTIFY enabledChanged)
|
||||||
|
Q_PROPERTY(QList<QObject*> competitions READ getCompetitionsQML NOTIFY competitionsChanged)
|
||||||
|
Q_PROPERTY(QList<QObject*> cups READ getCupsQML NOTIFY cupsChanged)
|
||||||
|
public:
|
||||||
|
friend class BRProvider;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const BRLeague* league;
|
||||||
|
|
||||||
|
QString name;
|
||||||
|
QColor color;
|
||||||
|
bool enabled;
|
||||||
|
|
||||||
|
QList<BRCompetition*> competitions;
|
||||||
|
QList<BRCup*> cups;
|
||||||
|
} BRLeagueData;
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode load() override;
|
||||||
|
|
||||||
|
Q_INVOKABLE QString getName();
|
||||||
|
Q_INVOKABLE QColor getColor();
|
||||||
|
Q_INVOKABLE bool getEnabled();
|
||||||
|
Q_INVOKABLE void setEnabled(bool enabled);
|
||||||
|
Q_INVOKABLE QList<BRCompetition*> getCompetitions();
|
||||||
|
Q_INVOKABLE QList<QObject*> getCompetitionsQML();
|
||||||
|
Q_INVOKABLE QList<QObject*> getCupsQML();
|
||||||
|
|
||||||
|
private:
|
||||||
|
BRLeague(BRProvider* provider, BRWidget::BRFederation federation, int id, BRLeagueData initialData);
|
||||||
|
void setData(BRLeagueData data);
|
||||||
|
|
||||||
|
QString name;
|
||||||
|
QColor color;
|
||||||
|
bool enabled;
|
||||||
|
|
||||||
|
QList<BRCompetition*> competitions;
|
||||||
|
QList<BRCup*> cups;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void metadataChanged();
|
||||||
|
void enabledChanged();
|
||||||
|
void competitionsChanged();
|
||||||
|
void cupsChanged();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BRLEAGUE_H
|
60
headers/brseason.h
Normal file
60
headers/brseason.h
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
#ifndef BRSEASON_H
|
||||||
|
#define BRSEASON_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "brwidget.h"
|
||||||
|
#include "brleague.h"
|
||||||
|
|
||||||
|
class BRSeason : public BRWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(int year READ getYear NOTIFY metadataChanged)
|
||||||
|
Q_PROPERTY(QString name READ getName NOTIFY metadataChanged)
|
||||||
|
Q_PROPERTY(QList<QObject*> leagues READ getLeaguesQML NOTIFY leaguesChanged)
|
||||||
|
Q_PROPERTY(QList<QObject*> competitions READ getCompetitionsQML NOTIFY competitionsChanged)
|
||||||
|
Q_PROPERTY(QList<QObject*> cups READ getCupsQML NOTIFY cupsChanged)
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
friend class BRProvider;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const BRSeason* season;
|
||||||
|
|
||||||
|
int year;
|
||||||
|
QString name;
|
||||||
|
bool nativeMultiLeagueSupport;
|
||||||
|
|
||||||
|
QList<BRLeague*> leagues;
|
||||||
|
} BRSeasonData;
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode load() override;
|
||||||
|
|
||||||
|
Q_INVOKABLE int getYear() const;
|
||||||
|
Q_INVOKABLE QString getName();
|
||||||
|
Q_INVOKABLE QList<QObject*> getLeaguesQML();
|
||||||
|
QList<BRLeague*> getLeagues() const;
|
||||||
|
Q_INVOKABLE QList<QObject*> getCompetitionsQML();
|
||||||
|
Q_INVOKABLE QList<QObject*> getCupsQML();
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
explicit BRSeason(BRProvider* provider, BRWidget::BRFederation federation, int id, BRSeasonData initialData);
|
||||||
|
void setData(BRSeasonData data);
|
||||||
|
|
||||||
|
int year;
|
||||||
|
QString name;
|
||||||
|
bool multiLeagueSupport;
|
||||||
|
|
||||||
|
QList<BRLeague*> leagues;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void metadataChanged();
|
||||||
|
void leaguesChanged();
|
||||||
|
void competitionsChanged();
|
||||||
|
void cupsChanged();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BRSEASON_H
|
|
@ -25,11 +25,11 @@
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
class ServerConn : public QObject
|
class BRServerConnector : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ServerConn(QObject *parent = nullptr);
|
explicit BRServerConnector(QObject *parent = nullptr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QVariantMap senddata(QUrl serviceUrl, QUrlQuery pdata = QUrlQuery());
|
QVariantMap senddata(QUrl serviceUrl, QUrlQuery pdata = QUrlQuery());
|
83
headers/brwidget.h
Normal file
83
headers/brwidget.h
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
#ifndef BRWIDGET_H
|
||||||
|
#define BRWIDGET_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class BRProvider;
|
||||||
|
|
||||||
|
class BRWidget : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(BRWidgetState state READ getState NOTIFY stateChanged)
|
||||||
|
public:
|
||||||
|
|
||||||
|
enum BRFederation {
|
||||||
|
UnknownFederation = -1,
|
||||||
|
IFSC,
|
||||||
|
DAV,
|
||||||
|
SAC
|
||||||
|
};
|
||||||
|
Q_ENUM(BRFederation)
|
||||||
|
|
||||||
|
|
||||||
|
enum BRDiscipline {
|
||||||
|
UnknownDiscipline = -1,
|
||||||
|
Speed,
|
||||||
|
Lead,
|
||||||
|
Boulder,
|
||||||
|
Combined,
|
||||||
|
AllDisciplines = 99
|
||||||
|
};
|
||||||
|
Q_ENUM(BRDiscipline)
|
||||||
|
|
||||||
|
enum BRWidgetState {
|
||||||
|
Unconfigured = -1,
|
||||||
|
Configured,
|
||||||
|
Loading,
|
||||||
|
Loaded
|
||||||
|
};
|
||||||
|
Q_ENUM(BRWidgetState)
|
||||||
|
|
||||||
|
enum BRWidgetStatusCode {
|
||||||
|
Success = 200,
|
||||||
|
InternalError = 900,
|
||||||
|
NoProviderError = 901,
|
||||||
|
NotImplementedError = 902,
|
||||||
|
OpeationNotSupportedError = 903
|
||||||
|
};
|
||||||
|
Q_ENUM(BRWidgetStatusCode)
|
||||||
|
|
||||||
|
Q_INVOKABLE virtual BRWidget::BRWidgetStatusCode load() = 0;
|
||||||
|
|
||||||
|
Q_INVOKABLE BRWidgetState getState() const;
|
||||||
|
Q_INVOKABLE BRFederation getFederation() const;
|
||||||
|
Q_INVOKABLE int getId() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
explicit BRWidget(BRProvider* provider, BRFederation federation, int id);
|
||||||
|
void setState(BRWidgetState state);
|
||||||
|
BRProvider* getProvider();
|
||||||
|
|
||||||
|
BRWidgetState state;
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
QList<QObject*> listToQmlList(QList<T*> list) {
|
||||||
|
QList<QObject*> tmpList;
|
||||||
|
|
||||||
|
for(T* item : list)
|
||||||
|
tmpList.append(static_cast<QObject*>(item));
|
||||||
|
|
||||||
|
return tmpList;
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
BRProvider* provider;
|
||||||
|
const BRFederation federation;
|
||||||
|
const int id;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void stateChanged();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BRWIDGET_H
|
80
headers/competition/brcategory.h
Normal file
80
headers/competition/brcategory.h
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
#ifndef BRCATEGORY_H
|
||||||
|
#define BRCATEGORY_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "brwidget.h"
|
||||||
|
#include "brround.h"
|
||||||
|
#include "brathlete.h"
|
||||||
|
#include "brresultdetailsgeneralresult.h"
|
||||||
|
|
||||||
|
class BRCompetition;
|
||||||
|
|
||||||
|
class BRCategory : public BRWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QString name READ getName NOTIFY metadataChanged)
|
||||||
|
Q_PROPERTY(BRDiscipline discipline READ getDiscipline NOTIFY metadataChanged)
|
||||||
|
Q_PROPERTY(BRCategoryStatus status READ getStatus NOTIFY metadataChanged)
|
||||||
|
Q_PROPERTY(BRRound* currentRound READ getCurrentRound WRITE setCurrentRound NOTIFY currentRoundChanged)
|
||||||
|
Q_PROPERTY(BRRound* generalResult READ getGeneralResult NOTIFY generalResultChanged)
|
||||||
|
Q_PROPERTY(QList<QObject*> rounds READ getRoundsQML NOTIFY roundsChanged)
|
||||||
|
public:
|
||||||
|
friend class BRProvider;
|
||||||
|
friend class BRCompetition;
|
||||||
|
|
||||||
|
enum BRCategoryStatus {
|
||||||
|
UnknownStatus = -1,
|
||||||
|
Registration,
|
||||||
|
Startlist,
|
||||||
|
Result
|
||||||
|
};
|
||||||
|
Q_ENUM(BRCategoryStatus)
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const BRCategory* category;
|
||||||
|
QString name;
|
||||||
|
BRDiscipline discipline;
|
||||||
|
BRCategoryStatus status;
|
||||||
|
BRRound* currentRound;
|
||||||
|
BRRound* generalResult;
|
||||||
|
|
||||||
|
QList<BRRound*> rounds;
|
||||||
|
} BRCategoryData;
|
||||||
|
|
||||||
|
Q_INVOKABLE BRWidget::BRWidgetStatusCode load() override;
|
||||||
|
Q_INVOKABLE BRCompetition* getCompetition() const;
|
||||||
|
Q_INVOKABLE QString getName();
|
||||||
|
Q_INVOKABLE BRDiscipline getDiscipline();
|
||||||
|
Q_INVOKABLE BRCategoryStatus getStatus();
|
||||||
|
Q_INVOKABLE BRRound* getCurrentRound() const;
|
||||||
|
Q_INVOKABLE void setCurrentRound(BRRound* round = nullptr);
|
||||||
|
Q_INVOKABLE BRRound* getGeneralResult();
|
||||||
|
Q_INVOKABLE QList<BRRound*> getRounds(bool includeGeneralResult = false) const;
|
||||||
|
Q_INVOKABLE QList<QObject*> getRoundsQML();
|
||||||
|
|
||||||
|
BRCategoryData getData();
|
||||||
|
|
||||||
|
private:
|
||||||
|
BRCategory(BRProvider* provider, BRWidget::BRFederation federation, int id, BRCategoryData initialData);
|
||||||
|
void setData(BRCategoryData data);
|
||||||
|
|
||||||
|
BRCompetition* competition;
|
||||||
|
BRRound* currentRound;
|
||||||
|
|
||||||
|
QString name;
|
||||||
|
BRDiscipline discipline;
|
||||||
|
BRCategoryStatus status;
|
||||||
|
BRRound* generalResult;
|
||||||
|
QList<BRRound*> rounds;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void metadataChanged();
|
||||||
|
void currentRoundChanged();
|
||||||
|
void roundsChanged();
|
||||||
|
void generalResultChanged();
|
||||||
|
void resultsChanged();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BRCATEGORY_H
|
94
headers/competition/brcompetition.h
Normal file
94
headers/competition/brcompetition.h
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
#ifndef BRCOMPETITION_H
|
||||||
|
#define BRCOMPETITION_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QDate>
|
||||||
|
#include <QUrl>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include "brwidget.h"
|
||||||
|
#include "brcategory.h"
|
||||||
|
|
||||||
|
class BRLeague;
|
||||||
|
|
||||||
|
class BRCompetition : public BRWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QString name READ getName NOTIFY metadataChanged)
|
||||||
|
Q_PROPERTY(QDate startDate READ getStartDate NOTIFY metadataChanged)
|
||||||
|
Q_PROPERTY(QDate endDate READ getEndDate NOTIFY metadataChanged)
|
||||||
|
Q_PROPERTY(QString dateSpan READ getDateSpan NOTIFY metadataChanged)
|
||||||
|
Q_PROPERTY(BRLeague* league READ getLeague NOTIFY metadataChanged)
|
||||||
|
Q_PROPERTY(QUrl eventWebsiteUrl READ getEventWebsiteUrl NOTIFY metadataChanged)
|
||||||
|
Q_PROPERTY(QList<QUrl> infosheetUrls READ getInfosheetUrls NOTIFY metadataChanged)
|
||||||
|
Q_PROPERTY(bool pinned READ getPinned WRITE setPinned NOTIFY pinnedChanged)
|
||||||
|
Q_PROPERTY(QList<QObject*> categories READ getCategoriesQML NOTIFY categoriesChanged)
|
||||||
|
Q_PROPERTY(BRCategory* currentCategory READ getCurrentCategory WRITE setCurrentCategory NOTIFY currentCategoryChanged)
|
||||||
|
Q_PROPERTY(QList<QObject*> results READ getResultsQML NOTIFY resultsChanged)
|
||||||
|
|
||||||
|
public:
|
||||||
|
friend class BRProvider;
|
||||||
|
friend class BRLeague;
|
||||||
|
|
||||||
|
typedef struct BRCompetitionData {
|
||||||
|
const BRCompetition* competition;
|
||||||
|
QString name;
|
||||||
|
QDate startDate;
|
||||||
|
QDate endDate;
|
||||||
|
QUrl eventWebsiteUrl;
|
||||||
|
QList<QUrl> infosheetUrls;
|
||||||
|
|
||||||
|
bool pinned;
|
||||||
|
BRCategory* currentCategory;
|
||||||
|
QList<BRCategory*> categories;
|
||||||
|
} BRCompetitionData;
|
||||||
|
|
||||||
|
Q_INVOKABLE BRWidget::BRWidgetStatusCode load() override;
|
||||||
|
|
||||||
|
Q_INVOKABLE QString getName();
|
||||||
|
Q_INVOKABLE QDate getStartDate();
|
||||||
|
Q_INVOKABLE QDate getEndDate();
|
||||||
|
Q_INVOKABLE QString getDateSpan();
|
||||||
|
Q_INVOKABLE BRLeague* getLeague();
|
||||||
|
Q_INVOKABLE QUrl getEventWebsiteUrl();
|
||||||
|
Q_INVOKABLE QList<QUrl> getInfosheetUrls();
|
||||||
|
Q_INVOKABLE bool getPinned();
|
||||||
|
Q_INVOKABLE void setPinned(bool pinned);
|
||||||
|
Q_INVOKABLE QList<QObject*> getCategoriesQML();
|
||||||
|
Q_INVOKABLE QList<BRCategory*> getCategories();
|
||||||
|
Q_INVOKABLE BRCategory* getCurrentCategory() const;
|
||||||
|
Q_INVOKABLE void setCurrentCategory(BRCategory* category);
|
||||||
|
Q_INVOKABLE QList<QObject*> getResultsQML();
|
||||||
|
|
||||||
|
static bool lessThan(BRCompetition* competition1, BRCompetition* competition2);
|
||||||
|
|
||||||
|
private:
|
||||||
|
explicit BRCompetition(BRProvider* provider, BRWidget::BRFederation federation, int id, BRCompetitionData initialData);
|
||||||
|
|
||||||
|
void setLeague(BRLeague* league);
|
||||||
|
|
||||||
|
// metadata
|
||||||
|
QString name;
|
||||||
|
QDate startDate;
|
||||||
|
QDate endDate;
|
||||||
|
BRLeague* league;
|
||||||
|
QUrl eventWebsiteUrl;
|
||||||
|
QList<QUrl> infosheetUrls;
|
||||||
|
|
||||||
|
// data
|
||||||
|
bool pinned;
|
||||||
|
QList<BRCategory*> categories;
|
||||||
|
BRCategory* currentCategory;
|
||||||
|
|
||||||
|
void setData(BRCompetitionData data);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void metadataChanged();
|
||||||
|
void pinnedChanged();
|
||||||
|
void categoriesChanged();
|
||||||
|
void currentCategoryChanged();
|
||||||
|
void resultsChanged();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BRCOMPETITION_H
|
56
headers/competition/brround.h
Normal file
56
headers/competition/brround.h
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
#ifndef BRROUND_H
|
||||||
|
#define BRROUND_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include "brwidget.h"
|
||||||
|
#include "brresult.h"
|
||||||
|
|
||||||
|
class BRCategory;
|
||||||
|
|
||||||
|
class BRRound : public BRWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QString name READ getName NOTIFY metadataChanged)
|
||||||
|
Q_PROPERTY(QList<QObject*> results READ getResultsQML NOTIFY resultsChanged)
|
||||||
|
|
||||||
|
public:
|
||||||
|
friend class BRProvider;
|
||||||
|
friend class BRCategory;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
BRRound* round;
|
||||||
|
|
||||||
|
QString name;
|
||||||
|
QList<BRResult*> results;
|
||||||
|
} BRRoundData;
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode load() override;
|
||||||
|
|
||||||
|
Q_INVOKABLE BRCategory* getCategory() const;
|
||||||
|
|
||||||
|
Q_INVOKABLE bool isGeneralResult() const;
|
||||||
|
|
||||||
|
Q_INVOKABLE QString getName();
|
||||||
|
Q_INVOKABLE QList<BRResult*> getResults();
|
||||||
|
Q_INVOKABLE QList<QObject*> getResultsQML();
|
||||||
|
|
||||||
|
BRRoundData getData();
|
||||||
|
|
||||||
|
static bool lessThan(BRRound* round1, BRRound* round2);
|
||||||
|
|
||||||
|
private:
|
||||||
|
BRRound(BRProvider* provider, BRWidget::BRFederation federation, int id, BRRoundData initialData, bool generalResult = false);
|
||||||
|
void setData(BRRoundData data);
|
||||||
|
|
||||||
|
BRCategory* category;
|
||||||
|
bool generalResult;
|
||||||
|
|
||||||
|
QString name;
|
||||||
|
QList<BRResult*> results;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void metadataChanged();
|
||||||
|
void resultsChanged();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BRROUND_H
|
57
headers/competition/result/brresult.h
Normal file
57
headers/competition/result/brresult.h
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
#ifndef BRRESULT_H
|
||||||
|
#define BRRESULT_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "brwidget.h"
|
||||||
|
#include "brresultdetails.h"
|
||||||
|
|
||||||
|
class BRAthlete;
|
||||||
|
class BRRound;
|
||||||
|
|
||||||
|
class BRResult : public BRWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(int rank READ getRank NOTIFY metadataChanged)
|
||||||
|
Q_PROPERTY(int startNumber READ getStartNumber NOTIFY metadataChanged)
|
||||||
|
Q_PROPERTY(BRResultDetails* details READ getDetails NOTIFY metadataChanged)
|
||||||
|
Q_PROPERTY(BRAthlete* athlete READ getAthlete NOTIFY metadataChanged)
|
||||||
|
|
||||||
|
public:
|
||||||
|
friend class BRProvider;
|
||||||
|
friend class BRRound;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const BRResult* result;
|
||||||
|
|
||||||
|
int rank;
|
||||||
|
int startNumber;
|
||||||
|
BRResultDetails* details;
|
||||||
|
BRAthlete* athlete;
|
||||||
|
} BRResultData;
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode load() override;
|
||||||
|
|
||||||
|
Q_INVOKABLE int getRank() const;
|
||||||
|
Q_INVOKABLE int getStartNumber() const;
|
||||||
|
Q_INVOKABLE BRResultDetails* getDetails() const;
|
||||||
|
Q_INVOKABLE BRAthlete* getAthlete() const;
|
||||||
|
Q_INVOKABLE BRRound* getRound() const;
|
||||||
|
|
||||||
|
static bool lessThan(BRResult* result1, BRResult* result2);
|
||||||
|
|
||||||
|
private:
|
||||||
|
BRResult(BRResultData initialData);
|
||||||
|
void setData(BRResultData data);
|
||||||
|
|
||||||
|
int rank;
|
||||||
|
int startNumber;
|
||||||
|
BRResultDetails* details;
|
||||||
|
BRAthlete* athlete;
|
||||||
|
BRRound* round;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void metadataChanged();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BRRESULT_H
|
50
headers/competition/result/brresultdetails.h
Normal file
50
headers/competition/result/brresultdetails.h
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
#ifndef BRRESULTDATA_H
|
||||||
|
#define BRRESULTDATA_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "brwidget.h"
|
||||||
|
|
||||||
|
class BRResult;
|
||||||
|
|
||||||
|
class BRResultDetails : public BRWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(BRResultDetailsType type READ getType NOTIFY metadataChanged)
|
||||||
|
public:
|
||||||
|
friend class BRResult;
|
||||||
|
|
||||||
|
enum BRResultDetailsType {
|
||||||
|
UnknownResultType = -1,
|
||||||
|
GeneralResult,
|
||||||
|
SpeedQualificationResult,
|
||||||
|
SpeedFinalResult,
|
||||||
|
LeadResult,
|
||||||
|
BoulderResult,
|
||||||
|
CombinedResult
|
||||||
|
};
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode load() final override;
|
||||||
|
Q_INVOKABLE virtual QString toString() = 0;
|
||||||
|
|
||||||
|
Q_INVOKABLE virtual QString string() final;
|
||||||
|
|
||||||
|
Q_INVOKABLE BRResultDetailsType getType();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
BRResultDetails(BRResultDetailsType type);
|
||||||
|
|
||||||
|
BRResult* getResult();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
BRResult* result;
|
||||||
|
BRResultDetailsType type;
|
||||||
|
|
||||||
|
|
||||||
|
BRWidget::BRDiscipline getDiscipline();
|
||||||
|
signals:
|
||||||
|
void metadataChanged();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BRRESULTDATA_H
|
28
headers/competition/result/brresultdetailsgeneralresult.h
Normal file
28
headers/competition/result/brresultdetailsgeneralresult.h
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
#ifndef BRGENERALRESULT_H
|
||||||
|
#define BRGENERALRESULT_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QDebug>
|
||||||
|
#include "brresultdetails.h"
|
||||||
|
|
||||||
|
class BRResult;
|
||||||
|
|
||||||
|
class BRResultDetailsGeneralResult : public BRResultDetails
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QList<QObject*> results READ getResultsQML NOTIFY resultsChanged)
|
||||||
|
public:
|
||||||
|
BRResultDetailsGeneralResult();
|
||||||
|
|
||||||
|
QList<BRResult*> getResults();
|
||||||
|
QList<QObject*> getResultsQML();
|
||||||
|
|
||||||
|
Q_INVOKABLE QString toString() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void resultsChanged();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BRGENERALRESULT_H
|
27
headers/competition/result/brresultdetailsunknown.h
Normal file
27
headers/competition/result/brresultdetailsunknown.h
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#ifndef BRRESULTDETAILSUNKNOWN_H
|
||||||
|
#define BRRESULTDETAILSUNKNOWN_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "brresultdetails.h"
|
||||||
|
|
||||||
|
class BRResultDetailsUnknown : public BRResultDetails
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QString score READ toString NOTIFY metadataChanged())
|
||||||
|
public:
|
||||||
|
BRResultDetailsUnknown(QString score);
|
||||||
|
|
||||||
|
Q_INVOKABLE QString toString() {
|
||||||
|
return this->score;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString score;
|
||||||
|
|
||||||
|
BRDiscipline getType() {
|
||||||
|
return BRWidget::UnknownDiscipline;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BRRESULTDETAILSUNKNOWN_H
|
42
headers/cup/brcup.h
Normal file
42
headers/cup/brcup.h
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
#ifndef BRCUP_H
|
||||||
|
#define BRCUP_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include "brwidget.h"
|
||||||
|
#include "brcategory.h"
|
||||||
|
|
||||||
|
class BRCup : public BRWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QString name READ getName NOTIFY metadataChanged)
|
||||||
|
Q_PROPERTY(QList<QObject*> categories READ getCategoriesQML NOTIFY categoriesChanged)
|
||||||
|
|
||||||
|
public:
|
||||||
|
friend class BRProvider;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const BRCup* cup;
|
||||||
|
QString name;
|
||||||
|
QList<BRCategory*> categories;
|
||||||
|
} BRCupData;
|
||||||
|
|
||||||
|
Q_INVOKABLE BRWidget::BRWidgetStatusCode load() override;
|
||||||
|
|
||||||
|
Q_INVOKABLE QString getName();
|
||||||
|
Q_INVOKABLE QList<QObject*> getCategoriesQML();
|
||||||
|
|
||||||
|
private:
|
||||||
|
BRCup(BRProvider* provider, BRWidget::BRFederation federation, int id, BRCupData initialData);
|
||||||
|
void setData(BRCupData data);
|
||||||
|
|
||||||
|
QString name;
|
||||||
|
QList<BRCategory*> categories;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void metadataChanged();
|
||||||
|
void categoriesChanged();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BRCUP_H
|
65
headers/provider/brprovider.h
Normal file
65
headers/provider/brprovider.h
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
#ifndef BRPROVIDER_H
|
||||||
|
#define BRPROVIDER_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QtNetwork>
|
||||||
|
#include <QEventLoop>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
|
#include "brwidget.h"
|
||||||
|
#include "brcalendar.h"
|
||||||
|
#include "brseason.h"
|
||||||
|
#include "brleague.h"
|
||||||
|
#include "brcompetition.h"
|
||||||
|
#include "brathlete.h"
|
||||||
|
#include "brcup.h"
|
||||||
|
#include "brresult.h"
|
||||||
|
#include "brresultdetailsunknown.h"
|
||||||
|
|
||||||
|
class BRProvider : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit BRProvider(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
friend class BRController;
|
||||||
|
friend class BRCalendar;
|
||||||
|
friend class BRSeason;
|
||||||
|
friend class BRLeague;
|
||||||
|
friend class BRCompetition;
|
||||||
|
friend class BRCategory;
|
||||||
|
friend class BRAthlete;
|
||||||
|
friend class BRRound;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QVariantMap serverRequest(QUrl serviceUrl, QList<QStringList> additionalHeaders = {}, QUrlQuery postData = QUrlQuery());
|
||||||
|
|
||||||
|
virtual BRCalendar* getCalendar(BRWidget::BRFederation federation) final;
|
||||||
|
virtual BRSeason* getSeason(BRWidget::BRFederation federation, int id, BRSeason::BRSeasonData initialData) final;
|
||||||
|
virtual BRLeague* getLeague(BRWidget::BRFederation federation, int id, BRLeague::BRLeagueData initialData) final;
|
||||||
|
virtual BRCompetition* getCompetition(BRWidget::BRFederation federation, int id, BRCompetition::BRCompetitionData initialData) final;
|
||||||
|
virtual BRCup* getCup(BRWidget::BRFederation federation, int id, BRCup::BRCupData initialData) final;
|
||||||
|
virtual BRCategory* getCategory(BRWidget::BRFederation federation, int id, BRCategory::BRCategoryData initialData) final;
|
||||||
|
virtual BRAthlete* getAthlete(BRWidget::BRFederation federation, int id, BRAthlete::BRAthleteData initialData) final;
|
||||||
|
virtual BRRound* getRound(BRWidget::BRFederation federation, int id, BRRound::BRRoundData initialData, bool generalResult = false) final;
|
||||||
|
virtual BRResult* getResult(BRResult::BRResultData initialData) final;
|
||||||
|
|
||||||
|
virtual void setCategoryData(BRCategory* category, BRCategory::BRCategoryData data) final {
|
||||||
|
category->setData(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void setRoundData(BRRound* round, BRRound::BRRoundData data) final {
|
||||||
|
round->setData(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual BRWidget::BRWidgetStatusCode getWidgetData(BRCalendar::BRCalendarData* calendarData) = 0;
|
||||||
|
virtual BRWidget::BRWidgetStatusCode getWidgetData(BRSeason::BRSeasonData* seasonData) = 0;
|
||||||
|
virtual BRWidget::BRWidgetStatusCode getWidgetData(BRLeague::BRLeagueData* leagueData) = 0;
|
||||||
|
virtual BRWidget::BRWidgetStatusCode getWidgetData(BRCompetition::BRCompetitionData* competitionData) = 0;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BRCONTROLLER_H
|
44
headers/provider/brproviderdr.h
Normal file
44
headers/provider/brproviderdr.h
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
#ifndef BRPROVIDERDR_H
|
||||||
|
#define BRPROVIDERDR_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "brprovider.h"
|
||||||
|
|
||||||
|
class BRProviderDr : public BRProvider
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit BRProviderDr(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
BRWidget::BRWidgetStatusCode getWidgetData(BRCalendar::BRCalendarData* calendarData) override;
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode getWidgetData(BRSeason::BRSeasonData* seasonData) override;
|
||||||
|
BRSeason::BRSeasonData parseSeasonData(int id, QVariantMap rawData);
|
||||||
|
void parseSeasonData(BRSeason::BRSeasonData* seasonData, int id, QVariantMap rawData);
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode getWidgetData(BRLeague::BRLeagueData* leagueData) override;
|
||||||
|
BRLeague::BRLeagueData parseLeagueData(QVariantMap leagueProperties, QVariantMap rawData);
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode getWidgetData(BRCompetition::BRCompetitionData* competitionData) override;
|
||||||
|
BRCompetition::BRCompetitionData parseCompetitionData(QVariantMap rawData, QVariantList globalCategoriesList, BRWidget::BRFederation federation);
|
||||||
|
void parseCompetitionData(BRCompetition::BRCompetitionData* competitionData, QVariantMap rawData, BRWidget::BRFederation federation);
|
||||||
|
|
||||||
|
BRCup::BRCupData parseCupData(QVariantList categoriesList, QVariantMap rawData, BRWidget::BRFederation federation);
|
||||||
|
|
||||||
|
BRCategory::BRCategoryData parseCategoryData(QVariantMap rawData);
|
||||||
|
void parseCategoryData(BRCategory::BRCategoryData* categoryData, QVariantMap rawData);
|
||||||
|
|
||||||
|
void parseRoundData(BRRound::BRRoundData* roundData, QVariantMap rawData, QString resultKeyAttachment = "");
|
||||||
|
|
||||||
|
BRAthlete::BRAthleteData parseAthletedata(QVariantMap rawData);
|
||||||
|
|
||||||
|
BRResult::BRResultData parseResultData(QVariantMap rawData);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QMap<BRWidget::BRFederation, QList<QVariantMap>> leagues;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BRPROVIDERDR_H
|
39
headers/provider/brprovidervl.h
Normal file
39
headers/provider/brprovidervl.h
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
#ifndef BRPROVIDERVL_H
|
||||||
|
#define BRPROVIDERVL_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "brprovider.h"
|
||||||
|
|
||||||
|
class BRProviderVl : public BRProvider
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit BRProviderVl(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
BRWidget::BRWidgetStatusCode getWidgetData(BRCalendar::BRCalendarData* calendarData) override;
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode getWidgetData(BRSeason::BRSeasonData* seasonData) override;
|
||||||
|
BRSeason::BRSeasonData parseSeasonData(QVariantMap rawData);
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode getWidgetData(BRLeague::BRLeagueData* leagueData) override;
|
||||||
|
void parseLeagueData(BRLeague::BRLeagueData* leagueData, QVariantMap rawData);
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode getWidgetData(BRCompetition::BRCompetitionData* competitionData) override;
|
||||||
|
BRCompetition::BRCompetitionData parseCompetitionData(QVariantMap rawData, QVariantList globalCategoriesList, BRWidget::BRFederation federation);
|
||||||
|
|
||||||
|
BRCup::BRCupData parseCupData(QVariantMap rawData, QVariantList globalCategoriesList);
|
||||||
|
|
||||||
|
BRCategory::BRCategoryData parseCategoryData(QVariantMap rawData);
|
||||||
|
//void parseCategoryData(BRCategory::BRCategoryData* categoryData, QVariantMap rawData);
|
||||||
|
|
||||||
|
BRRound::BRRoundData parseRoundData(QVariantMap rawData);
|
||||||
|
void parseRoundData(BRRound::BRRoundData* roundData, QVariantMap rawData);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QMap<BRWidget::BRFederation, QList<QVariantMap>> leagues;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BRPROVIDERVL_H
|
|
@ -53,11 +53,23 @@ ListView {
|
||||||
|
|
||||||
width: 8
|
width: 8
|
||||||
|
|
||||||
visible: control.model > 0
|
visible: control.model.length > 0
|
||||||
|
|
||||||
active: true
|
active: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
header: Item {
|
||||||
|
id: topSpacerItm
|
||||||
|
width: parent.width
|
||||||
|
height: 10
|
||||||
|
}
|
||||||
|
|
||||||
|
footer: Item {
|
||||||
|
id: bottomSpacerItm
|
||||||
|
width: parent.width
|
||||||
|
height: 10
|
||||||
|
}
|
||||||
|
|
||||||
Behavior on opacity {
|
Behavior on opacity {
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
duration: 200
|
duration: 200
|
||||||
|
|
|
@ -162,7 +162,7 @@ Item {
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: control.target
|
target: control.target
|
||||||
onDragEnded: {
|
function onDragEnded() {
|
||||||
if(userPosition >= control.dragOutPosition * control.dragRefreshPositionMultiplier){
|
if(userPosition >= control.dragOutPosition * control.dragRefreshPositionMultiplier){
|
||||||
control.state = "refreshing"
|
control.state = "refreshing"
|
||||||
preRefreshTimer.start()
|
preRefreshTimer.start()
|
||||||
|
|
139
resources/qml/Components/SelectorPopup.qml
Normal file
139
resources/qml/Components/SelectorPopup.qml
Normal file
|
@ -0,0 +1,139 @@
|
||||||
|
import QtQuick 2.9
|
||||||
|
import QtQuick.Controls 2.4
|
||||||
|
import QtQuick.Controls.Material 2.3
|
||||||
|
|
||||||
|
Dialog {
|
||||||
|
id: control
|
||||||
|
|
||||||
|
property var dataObj
|
||||||
|
property string subTitle: ""
|
||||||
|
property int implicitY: parent.height - implicitHeight
|
||||||
|
|
||||||
|
signal selectionFinished(int index, var data)
|
||||||
|
|
||||||
|
parent: Overlay.overlay
|
||||||
|
|
||||||
|
x: 0
|
||||||
|
y: parent.height - implicitHeight
|
||||||
|
|
||||||
|
opacity: 1
|
||||||
|
|
||||||
|
width: parent.width
|
||||||
|
implicitWidth: width
|
||||||
|
contentHeight: Math.min(parent.height * 0.7, implicitContentHeight)
|
||||||
|
implicitHeight: contentHeight + topPadding + bottomPadding + header.height
|
||||||
|
padding: 30
|
||||||
|
|
||||||
|
modal: true
|
||||||
|
focus: true
|
||||||
|
|
||||||
|
title: ""
|
||||||
|
|
||||||
|
header: Column {
|
||||||
|
id: selectorPuHeaderCol
|
||||||
|
|
||||||
|
width: control.width
|
||||||
|
height: headerSubLa.text !== "" && headerLa.text !== "" ? 73 : 40
|
||||||
|
|
||||||
|
Label {
|
||||||
|
id: headerLa
|
||||||
|
|
||||||
|
visible: control.title
|
||||||
|
|
||||||
|
width: selectorPuHeaderCol.width
|
||||||
|
|
||||||
|
elide: "ElideRight"
|
||||||
|
padding: control.padding
|
||||||
|
bottomPadding: 0
|
||||||
|
font.bold: true
|
||||||
|
font.pixelSize: 16
|
||||||
|
|
||||||
|
text: control.title
|
||||||
|
|
||||||
|
onLinkActivated: {
|
||||||
|
console.log("Opening " + link)
|
||||||
|
Qt.openUrlExternally(link)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
id: headerSubLa
|
||||||
|
|
||||||
|
visible: control.subTitle
|
||||||
|
|
||||||
|
width: selectorPuHeaderCol.width
|
||||||
|
|
||||||
|
elide: "ElideRight"
|
||||||
|
padding: control.padding
|
||||||
|
topPadding: 5
|
||||||
|
bottomPadding: 0
|
||||||
|
font.bold: true
|
||||||
|
font.pixelSize: 16
|
||||||
|
|
||||||
|
text: control.subTitle
|
||||||
|
|
||||||
|
onLinkActivated: {
|
||||||
|
console.log("Opening " + link)
|
||||||
|
Qt.openUrlExternally(link)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
background: Item {
|
||||||
|
Rectangle {
|
||||||
|
id: backgroundRect
|
||||||
|
anchors {
|
||||||
|
fill: parent
|
||||||
|
bottomMargin: -radius
|
||||||
|
}
|
||||||
|
|
||||||
|
radius: control.leftPadding
|
||||||
|
|
||||||
|
color: control.Material.dialogColor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function appear(dataObj, title, subTitle) {
|
||||||
|
|
||||||
|
if(dataObj.length > 0){
|
||||||
|
control.dataObj = dataObj
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
control.dataObj = undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
control.title = title
|
||||||
|
control.subTitle = subTitle === undefined ? "":subTitle
|
||||||
|
control.open()
|
||||||
|
}
|
||||||
|
|
||||||
|
enter: Transition {
|
||||||
|
NumberAnimation {
|
||||||
|
property: "opacity";
|
||||||
|
from: 0
|
||||||
|
to: 1.0
|
||||||
|
easing.type: Easing.Linear
|
||||||
|
}
|
||||||
|
|
||||||
|
NumberAnimation {
|
||||||
|
property: "y"
|
||||||
|
from: control.parent.height - control.implicitHeight * 0.7
|
||||||
|
to: control.parent.height - control.implicitHeight
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exit: Transition {
|
||||||
|
NumberAnimation {
|
||||||
|
property: "opacity";
|
||||||
|
from: 1
|
||||||
|
to: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
NumberAnimation {
|
||||||
|
property: "y"
|
||||||
|
from: control.parent.height - control.implicitHeight
|
||||||
|
to: control.parent.height - control.implicitHeight * 0.7
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
141
resources/qml/Pages/BRWidgetPage.qml
Normal file
141
resources/qml/Pages/BRWidgetPage.qml
Normal file
|
@ -0,0 +1,141 @@
|
||||||
|
/*
|
||||||
|
blueROCK - for digital rock
|
||||||
|
Copyright (C) 2019 Dorian Zedler
|
||||||
|
|
||||||
|
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 3 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import QtQuick 2.9
|
||||||
|
import QtQuick.Controls 2.4
|
||||||
|
//import QtGraphicalEffects 1.0
|
||||||
|
//import QtQuick.Templates 2.04 as T
|
||||||
|
//import QtQuick.Controls.impl 2.04
|
||||||
|
import QtQuick.Controls.Material 2.3
|
||||||
|
import de.itsblue.blueRock 2.0
|
||||||
|
|
||||||
|
import "../Components"
|
||||||
|
|
||||||
|
Page {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
property BRWidget data
|
||||||
|
property Component headerComponent
|
||||||
|
property alias selector: selectorPopup
|
||||||
|
|
||||||
|
property string subTitle
|
||||||
|
property bool titleIsPageTitle: true
|
||||||
|
|
||||||
|
property int status: -1
|
||||||
|
property bool ready: false
|
||||||
|
|
||||||
|
signal loadingFinished()
|
||||||
|
signal selectionFinished(int index, var data)
|
||||||
|
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
console.log("TRYING TO LOAD")
|
||||||
|
var status = data.load()
|
||||||
|
console.log(data)
|
||||||
|
if(status !== BRWidget.Success)
|
||||||
|
ready = false
|
||||||
|
else
|
||||||
|
ready = true
|
||||||
|
loadingFinished()
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadData(params) {
|
||||||
|
// params is an object and can contain: {
|
||||||
|
// comp: competitionId,
|
||||||
|
// person: personId,
|
||||||
|
// cat: categoryId,
|
||||||
|
// nation: nationString ('', 'GER', 'SUI')
|
||||||
|
// route: (int) round
|
||||||
|
// type: ('','starters', 'nat_team_ranking', 'sektionenwertung', 'regionalzentren'),
|
||||||
|
//}
|
||||||
|
|
||||||
|
var ret = serverConn.getWidgetData(params)
|
||||||
|
|
||||||
|
root.status = ret["status"]
|
||||||
|
|
||||||
|
if(ret["status"] === 200){
|
||||||
|
root.widgetData = ret["data"]
|
||||||
|
root.widgetType = checkWidgetType(params, root.widgetData)
|
||||||
|
if(widgetLd.load()){
|
||||||
|
root.ready = true
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//root.status = 901
|
||||||
|
root.ready = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(ret["status"] === 404 && [WidgetPage.WidgetType.Registration, WidgetPage.WidgetType.Startlist, WidgetPage.WidgetType.Result].includes(root.widgetType) && root.params["route"] !== "") {
|
||||||
|
// if we get a 404 and have startlist, results or registration, the route was not found -> remove route and try again
|
||||||
|
root.params["route"] = ""
|
||||||
|
loadData(root.params)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
root.ready = false
|
||||||
|
}
|
||||||
|
|
||||||
|
app.errorCode = root.status
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectorPopup {
|
||||||
|
id: selectorPopup
|
||||||
|
|
||||||
|
contentItem: ListView {
|
||||||
|
id: selectorLv
|
||||||
|
|
||||||
|
property int delegateHeight: 50
|
||||||
|
spacing: 10
|
||||||
|
|
||||||
|
clip: true
|
||||||
|
|
||||||
|
implicitWidth: selectorPopup.width
|
||||||
|
implicitHeight: model === undefined ? 0:(delegateHeight + spacing) * model.length
|
||||||
|
|
||||||
|
model: selectorPopup.dataObj !== undefined ? selectorPopup.dataObj:undefined
|
||||||
|
|
||||||
|
ScrollIndicator.vertical: ScrollIndicator {
|
||||||
|
parent: selectorLv.parent
|
||||||
|
anchors {
|
||||||
|
top: selectorLv.top
|
||||||
|
left: selectorLv.right
|
||||||
|
margins: 10
|
||||||
|
leftMargin: 3
|
||||||
|
bottom: selectorLv.bottom
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
delegate: Button {
|
||||||
|
id: catBt
|
||||||
|
|
||||||
|
width: selectorLv.width
|
||||||
|
height: text !== "" ? selectorLv.delegateHeight:0
|
||||||
|
|
||||||
|
flat: true
|
||||||
|
|
||||||
|
text: selectorPopup.dataObj[index].text
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
selectorPopup.close()
|
||||||
|
control.selectionFinished(index, selectorPopup.dataObj[index].data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
370
resources/qml/Pages/CalendarPage.qml
Normal file
370
resources/qml/Pages/CalendarPage.qml
Normal file
|
@ -0,0 +1,370 @@
|
||||||
|
/*
|
||||||
|
blueROCK - for digital rock
|
||||||
|
Copyright (C) 2019 Dorian Zedler
|
||||||
|
|
||||||
|
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 3 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import QtQuick 2.9
|
||||||
|
import QtQuick.Controls 2.4
|
||||||
|
import QtQuick.Layouts 1.3
|
||||||
|
import de.itsblue.blueRock 2.0
|
||||||
|
|
||||||
|
import "../Components"
|
||||||
|
|
||||||
|
|
||||||
|
BRWidgetPage {
|
||||||
|
id: control
|
||||||
|
|
||||||
|
title: control.data.title
|
||||||
|
headerComponent: RowLayout {
|
||||||
|
|
||||||
|
height: parent.height
|
||||||
|
//width: 10//childrenRect.width
|
||||||
|
|
||||||
|
spacing: 0
|
||||||
|
|
||||||
|
ToolButton {
|
||||||
|
id:yearToolBt
|
||||||
|
|
||||||
|
onClicked: control.changeSeason()
|
||||||
|
|
||||||
|
icon.name: "year"
|
||||||
|
}
|
||||||
|
|
||||||
|
ToolButton {
|
||||||
|
id: filterToolBt
|
||||||
|
|
||||||
|
onClicked: control.changeLeagues()
|
||||||
|
|
||||||
|
icon.name: "filter"
|
||||||
|
}
|
||||||
|
|
||||||
|
ToolButton {
|
||||||
|
id: cupToolBt
|
||||||
|
|
||||||
|
onClicked: control.openCup()
|
||||||
|
|
||||||
|
icon.name: "cup"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onLoadingFinished: {
|
||||||
|
calendarLv.autoScroll()
|
||||||
|
}
|
||||||
|
|
||||||
|
onSelectionFinished: {
|
||||||
|
if(data.task === "competition"){
|
||||||
|
loadingDl.open()
|
||||||
|
data.competition.currentCategory = data.category
|
||||||
|
app.openResults(data.competition)
|
||||||
|
loadingDl.close()
|
||||||
|
//app.openWidget({comp: data.comp, cat: data.cat, type:data.status === 4 ? 'starters':''})
|
||||||
|
}
|
||||||
|
else if(data.task === "season"){
|
||||||
|
loadingDl.open()
|
||||||
|
control.data.currentSeason = data.season
|
||||||
|
loadingDl.close()
|
||||||
|
}
|
||||||
|
else if(data.task === "cup1"){
|
||||||
|
control.openCup(data)
|
||||||
|
}
|
||||||
|
else if(data.task === "cup2"){
|
||||||
|
app.openWidget({cup: data.cup, cat: data.cat})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeSeason(){
|
||||||
|
var selectOptions = []
|
||||||
|
|
||||||
|
for(var i = 0; i < control.data.seasons.length; i++){
|
||||||
|
selectOptions.push({text: control.data.seasons[i].name, data:{task: "season", season: control.data.seasons[i]}})
|
||||||
|
}
|
||||||
|
|
||||||
|
selector.appear(selectOptions, qsTr("select season"))
|
||||||
|
}
|
||||||
|
|
||||||
|
function openCompetition(competition){
|
||||||
|
var selectOptions = []
|
||||||
|
var categories = competition.categories
|
||||||
|
for(var i = 0; i < categories.length; i++){
|
||||||
|
selectOptions.push({text: categories[i].name, data:{task: "competition", category: categories[i], competition: competition, /*TODO*/ status:categories.status}})
|
||||||
|
}
|
||||||
|
|
||||||
|
var infoUrls = competition.infosheetUrls
|
||||||
|
var infosheet = "";
|
||||||
|
if(infoUrls.length >= 1)
|
||||||
|
infosheet += ("<a href='" + infoUrls[0] + "'>" + qsTr('infosheet') + "</a>")
|
||||||
|
if(infoUrls.length === 2)
|
||||||
|
infosheet += (", <a href='" + infoUrls[1] + "'>" + qsTr('further infos') + "</a>")
|
||||||
|
|
||||||
|
var eventWebsite = competition.eventWebsiteUrl.toString() !== "" ? ("<a href='" + competition.eventWebsiteUrl + "'>" + qsTr('Event Website') + "</a>"):""
|
||||||
|
|
||||||
|
selector.appear(selectOptions, competition.name, eventWebsite + ((eventWebsite !== "" && infosheet !== "") ? ", ":"") + infosheet )
|
||||||
|
}
|
||||||
|
|
||||||
|
function openCup(data) {
|
||||||
|
|
||||||
|
var cups = control.data.currentSeason.cups
|
||||||
|
|
||||||
|
var prop
|
||||||
|
var selectOptions = []
|
||||||
|
var selectTitle = ""
|
||||||
|
|
||||||
|
if(data === undefined){
|
||||||
|
// opened for the first time -> select cup
|
||||||
|
selectTitle = qsTr("select cup")
|
||||||
|
|
||||||
|
for(var i = 0; i < cups.length; i++){
|
||||||
|
selectOptions.push({text: cups[i].name, data:{task: "cup1", cup: cups[i]}})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(data.task === "cup1"){
|
||||||
|
// opened for the second time -> select cat
|
||||||
|
var cup = data.cup
|
||||||
|
|
||||||
|
selectTitle = cup['name'] + ": " + qsTr("select category")
|
||||||
|
|
||||||
|
for(var c = 0; c < cup.categories.length; c++){
|
||||||
|
selectOptions.push({text: cup.categories[c].name, data:{task: "cup2", cup: data.cup, cat: cup.categories[c]}})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
selector.appear(selectOptions, selectTitle)
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeLeagues() {
|
||||||
|
var leagues = control.data.currentSeason.leagues
|
||||||
|
var selectOptions = []
|
||||||
|
|
||||||
|
for(var i = 0; i < leagues.length; i++) {
|
||||||
|
selectOptions.push( {text: leagues[i].name, data:{task:"leagues", league: leagues[i]}} )
|
||||||
|
}
|
||||||
|
|
||||||
|
//compCats.push( {"text": qsTr("Pinned"), "data": {"sort_rank":0, "cat_id":[-1]}} )
|
||||||
|
console.log("leagues: " + leagues)
|
||||||
|
filterSelectPu.appear(selectOptions, qsTr("Select Filters"), "")
|
||||||
|
}
|
||||||
|
|
||||||
|
DataListView {
|
||||||
|
id: calendarLv
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
model: control.data.currentSeason.competitions
|
||||||
|
|
||||||
|
onRefresh: control.data.load()
|
||||||
|
|
||||||
|
function autoScroll() {
|
||||||
|
// function to scroll to the next competition that is not already over
|
||||||
|
var compList = calendarLv.model
|
||||||
|
|
||||||
|
if(control.data.currentSeason.year === new Date().getFullYear()){
|
||||||
|
console.log("SCROLLING")
|
||||||
|
for(var i = 0; i < compList.length; i ++){
|
||||||
|
if(compList[i].endDate.getTime() < new Date().getTime()){
|
||||||
|
// end date is already over -> move the list view down!
|
||||||
|
calendarLv.positionViewAtIndex(i, ListView.Top)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
delegate: ItemDelegate {
|
||||||
|
id: competitionDel
|
||||||
|
|
||||||
|
property var thisData: modelData
|
||||||
|
|
||||||
|
width: calendarLv.width
|
||||||
|
height: compDelCol.height + 10
|
||||||
|
|
||||||
|
enabled: thisData.categories.length > 0 || thisData.eventWebsiteUrl.toString() !== "" || thisData.infosheetUrls.length > 0
|
||||||
|
|
||||||
|
opacity: 0
|
||||||
|
scale: 0.9
|
||||||
|
|
||||||
|
onThisDataChanged: fadeInPa.start()
|
||||||
|
|
||||||
|
Behavior on height {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: 400
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onClicked: control.openCompetition(competitionDel.thisData)
|
||||||
|
|
||||||
|
ParallelAnimation {
|
||||||
|
id: fadeInPa
|
||||||
|
NumberAnimation { target: competitionDel; property: "opacity"; from: 0; to: 1.0; duration: 400 }
|
||||||
|
NumberAnimation { target: competitionDel; property: "scale"; from: 0.8; to: 1.0; duration: 400 }
|
||||||
|
}
|
||||||
|
|
||||||
|
ParallelAnimation {
|
||||||
|
id: fadeOutPa
|
||||||
|
NumberAnimation { target: competitionDel; property: "opacity"; from: 1; to: 0; duration: 400 }
|
||||||
|
NumberAnimation { target: competitionDel; property: "scale"; from: 1; to: 0.8; duration: 400 }
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: delBackroundRect
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
opacity: 0.5
|
||||||
|
|
||||||
|
color: competitionDel.thisData.league.color
|
||||||
|
}
|
||||||
|
|
||||||
|
Column {
|
||||||
|
id: compDelCol
|
||||||
|
|
||||||
|
anchors.centerIn: parent
|
||||||
|
|
||||||
|
width: parent.width * 0.97
|
||||||
|
|
||||||
|
spacing: 10
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
width: parent.width
|
||||||
|
Label {
|
||||||
|
id: nameLa
|
||||||
|
|
||||||
|
width: parent.width
|
||||||
|
|
||||||
|
font.bold: true
|
||||||
|
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
|
||||||
|
text: competitionDel.thisData.name
|
||||||
|
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
|
||||||
|
ToolButton {
|
||||||
|
id: bookmarkTb
|
||||||
|
icon.name: competitionDel.thisData.pinned ? "pinFilled":"pin"
|
||||||
|
onClicked: {
|
||||||
|
competitionDel.thisData.pinned = !competitionDel.thisData.pinned
|
||||||
|
}
|
||||||
|
|
||||||
|
Layout.alignment: Layout.Right
|
||||||
|
|
||||||
|
Behavior on icon.name {
|
||||||
|
SequentialAnimation {
|
||||||
|
NumberAnimation {
|
||||||
|
property: "scale"
|
||||||
|
target: bookmarkTb
|
||||||
|
duration: 75
|
||||||
|
to: 0.8
|
||||||
|
}
|
||||||
|
NumberAnimation {
|
||||||
|
property: "scale"
|
||||||
|
target: bookmarkTb
|
||||||
|
duration: 75
|
||||||
|
to: 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
id: dateLa
|
||||||
|
|
||||||
|
color: "grey"
|
||||||
|
|
||||||
|
text: competitionDel.thisData.dateSpan
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: bottomLineRa
|
||||||
|
|
||||||
|
anchors {
|
||||||
|
bottom: parent.bottom
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
}
|
||||||
|
|
||||||
|
height: 1
|
||||||
|
|
||||||
|
color: "lightgrey"
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
section.property: "month"
|
||||||
|
section.delegate: ItemDelegate {
|
||||||
|
id: name
|
||||||
|
background: Rectangle {
|
||||||
|
color: "red"
|
||||||
|
}
|
||||||
|
|
||||||
|
width: parent.width
|
||||||
|
text: section
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectorPopup {
|
||||||
|
id: filterSelectPu
|
||||||
|
|
||||||
|
contentItem: ListView {
|
||||||
|
id: selectorLv
|
||||||
|
|
||||||
|
property int delegateHeight: 50
|
||||||
|
spacing: 10
|
||||||
|
|
||||||
|
clip: true
|
||||||
|
|
||||||
|
implicitWidth: parent.width
|
||||||
|
implicitHeight: model === undefined ? 0:(delegateHeight + spacing) * model.length
|
||||||
|
|
||||||
|
model: filterSelectPu.dataObj
|
||||||
|
|
||||||
|
ScrollIndicator.vertical: ScrollIndicator {
|
||||||
|
parent: selectorLv.parent
|
||||||
|
anchors {
|
||||||
|
top: selectorLv.top
|
||||||
|
left: selectorLv.right
|
||||||
|
margins: 10
|
||||||
|
leftMargin: 3
|
||||||
|
bottom: selectorLv.bottom
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
delegate: CheckDelegate {
|
||||||
|
id: catBt
|
||||||
|
|
||||||
|
property var thisData: modelData
|
||||||
|
|
||||||
|
width: parent.width
|
||||||
|
height: text !== "" ? selectorLv.delegateHeight:0
|
||||||
|
|
||||||
|
checked: thisData.data.league.enabled
|
||||||
|
|
||||||
|
text: thisData.text
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
if(thisData.data.league.state !== BRWidget.Loaded) {
|
||||||
|
loadingDl.open()
|
||||||
|
thisData.data.league.load()
|
||||||
|
loadingDl.close()
|
||||||
|
}
|
||||||
|
|
||||||
|
thisData.data.league.enabled = checked
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
872
resources/qml/Pages/ResultPage.qml
Normal file
872
resources/qml/Pages/ResultPage.qml
Normal file
|
@ -0,0 +1,872 @@
|
||||||
|
/*
|
||||||
|
blueROCK - for digital rock
|
||||||
|
Copyright (C) 2019 Dorian Zedler
|
||||||
|
|
||||||
|
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 3 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import QtQuick 2.9
|
||||||
|
import QtQuick.Controls 2.5
|
||||||
|
import QtQuick.Layouts 1.3
|
||||||
|
import QtGraphicalEffects 1.0
|
||||||
|
import QtQuick.Controls.Material 2.3
|
||||||
|
//import QtLocation 5.13
|
||||||
|
|
||||||
|
import QtPurchasing 1.12
|
||||||
|
|
||||||
|
import "../Components"
|
||||||
|
BRWidgetPage {
|
||||||
|
id: control
|
||||||
|
ready: true
|
||||||
|
title: data.name
|
||||||
|
titleIsPageTitle: true
|
||||||
|
subTitle: data.currentCategory.currentRound.name + " " + data.currentCategory.name + " " + qsTr("(Results)")
|
||||||
|
|
||||||
|
headerComponent: RowLayout {
|
||||||
|
id: headerComponent
|
||||||
|
|
||||||
|
height: parent.height
|
||||||
|
|
||||||
|
spacing: 0
|
||||||
|
|
||||||
|
ToolButton {
|
||||||
|
id: flowToolBt
|
||||||
|
|
||||||
|
visible: false // TOODO: speedFlowChart.enabled
|
||||||
|
|
||||||
|
enabled: true // TODO control.data.currentCategory.currentRound.getId() === -1 && Object.keys(control.widgetData['route_names']).length > 2
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
if(speedFlowChartBackgroundRect.state === "hidden"){
|
||||||
|
speedFlowChartBackgroundRect.state ="visible"
|
||||||
|
control.positionViewAtBeginning()
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
speedFlowChartBackgroundRect.state = "hidden"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
icon.name: "flowchart"
|
||||||
|
}
|
||||||
|
|
||||||
|
ToolButton {
|
||||||
|
id: moreToolBt
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
control.changeCategory()
|
||||||
|
}
|
||||||
|
|
||||||
|
icon.name: "menu"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onLoadingFinished: {
|
||||||
|
return;
|
||||||
|
if(resultLv.model.length > 0){
|
||||||
|
control.ready = true
|
||||||
|
control.status = 200
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
control.ready = false
|
||||||
|
control.status = 901
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!control.ready)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
onSelectionFinished: {
|
||||||
|
if(data.task === "category"){
|
||||||
|
loadingDl.open()
|
||||||
|
control.data.currentCategory = data.category
|
||||||
|
control.data.load()
|
||||||
|
loadingDl.close()
|
||||||
|
}
|
||||||
|
else if(data.task === "season"){
|
||||||
|
loadingDl.open()
|
||||||
|
control.data.currentSeason = data.season
|
||||||
|
loadingDl.close()
|
||||||
|
}
|
||||||
|
else if(data.task === "cup1"){
|
||||||
|
control.openCup(data)
|
||||||
|
}
|
||||||
|
else if(data.task === "cup2"){
|
||||||
|
app.openWidget({cup: data.cup, cat: data.cat})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeCategory(){
|
||||||
|
var selectOptions = []
|
||||||
|
var categories = control.data.categories
|
||||||
|
for(var i = 0; i < categories.length; i++){
|
||||||
|
if(categories[i] === control.data.currentCategory)
|
||||||
|
continue
|
||||||
|
selectOptions.push({text: categories[i].name, data:{task: "category", category: categories[i]}})
|
||||||
|
}
|
||||||
|
|
||||||
|
selector.appear(selectOptions, qsTr("select cat"))
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeRound(round) {
|
||||||
|
loadingDl.open()
|
||||||
|
control.data.currentCategory.currentRound = round
|
||||||
|
control.data.load()
|
||||||
|
loadingDl.close()
|
||||||
|
}
|
||||||
|
|
||||||
|
DataListView {
|
||||||
|
id: resultLv
|
||||||
|
|
||||||
|
anchors {
|
||||||
|
top: parent.top
|
||||||
|
topMargin: 0
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
bottom: routeSelectTb.top
|
||||||
|
}
|
||||||
|
|
||||||
|
model: control.data.results
|
||||||
|
|
||||||
|
onRefresh: {
|
||||||
|
control.data.load()
|
||||||
|
}
|
||||||
|
|
||||||
|
/* TODO onWidgetDataChanged: {
|
||||||
|
console.log("widget data changed")
|
||||||
|
|
||||||
|
if(control.widgetData['discipline'] === 'speed' && control.widgetData['route_order'] === "-1" && Object.keys(control.widgetData['route_names']).length > 2){
|
||||||
|
speedFlowChart.flowchartData = ({})
|
||||||
|
speedFlowChart.enabled = true
|
||||||
|
speedFlowChart.flowchartData = control.widgetData
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
speedFlowChart.enabled = false
|
||||||
|
speedFlowChart.flowchartData = ({})
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
onContentYChanged: {
|
||||||
|
if(contentY > 0 && speedFlowChartBackgroundRect.state === "visible"){
|
||||||
|
resultLv.positionViewAtBeginning()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
header: Item {}
|
||||||
|
|
||||||
|
delegate: ItemDelegate {
|
||||||
|
id: partDel
|
||||||
|
|
||||||
|
property int ind: index
|
||||||
|
property var thisData: modelData
|
||||||
|
|
||||||
|
enabled: speedFlowChartBackgroundRect.state === "hidden"
|
||||||
|
|
||||||
|
width: resultLv.width
|
||||||
|
height: 70
|
||||||
|
|
||||||
|
text: ""
|
||||||
|
|
||||||
|
opacity: 0
|
||||||
|
scale: 0.9
|
||||||
|
|
||||||
|
onThisDataChanged: {
|
||||||
|
fadeInPa.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
app.openWidget({person:thisData["PerId"]})
|
||||||
|
}
|
||||||
|
|
||||||
|
ParallelAnimation {
|
||||||
|
id: fadeInPa
|
||||||
|
NumberAnimation { target: partDel; property: "opacity"; from: 0; to: 1.0; duration: 400 }
|
||||||
|
NumberAnimation { target: partDel; property: "scale"; from: 0.8; to: 1.0; duration: 400 }
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: partDelBackgroundRect
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
width: partDel.width
|
||||||
|
|
||||||
|
color: partDel.ind % 2 == 0 ? "white":"lightgrey"
|
||||||
|
|
||||||
|
opacity: 0.2
|
||||||
|
}
|
||||||
|
|
||||||
|
Column {
|
||||||
|
id: partDelCol
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: 5
|
||||||
|
|
||||||
|
Row {
|
||||||
|
id: partDelFirstRow
|
||||||
|
|
||||||
|
width: parent.width
|
||||||
|
height: parent.height - partDelSecondRow.height
|
||||||
|
|
||||||
|
Label {
|
||||||
|
height: parent.height
|
||||||
|
width: text === "" ? parent.width * 0.08:parent.width * 0.1
|
||||||
|
|
||||||
|
fontSizeMode: Text.Fit
|
||||||
|
font.bold: true
|
||||||
|
font.pixelSize: height * 0.6//Math.abs( partDelSecondRow.height > 0 ? height * 0.6:height * 0.4 )
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
|
||||||
|
text: partDel.thisData.rank
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
height: parent.height
|
||||||
|
width: parent.width * 0.5
|
||||||
|
|
||||||
|
fontSizeMode: Text.Fit
|
||||||
|
font.bold: true
|
||||||
|
font.pixelSize: height * 0.6//Math.abs( partDelSecondRow.height > 0 ? height * 0.6:height * 0.4 )
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
horizontalAlignment: Text.AlignLeft
|
||||||
|
|
||||||
|
text: partDel.thisData.athlete.firstName + " " + partDel.thisData.athlete.lastName + (partDel.thisData["start_number"] !== undefined ? (" (" + partDel.thisData["start_number"] + ")"):"")
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
height: parent.height
|
||||||
|
width: parent.width * 0.4
|
||||||
|
|
||||||
|
fontSizeMode: Text.Fit
|
||||||
|
font.bold: false
|
||||||
|
font.pixelSize: height * 0.6 //Math.abs( partDelSecondRow.height > 0 ? height * 0.4:height * 0.3 )
|
||||||
|
minimumPixelSize: height * 0.3 < 1 ? 1:height * 0.3
|
||||||
|
|
||||||
|
elide: "ElideRight"
|
||||||
|
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
|
||||||
|
text: "<html>(<a href=\"" + (partDel.thisData.athlete.federationUrl === undefined ? "":partDel.thisData.athlete.federationUrl).toString() + "\">" + partDel.thisData.athlete.federation + "</a>)</html>"
|
||||||
|
|
||||||
|
onLinkActivated: {
|
||||||
|
Qt.openUrlExternally(link)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Row {
|
||||||
|
id: partDelSecondRow
|
||||||
|
|
||||||
|
width: parent.width
|
||||||
|
height: resultLa.acitve ? parent.height / 2 : 0 // TODO multiResRow.active || multiGenResRow.active || resultLa.acitve ? parent.height / 2 : 0
|
||||||
|
/*
|
||||||
|
Row {
|
||||||
|
id: multiResRow
|
||||||
|
|
||||||
|
property bool active: false // TODO parseInt(widgetData[ "route_order" ]) > -1 && boulderResRep.model > 0
|
||||||
|
|
||||||
|
height: parent.height
|
||||||
|
width: active ? parent.width * 0.75:0
|
||||||
|
|
||||||
|
enabled: parseInt(widgetData[ "route_order" ]) > -1 && boulderResRep.model > 0
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
id: boulderResRep
|
||||||
|
model: parseInt(widgetData[ "route_num_problems" ])
|
||||||
|
|
||||||
|
function getDataForIcon(index){
|
||||||
|
var resultString = widgetData[ "participants" ][partDel.ind]["boulder"+(index+1)]
|
||||||
|
|
||||||
|
var resultList = []
|
||||||
|
|
||||||
|
if( resultString !== undefined){
|
||||||
|
resultString = resultString.replace("t", "")
|
||||||
|
resultString = resultString.replace("z", "")
|
||||||
|
resultString = resultString.replace("b", "")
|
||||||
|
resultList = resultString.split(" ")
|
||||||
|
|
||||||
|
while (resultList.length < 2){
|
||||||
|
resultList.unshift(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
resultList = [-1,-1]
|
||||||
|
}
|
||||||
|
|
||||||
|
return resultList
|
||||||
|
}
|
||||||
|
|
||||||
|
delegate: Item {
|
||||||
|
id: boulderResItm
|
||||||
|
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
|
||||||
|
width: parent.width / ( boulderResRep.model )
|
||||||
|
height: parent.height
|
||||||
|
|
||||||
|
Canvas {
|
||||||
|
id: boulderResCv
|
||||||
|
|
||||||
|
property var resultData: boulderResRep.getDataForIcon(index)
|
||||||
|
|
||||||
|
onResultDataChanged: {
|
||||||
|
boulderResCv.requestPaint()
|
||||||
|
}
|
||||||
|
|
||||||
|
anchors.centerIn: parent
|
||||||
|
|
||||||
|
height: parent.height > parent.width ? parent.width * 0.9:parent.height * 0.9
|
||||||
|
width: height
|
||||||
|
|
||||||
|
onPaint: {
|
||||||
|
var width = 24//boulderResCv.width * 0.9
|
||||||
|
var height = width
|
||||||
|
|
||||||
|
var radius = width * 0.3
|
||||||
|
|
||||||
|
var offsetX = width * 0.05
|
||||||
|
var offsetY = height * 0.05
|
||||||
|
|
||||||
|
//console.log("drawing result rect with width: " + width + " and height: " + height)
|
||||||
|
|
||||||
|
var context = getContext("2d");
|
||||||
|
|
||||||
|
// clear all remainings from other routes
|
||||||
|
context.clearRect(0, 0, width, height);
|
||||||
|
|
||||||
|
context.beginPath();
|
||||||
|
|
||||||
|
context.moveTo(0 + offsetX + radius, 0 + offsetY);
|
||||||
|
|
||||||
|
// top line
|
||||||
|
context.lineTo(width - radius + offsetX, 0 + offsetY);
|
||||||
|
// top right corner
|
||||||
|
context.arc(width-radius + offsetX, radius + offsetY, radius, 1.5 * Math.PI, 0);
|
||||||
|
// right line
|
||||||
|
context.lineTo(width + offsetX, height - radius + offsetY);
|
||||||
|
// bottom right corner
|
||||||
|
context.arc(width-radius + offsetX, height - radius + offsetY, radius, 0, 0.5 * Math.PI);
|
||||||
|
// bottom line
|
||||||
|
context.lineTo(0 + radius + offsetX, height + offsetY);
|
||||||
|
// bottom left corner
|
||||||
|
context.arc(radius + offsetY, height - radius + offsetY, radius, 0.5 * Math.PI, Math.PI);
|
||||||
|
// left line
|
||||||
|
context.lineTo(0 + offsetX, radius + offsetY);
|
||||||
|
// top left corner
|
||||||
|
context.arc(radius + offsetX, radius + offsetY, radius, Math.PI, 1.5 * Math.PI);
|
||||||
|
|
||||||
|
// fill
|
||||||
|
if(resultData[0] !== -1) {
|
||||||
|
// if there is a result available -> draw background
|
||||||
|
context.fillStyle = "#b7b7b7";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
context.fillStyle = "transparent";
|
||||||
|
}
|
||||||
|
|
||||||
|
context.fill();
|
||||||
|
|
||||||
|
// outline
|
||||||
|
context.lineWidth = 1;
|
||||||
|
context.strokeStyle = '#424242';
|
||||||
|
context.stroke();
|
||||||
|
|
||||||
|
if(resultData[1] > 0){
|
||||||
|
|
||||||
|
// the first triangle
|
||||||
|
context.beginPath();
|
||||||
|
|
||||||
|
// top right corner
|
||||||
|
context.arc(width-radius + offsetX, radius + offsetY, radius, 1.75 * Math.PI, 0);
|
||||||
|
|
||||||
|
// right line
|
||||||
|
context.lineTo(width + offsetX, height - radius + offsetY);
|
||||||
|
|
||||||
|
// bottom right corner
|
||||||
|
context.arc(width-radius + offsetX, height - radius + offsetY, radius, 0, 0.5 * Math.PI);
|
||||||
|
|
||||||
|
// bottom line
|
||||||
|
context.lineTo(0 + radius + offsetX, height + offsetY);
|
||||||
|
// bottom left corner
|
||||||
|
context.arc(radius + offsetX, height - radius + offsetY, radius, 0.5 * Math.PI, 0.75 * Math.PI);
|
||||||
|
context.closePath();
|
||||||
|
|
||||||
|
context.fillStyle = "#44ed38";
|
||||||
|
context.fill();
|
||||||
|
|
||||||
|
// outline
|
||||||
|
context.lineWidth = 1;
|
||||||
|
context.strokeStyle = '#424242';
|
||||||
|
context.stroke();
|
||||||
|
|
||||||
|
|
||||||
|
if(resultData[0] > 0){
|
||||||
|
// the second triangle
|
||||||
|
context.beginPath();
|
||||||
|
// bottom left corner
|
||||||
|
context.arc(radius + offsetX, height - radius + offsetY, radius, 0.75 * Math.PI, 1 * Math.PI);
|
||||||
|
// left line
|
||||||
|
context.lineTo(0 + offsetX, radius + offsetY);
|
||||||
|
// top left corner
|
||||||
|
context.arc(radius + offsetX, radius + offsetY, radius, Math.PI, 1.5 * Math.PI);
|
||||||
|
// top line
|
||||||
|
context.lineTo(width - radius + offsetX, 0 + offsetY);
|
||||||
|
// top right corner
|
||||||
|
context.arc(width-radius + offsetX, radius + offsetY, radius, 1.5 * Math.PI, 1.75 * Math.PI);
|
||||||
|
|
||||||
|
context.closePath();
|
||||||
|
|
||||||
|
context.fillStyle = "#44ed38";
|
||||||
|
context.fill();
|
||||||
|
|
||||||
|
// outline
|
||||||
|
context.lineWidth = 1;
|
||||||
|
context.strokeStyle = '#424242';
|
||||||
|
context.stroke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
id: boulderResZoneLa
|
||||||
|
|
||||||
|
anchors {
|
||||||
|
right: parent.right
|
||||||
|
bottom: parent.bottom
|
||||||
|
margins: boulderResCv.height * 0.05
|
||||||
|
}
|
||||||
|
|
||||||
|
height: parent.height / 2
|
||||||
|
width: parent.width / 2
|
||||||
|
|
||||||
|
visible: parseInt(text) > 0
|
||||||
|
|
||||||
|
fontSizeMode: Text.Fit
|
||||||
|
font.pixelSize: height
|
||||||
|
minimumPixelSize: 1
|
||||||
|
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
|
||||||
|
text: boulderResCv.resultData[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
id: boulderResTopLa
|
||||||
|
|
||||||
|
anchors {
|
||||||
|
left: parent.left
|
||||||
|
top: parent.top
|
||||||
|
margins: boulderResCv.height * 0.05
|
||||||
|
}
|
||||||
|
|
||||||
|
height: parent.height / 2
|
||||||
|
width: parent.width / 2
|
||||||
|
|
||||||
|
visible: parseInt(text) > 0
|
||||||
|
|
||||||
|
fontSizeMode: Text.Fit
|
||||||
|
font.pixelSize: height
|
||||||
|
minimumPixelSize: 1
|
||||||
|
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
|
||||||
|
text: boulderResCv.resultData[0]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Row {
|
||||||
|
id: multiGenResRow
|
||||||
|
|
||||||
|
property bool active: false // TODO ((parseInt(widgetData[ "route_order" ]) === -1) && (generalResRep.model > 0)) ? true:false
|
||||||
|
|
||||||
|
height: parent.height
|
||||||
|
width: active ? parent.width - resultLa.width:0
|
||||||
|
|
||||||
|
enabled: ((parseInt(widgetData[ "route_order" ]) === -1) && (generalResRep.model > 0)) ? true:false
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
id: generalResRep
|
||||||
|
|
||||||
|
property var routes: getRoutes()
|
||||||
|
model: routes.length
|
||||||
|
|
||||||
|
function getRoutes() {
|
||||||
|
|
||||||
|
var obj = widgetData["route_names"]
|
||||||
|
var routes = []
|
||||||
|
|
||||||
|
for(var prop in obj) {
|
||||||
|
// go through the whole array and search for data keys
|
||||||
|
if (obj.hasOwnProperty(prop) && prop > -1) {
|
||||||
|
routes.push([prop, obj[prop]])
|
||||||
|
//console.log("found " + obj[prop] + " at index " + prop)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
routes.sort(function(a, b) {
|
||||||
|
return a[0] - b[0];
|
||||||
|
});
|
||||||
|
|
||||||
|
return routes
|
||||||
|
}
|
||||||
|
|
||||||
|
delegate: Item {
|
||||||
|
id: boulderGenResItm
|
||||||
|
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
|
||||||
|
width: parent.width / ( generalResRep.model )
|
||||||
|
height: parent.height
|
||||||
|
|
||||||
|
visible: multiGenResRow.active
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
|
||||||
|
anchors {
|
||||||
|
left: parent.left
|
||||||
|
}
|
||||||
|
|
||||||
|
width: 1
|
||||||
|
height: parent.height
|
||||||
|
|
||||||
|
visible: index === 0
|
||||||
|
|
||||||
|
color: "grey"
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
anchors {
|
||||||
|
right: parent.right
|
||||||
|
}
|
||||||
|
|
||||||
|
width: 1
|
||||||
|
height: parent.height
|
||||||
|
|
||||||
|
color: "grey"
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
id: boulderGenResLa
|
||||||
|
anchors.centerIn: parent
|
||||||
|
|
||||||
|
height: parent.height
|
||||||
|
width: parent.width * 0.9
|
||||||
|
|
||||||
|
fontSizeMode: Text.Fit
|
||||||
|
font.pixelSize: Math.abs( height * 0.6 )
|
||||||
|
minimumPixelSize: 1
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
|
||||||
|
text: widgetData[ "participants" ][partDel.ind]["result"+(generalResRep.routes[index][0])] === undefined ? "":widgetData[ "participants" ][partDel.ind]["result"+(generalResRep.routes[index][0])]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
Label {
|
||||||
|
id: resultLa
|
||||||
|
|
||||||
|
property bool acitve: true // TODO ( boulderResRep.model > 0 || widgetData["discipline"] !== "boulder" ) && parseInt(widgetData[ "route_order" ]) > -1
|
||||||
|
|
||||||
|
width: enabled ? parent.width * 0.75:0
|
||||||
|
height: enabled ? parent.height:0
|
||||||
|
|
||||||
|
enabled: true //( boulderResRep.model > 0 || widgetData["discipline"] !== "boulder" ) && parseInt(widgetData[ "route_order" ]) > -1
|
||||||
|
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
horizontalAlignment: Text.AlignLeft
|
||||||
|
|
||||||
|
fontSizeMode: Text.Fit
|
||||||
|
font.pixelSize: Math.abs( height * 0.6 )
|
||||||
|
minimumPixelSize: 1
|
||||||
|
|
||||||
|
text: partDel.thisData.details.string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PullRefresher {
|
||||||
|
target: resultLv
|
||||||
|
|
||||||
|
postRefreshDelay: 0
|
||||||
|
|
||||||
|
busyIndicator: FancyBusyIndicator {}
|
||||||
|
refreshPosition: height * 1.3
|
||||||
|
|
||||||
|
onRefreshRequested: {
|
||||||
|
resultLv.refresh()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RectangularGlow {
|
||||||
|
id: toolBarEffect
|
||||||
|
glowRadius: 3
|
||||||
|
spread: 0.2
|
||||||
|
color: "black"
|
||||||
|
opacity: 0.3
|
||||||
|
anchors.fill: routeSelectTb
|
||||||
|
}
|
||||||
|
|
||||||
|
TabBar {
|
||||||
|
id: routeSelectTb
|
||||||
|
|
||||||
|
property var tabs: control.data.currentCategory.rounds
|
||||||
|
property var tabIndexes: []
|
||||||
|
|
||||||
|
enabled: speedFlowChartBackgroundRect.state === "hidden"
|
||||||
|
|
||||||
|
anchors {
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
bottom: parent.bottom
|
||||||
|
}
|
||||||
|
|
||||||
|
height: tabs.length > 1 ? 50:0
|
||||||
|
width: parent.width
|
||||||
|
|
||||||
|
position: TabBar.Footer
|
||||||
|
|
||||||
|
currentIndex: tabs.indexOf(control.data.currentCategory.currentRound)
|
||||||
|
|
||||||
|
onTabsChanged: {
|
||||||
|
console.log("tabs: " + tabs + " rounds: " + control.data.currentCategory.rounds)
|
||||||
|
}
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
id: routeSelectButtonRep
|
||||||
|
|
||||||
|
model: routeSelectTb.tabs
|
||||||
|
|
||||||
|
onModelChanged: {
|
||||||
|
//routeSelectTb.setCurrentIndex(routeSelectTb.tabs.indexOf(control.data.currentCategory.currentRound))
|
||||||
|
}
|
||||||
|
|
||||||
|
delegate: TabButton {
|
||||||
|
text: modelData.name
|
||||||
|
|
||||||
|
width: Math.max(150, routeSelectTb.width / routeSelectButtonRep.model.length) //text.length * font.pixelSize
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
control.changeRound(modelData)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: speedFlowChartBackgroundRect
|
||||||
|
|
||||||
|
state: "hidden"
|
||||||
|
|
||||||
|
anchors {
|
||||||
|
top: control.top
|
||||||
|
bottom: control.bottom
|
||||||
|
left: control.right
|
||||||
|
}
|
||||||
|
|
||||||
|
width: control.width
|
||||||
|
height: control.height
|
||||||
|
|
||||||
|
color: Material.background
|
||||||
|
|
||||||
|
SpeedFlowChart {
|
||||||
|
id: speedFlowChart
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
flowchartData: ({})
|
||||||
|
|
||||||
|
onEnabledChanged: {
|
||||||
|
if(!enabled){
|
||||||
|
speedFlowChartBackgroundRect.state = 'hidden'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: speedFlowChartLockedOverlay
|
||||||
|
|
||||||
|
state: appSettings.read("speedBackendPurchase") === "1" ? "unlocked":"locked"
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: -20
|
||||||
|
|
||||||
|
color: "white"
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: speedFlowChartProduct
|
||||||
|
function onPurchaseRestored() {
|
||||||
|
speedFlowChartLockedOverlay.state = appSettings.read("speedBackendPurchase") === "1" ? "unlocked":"locked"
|
||||||
|
}
|
||||||
|
|
||||||
|
function onPurchaseSucceeded() {
|
||||||
|
speedFlowChartLockedOverlay.state = appSettings.read("speedBackendPurchase") === "1" ? "unlocked":"locked"
|
||||||
|
}
|
||||||
|
|
||||||
|
function onPurchaseFailed() {
|
||||||
|
purchaseBt.text = qsTr("Purchase failed")
|
||||||
|
purchaseBt.enabled = false
|
||||||
|
buttonTextResetTimer.start()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: buttonTextResetTimer
|
||||||
|
interval: 2000
|
||||||
|
running: false
|
||||||
|
repeat: false
|
||||||
|
onTriggered: {
|
||||||
|
purchaseBt.text = (speedFlowChartProduct.status === Product.Registered
|
||||||
|
? "Buy now for " + speedFlowChartProduct.price
|
||||||
|
: qsTr("this item is currently unavailable"))
|
||||||
|
purchaseBt.enabled = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
id: lockedLayout
|
||||||
|
|
||||||
|
anchors {
|
||||||
|
fill: parent
|
||||||
|
topMargin: parent.height * 0.05
|
||||||
|
bottomMargin: parent.height * 0.1
|
||||||
|
rightMargin: parent.width * 0.1 + 20
|
||||||
|
leftMargin: parent.width * 0.1 + 20
|
||||||
|
}
|
||||||
|
|
||||||
|
//spacing: parent.height * 0.05
|
||||||
|
|
||||||
|
Image {
|
||||||
|
id: name
|
||||||
|
|
||||||
|
Layout.alignment: Layout.Center
|
||||||
|
Layout.preferredHeight: height
|
||||||
|
Layout.preferredWidth: width
|
||||||
|
|
||||||
|
width: lockedLayout.height * 0.1
|
||||||
|
height: width
|
||||||
|
|
||||||
|
mipmap: true
|
||||||
|
|
||||||
|
source: "qrc:/icons/lock.png"
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
height: parent.height * 0.05
|
||||||
|
|
||||||
|
text: qsTr("This is a premium feature.")
|
||||||
|
|
||||||
|
font.bold: true
|
||||||
|
font.pixelSize: parent.height * 0.05
|
||||||
|
fontSizeMode: Text.Fit
|
||||||
|
|
||||||
|
minimumPixelSize: 1
|
||||||
|
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
SwipeGallery {
|
||||||
|
Layout.fillHeight: true
|
||||||
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
images: ["qrc:/screenshots/SpeedFlowchartDemo/1.png","qrc:/screenshots/SpeedFlowchartDemo/2.png","qrc:/screenshots/SpeedFlowchartDemo/3.png"]
|
||||||
|
}
|
||||||
|
|
||||||
|
Button {
|
||||||
|
id: purchaseBt
|
||||||
|
Layout.alignment: Layout.Center
|
||||||
|
enabled: speedFlowChartProduct.status === Product.Registered
|
||||||
|
text: speedFlowChartProduct.status === Product.Registered
|
||||||
|
? "Buy now for " + speedFlowChartProduct.price
|
||||||
|
: qsTr("this item is currently unavailable")
|
||||||
|
icon.name: "buy"
|
||||||
|
//display: AbstractButton.TextBesideIcon
|
||||||
|
onClicked: speedFlowChartProduct.purchase()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
states: [
|
||||||
|
State {
|
||||||
|
name: "unlocked"
|
||||||
|
PropertyChanges {
|
||||||
|
target: speedFlowChartLockedOverlay
|
||||||
|
visible: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
State {
|
||||||
|
name: "locked"
|
||||||
|
PropertyChanges {
|
||||||
|
target: speedFlowChartLockedOverlay
|
||||||
|
visible: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
states: [
|
||||||
|
State {
|
||||||
|
name: "hidden"
|
||||||
|
PropertyChanges {
|
||||||
|
target: speedFlowChartBackgroundRect
|
||||||
|
opacity: 0
|
||||||
|
anchors.leftMargin: 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
State {
|
||||||
|
name: "visible"
|
||||||
|
PropertyChanges {
|
||||||
|
target: speedFlowChartBackgroundRect
|
||||||
|
opacity: 1
|
||||||
|
anchors.leftMargin: -parent.width
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
transitions: [
|
||||||
|
Transition {
|
||||||
|
NumberAnimation {
|
||||||
|
properties: "opacity,scale,anchors.leftMargin"
|
||||||
|
duration: 200
|
||||||
|
easing.type: Easing.InOutQuad
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
import QtQuick 2.0
|
import QtQuick 2.0
|
||||||
import QtQuick.Controls 2.4
|
import QtQuick.Controls 2.4
|
||||||
|
import de.itsblue.blueRock 2.0
|
||||||
|
|
||||||
import "../Components"
|
import "../Components"
|
||||||
|
|
||||||
|
@ -60,10 +61,7 @@ Page {
|
||||||
|
|
||||||
image: "qrc:/icons/ifsc.png"
|
image: "qrc:/icons/ifsc.png"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: app.openCalendar(BRWidget.IFSC)
|
||||||
app.openWidget({nation:"ICC"})
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FancyButton {
|
FancyButton {
|
||||||
|
@ -74,10 +72,7 @@ Page {
|
||||||
|
|
||||||
image: "qrc:/icons/dav.png"
|
image: "qrc:/icons/dav.png"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: app.openCalendar(BRWidget.DAV)
|
||||||
app.openWidget({nation:"GER"})
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FancyButton {
|
FancyButton {
|
||||||
|
@ -88,10 +83,7 @@ Page {
|
||||||
|
|
||||||
image: "qrc:/icons/sac.png"
|
image: "qrc:/icons/sac.png"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: app.openCalendar(BRWidget.SAC)
|
||||||
app.openWidget({nation:"SUI"})
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import QtQuick.Layouts 1.3
|
||||||
import QtPurchasing 1.12
|
import QtPurchasing 1.12
|
||||||
|
|
||||||
import com.itsblue.digitalRockRanking 1.0
|
import com.itsblue.digitalRockRanking 1.0
|
||||||
|
import de.itsblue.blueRock 2.0
|
||||||
|
|
||||||
import "./Pages"
|
import "./Pages"
|
||||||
import "./Components"
|
import "./Components"
|
||||||
|
@ -38,174 +39,6 @@ Window {
|
||||||
|
|
||||||
property int errorCode: -1
|
property int errorCode: -1
|
||||||
|
|
||||||
// comp cats source:
|
|
||||||
// - https://github.com/ralfbecker/ranking/blob/master/sitemgr/digitalrock/icc_calendar.php
|
|
||||||
// - https://github.com/ralfbecker/ranking/blob/master/sitemgr/digitalrock/dav_calendar.php
|
|
||||||
// - https://github.com/ralfbecker/ranking/blob/master/sitemgr/digitalrock/sac_calendar.php
|
|
||||||
|
|
||||||
property var compCats: {
|
|
||||||
|
|
||||||
// --- ICC ---
|
|
||||||
|
|
||||||
/*'int' : {
|
|
||||||
'label' : 'International',
|
|
||||||
'nation' : 'ICC',
|
|
||||||
'wettk_reg' : '^[0-9]{2,2}[_^E]{1}[^YJ]{1,1}.*',
|
|
||||||
'serie_reg' : '^[0-9]{2,2}_(WC|TR){1,1}.*',
|
|
||||||
'rang_title': 'CUWR continuously updated WORLDRANKING',
|
|
||||||
'bgcolor' : '#B8C8FF',
|
|
||||||
'nat_team_ranking' : '',
|
|
||||||
'cat_id' : [68,86]//[68,69,70,86,259]
|
|
||||||
},*/
|
|
||||||
'worldcup': {
|
|
||||||
'label' : 'World Cups',
|
|
||||||
'nation' : 'ICC',
|
|
||||||
'bgcolor' : '#B8C8FF',
|
|
||||||
'sort_rank': 1,
|
|
||||||
'cat_id' : [69]
|
|
||||||
},
|
|
||||||
'youth' : {
|
|
||||||
'label' : 'Youth Events',
|
|
||||||
'nation' : 'ICC',
|
|
||||||
'wettk_reg' : '^[0-9]{2,2}(EYC|_J|_Y){1,1}.*',
|
|
||||||
'serie_reg' : '^[0-9]{2,2}_EYC',
|
|
||||||
'rang_title': '',
|
|
||||||
'bgcolor' : '#D8E8FF',
|
|
||||||
'sort_rank': 2,
|
|
||||||
'cat_id' : [71,258]
|
|
||||||
},
|
|
||||||
'cont': {
|
|
||||||
'label' : 'Continental Events',
|
|
||||||
'nation' : 'ICC',
|
|
||||||
'bgcolor' : '#B8C8FF',
|
|
||||||
'sort_rank': 3,
|
|
||||||
'cat_id' : [262]
|
|
||||||
},
|
|
||||||
'masters' : {
|
|
||||||
'label' : 'Masters and Promo Events',
|
|
||||||
'nation' : 'ICC',
|
|
||||||
'wettk_reg' : '^[0-9]{2,2}_[^PWERASL]{1}.*',
|
|
||||||
// 'serie_reg' : '^[0-9]{2,2}_(WC|TR){1,1}.*',
|
|
||||||
// 'rang_title': 'CUWR continuously updated WORLDRANKING',
|
|
||||||
'bgcolor' : '#F0F0F0',
|
|
||||||
'sort_rank': 4,
|
|
||||||
'cat_id' : [70]
|
|
||||||
},
|
|
||||||
'para' : {
|
|
||||||
'label' : 'Paraclimbing Events',
|
|
||||||
'nation' : 'ICC',
|
|
||||||
'wettk_reg' : '^[0-9]{2,2}_PE.*',
|
|
||||||
'bgcolor' : '#F0F0F0',
|
|
||||||
'sort_rank': 5,
|
|
||||||
'cat_id' : [256,259]
|
|
||||||
},
|
|
||||||
'games': {
|
|
||||||
'label': 'Games',
|
|
||||||
'nation': 'ICC',
|
|
||||||
'bgcolor' : '#B8C8FF',
|
|
||||||
'sort_rank': 6,
|
|
||||||
'cat_id': [68,86]
|
|
||||||
},
|
|
||||||
|
|
||||||
// --- GER ---
|
|
||||||
|
|
||||||
/*'ger_boulder' : {
|
|
||||||
'label' : 'Bouldern',
|
|
||||||
'nation' : 'GER',
|
|
||||||
'wettk_reg' : '^[0-9]{2,2}_B+.*',
|
|
||||||
'serie_reg' : '^[0-9]{2,2}_BC',
|
|
||||||
'bgcolor' : '#FFDBA8', //'#f59d30'
|
|
||||||
'cat_id' : [59]
|
|
||||||
},
|
|
||||||
'ger' : {
|
|
||||||
'label' : 'Lead',
|
|
||||||
'nation' : 'GER',
|
|
||||||
'wettk_reg' : '^[0-9]{2,2}[_J]{1,1}[^WLJ]+.*',
|
|
||||||
'serie_reg' : '^[0-9]{2,2}_DC',
|
|
||||||
'bgcolor' : '#A8F0A8', //'#69b9a9'
|
|
||||||
'cat_id' : [57]
|
|
||||||
},
|
|
||||||
'ger_speed' : {
|
|
||||||
'label' : 'Speed',
|
|
||||||
'nation' : 'GER',
|
|
||||||
'wettk_reg' : '^[0-9]{2,2}[_J]{1,1}[^WLJ]+.*',
|
|
||||||
'serie_reg' : '',
|
|
||||||
'rang_title': '',
|
|
||||||
'bgcolor' : '#A8F0A8', //'#e72e5d'
|
|
||||||
'cat_id' : [60]
|
|
||||||
},*/
|
|
||||||
|
|
||||||
'ger_meisterschaft' : {
|
|
||||||
'label' : 'Deutsche Meisterschaft',
|
|
||||||
'nation' : 'GER',
|
|
||||||
'bgcolor' : '#A8F0A8',
|
|
||||||
'sort_rank': 1,
|
|
||||||
'cat_id' : [57, 59, 60]
|
|
||||||
},
|
|
||||||
|
|
||||||
'ger_jugend' : {
|
|
||||||
'label' : 'Deutscher Jugendcup',
|
|
||||||
'nation' : 'GER',
|
|
||||||
'wettk_reg' : '^[0-9]{2,2}[_J]{1,1}[^WL]+.*',
|
|
||||||
'serie_reg' : '^[0-9]{2,2}_JC',
|
|
||||||
// 'rang_title': 'Deutsche Jugend RANGLISTE',
|
|
||||||
'bgcolor' : '#D8FFD8',
|
|
||||||
'sort_rank': 2,
|
|
||||||
'cat_id' : [58]
|
|
||||||
},
|
|
||||||
'ger_state' : {
|
|
||||||
'label' : 'Landesmeisterschaft',
|
|
||||||
'nation' : 'GER',
|
|
||||||
'wettk_reg' : '^[0-9]{2,2}[_J]{1,1}LM.*',
|
|
||||||
'serie_reg' : '^[0-9]{2,2}[_J]{1,1}LM.*',
|
|
||||||
'rang_title': '',
|
|
||||||
'bgcolor' : '#F0F0F0',
|
|
||||||
'sort_rank': 3,
|
|
||||||
'cat_id' : [61,56]
|
|
||||||
},
|
|
||||||
|
|
||||||
// --- SUI ---
|
|
||||||
|
|
||||||
'sui' : {
|
|
||||||
'label' : 'Erwachsene',
|
|
||||||
'nation' : 'SUI',
|
|
||||||
'wettk_reg' : '^[0-9]{2,2}_[^R].*',
|
|
||||||
'serie_reg' : '.*',
|
|
||||||
'rang_title': 'SWISS RANKING',
|
|
||||||
'bgcolor' : '#A8F0A8',
|
|
||||||
'sort_rank': 1,
|
|
||||||
'cat_id' : [62,63]
|
|
||||||
},
|
|
||||||
'sui_jugend' : {
|
|
||||||
'label' : 'Jugend',
|
|
||||||
'nation' : 'SUI',
|
|
||||||
'wettk_reg' : '^[0-9]{2,2}_[^R].*',
|
|
||||||
'serie_reg' : '.*',
|
|
||||||
'rang_title': 'SWISS RANKING',
|
|
||||||
'bgcolor' : '#D8FFD8',
|
|
||||||
'sort_rank': 2,
|
|
||||||
'cat_id' : [65]
|
|
||||||
},
|
|
||||||
'sui_local' : {
|
|
||||||
'label' : 'RegioCups',
|
|
||||||
'nation' : 'SUI',
|
|
||||||
'wettk_reg' : '^[0-9]{2,2}_RG_.*',
|
|
||||||
'rang_title': '',
|
|
||||||
'bgcolor' : '#F0F0F0',
|
|
||||||
'sort_rank': 3,
|
|
||||||
'cat_id' : [64]
|
|
||||||
},
|
|
||||||
'sui_ice' : {
|
|
||||||
'label' : 'Iceclimbing',
|
|
||||||
'nation' : 'SUI',
|
|
||||||
'wettk_reg' : '^[0-9]{2,2}_RC_.*',
|
|
||||||
'rang_title': '',
|
|
||||||
'bgcolor' : '#F0F0F0',
|
|
||||||
'sort_rank': 4,
|
|
||||||
'cat_id' : [84]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
@ -224,6 +57,10 @@ Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BRController {
|
||||||
|
id: brController
|
||||||
|
}
|
||||||
|
|
||||||
ServerConn {
|
ServerConn {
|
||||||
id: serverConn
|
id: serverConn
|
||||||
}
|
}
|
||||||
|
@ -304,7 +141,8 @@ Window {
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
|
|
||||||
anchors.fill: parent
|
width: toolBar.width
|
||||||
|
height: toolBar.height
|
||||||
|
|
||||||
spacing: width * 0.02
|
spacing: width * 0.02
|
||||||
|
|
||||||
|
@ -325,9 +163,10 @@ Window {
|
||||||
Column {
|
Column {
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
Layout.alignment: Layout.Center
|
||||||
|
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
width: parent.width - extraComponentLoader.width - toolButton.width - 3 * parent.spacing
|
//width: parent.width - extraComponentLoader.width - toolButton.width - 3 * parent.spacing
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
id: toolBarTitleLa
|
id: toolBarTitleLa
|
||||||
|
@ -411,28 +250,29 @@ Window {
|
||||||
|
|
||||||
height: parent.height
|
height: parent.height
|
||||||
|
|
||||||
Layout.alignment: Layout.Right
|
Layout.alignment: Layout.Center
|
||||||
|
|
||||||
|
active: true
|
||||||
|
|
||||||
onStatusChanged: {
|
onStatusChanged: {
|
||||||
//console.log("loader status changed: " + status)
|
console.log("LOADER status changed: " + status)
|
||||||
|
|
||||||
if(status == 0){
|
if(status === Loader.Ready){
|
||||||
extraComponentLoader.Layout.preferredWidth = 0
|
console.log("set loader width to: " + extraComponentLoader.Layout.preferredWidth + " for a item width of: " + extraComponentLoader.item.implicitWidth)
|
||||||
}
|
|
||||||
else {
|
|
||||||
extraComponentLoader.item.width = extraComponentLoader.item.implicitWidth
|
extraComponentLoader.item.width = extraComponentLoader.item.implicitWidth
|
||||||
extraComponentLoader.Layout.preferredWidth = extraComponentLoader.item.width
|
extraComponentLoader.Layout.preferredWidth = extraComponentLoader.item.width
|
||||||
widthChangedCon.target = extraComponentLoader.item
|
widthChangedCon.target = extraComponentLoader.item
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
//console.log("set loader width to: " + extraComponentLoader.Layout.preferredWidth + " for a item width of: " + extraComponentLoader.item.implicitWidth)
|
extraComponentLoader.Layout.preferredWidth = 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//sourceComponent: mainStack.currentItem.headerComponent
|
//sourceComponent: mainStack.currentItem.headerComponent
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: mainStack
|
target: mainStack
|
||||||
onCurrentItemChanged: {
|
function onCurrentItemChanged() {
|
||||||
secondCon.target = mainStack.currentItem
|
secondCon.target = mainStack.currentItem
|
||||||
disappearNa.start()
|
disappearNa.start()
|
||||||
}
|
}
|
||||||
|
@ -440,14 +280,14 @@ Window {
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
id: secondCon
|
id: secondCon
|
||||||
onHeaderComponentChanged: {
|
function onHeaderComponentChanged() {
|
||||||
disappearNa.start()
|
disappearNa.start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
id: widthChangedCon
|
id: widthChangedCon
|
||||||
onImplicitWidthChanged:{
|
function onImplicitWidthChanged() {
|
||||||
extraComponentLoader.item.width = extraComponentLoader.item.implicitWidth
|
extraComponentLoader.item.width = extraComponentLoader.item.implicitWidth
|
||||||
extraComponentLoader.Layout.preferredWidth = extraComponentLoader.item.implicitWidth
|
extraComponentLoader.Layout.preferredWidth = extraComponentLoader.item.implicitWidth
|
||||||
}
|
}
|
||||||
|
@ -506,6 +346,9 @@ Window {
|
||||||
|
|
||||||
onRunningChanged: {
|
onRunningChanged: {
|
||||||
if(!running){
|
if(!running){
|
||||||
|
console.log("SETTING HEADER COMP")
|
||||||
|
extraComponentLoader.Layout.preferredWidth = 0
|
||||||
|
extraComponentLoader.sourceComponent = null
|
||||||
extraComponentLoader.sourceComponent = mainStack.currentItem.headerComponent
|
extraComponentLoader.sourceComponent = mainStack.currentItem.headerComponent
|
||||||
appearNa.start()
|
appearNa.start()
|
||||||
}
|
}
|
||||||
|
@ -595,7 +438,9 @@ Window {
|
||||||
function openWidget(params){
|
function openWidget(params){
|
||||||
loadingDl.open()
|
loadingDl.open()
|
||||||
|
|
||||||
|
console.log("OPENING COMP 2")
|
||||||
var calComp = Qt.createComponent("qrc:/Pages/WidgetPage.qml").createObject(null, {"params": params})
|
var calComp = Qt.createComponent("qrc:/Pages/WidgetPage.qml").createObject(null, {"params": params})
|
||||||
|
console.log("OPENING COMP 3")
|
||||||
app.errorCode = calComp.status
|
app.errorCode = calComp.status
|
||||||
|
|
||||||
if(calComp.ready){
|
if(calComp.ready){
|
||||||
|
@ -608,6 +453,41 @@ Window {
|
||||||
loadingDl.close()
|
loadingDl.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function openCalendar(federation) {
|
||||||
|
loadingDl.open()
|
||||||
|
var newPageComp = Qt.createComponent("qrc:/Pages/CalendarPage.qml").createObject(null, {"data": brController.getCalendar(federation)})
|
||||||
|
|
||||||
|
app.errorCode = newPageComp.status
|
||||||
|
|
||||||
|
if(newPageComp.ready){
|
||||||
|
mainStack.push(newPageComp)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
delete(newPageComp)
|
||||||
|
}
|
||||||
|
|
||||||
|
loadingDl.close()
|
||||||
|
}
|
||||||
|
|
||||||
|
function openResults(competition) {
|
||||||
|
loadingDl.open()
|
||||||
|
|
||||||
|
console.log("OPENING COMP 2")
|
||||||
|
var newPageComp = Qt.createComponent("qrc:/Pages/ResultPage.qml").createObject(null, {"data": competition})
|
||||||
|
|
||||||
|
console.log("OPENING COMP 3")
|
||||||
|
app.errorCode = newPageComp.status
|
||||||
|
|
||||||
|
if(newPageComp.ready){
|
||||||
|
mainStack.push(newPageComp)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
delete(newPageComp)
|
||||||
|
}
|
||||||
|
|
||||||
|
loadingDl.close()
|
||||||
|
}
|
||||||
|
|
||||||
function defaultString(string, defaultString){
|
function defaultString(string, defaultString){
|
||||||
if(string === undefined || string === null){
|
if(string === undefined || string === null){
|
||||||
return defaultString
|
return defaultString
|
||||||
|
|
|
@ -19,5 +19,9 @@
|
||||||
<file>Pages/AthleteSearchPage.qml</file>
|
<file>Pages/AthleteSearchPage.qml</file>
|
||||||
<file>Components/SpeedFlowChart.qml</file>
|
<file>Components/SpeedFlowChart.qml</file>
|
||||||
<file>Components/SwipeGallery.qml</file>
|
<file>Components/SwipeGallery.qml</file>
|
||||||
|
<file>Pages/CalendarPage.qml</file>
|
||||||
|
<file>Pages/BRWidgetPage.qml</file>
|
||||||
|
<file>Pages/ResultPage.qml</file>
|
||||||
|
<file>Components/SelectorPopup.qml</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
72
sources/brathlete.cpp
Normal file
72
sources/brathlete.cpp
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
#include "brathlete.h"
|
||||||
|
|
||||||
|
BRAthlete::BRAthlete(BRProvider* provider, BRWidget::BRFederation federation, int id, BRAthleteData initialData) : BRWidget(provider, federation, id)
|
||||||
|
{
|
||||||
|
this->setData(initialData);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString BRAthlete::getFirstName() {
|
||||||
|
return this->firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString BRAthlete::getLastName() {
|
||||||
|
return this->lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString BRAthlete::getCity() {
|
||||||
|
return this->city;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString BRAthlete::getFederation() {
|
||||||
|
return this->federation;
|
||||||
|
}
|
||||||
|
|
||||||
|
QUrl BRAthlete::getFederationUrl() {
|
||||||
|
return this->federationUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
int BRAthlete::getYearOfBirth() {
|
||||||
|
return this->yearOfBirth;
|
||||||
|
}
|
||||||
|
|
||||||
|
BRAthlete::BRAthleteGender BRAthlete::getGender() {
|
||||||
|
return this->gender;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString BRAthlete::getNation() {
|
||||||
|
return this->nation;
|
||||||
|
}
|
||||||
|
|
||||||
|
int BRAthlete::getAge() {
|
||||||
|
return this->age;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BRAthlete::setData(BRAthleteData data) {
|
||||||
|
this->firstName = data.firstName;
|
||||||
|
this->lastName = data.lastName;
|
||||||
|
this->city = data.city;
|
||||||
|
this->federation = data.federation;
|
||||||
|
this->federationUrl = data.federationUrl;
|
||||||
|
this->yearOfBirth = data.yearOfBirth;
|
||||||
|
this->gender = data.gender;
|
||||||
|
this->nation = data.nation;
|
||||||
|
this->age = data.age;
|
||||||
|
emit this->metadataChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode BRAthlete::load() {
|
||||||
|
|
||||||
|
BRAthleteData newData {
|
||||||
|
this,
|
||||||
|
|
||||||
|
this->firstName,
|
||||||
|
this->lastName,
|
||||||
|
this->city,
|
||||||
|
this->federation,
|
||||||
|
this->federationUrl,
|
||||||
|
this->yearOfBirth,
|
||||||
|
this->gender,
|
||||||
|
this->nation,
|
||||||
|
this->age,
|
||||||
|
};
|
||||||
|
}
|
70
sources/brcalendar.cpp
Normal file
70
sources/brcalendar.cpp
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
#include "brcalendar.h"
|
||||||
|
#include "brprovider.h"
|
||||||
|
|
||||||
|
BRCalendar::BRCalendar(BRProvider* provider, BRFederation federation) : BRWidget(provider, federation, -1)
|
||||||
|
{
|
||||||
|
this->currentSeason = nullptr;
|
||||||
|
this->seasons = {};
|
||||||
|
|
||||||
|
connect(this, &BRCalendar::currentSeasonChanged, this, &BRCalendar::titleChanged);
|
||||||
|
connect(this, &BRCalendar::seasonsChanged, this, &BRCalendar::titleChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString BRCalendar::getTitle() {
|
||||||
|
QString title = QStringList({"IFSC", "DAV", "SAC"})[this->getFederation()] + " " + tr("calendar");
|
||||||
|
|
||||||
|
if(this->currentSeason != nullptr)
|
||||||
|
title += " " + this->currentSeason->getName();
|
||||||
|
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QObject*> BRCalendar::getSeasonsQML() {
|
||||||
|
return this->listToQmlList(this->seasons);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRSeason* BRCalendar::getCurrentSeason() {
|
||||||
|
return this->currentSeason;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BRCalendar::setCurrentSeason(BRSeason* season) {
|
||||||
|
if(!this->seasons.contains(season))
|
||||||
|
return;
|
||||||
|
|
||||||
|
this->currentSeason = season;
|
||||||
|
this->currentSeason->load();
|
||||||
|
emit this->currentSeasonChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode BRCalendar::load() {
|
||||||
|
if(this->getProvider() == nullptr)
|
||||||
|
return BRWidget::NoProviderError;
|
||||||
|
|
||||||
|
// reload all comp data using our providers
|
||||||
|
|
||||||
|
BRCalendarData newData {
|
||||||
|
this,
|
||||||
|
this->currentSeason,
|
||||||
|
this->seasons
|
||||||
|
};
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode statusCode = this->getProvider()->getWidgetData(&newData);
|
||||||
|
|
||||||
|
if(statusCode != BRWidget::Success)
|
||||||
|
return statusCode;
|
||||||
|
|
||||||
|
if(this->seasons != newData.seasons) {
|
||||||
|
this->seasons.clear();
|
||||||
|
this->seasons = newData.seasons;
|
||||||
|
emit this->seasonsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this->currentSeason != newData.currentSeason) {
|
||||||
|
this->currentSeason = newData.currentSeason;
|
||||||
|
emit this->currentSeasonChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return statusCode;
|
||||||
|
}
|
15
sources/brcontroller.cpp
Normal file
15
sources/brcontroller.cpp
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
#include "brcontroller.h"
|
||||||
|
|
||||||
|
BRController::BRController(QObject *parent) : QObject(parent)
|
||||||
|
{
|
||||||
|
this->providerDr = new BRProviderDr(this);
|
||||||
|
this->providerVl = new BRProviderVl(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRCalendar* BRController::getCalendar(BRWidget::BRFederation federation) {
|
||||||
|
if(federation == BRWidget::IFSC)
|
||||||
|
return this->providerVl->getCalendar(federation);
|
||||||
|
else
|
||||||
|
return this->providerDr->getCalendar(federation);
|
||||||
|
}
|
104
sources/brleague.cpp
Normal file
104
sources/brleague.cpp
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
#include "brleague.h"
|
||||||
|
#include "brprovider.h"
|
||||||
|
|
||||||
|
BRLeague::BRLeague(BRProvider* provider, BRWidget::BRFederation federation, int id, BRLeagueData initialData) : BRWidget(provider, federation, id)
|
||||||
|
{
|
||||||
|
this->competitions = {};
|
||||||
|
connect(this, &BRLeague::stateChanged, this, &BRLeague::enabledChanged);
|
||||||
|
this->setState(Configured);
|
||||||
|
this->setData(initialData);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString BRLeague::getName() {
|
||||||
|
return this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
QColor BRLeague::getColor() {
|
||||||
|
return this->color;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool BRLeague::getEnabled() {
|
||||||
|
return this->enabled && this->state == Loaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BRLeague::setEnabled(bool enabled) {
|
||||||
|
if(this->enabled == enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this->enabled = enabled;
|
||||||
|
emit this->enabledChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<BRCompetition*> BRLeague::getCompetitions() {
|
||||||
|
return this->competitions;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QObject*> BRLeague::getCompetitionsQML() {
|
||||||
|
return this->listToQmlList(this->competitions);
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QObject*> BRLeague::getCupsQML() {
|
||||||
|
return this->listToQmlList(this->cups);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BRLeague::setData(BRLeagueData data) {
|
||||||
|
|
||||||
|
this->name = data.name;
|
||||||
|
this->color = data.color;
|
||||||
|
emit this->metadataChanged();
|
||||||
|
|
||||||
|
if(this->competitions != data.competitions) {
|
||||||
|
this->competitions.clear();
|
||||||
|
this->competitions = data.competitions;
|
||||||
|
|
||||||
|
for(BRCompetition* competition : this->competitions) {
|
||||||
|
competition->setLeague(this);
|
||||||
|
connect(competition, &BRCompetition::pinnedChanged, this, &BRLeague::competitionsChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
emit this->competitionsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this->cups != data.cups) {
|
||||||
|
this->cups.clear();
|
||||||
|
this->cups = data.cups;
|
||||||
|
emit this->cupsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this->competitions.length() > 0 || this->cups.length() > 0)
|
||||||
|
this->setState(Loaded);
|
||||||
|
else
|
||||||
|
this->setState(Configured);
|
||||||
|
|
||||||
|
if(data.enabled != this->enabled) {
|
||||||
|
this->enabled = data.enabled;
|
||||||
|
emit this->enabledChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode BRLeague::load() {
|
||||||
|
if(this->getProvider() == nullptr)
|
||||||
|
return BRWidget::NoProviderError;
|
||||||
|
|
||||||
|
this->setState(Loading);
|
||||||
|
|
||||||
|
BRLeagueData newData {
|
||||||
|
this,
|
||||||
|
this->name,
|
||||||
|
this->color,
|
||||||
|
this->enabled,
|
||||||
|
this->competitions,
|
||||||
|
this->cups
|
||||||
|
};
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode statusCode = this->getProvider()->getWidgetData(&newData);
|
||||||
|
|
||||||
|
if(statusCode != BRWidget::Success)
|
||||||
|
return statusCode;
|
||||||
|
|
||||||
|
this->setData(newData);
|
||||||
|
|
||||||
|
return statusCode;
|
||||||
|
}
|
98
sources/brseason.cpp
Normal file
98
sources/brseason.cpp
Normal file
|
@ -0,0 +1,98 @@
|
||||||
|
#include "brseason.h"
|
||||||
|
#include "brprovider.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
BRSeason::BRSeason(BRProvider* provider, BRWidget::BRFederation federation, int id, BRSeasonData initialData) : BRWidget(provider, federation, id)
|
||||||
|
{
|
||||||
|
connect(this, &BRSeason::leaguesChanged, this, &BRSeason::competitionsChanged);
|
||||||
|
connect(this, &BRSeason::leaguesChanged, this, &BRSeason::cupsChanged);
|
||||||
|
this->leagues = {};
|
||||||
|
this->setData(initialData);
|
||||||
|
}
|
||||||
|
|
||||||
|
int BRSeason::getYear() const {
|
||||||
|
return this->year;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString BRSeason::getName() {
|
||||||
|
return this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QObject*> BRSeason::getLeaguesQML() {
|
||||||
|
return this->listToQmlList(this->leagues);
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<BRLeague*> BRSeason::getLeagues() const {
|
||||||
|
return this->leagues;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QObject*> BRSeason::getCompetitionsQML() {
|
||||||
|
QList<BRCompetition*> allCompetitions;
|
||||||
|
|
||||||
|
for(BRLeague* league : this->leagues) {
|
||||||
|
if(league->getEnabled())
|
||||||
|
allCompetitions.append(league->getCompetitions());
|
||||||
|
else
|
||||||
|
for(BRCompetition* competition : league->getCompetitions())
|
||||||
|
if(competition->getPinned())
|
||||||
|
allCompetitions.append(competition);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::sort(allCompetitions.begin(), allCompetitions.end(), BRCompetition::lessThan);
|
||||||
|
|
||||||
|
return this->listToQmlList(allCompetitions);
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QObject*> BRSeason::getCupsQML() {
|
||||||
|
QList<QObject*> allCups;
|
||||||
|
|
||||||
|
for(BRLeague* league : this->leagues) {
|
||||||
|
allCups.append(league->getCupsQML());
|
||||||
|
}
|
||||||
|
|
||||||
|
return this->listToQmlList(allCups);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BRSeason::setData(BRSeasonData data) {
|
||||||
|
this->year = data.year;
|
||||||
|
this->name = data.name;
|
||||||
|
this->multiLeagueSupport = data.nativeMultiLeagueSupport;
|
||||||
|
emit this->metadataChanged();
|
||||||
|
|
||||||
|
if(this->leagues != data.leagues) {
|
||||||
|
this->leagues.clear();
|
||||||
|
this->leagues = data.leagues;
|
||||||
|
emit this->leaguesChanged();
|
||||||
|
|
||||||
|
for(BRLeague* league : this->leagues) {
|
||||||
|
connect(league, &BRLeague::competitionsChanged, this, &BRSeason::competitionsChanged);
|
||||||
|
connect(league, &BRLeague::enabledChanged, this, &BRSeason::competitionsChanged);
|
||||||
|
connect(league, &BRLeague::cupsChanged, this, &BRSeason::cupsChanged);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode BRSeason::load() {
|
||||||
|
if(this->getProvider() == nullptr)
|
||||||
|
return BRWidget::NoProviderError;
|
||||||
|
|
||||||
|
// reload all comp data using our providers
|
||||||
|
|
||||||
|
BRSeasonData newData {
|
||||||
|
this,
|
||||||
|
this->year,
|
||||||
|
this->name,
|
||||||
|
this->multiLeagueSupport,
|
||||||
|
this->leagues
|
||||||
|
};
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode statusCode = this->getProvider()->getWidgetData(&newData);
|
||||||
|
|
||||||
|
if(statusCode != BRWidget::Success)
|
||||||
|
return statusCode;
|
||||||
|
|
||||||
|
this->setData(newData);
|
||||||
|
|
||||||
|
return statusCode;
|
||||||
|
}
|
|
@ -16,13 +16,13 @@
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "headers/serverconn.h"
|
#include "brserverconnector.h"
|
||||||
|
|
||||||
ServerConn::ServerConn(QObject *parent) : QObject(parent)
|
BRServerConnector::BRServerConnector(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant ServerConn::getWidgetData(QVariantMap params){
|
QVariant BRServerConnector::getWidgetData(QVariantMap params){
|
||||||
QString requestUrl;
|
QString requestUrl;
|
||||||
if(params["nation"].toString() == "ICC"){
|
if(params["nation"].toString() == "ICC"){
|
||||||
requestUrl = "https://ifsc-egw.wavecdn.net/egw/ranking/json.php?";
|
requestUrl = "https://ifsc-egw.wavecdn.net/egw/ranking/json.php?";
|
||||||
|
@ -65,7 +65,7 @@ QVariant ServerConn::getWidgetData(QVariantMap params){
|
||||||
// --- Helper functions ---
|
// --- Helper functions ---
|
||||||
// ------------------------
|
// ------------------------
|
||||||
|
|
||||||
QVariantMap ServerConn::senddata(QUrl serviceUrl, QUrlQuery pdata)
|
QVariantMap BRServerConnector::senddata(QUrl serviceUrl, QUrlQuery pdata)
|
||||||
{
|
{
|
||||||
// create network manager
|
// create network manager
|
||||||
QNetworkAccessManager * networkManager = new QNetworkAccessManager();
|
QNetworkAccessManager * networkManager = new QNetworkAccessManager();
|
33
sources/brwidget.cpp
Normal file
33
sources/brwidget.cpp
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#include "brwidget.h"
|
||||||
|
|
||||||
|
#include "brprovider.h"
|
||||||
|
|
||||||
|
BRWidget::BRWidget(BRProvider* provider, BRFederation federation, int id) : QObject(provider), provider(provider), federation(federation), id(id)
|
||||||
|
{
|
||||||
|
this->state = Unconfigured;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRWidget::BRWidgetState BRWidget::getState() const {
|
||||||
|
return this->state;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BRWidget::setState(BRWidgetState state) {
|
||||||
|
if(this->state == state)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this->state = state;
|
||||||
|
emit this->stateChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
BRWidget::BRFederation BRWidget::getFederation() const {
|
||||||
|
return this->federation;
|
||||||
|
}
|
||||||
|
|
||||||
|
BRProvider* BRWidget::getProvider() {
|
||||||
|
return this->provider;
|
||||||
|
}
|
||||||
|
|
||||||
|
int BRWidget::getId() const {
|
||||||
|
return this->id;
|
||||||
|
}
|
109
sources/competition/brcategory.cpp
Normal file
109
sources/competition/brcategory.cpp
Normal file
|
@ -0,0 +1,109 @@
|
||||||
|
#include "brcategory.h"
|
||||||
|
#include "brprovider.h"
|
||||||
|
#include "brcompetition.h"
|
||||||
|
|
||||||
|
BRCategory::BRCategory(BRProvider* provider, BRWidget::BRFederation federation, int id, BRCategoryData initialData) : BRWidget(provider, federation, id)
|
||||||
|
{
|
||||||
|
this->currentRound = nullptr;
|
||||||
|
this->discipline = UnknownDiscipline;
|
||||||
|
this->generalResult = nullptr;
|
||||||
|
connect(this, &BRCategory::generalResultChanged, this, &BRCategory::resultsChanged);
|
||||||
|
connect(this, &BRCategory::roundsChanged, this, &BRCategory::resultsChanged);
|
||||||
|
this->setData(initialData);
|
||||||
|
}
|
||||||
|
|
||||||
|
BRCompetition* BRCategory::getCompetition() const {
|
||||||
|
return this->competition;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString BRCategory::getName() {
|
||||||
|
return this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
BRCategory::BRDiscipline BRCategory::getDiscipline() {
|
||||||
|
return this->discipline;
|
||||||
|
}
|
||||||
|
|
||||||
|
BRCategory::BRCategoryStatus BRCategory::getStatus() {
|
||||||
|
return this->status;
|
||||||
|
}
|
||||||
|
|
||||||
|
BRRound* BRCategory::getCurrentRound() const {
|
||||||
|
return this->currentRound;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BRCategory::setCurrentRound(BRRound* round) {
|
||||||
|
if(!this->rounds.contains(round) && this->generalResult != round)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this->currentRound = round;
|
||||||
|
emit this->currentRoundChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
BRRound* BRCategory::getGeneralResult() {
|
||||||
|
return this->generalResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<BRRound*> BRCategory::getRounds(bool includeGeneralResult) const {
|
||||||
|
QList<BRRound*> rounds;
|
||||||
|
if(includeGeneralResult && this->generalResult != nullptr)
|
||||||
|
rounds.append(this->generalResult);
|
||||||
|
|
||||||
|
rounds.append(this->rounds);
|
||||||
|
|
||||||
|
return rounds;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QObject*> BRCategory::getRoundsQML() {
|
||||||
|
return this->listToQmlList(this->getRounds(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
BRCategory::BRCategoryData BRCategory::getData() {
|
||||||
|
BRCategory::BRCategoryData data {
|
||||||
|
this,
|
||||||
|
this->name,
|
||||||
|
this->discipline,
|
||||||
|
this->status,
|
||||||
|
this->currentRound,
|
||||||
|
this->generalResult,
|
||||||
|
this->rounds
|
||||||
|
};
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BRCategory::setData(BRCategoryData data) {
|
||||||
|
this->name = data.name;
|
||||||
|
this->discipline = data.discipline;
|
||||||
|
this->status = data.status;
|
||||||
|
emit this->metadataChanged();
|
||||||
|
|
||||||
|
if(this->currentRound != data.currentRound) {
|
||||||
|
this->currentRound = data.currentRound;
|
||||||
|
emit this->currentRoundChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this->generalResult != data.generalResult) {
|
||||||
|
this->generalResult = data.generalResult;
|
||||||
|
this->generalResult->category = this;
|
||||||
|
connect(this->generalResult, &BRRound::resultsChanged, this, &BRCategory::generalResultChanged);
|
||||||
|
emit this->generalResultChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this->rounds != data.rounds) {
|
||||||
|
this->rounds.clear();
|
||||||
|
this->rounds = data.rounds;
|
||||||
|
|
||||||
|
for(BRRound* round : this->rounds) {
|
||||||
|
round->category = this;
|
||||||
|
connect(round, &BRRound::resultsChanged, this, &BRCategory::resultsChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
emit this->roundsChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode BRCategory::load() {
|
||||||
|
return BRWidget::OpeationNotSupportedError;
|
||||||
|
}
|
163
sources/competition/brcompetition.cpp
Normal file
163
sources/competition/brcompetition.cpp
Normal file
|
@ -0,0 +1,163 @@
|
||||||
|
#include "brcompetition.h"
|
||||||
|
#include "brleague.h"
|
||||||
|
#include "brprovider.h"
|
||||||
|
|
||||||
|
BRCompetition::BRCompetition(BRProvider* provider, BRWidget::BRFederation federation, int id, BRCompetitionData initialData) : BRWidget(provider, federation, id) {
|
||||||
|
this->currentCategory = nullptr;
|
||||||
|
this->eventWebsiteUrl = "";
|
||||||
|
this->pinned = false;
|
||||||
|
connect(this, &BRCompetition::categoriesChanged, this, &BRCompetition::resultsChanged);
|
||||||
|
this->setData(initialData);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BRCompetition::setLeague(BRLeague* league) {
|
||||||
|
if(league == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this->league = league;
|
||||||
|
emit this->metadataChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString BRCompetition::getName() {
|
||||||
|
return this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDate BRCompetition::getStartDate() {
|
||||||
|
return this->startDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDate BRCompetition::getEndDate() {
|
||||||
|
return this->endDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString BRCompetition::getDateSpan() {
|
||||||
|
if(this->startDate == this->endDate)
|
||||||
|
return this->startDate.toString("d MMMM yyyy");
|
||||||
|
else
|
||||||
|
return this->startDate.toString("d MMMM yyyy") + " - " + this->endDate.toString("d MMMM yyyy");
|
||||||
|
}
|
||||||
|
|
||||||
|
BRLeague* BRCompetition::getLeague() {
|
||||||
|
return this->league;
|
||||||
|
}
|
||||||
|
|
||||||
|
QUrl BRCompetition::getEventWebsiteUrl() {
|
||||||
|
return this->eventWebsiteUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QUrl> BRCompetition::getInfosheetUrls() {
|
||||||
|
return this->infosheetUrls;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BRCompetition::getPinned() {
|
||||||
|
return this->pinned;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BRCompetition::setPinned(bool pinned) {
|
||||||
|
if(this->pinned == pinned)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this->pinned= pinned;
|
||||||
|
emit this->pinnedChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QObject*> BRCompetition::getCategoriesQML() {
|
||||||
|
return this->listToQmlList(this->categories);
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<BRCategory*> BRCompetition::getCategories() {
|
||||||
|
return this->categories;
|
||||||
|
}
|
||||||
|
|
||||||
|
BRCategory* BRCompetition::getCurrentCategory() const {
|
||||||
|
return this->currentCategory;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BRCompetition::setCurrentCategory(BRCategory* category) {
|
||||||
|
if(!this->categories.contains(category))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// try to find the same round in the new category
|
||||||
|
if(this->currentCategory != nullptr && this->currentCategory->getCurrentRound() != nullptr) {
|
||||||
|
QString currentRoundName = this->currentCategory->getCurrentRound()->getName();
|
||||||
|
|
||||||
|
// search round name in new category
|
||||||
|
for(BRRound* round : category->getRounds()) {
|
||||||
|
qDebug() << "Trying to restore round: " << currentRoundName << " with round: " << round->getName();
|
||||||
|
if(round->getName() == currentRoundName)
|
||||||
|
category->setCurrentRound(round);
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug() << "Restored round with ID: " << category->currentRound->getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
this->currentCategory = category;
|
||||||
|
emit this->currentCategoryChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QObject*> BRCompetition::getResultsQML() {
|
||||||
|
if(this->currentCategory == nullptr)
|
||||||
|
return {};
|
||||||
|
|
||||||
|
qDebug() << "getting results";
|
||||||
|
if( this->currentCategory->getCurrentRound() != nullptr)
|
||||||
|
return this->currentCategory->getCurrentRound()->getResultsQML();
|
||||||
|
else if(this->currentCategory->getGeneralResult() != nullptr)
|
||||||
|
return this->currentCategory->getGeneralResult()->getResultsQML();
|
||||||
|
else
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode BRCompetition::load() {
|
||||||
|
BRCompetitionData newData {
|
||||||
|
this,
|
||||||
|
this->name,
|
||||||
|
this->startDate,
|
||||||
|
this->endDate,
|
||||||
|
this->eventWebsiteUrl,
|
||||||
|
this->infosheetUrls,
|
||||||
|
|
||||||
|
this->pinned,
|
||||||
|
this->currentCategory,
|
||||||
|
this->categories
|
||||||
|
};
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode statusCode = this->getProvider()->getWidgetData(&newData);
|
||||||
|
|
||||||
|
if(statusCode != BRWidget::Success)
|
||||||
|
return statusCode;
|
||||||
|
|
||||||
|
this->setData(newData);
|
||||||
|
|
||||||
|
return BRWidget::Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BRCompetition::setData(BRCompetition::BRCompetitionData data) {
|
||||||
|
this->name = data.name;
|
||||||
|
this->startDate = data.startDate;
|
||||||
|
this->endDate = data.endDate;
|
||||||
|
this->eventWebsiteUrl = data.eventWebsiteUrl;
|
||||||
|
this->infosheetUrls = data.infosheetUrls;
|
||||||
|
emit this->metadataChanged();
|
||||||
|
|
||||||
|
if(this->currentCategory != data.currentCategory) {
|
||||||
|
this->currentCategory = data.currentCategory;
|
||||||
|
emit this->currentCategoryChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this->categories != data.categories) {
|
||||||
|
this->categories.clear();
|
||||||
|
this->categories = data.categories;
|
||||||
|
for(BRCategory* category : this->categories) {
|
||||||
|
category->competition = this;
|
||||||
|
connect(category, &BRCategory::resultsChanged, this, &BRCompetition::resultsChanged);
|
||||||
|
}
|
||||||
|
emit this->categoriesChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool BRCompetition::lessThan(BRCompetition* competition1, BRCompetition* competition2) {
|
||||||
|
return competition1->startDate < competition2->startDate;
|
||||||
|
}
|
65
sources/competition/brround.cpp
Normal file
65
sources/competition/brround.cpp
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
#include "brround.h"
|
||||||
|
#include "brprovider.h"
|
||||||
|
|
||||||
|
BRRound::BRRound(BRProvider* provider, BRWidget::BRFederation federation, int id, BRRoundData initialData, bool generalResult) : BRWidget(provider, federation, id)
|
||||||
|
{
|
||||||
|
this->generalResult = generalResult;
|
||||||
|
this->results = {};
|
||||||
|
this->setData(initialData);
|
||||||
|
}
|
||||||
|
|
||||||
|
BRCategory* BRRound::getCategory() const {
|
||||||
|
return this->category;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BRRound::isGeneralResult() const {
|
||||||
|
return this->generalResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString BRRound::getName() {
|
||||||
|
return this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<BRResult*> BRRound::getResults() {
|
||||||
|
return this->results;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QObject*> BRRound::getResultsQML() {
|
||||||
|
return this->listToQmlList(this->results);
|
||||||
|
}
|
||||||
|
|
||||||
|
BRRound::BRRoundData BRRound::getData() {
|
||||||
|
BRRound::BRRoundData data {
|
||||||
|
this,
|
||||||
|
this->name,
|
||||||
|
this->results
|
||||||
|
};
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode BRRound::load() {
|
||||||
|
return BRWidget::OpeationNotSupportedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BRRound::setData(BRRoundData data) {
|
||||||
|
this->name = data.name;
|
||||||
|
emit this->metadataChanged();
|
||||||
|
|
||||||
|
if(this->results != data.results) {
|
||||||
|
this->results.clear();
|
||||||
|
this->results = data.results;
|
||||||
|
|
||||||
|
for(BRResult* result : this->results)
|
||||||
|
result->round = this;
|
||||||
|
|
||||||
|
emit this->resultsChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool BRRound::lessThan(BRRound* round1, BRRound* round2) {
|
||||||
|
// TODO ??
|
||||||
|
return round1->getId() < round2->getId();
|
||||||
|
}
|
||||||
|
|
55
sources/competition/result/brresult.cpp
Normal file
55
sources/competition/result/brresult.cpp
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
#include "brresult.h"
|
||||||
|
#include "brround.h"
|
||||||
|
#include "brcategory.h"
|
||||||
|
|
||||||
|
BRResult::BRResult(BRResultData initialData) : BRWidget(nullptr, BRWidget::UnknownFederation, -1)
|
||||||
|
{
|
||||||
|
this->round = nullptr;
|
||||||
|
this->setData(initialData);
|
||||||
|
}
|
||||||
|
|
||||||
|
int BRResult::getRank() const {
|
||||||
|
return this->rank;
|
||||||
|
}
|
||||||
|
|
||||||
|
int BRResult::getStartNumber() const {
|
||||||
|
return this->startNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
BRAthlete* BRResult::getAthlete() const {
|
||||||
|
return this->athlete;
|
||||||
|
}
|
||||||
|
|
||||||
|
BRResultDetails* BRResult::getDetails() const {
|
||||||
|
return this->details;
|
||||||
|
}
|
||||||
|
|
||||||
|
BRRound* BRResult::getRound() const {
|
||||||
|
return this->round;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BRResult::setData(BRResultData data) {
|
||||||
|
this->rank = data.rank;
|
||||||
|
this->startNumber = data.startNumber;
|
||||||
|
|
||||||
|
this->details = data.details;
|
||||||
|
if(data.details != nullptr)
|
||||||
|
this->details->result = this;
|
||||||
|
|
||||||
|
this->athlete = data.athlete;
|
||||||
|
emit this->metadataChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode BRResult::load() {
|
||||||
|
return BRWidget::OpeationNotSupportedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool BRResult::lessThan(BRResult* result1, BRResult* result2) {
|
||||||
|
if(result1->getAthlete()->getId() == result2->getAthlete()->getId())
|
||||||
|
return BRRound::lessThan(result1->getRound(), result2->getRound());
|
||||||
|
else
|
||||||
|
return result1->getRank() < result2->getRank();
|
||||||
|
|
||||||
|
}
|
42
sources/competition/result/brresultdetails.cpp
Normal file
42
sources/competition/result/brresultdetails.cpp
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
#include "brresultdetails.h"
|
||||||
|
|
||||||
|
BRResultDetails::BRResultDetails(BRResultDetailsType type) : BRWidget(nullptr, BRWidget::UnknownFederation, -1)
|
||||||
|
{
|
||||||
|
this->type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString BRResultDetails::string() {
|
||||||
|
return this->toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
BRResultDetails::BRResultDetailsType BRResultDetails::getType() {
|
||||||
|
return this->type;
|
||||||
|
}
|
||||||
|
|
||||||
|
BRResult* BRResultDetails::getResult() {
|
||||||
|
return this->result;
|
||||||
|
}
|
||||||
|
|
||||||
|
BRWidget::BRDiscipline BRResultDetails::getDiscipline() {
|
||||||
|
switch (this->type) {
|
||||||
|
case GeneralResult:
|
||||||
|
return BRWidget::AllDisciplines;
|
||||||
|
case SpeedQualificationResult:
|
||||||
|
case SpeedFinalResult:
|
||||||
|
return BRWidget::Speed;
|
||||||
|
case LeadResult:
|
||||||
|
return BRWidget::Lead;
|
||||||
|
case BoulderResult:
|
||||||
|
return BRWidget::Boulder;
|
||||||
|
case CombinedResult:
|
||||||
|
return BRWidget::Combined;
|
||||||
|
case UnknownResultType:
|
||||||
|
return BRWidget::AllDisciplines;
|
||||||
|
default:
|
||||||
|
return BRWidget::UnknownDiscipline;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode BRResultDetails::load() {
|
||||||
|
return BRWidget::OpeationNotSupportedError;
|
||||||
|
}
|
44
sources/competition/result/brresultdetailsgeneralresult.cpp
Normal file
44
sources/competition/result/brresultdetailsgeneralresult.cpp
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
#include "brresultdetailsgeneralresult.h"
|
||||||
|
#include "brcategory.h"
|
||||||
|
#include "brresult.h"
|
||||||
|
|
||||||
|
BRResultDetailsGeneralResult::BRResultDetailsGeneralResult() : BRResultDetails(BRResultDetails::GeneralResult)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QString BRResultDetailsGeneralResult::toString() {
|
||||||
|
QString resultString = "";
|
||||||
|
|
||||||
|
for(BRResult* result : this->getResults())
|
||||||
|
resultString += result->getDetails()->toString() + " | " ;
|
||||||
|
|
||||||
|
resultString = resultString.left(resultString.length() - 3);
|
||||||
|
|
||||||
|
return resultString;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<BRResult*> BRResultDetailsGeneralResult::getResults() {
|
||||||
|
|
||||||
|
if(this->getResult() == nullptr || this->getResult()->getRound() == nullptr || this->getResult()->getRound()->getCategory() == nullptr)
|
||||||
|
return {};
|
||||||
|
|
||||||
|
BRCategory* category = this->getResult()->getRound()->getCategory();
|
||||||
|
|
||||||
|
// get all results of this athlete from all rounds
|
||||||
|
QList<BRResult*> results;
|
||||||
|
for(BRRound* round : category->getRounds()) {
|
||||||
|
for(BRResult* result : round->getResults()) {
|
||||||
|
if(result->getAthlete()->getId() == this->getResult()->getAthlete()->getId()) {
|
||||||
|
results.append(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QObject*> BRResultDetailsGeneralResult::getResultsQML() {
|
||||||
|
return this->listToQmlList(this->getResults());
|
||||||
|
}
|
||||||
|
|
6
sources/competition/result/brresultdetailsunknown.cpp
Normal file
6
sources/competition/result/brresultdetailsunknown.cpp
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#include "brresultdetailsunknown.h"
|
||||||
|
|
||||||
|
BRResultDetailsUnknown::BRResultDetailsUnknown(QString score) : BRResultDetails(BRResultDetails::UnknownResultType)
|
||||||
|
{
|
||||||
|
this->score = score;
|
||||||
|
}
|
31
sources/cup/brcup.cpp
Normal file
31
sources/cup/brcup.cpp
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
#include "brcup.h"
|
||||||
|
|
||||||
|
BRCup::BRCup(BRProvider* provider, BRWidget::BRFederation federation, int id, BRCupData initialData) : BRWidget(provider, federation, id)
|
||||||
|
{
|
||||||
|
this->categories = {};
|
||||||
|
this->setData(initialData);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString BRCup::getName() {
|
||||||
|
return this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QObject*> BRCup::getCategoriesQML() {
|
||||||
|
return this->listToQmlList(this->categories);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BRCup::setData(BRCupData data) {
|
||||||
|
this->name = data.name;
|
||||||
|
emit this->metadataChanged();
|
||||||
|
|
||||||
|
if(this->categories != data.categories) {
|
||||||
|
this->categories.clear();
|
||||||
|
this->categories = data.categories;
|
||||||
|
emit this->categoriesChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode BRCup::load() {
|
||||||
|
// TODO
|
||||||
|
}
|
|
@ -23,8 +23,9 @@
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QStyleFactory>
|
#include <QStyleFactory>
|
||||||
|
|
||||||
#include "headers/serverconn.h"
|
#include "brserverconnector.h"
|
||||||
#include "headers/appsettings.h"
|
#include "appsettings.h"
|
||||||
|
#include "brcontroller.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
@ -38,9 +39,25 @@ int main(int argc, char *argv[])
|
||||||
QIcon::setFallbackSearchPaths(QIcon::fallbackSearchPaths() << ":/resources/shared/icons");
|
QIcon::setFallbackSearchPaths(QIcon::fallbackSearchPaths() << ":/resources/shared/icons");
|
||||||
QIcon::setThemeName("bluerock");
|
QIcon::setThemeName("bluerock");
|
||||||
|
|
||||||
qmlRegisterType<ServerConn>("com.itsblue.digitalRockRanking", 1, 0, "ServerConn");
|
qmlRegisterType<BRServerConnector>("com.itsblue.digitalRockRanking", 1, 0, "ServerConn");
|
||||||
qmlRegisterType<AppSettings>("com.itsblue.digitalRockRanking", 1, 0, "AppSettings");
|
qmlRegisterType<AppSettings>("com.itsblue.digitalRockRanking", 1, 0, "AppSettings");
|
||||||
|
|
||||||
|
qmlRegisterType<BRController>("de.itsblue.blueRock", 2, 0, "BRController");
|
||||||
|
qmlRegisterUncreatableType<BRCalendar>("de.itsblue.blueRock", 2, 0, "BRCalendar", "BRCalendar is not creatable");
|
||||||
|
qmlRegisterUncreatableType<BRSeason>("de.itsblue.blueRock", 2, 0, "BRSeason", "BRSeason is not creatable");
|
||||||
|
qmlRegisterUncreatableType<BRLeague>("de.itsblue.blueRock", 2, 0, "BRLeague", "BRLeague is not creatable");
|
||||||
|
qmlRegisterUncreatableType<BRCompetition>("de.itsblue.blueRock", 2, 0, "BRCompetition", "BRCompetition is not creatable");
|
||||||
|
qmlRegisterUncreatableType<BRCup>("de.itsblue.blueRock", 2, 0, "BRCup", "BRCup is not creatable");
|
||||||
|
qmlRegisterUncreatableType<BRCategory>("de.itsblue.blueRock", 2, 0, "BRCategory", "BRCategory is not creatable");
|
||||||
|
qmlRegisterUncreatableType<BRRound>("de.itsblue.blueRock", 2, 0, "BRRound", "BRRound is not creatable");
|
||||||
|
qmlRegisterUncreatableType<BRAthlete>("de.itsblue.blueRock", 2, 0, "BRAthlete", "BRAthlete is not creatable");
|
||||||
|
qmlRegisterUncreatableType<BRResult>("de.itsblue.blueRock", 2, 0, "BRResult", "BRResult is not creatable");
|
||||||
|
qmlRegisterUncreatableType<BRWidget>("de.itsblue.blueRock", 2, 0, "BRWidget", "BRWidget is not creatable");
|
||||||
|
qRegisterMetaType<BRWidget::BRFederation>("BRWidget::BRFederation");
|
||||||
|
qRegisterMetaType<BRWidget::BRWidgetState>("BRWidget::BRWidgetState");
|
||||||
|
qRegisterMetaType<BRWidget::BRWidgetStatusCode>("BRWidget::BRWidgetStatusCode");
|
||||||
|
//qmlRegisterType<BRController>("de.itsblue.blueRock", 2, 0, "BRController");
|
||||||
|
|
||||||
QQmlApplicationEngine engine;
|
QQmlApplicationEngine engine;
|
||||||
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
|
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
|
||||||
if (engine.rootObjects().isEmpty())
|
if (engine.rootObjects().isEmpty())
|
||||||
|
|
116
sources/provider/brprovider.cpp
Normal file
116
sources/provider/brprovider.cpp
Normal file
|
@ -0,0 +1,116 @@
|
||||||
|
#include "brprovider.h"
|
||||||
|
|
||||||
|
BRProvider::BRProvider(QObject *parent) : QObject(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
BRCalendar* BRProvider::getCalendar(BRWidget::BRFederation federation) {
|
||||||
|
return new BRCalendar(this, federation);
|
||||||
|
}
|
||||||
|
|
||||||
|
BRSeason* BRProvider::getSeason(BRWidget::BRFederation federation, int id, BRSeason::BRSeasonData initialData) {
|
||||||
|
return new BRSeason(this, federation, id, initialData);
|
||||||
|
}
|
||||||
|
|
||||||
|
BRLeague* BRProvider::getLeague(BRWidget::BRFederation federation, int id, BRLeague::BRLeagueData initialData) {
|
||||||
|
return new BRLeague(this, federation, id, initialData);
|
||||||
|
}
|
||||||
|
|
||||||
|
BRCompetition* BRProvider::getCompetition(BRWidget::BRFederation federation, int id, BRCompetition::BRCompetitionData initialData) {
|
||||||
|
return new BRCompetition(this, federation, id, initialData);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRCup* BRProvider::getCup(BRWidget::BRFederation federation, int id, BRCup::BRCupData initialData) {
|
||||||
|
return new BRCup(this, federation, id, initialData);
|
||||||
|
}
|
||||||
|
|
||||||
|
BRCategory* BRProvider::getCategory(BRWidget::BRFederation federation, int id, BRCategory::BRCategoryData initialData) {
|
||||||
|
return new BRCategory(this, federation, id, initialData);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRAthlete* BRProvider::getAthlete(BRWidget::BRFederation federation, int id, BRAthlete::BRAthleteData initialData) {
|
||||||
|
return new BRAthlete(this, federation, id, initialData);
|
||||||
|
}
|
||||||
|
|
||||||
|
BRRound* BRProvider::getRound(BRWidget::BRFederation federation, int id, BRRound::BRRoundData initialData, bool generalResult) {
|
||||||
|
return new BRRound(this, federation, id, initialData, generalResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRResult* BRProvider::getResult(BRResult::BRResultData initialData) {
|
||||||
|
return new BRResult(initialData);
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariantMap BRProvider::serverRequest(QUrl serviceUrl, QList<QStringList> additionalHeaders, QUrlQuery postData)
|
||||||
|
{
|
||||||
|
qDebug() << "requesting: " << serviceUrl;
|
||||||
|
|
||||||
|
// create network manager
|
||||||
|
QNetworkAccessManager * networkManager = new QNetworkAccessManager();
|
||||||
|
|
||||||
|
QVariantMap ret; //this is a custom type to store the return-data
|
||||||
|
|
||||||
|
// Create network request
|
||||||
|
QNetworkRequest request(serviceUrl);
|
||||||
|
|
||||||
|
// insert additional headers
|
||||||
|
for(QStringList additionalHeader : additionalHeaders) {
|
||||||
|
if(additionalHeader.length() == 2)
|
||||||
|
request.setRawHeader(additionalHeader[0].toUtf8(), additionalHeader[1].toUtf8());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//QSslConfiguration config = QSslConfiguration::defaultConfiguration();
|
||||||
|
//config.setProtocol(QSsl::TlsV1_2);
|
||||||
|
//request.setSslConfiguration(config);
|
||||||
|
|
||||||
|
//send a POST request with the given url and data to the server
|
||||||
|
|
||||||
|
QNetworkReply *reply;
|
||||||
|
|
||||||
|
if(postData.isEmpty()){
|
||||||
|
// if no post data is given -> send a GET request
|
||||||
|
reply = networkManager->get(request);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// if post data is given -> send POST request
|
||||||
|
reply = networkManager->post(request, postData.toString(QUrl::FullyEncoded).toUtf8());
|
||||||
|
}
|
||||||
|
|
||||||
|
// loop to wait until the request has finished before processing the data
|
||||||
|
QEventLoop loop;
|
||||||
|
// timer to cancel the request after 3 seconds
|
||||||
|
QTimer timer;
|
||||||
|
timer.setSingleShot(true);
|
||||||
|
|
||||||
|
// quit the loop when the request finised
|
||||||
|
loop.connect(networkManager, SIGNAL(finished(QNetworkReply*)), SLOT(quit()));
|
||||||
|
// or the timer timed out
|
||||||
|
loop.connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
|
||||||
|
// start the timer
|
||||||
|
timer.start(10000);
|
||||||
|
// start the loop
|
||||||
|
loop.exec();
|
||||||
|
|
||||||
|
//get the status code
|
||||||
|
QVariant status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
|
||||||
|
|
||||||
|
qDebug() << "Finished: " << status_code;
|
||||||
|
|
||||||
|
ret.insert("status", status_code.toInt());
|
||||||
|
|
||||||
|
//get the full text response
|
||||||
|
ret.insert("text", QString::fromUtf8(reply->readAll()));
|
||||||
|
|
||||||
|
// delete the reply object
|
||||||
|
delete reply;
|
||||||
|
|
||||||
|
// delete the newtwork access manager object
|
||||||
|
delete networkManager;
|
||||||
|
|
||||||
|
//return the data
|
||||||
|
return(ret);
|
||||||
|
}
|
517
sources/provider/brproviderdr.cpp
Normal file
517
sources/provider/brproviderdr.cpp
Normal file
|
@ -0,0 +1,517 @@
|
||||||
|
#include "brproviderdr.h"
|
||||||
|
|
||||||
|
BRProviderDr::BRProviderDr(QObject *parent) : BRProvider(parent)
|
||||||
|
{
|
||||||
|
// leagues source:
|
||||||
|
// - https://github.com/ralfbecker/ranking/blob/master/sitemgr/digitalrock/dav_calendar.php
|
||||||
|
// - 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})}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
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::BRWidgetStatusCode BRProviderDr::getWidgetData(BRCalendar::BRCalendarData* calendarData)
|
||||||
|
{
|
||||||
|
// load some data
|
||||||
|
QString nationStr = calendarData->calendar->getFederation() == BRWidget::SAC ? "SUI":"GER";
|
||||||
|
qDebug() << "Nation str: " << nationStr << " federation: " << calendarData->calendar->getFederation();
|
||||||
|
int year = QDate::currentDate().year();
|
||||||
|
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", calendarData->calendar->getFederation());
|
||||||
|
|
||||||
|
// create seasons
|
||||||
|
QVariantList seasons = data["years"].toList();
|
||||||
|
|
||||||
|
for(QVariant seasonVar : seasons) {
|
||||||
|
int seasonId = seasonVar.toString().toInt();
|
||||||
|
BRSeason* season = this->getSeason(
|
||||||
|
calendarData->calendar->getFederation(),
|
||||||
|
seasonId,
|
||||||
|
this->parseSeasonData(seasonId, data)
|
||||||
|
);
|
||||||
|
|
||||||
|
calendarData->seasons.append(season);
|
||||||
|
|
||||||
|
if(seasonId == year)
|
||||||
|
calendarData->currentSeason = season;
|
||||||
|
}
|
||||||
|
|
||||||
|
return BRWidget::Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode BRProviderDr::getWidgetData(BRSeason::BRSeasonData* seasonData) {
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
BRSeason::BRSeasonData BRProviderDr::parseSeasonData(int id, QVariantMap rawData) {
|
||||||
|
BRSeason::BRSeasonData data;
|
||||||
|
this->parseSeasonData(&data, id, rawData);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BRProviderDr::parseSeasonData(BRSeason::BRSeasonData* seasonData, int id, QVariantMap rawData) {
|
||||||
|
seasonData->year = id;
|
||||||
|
seasonData->nativeMultiLeagueSupport = true;
|
||||||
|
seasonData->name = QString::number(id);
|
||||||
|
|
||||||
|
qDebug() << "Parsing season: " << seasonData->name;
|
||||||
|
|
||||||
|
BRWidget::BRFederation federation = BRWidget::BRFederation(rawData["federation"].toInt(0));
|
||||||
|
|
||||||
|
// insert the leagues if the season is the current one
|
||||||
|
if(seasonData->name == rawData["year"].toString())
|
||||||
|
for(QVariantMap leagueVar : this->leagues[federation]) {
|
||||||
|
BRLeague* league = this->getLeague(federation, leagueVar["id"].toInt(), this->parseLeagueData(leagueVar, rawData));
|
||||||
|
seasonData->leagues.append(league);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode BRProviderDr::getWidgetData(BRLeague::BRLeagueData* leagueData) {
|
||||||
|
Q_UNUSED(leagueData)
|
||||||
|
return BRWidget::NotImplementedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
BRLeague::BRLeagueData BRProviderDr::parseLeagueData(QVariantMap leagueProperties, QVariantMap rawData) {
|
||||||
|
|
||||||
|
BRLeague::BRLeagueData data;
|
||||||
|
|
||||||
|
BRWidget::BRFederation federation = BRWidget::BRFederation(rawData["federation"].toInt(0));
|
||||||
|
|
||||||
|
data.name = leagueProperties["name"].toString();
|
||||||
|
data.color = QColor(leagueProperties["color"].toString());
|
||||||
|
data.enabled = true;
|
||||||
|
|
||||||
|
qDebug() << "- Parsing league: " << data.name;
|
||||||
|
|
||||||
|
// parse competitions
|
||||||
|
QVariantList competitionsVar = rawData["competitions"].toList();
|
||||||
|
|
||||||
|
// TODO: make more efficient
|
||||||
|
|
||||||
|
for(QVariant competitionVar : competitionsVar) {
|
||||||
|
QVariantMap competitionMap = competitionVar.toMap();
|
||||||
|
|
||||||
|
// check if this competition is part of this league
|
||||||
|
if(leagueProperties["leagueIDs"].toList().contains(competitionMap["cat_id"].toInt())) {
|
||||||
|
BRCompetition* competition = this->getCompetition(federation, competitionVar.toMap()["WetId"].toInt(), this->parseCompetitionData(competitionMap, rawData["cats"].toList(), federation));
|
||||||
|
data.competitions.append(competition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if this is league with id 0
|
||||||
|
if(leagueProperties["id"].toInt() == 0) {
|
||||||
|
// parse cups
|
||||||
|
QVariantList cupsVar = rawData["cups"].toList();
|
||||||
|
|
||||||
|
for(QVariant cupVar : cupsVar) {
|
||||||
|
QVariantMap cupMap = cupVar.toMap();
|
||||||
|
BRCup* cup = this->getCup(federation, cupMap["SerId"].toInt(), this->parseCupData(rawData["cats"].toList(), cupMap, federation));
|
||||||
|
data.cups.append(cup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode BRProviderDr::getWidgetData(BRCompetition::BRCompetitionData* competitionData) {
|
||||||
|
|
||||||
|
if(competitionData->competition->getCurrentCategory() == nullptr)
|
||||||
|
return BRWidget::OpeationNotSupportedError;
|
||||||
|
|
||||||
|
// reload all data
|
||||||
|
BRCategory* currentCategory = competitionData->competition->getCurrentCategory();
|
||||||
|
QVariantMap ret;
|
||||||
|
int retryCount = 0;
|
||||||
|
|
||||||
|
// handle route not found errors
|
||||||
|
do {
|
||||||
|
retryCount ++;
|
||||||
|
// load category data
|
||||||
|
QString competitionId = QString::number(currentCategory->getCompetition()->getId());
|
||||||
|
QString categoryId = QString::number(currentCategory->getId());
|
||||||
|
QString requestUrl = "https://www.digitalrock.de/egroupware/ranking/json.php?comp=" + competitionId + "&cat=" + categoryId;
|
||||||
|
|
||||||
|
if(currentCategory->getCurrentRound() != nullptr && currentCategory->getCurrentRound()->getId() >= 0)
|
||||||
|
requestUrl += "&route=" + QString::number(currentCategory->getCurrentRound()->getId());
|
||||||
|
|
||||||
|
ret = this->serverRequest(QUrl(requestUrl));
|
||||||
|
|
||||||
|
// handle route not found errors
|
||||||
|
if(ret["status"] != 200 && (ret["status"] != 404 || retryCount > 1)) {
|
||||||
|
// request was a failure
|
||||||
|
return BRWidget::BRWidgetStatusCode(ret["status"].toInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
// if 404 is returned, the route probaply does not exist -> try again without route
|
||||||
|
currentCategory->setCurrentRound(currentCategory->getGeneralResult());
|
||||||
|
|
||||||
|
} while(ret["status"] != 200);
|
||||||
|
|
||||||
|
QVariantMap data = QJsonDocument::fromJson(ret["text"].toString().toUtf8()).toVariant().toMap();
|
||||||
|
|
||||||
|
this->parseCompetitionData(competitionData, data, competitionData->competition->getFederation());
|
||||||
|
|
||||||
|
return BRWidget::Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
BRCompetition::BRCompetitionData BRProviderDr::parseCompetitionData(QVariantMap rawData, QVariantList globalCategoriesList, BRWidget::BRFederation federation) {
|
||||||
|
// Load competition data from calendar
|
||||||
|
BRCompetition::BRCompetitionData data;
|
||||||
|
|
||||||
|
data.name = rawData["name"].toString();
|
||||||
|
|
||||||
|
qDebug() << "-- Parsing competition: " << data.name;
|
||||||
|
|
||||||
|
if(rawData.contains("date"))
|
||||||
|
data.startDate = QDate::fromString(rawData["date"].toString(), "yyyy-MM-dd");
|
||||||
|
if(rawData.contains("date_end"))
|
||||||
|
data.endDate = QDate::fromString(rawData["date_end"].toString(), "yyyy-MM-dd");
|
||||||
|
|
||||||
|
if(rawData.contains("homepage"))
|
||||||
|
data.eventWebsiteUrl = rawData["homepage"].toString();
|
||||||
|
|
||||||
|
// load infosheet URLs
|
||||||
|
for(int i = 0; i < 2; i++) {
|
||||||
|
QString infosheetName = QStringList({"info", "info2"})[i];
|
||||||
|
if(rawData.contains(infosheetName)) {
|
||||||
|
QString url = rawData[infosheetName].toString();
|
||||||
|
|
||||||
|
if(federation == BRWidget::DAV)
|
||||||
|
url = "http://ranking.alpenverein.de/" + QString::number(data.startDate.year()) + "/GER/" + rawData["rkey"].toString() + ".pdf";
|
||||||
|
|
||||||
|
data.infosheetUrls.append(url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// load categories
|
||||||
|
QVariantList categoriesList = rawData["cats"].toList();
|
||||||
|
data.categories.clear();
|
||||||
|
|
||||||
|
for(QVariant categoryVar : categoriesList) {
|
||||||
|
QVariantMap categoryMap = categoryVar.toMap();
|
||||||
|
|
||||||
|
// parse discipline
|
||||||
|
QString discipline;
|
||||||
|
if(rawData.contains("discipline")) {
|
||||||
|
// all categories have the same discipline
|
||||||
|
discipline = rawData["discipline"].toString();
|
||||||
|
// remove numbers (the Year of a competition is in the discipline somtimes)
|
||||||
|
discipline = discipline.remove( QRegExp("/[0-9]/g") );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
// categories discipline may differ
|
||||||
|
// search category in global categories list
|
||||||
|
for(QVariant globalCategoryVar : globalCategoriesList) {
|
||||||
|
QVariantMap globalCategoryMap = globalCategoryVar.toMap();
|
||||||
|
if(categoryMap["GrpId"].toInt() == globalCategoryMap["GrpId"].toInt()) {
|
||||||
|
// TODO: gender
|
||||||
|
discipline = globalCategoryMap["discipline"].toString();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
categoryMap.insert("discipline", discipline);
|
||||||
|
|
||||||
|
BRCategory* category = this->getCategory(federation, categoryMap["GrpId"].toInt(), this->parseCategoryData(categoryMap));
|
||||||
|
data.categories.append(category);
|
||||||
|
}
|
||||||
|
|
||||||
|
data.currentCategory = nullptr;
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BRProviderDr::parseCompetitionData(BRCompetition::BRCompetitionData* competitionData, QVariantMap rawData, BRWidget::BRFederation federation) {
|
||||||
|
|
||||||
|
// load competition data from category page (?comp=X&cat=Y)
|
||||||
|
competitionData->name = rawData["comp_name"].toString();
|
||||||
|
|
||||||
|
// reload categories
|
||||||
|
// As digitalrock does not allow to get rounds in the competiton calendar
|
||||||
|
// we need to populate all categories with their rounds when the first category is loaded.
|
||||||
|
// for that, all categories are recreated
|
||||||
|
QVariantList categoriesList = rawData["categorys"].toList();
|
||||||
|
|
||||||
|
// store old categories
|
||||||
|
QMap<int, BRCategory*> oldCategories;
|
||||||
|
for(BRCategory* category : competitionData->categories)
|
||||||
|
if(!oldCategories.contains(category->getId()))
|
||||||
|
oldCategories.insert(category->getId(), category);
|
||||||
|
|
||||||
|
competitionData->categories.clear();
|
||||||
|
|
||||||
|
for(QVariant categoryVar : categoriesList) {
|
||||||
|
QVariantMap categoryMap = categoryVar.toMap();
|
||||||
|
int categoryId = categoryMap["GrpId"].toInt();
|
||||||
|
|
||||||
|
BRCategory::BRCategoryData categoryData;
|
||||||
|
categoryData.name = categoryMap["name"].toString();
|
||||||
|
|
||||||
|
// restore data that is not available in competition view of the API
|
||||||
|
if(oldCategories.contains(categoryId)) {
|
||||||
|
categoryData.status = oldCategories[categoryId]->getStatus();
|
||||||
|
categoryData.discipline = oldCategories[categoryId]->getDiscipline();
|
||||||
|
}
|
||||||
|
|
||||||
|
categoryData.currentRound = nullptr;
|
||||||
|
categoryData.generalResult = nullptr;
|
||||||
|
|
||||||
|
qDebug() << "Loading category: " << categoryData.name << " with discipline: " << categoryData.discipline;
|
||||||
|
|
||||||
|
QVariantMap roundList;
|
||||||
|
// check if route_names are given:
|
||||||
|
if(rawData.contains("route_names"))
|
||||||
|
roundList = rawData["route_names"].toMap();
|
||||||
|
|
||||||
|
// load rounds
|
||||||
|
for(QString roundId : roundList.keys()) {
|
||||||
|
if(roundId.toInt() < 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
BRRound::BRRoundData roundData;
|
||||||
|
roundData.name = roundList[roundId].toString();
|
||||||
|
BRRound* round = this->getRound(competitionData->competition->getFederation(), roundId.toInt(), roundData);
|
||||||
|
categoryData.rounds.append(round);
|
||||||
|
|
||||||
|
// if this was the previous round -> restore it!
|
||||||
|
if(round->getId() == rawData["route_order"].toInt())
|
||||||
|
categoryData.currentRound = round;
|
||||||
|
}
|
||||||
|
|
||||||
|
// general result
|
||||||
|
BRRound::BRRoundData generalResultRoundData;
|
||||||
|
generalResultRoundData.name = "Gesamtergebnis";
|
||||||
|
categoryData.generalResult = this->getRound(competitionData->competition->getFederation(), -1, generalResultRoundData, true);
|
||||||
|
|
||||||
|
// set default round if it was not restored
|
||||||
|
if(categoryData.currentRound == nullptr)
|
||||||
|
categoryData.currentRound = categoryData.generalResult;
|
||||||
|
|
||||||
|
BRCategory* category = this->getCategory(federation, categoryId, categoryData);
|
||||||
|
competitionData->categories.append(category);
|
||||||
|
|
||||||
|
// restore current category and load its reults
|
||||||
|
if(category->getId() == rawData["GrpId"]) {
|
||||||
|
competitionData->currentCategory = category;
|
||||||
|
|
||||||
|
// if we have a currentRound or a general result
|
||||||
|
if(categoryData.currentRound != nullptr) {
|
||||||
|
qDebug() << "-- Current Round is: " << categoryData.currentRound->getName() << " with id: " << categoryData.currentRound->getId();
|
||||||
|
BRRound::BRRoundData roundData = categoryData.currentRound->getData();
|
||||||
|
this->parseRoundData(&roundData, rawData);
|
||||||
|
this->setRoundData(categoryData.currentRound, roundData);
|
||||||
|
|
||||||
|
// if we have a general result -> load all other round results
|
||||||
|
if(categoryData.currentRound->isGeneralResult()) {
|
||||||
|
for(BRRound* round : categoryData.rounds) {
|
||||||
|
BRRound::BRRoundData roundData = round->getData();
|
||||||
|
this->parseRoundData(&roundData, rawData, QString::number(round->getId()));
|
||||||
|
this->setRoundData(round, roundData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete old categories
|
||||||
|
for(int categoryId : oldCategories.keys()) {
|
||||||
|
oldCategories[categoryId]->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BRCup::BRCupData BRProviderDr::parseCupData(QVariantList categoriesList, QVariantMap rawData, BRWidget::BRFederation federation) {
|
||||||
|
BRCup::BRCupData data;
|
||||||
|
|
||||||
|
data.name = rawData["name"].toString();
|
||||||
|
|
||||||
|
qDebug() << "- Parsing Cup: " << data.name;
|
||||||
|
|
||||||
|
// parse categories
|
||||||
|
for(QVariant categoryName : rawData["cats"].toList()) {
|
||||||
|
// find category name in cats:
|
||||||
|
|
||||||
|
for(QVariant categoryVar : categoriesList) {
|
||||||
|
QVariantMap categoryMap = categoryVar.toMap();
|
||||||
|
if(categoryMap["rkey"].toString() == categoryName.toString()) {
|
||||||
|
BRCategory* category = this->getCategory(federation, rawData["GrpId"].toInt(), this->parseCategoryData(categoryMap));
|
||||||
|
data.categories.append(category);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
BRCategory::BRCategoryData BRProviderDr::parseCategoryData(QVariantMap rawData) {
|
||||||
|
BRCategory::BRCategoryData data;
|
||||||
|
// TODO: gender
|
||||||
|
|
||||||
|
data.name = rawData["name"].toString();
|
||||||
|
data.currentRound = nullptr;
|
||||||
|
data.generalResult = nullptr;
|
||||||
|
|
||||||
|
QMap<int, BRCategory::BRCategoryStatus> statusTranslations = {
|
||||||
|
{4, BRCategory::Registration},
|
||||||
|
{2, BRCategory::Startlist},
|
||||||
|
{1, BRCategory::Result},
|
||||||
|
{0, BRCategory::Result}
|
||||||
|
};
|
||||||
|
|
||||||
|
QMap<QString, BRCategory::BRDiscipline> disciplineTranslations = {
|
||||||
|
{"boulder", BRCategory::Boulder},
|
||||||
|
{"lead", BRCategory::Lead},
|
||||||
|
{"speed", BRCategory::Speed}
|
||||||
|
};
|
||||||
|
|
||||||
|
if(disciplineTranslations.contains(rawData["discipline"].toString()))
|
||||||
|
data.discipline = disciplineTranslations[rawData["discipline"].toString()];
|
||||||
|
else
|
||||||
|
data.discipline = BRCategory::UnknownDiscipline;
|
||||||
|
|
||||||
|
// parse status
|
||||||
|
if(rawData.contains("status") && statusTranslations.contains(rawData["status"].toInt()))
|
||||||
|
data.status = statusTranslations[rawData["status"].toInt()];
|
||||||
|
else
|
||||||
|
data.status = BRCategory::UnknownStatus;
|
||||||
|
|
||||||
|
qDebug() << "-- Parsing category: " << data.name << " with discipline: " << data.discipline << " and status: " << data.status;
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BRProviderDr::parseCategoryData(BRCategory::BRCategoryData* categoryData, QVariantMap rawData) {
|
||||||
|
|
||||||
|
// category is already set-up -> only load rounds!
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void BRProviderDr::parseRoundData(BRRound::BRRoundData* roundData, QVariantMap rawData, QString resultKeyAttachment) {
|
||||||
|
roundData->results = {};
|
||||||
|
// load results
|
||||||
|
QVariantList resultList = rawData["participants"].toList();
|
||||||
|
for(QVariant resultVar : resultList) {
|
||||||
|
QVariantMap resultMap = resultVar.toMap();
|
||||||
|
// load athlete
|
||||||
|
BRAthlete* athlete = this->getAthlete(roundData->round->getFederation(), resultMap["PerId"].toInt(), this->parseAthletedata(resultMap));
|
||||||
|
|
||||||
|
// load result
|
||||||
|
// TODO: start number
|
||||||
|
BRResult::BRResultData resultData;
|
||||||
|
resultData.startNumber = resultMap["start_number"].toInt();
|
||||||
|
resultData.athlete = athlete;
|
||||||
|
resultData.rank = resultMap["result_rank" + resultKeyAttachment].toInt();
|
||||||
|
resultData.details = nullptr;
|
||||||
|
|
||||||
|
// load details:
|
||||||
|
// - check if we have a general result
|
||||||
|
if(roundData->round->isGeneralResult())
|
||||||
|
resultData.details = new BRResultDetailsGeneralResult();
|
||||||
|
else
|
||||||
|
resultData.details = new BRResultDetailsUnknown(resultMap["result" + resultKeyAttachment].toString());
|
||||||
|
|
||||||
|
BRResult* result = this->getResult(resultData);
|
||||||
|
roundData->results.append(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BRAthlete::BRAthleteData BRProviderDr::parseAthletedata(QVariantMap rawData) {
|
||||||
|
BRAthlete::BRAthleteData data;
|
||||||
|
|
||||||
|
data.firstName = rawData["firstname"].toString();
|
||||||
|
data.lastName = rawData["lastname"].toString();
|
||||||
|
data.federation = rawData["federation"].toString();
|
||||||
|
data.federationUrl = rawData["fed_url"].toUrl();
|
||||||
|
data.nation = rawData["nation"].toString();
|
||||||
|
data.city = rawData["city"].toString();
|
||||||
|
data.yearOfBirth = rawData["birthyear"].toInt();
|
||||||
|
qDebug() << "--- Parsing athlete: " << data.firstName << " " << data.lastName;
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
BRResult::BRResultData BRProviderDr::parseResultData(QVariantMap rawData) {
|
||||||
|
|
||||||
|
}
|
430
sources/provider/brprovidervl.cpp
Normal file
430
sources/provider/brprovidervl.cpp
Normal file
|
@ -0,0 +1,430 @@
|
||||||
|
#include "brprovidervl.h"
|
||||||
|
|
||||||
|
BRProviderVl::BRProviderVl(QObject *parent) : BRProvider(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode BRProviderVl::getWidgetData(BRCalendar::BRCalendarData* calendarData)
|
||||||
|
{
|
||||||
|
// load some data
|
||||||
|
QString requestUrl = "https://ifsc.results.info/api/v1/";
|
||||||
|
QVariantMap ret = this->serverRequest(QUrl(requestUrl), {{"x-auth-token", "cc7375f680648e7e6171e035e70351eb"}, {"Referer", "https://ifsc.results.info/"}});
|
||||||
|
|
||||||
|
if(ret["status"] != 200){
|
||||||
|
// request was a failure
|
||||||
|
return BRWidget::BRWidgetStatusCode(ret["status"].toInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariantMap data = QJsonDocument::fromJson(ret["text"].toString().toUtf8()).toVariant().toMap();
|
||||||
|
|
||||||
|
// create seasons
|
||||||
|
QVariantList seasons = data["seasons"].toList();
|
||||||
|
|
||||||
|
for(QVariant seasonVar : seasons) {
|
||||||
|
QVariantMap seasonMap = seasonVar.toMap();
|
||||||
|
int seasonId = seasonMap["name"].toInt();
|
||||||
|
BRSeason* season = this->getSeason(
|
||||||
|
calendarData->calendar->getFederation(),
|
||||||
|
seasonId,
|
||||||
|
this->parseSeasonData(seasonMap)
|
||||||
|
);
|
||||||
|
|
||||||
|
calendarData->seasons.append(season);
|
||||||
|
qDebug() << "Inserted season:" << season->getName();
|
||||||
|
|
||||||
|
if(seasonId == data["current"].toMap()["season"].toInt())
|
||||||
|
calendarData->currentSeason = season;
|
||||||
|
}
|
||||||
|
|
||||||
|
// load default league of current season
|
||||||
|
calendarData->currentSeason->getLeagues()[0]->load();
|
||||||
|
|
||||||
|
return BRWidget::Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode BRProviderVl::getWidgetData(BRSeason::BRSeasonData* seasonData) {
|
||||||
|
if(seasonData->season->getLeagues().length() > 0) {
|
||||||
|
// leagues are already loaded
|
||||||
|
|
||||||
|
// load default league
|
||||||
|
seasonData->season->getLeagues()[0]->load();
|
||||||
|
|
||||||
|
return BRWidget::Success;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// should never happen
|
||||||
|
return BRWidget::NotImplementedError;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BRSeason::BRSeasonData BRProviderVl::parseSeasonData(QVariantMap rawData) {
|
||||||
|
BRSeason::BRSeasonData data;
|
||||||
|
data.year = rawData["name"].toInt();
|
||||||
|
data.name = rawData["name"].toString();
|
||||||
|
data.nativeMultiLeagueSupport = false;
|
||||||
|
|
||||||
|
// insert the leagues
|
||||||
|
for(QVariant leagueVar : rawData["leagues"].toList()) {
|
||||||
|
QVariantMap leagueMap = leagueVar.toMap();
|
||||||
|
|
||||||
|
BRLeague::BRLeagueData leagueData;
|
||||||
|
leagueData.name = leagueMap["name"].toString();
|
||||||
|
int leagueId = leagueMap["url"].toString().split("/").last().toInt();
|
||||||
|
|
||||||
|
BRLeague* league = this->getLeague(BRWidget::IFSC, leagueId, leagueData);
|
||||||
|
data.leagues.append(league);
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode BRProviderVl::getWidgetData(BRLeague::BRLeagueData* leagueData) {
|
||||||
|
// load some data
|
||||||
|
QString requestUrl = "https://ifsc.results.info/api/v1/season_leagues/" + QString::number(leagueData->league->getId());
|
||||||
|
QVariantMap ret = this->serverRequest(QUrl(requestUrl), {{"x-auth-token", "cc7375f680648e7e6171e035e70351eb"}, {"Referer", "https://ifsc.results.info/"}});
|
||||||
|
|
||||||
|
if(ret["status"] != 200){
|
||||||
|
// request was a failure
|
||||||
|
return BRWidget::BRWidgetStatusCode(ret["status"].toInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariantMap data = QJsonDocument::fromJson(ret["text"].toString().toUtf8()).toVariant().toMap();
|
||||||
|
|
||||||
|
this->parseLeagueData(leagueData, data);
|
||||||
|
|
||||||
|
return BRWidget::Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BRProviderVl::parseLeagueData(BRLeague::BRLeagueData* data, QVariantMap rawData) {
|
||||||
|
|
||||||
|
BRWidget::BRFederation federation = BRWidget::BRFederation(rawData["federation"].toInt(0));
|
||||||
|
|
||||||
|
data->name = rawData["league"].toString();
|
||||||
|
data->color = QColor("#ffffff"); // TODO
|
||||||
|
data->enabled = true;
|
||||||
|
|
||||||
|
qDebug() << "Adding league: " << data->name;
|
||||||
|
|
||||||
|
// parse competitions
|
||||||
|
QVariantList competitionsVar = rawData["events"].toList();
|
||||||
|
|
||||||
|
for(QVariant competitionVar : competitionsVar) {
|
||||||
|
QVariantMap competitionMap = competitionVar.toMap();
|
||||||
|
|
||||||
|
qDebug() << "- Adding competition: " << competitionMap["event"].toString();
|
||||||
|
BRCompetition* competition = this->getCompetition(federation, competitionVar.toMap()["event_id"].toInt(), this->parseCompetitionData(competitionMap, rawData["d_cats"].toList(), federation));
|
||||||
|
data->competitions.append(competition);
|
||||||
|
}
|
||||||
|
|
||||||
|
// parse cups
|
||||||
|
QVariantList cupsVar = rawData["cups"].toList();
|
||||||
|
|
||||||
|
for(QVariant cupVar : cupsVar) {
|
||||||
|
QVariantMap cupMap = cupVar.toMap();
|
||||||
|
BRCup* cup = this->getCup(federation, cupMap["cup_id"].toInt(), this->parseCupData(cupMap, rawData["d_cats"].toList()));
|
||||||
|
data->cups.append(cup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode BRProviderVl::getWidgetData(BRCompetition::BRCompetitionData* competitionData) {
|
||||||
|
if(competitionData->competition->getCurrentCategory() == nullptr)
|
||||||
|
return BRWidget::OpeationNotSupportedError;
|
||||||
|
|
||||||
|
BRCategory* currentCategory = competitionData->competition->getCurrentCategory();
|
||||||
|
|
||||||
|
if(currentCategory->getCurrentRound() == nullptr)
|
||||||
|
return BRWidget::OpeationNotSupportedError;
|
||||||
|
|
||||||
|
BRRound* currentRound = currentCategory->getCurrentRound();
|
||||||
|
BRRound::BRRoundData roundData = currentRound->getData();
|
||||||
|
|
||||||
|
qDebug() << "LOADING ROUND DATA";
|
||||||
|
// load round data
|
||||||
|
QString competitionId = QString::number(roundData.round->getCategory()->getCompetition()->getId());
|
||||||
|
QString categoryId = QString::number(roundData.round->getCategory()->getId());
|
||||||
|
QString roundId = QString::number(roundData.round->getId());
|
||||||
|
|
||||||
|
QString requestUrl;
|
||||||
|
|
||||||
|
if(roundId == "-1") {
|
||||||
|
requestUrl = "https://ifsc.results.info/api/v1/events/" + competitionId + "/result/" + categoryId;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
requestUrl = "https://ifsc.results.info/api/v1/category_rounds/" + roundId + "/results";
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariantMap ret = this->serverRequest(QUrl(requestUrl), {{"x-auth-token", "cc7375f680648e7e6171e035e70351eb"}, {"Referer", "https://ifsc.results.info/"}});
|
||||||
|
|
||||||
|
if(ret["status"] != 200){
|
||||||
|
// request was a failure
|
||||||
|
return BRWidget::BRWidgetStatusCode(ret["status"].toInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariantMap data = QJsonDocument::fromJson(ret["text"].toString().toUtf8()).toVariant().toMap();
|
||||||
|
|
||||||
|
// TODO: reload all rounds, as they may change!
|
||||||
|
// (load category instead of competition)
|
||||||
|
this->parseRoundData(&roundData, data);
|
||||||
|
this->setRoundData(currentRound, roundData);
|
||||||
|
|
||||||
|
return BRWidget::Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
BRCompetition::BRCompetitionData BRProviderVl::parseCompetitionData(QVariantMap rawData, QVariantList globalCategoriesList, BRWidget::BRFederation federation) {
|
||||||
|
|
||||||
|
BRCompetition::BRCompetitionData data;
|
||||||
|
|
||||||
|
data.name = rawData["event"].toString();
|
||||||
|
|
||||||
|
data.startDate = QDate::fromString(rawData["starts_at"].toString().split(" ")[0], "yyyy-MM-dd");
|
||||||
|
data.endDate = QDate::fromString(rawData["ends_at"].toString().split(" ")[0], "yyyy-MM-dd");
|
||||||
|
|
||||||
|
data.eventWebsiteUrl = "";
|
||||||
|
|
||||||
|
for(int i = 0; i < 2; i++) {
|
||||||
|
QString infosheetName = QStringList({"infosheet_url", "additional_info_url"})[i];
|
||||||
|
if(rawData.contains(infosheetName) && !rawData[infosheetName].isNull()) {
|
||||||
|
data.infosheetUrls.append("https://ifsc.results.info" + rawData[infosheetName].toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariantList categoriesList = rawData["d_cats"].toList();
|
||||||
|
for(QVariant categoryVar : categoriesList) {
|
||||||
|
QVariantMap categoryMap = categoryVar.toMap();
|
||||||
|
|
||||||
|
// search category in global categories list
|
||||||
|
for(QVariant globalCategoryVar : globalCategoriesList) {
|
||||||
|
QVariantMap globalCategoryMap = globalCategoryVar.toMap();
|
||||||
|
if(categoryMap["id"].toInt() == globalCategoryMap["id"].toInt()) {
|
||||||
|
categoryMap.insert("discipline", globalCategoryMap["discipline"].toString());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BRCategory* category = this->getCategory(federation, categoryMap["id"].toInt(), this->parseCategoryData(categoryMap));
|
||||||
|
data.categories.append(category);
|
||||||
|
}
|
||||||
|
|
||||||
|
data.currentCategory = nullptr;
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRCup::BRCupData BRProviderVl::parseCupData(QVariantMap rawData, QVariantList globalCategoriesList) {
|
||||||
|
BRCup::BRCupData data;
|
||||||
|
|
||||||
|
data.name = rawData["cup"].toString();
|
||||||
|
|
||||||
|
// parse categories
|
||||||
|
for(QVariant categoryVar : rawData["d_cats"].toList()) {
|
||||||
|
// find category name in cats:
|
||||||
|
|
||||||
|
QVariantMap categoryMap = categoryVar.toMap();
|
||||||
|
|
||||||
|
int categoryId = categoryMap["ranking_url"].toString().split("/").last().toInt();
|
||||||
|
|
||||||
|
// search category in global categories list
|
||||||
|
for(QVariant globalCategoryVar : globalCategoriesList) {
|
||||||
|
QVariantMap globalCategoryMap = globalCategoryVar.toMap();
|
||||||
|
if(categoryId == globalCategoryMap["id"].toInt()) {
|
||||||
|
categoryMap.insert("discipline", globalCategoryMap["discipline"].toString());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BRCategory* category = this->getCategory(BRWidget::IFSC, categoryId, this->parseCategoryData(categoryMap));
|
||||||
|
data.categories.append(category);
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
BRCategory::BRCategoryData BRProviderVl::parseCategoryData(QVariantMap rawData) {
|
||||||
|
BRCategory::BRCategoryData data;
|
||||||
|
|
||||||
|
data.name = rawData["name"].toString();
|
||||||
|
// TODO: gender
|
||||||
|
|
||||||
|
// parse status and discipline
|
||||||
|
QMap<QString, BRCategory::BRCategoryStatus> statusTranslations = {
|
||||||
|
{"registration_pending", BRCategory::Registration},
|
||||||
|
{"registration_active", BRCategory::Registration},
|
||||||
|
// TODO {2, BRCategory::Startlist},
|
||||||
|
{"active", BRCategory::Result},
|
||||||
|
{"finished", BRCategory::Result}
|
||||||
|
};
|
||||||
|
|
||||||
|
QMap<QString, BRCategory::BRDiscipline> disciplineTranslations = {
|
||||||
|
{"Boulder", BRCategory::Boulder},
|
||||||
|
{"Lead", BRCategory::Lead},
|
||||||
|
{"Speed", BRCategory::Speed}
|
||||||
|
};
|
||||||
|
|
||||||
|
if(disciplineTranslations.contains(rawData["discipline"].toString()))
|
||||||
|
data.discipline = disciplineTranslations[rawData["discipline"].toString()];
|
||||||
|
else
|
||||||
|
data.discipline = BRCategory::UnknownDiscipline;
|
||||||
|
|
||||||
|
if(statusTranslations.contains(rawData["status"].toString()))
|
||||||
|
data.status = statusTranslations[rawData["status"].toString()];
|
||||||
|
else
|
||||||
|
data.status = BRCategory::UnknownStatus;
|
||||||
|
|
||||||
|
qDebug() << "-- Parsing category: " << data.name << " with discipline: " << data.discipline << " and status: " << data.status;
|
||||||
|
|
||||||
|
data.currentRound = nullptr;
|
||||||
|
|
||||||
|
BRRound::BRRoundData roundData;
|
||||||
|
roundData.name = "General result";
|
||||||
|
qDebug() << "--- Adding round: " << roundData.name;
|
||||||
|
data.generalResult = this->getRound(BRWidget::IFSC, -1, roundData, true);
|
||||||
|
|
||||||
|
// load rounds
|
||||||
|
QVariantList roundsList = rawData["category_rounds"].toList();
|
||||||
|
// insert general result
|
||||||
|
for(QVariant roundVar : roundsList) {
|
||||||
|
QVariantMap roundMap = roundVar.toMap();
|
||||||
|
|
||||||
|
BRRound::BRRoundData roundData;
|
||||||
|
roundData.name = roundMap["name"].toString();
|
||||||
|
qDebug() << "--- Adding round: " << roundData.name;
|
||||||
|
BRRound* round = this->getRound(BRWidget::IFSC, roundMap["category_round_id"].toInt(), roundData);
|
||||||
|
data.rounds.append(round);
|
||||||
|
}
|
||||||
|
|
||||||
|
data.currentRound = data.generalResult;
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*void BRProviderVl::parseCategoryData(BRCategory::BRCategoryData* categoryData, QVariantMap rawData) {
|
||||||
|
|
||||||
|
// no need to load rounds, they were already loaded when the whole competition was loaded!
|
||||||
|
|
||||||
|
qDebug() << "INITIALLY PARSING CATEGORY";
|
||||||
|
// load athletes
|
||||||
|
QVariantList atheletList = rawData["ranking"].toList();
|
||||||
|
QMap<int, BRAthlete*> tmpAthletes;
|
||||||
|
|
||||||
|
// load general result
|
||||||
|
BRRound::BRRoundData roundData;
|
||||||
|
|
||||||
|
// TODO status
|
||||||
|
roundData.name = tr("General result");
|
||||||
|
|
||||||
|
// parse Ranking
|
||||||
|
QVariantList resultList = rawData["ranking"].toList();
|
||||||
|
for(QVariant resultVar : resultList) {
|
||||||
|
QVariantMap resultMap = resultVar.toMap();
|
||||||
|
|
||||||
|
int athleteId = resultMap["athlete_id"].toInt();
|
||||||
|
if(!tmpAthletes.contains(athleteId))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
qDebug() << "Adding result: rank: " << resultMap["rank"];
|
||||||
|
BRResult::BRResultData resultData;
|
||||||
|
resultData.rank = resultMap["rank"].toInt();
|
||||||
|
resultData.athlete = tmpAthletes[athleteId];
|
||||||
|
BRResult* result = this->getResult(resultData);
|
||||||
|
roundData.results.append(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
BRRound* generalResultRound = this->getRound(BRWidget::IFSC, -1, roundData);
|
||||||
|
qDebug() << "General result round: " << generalResultRound;
|
||||||
|
categoryData->rounds.insert(0, generalResultRound);
|
||||||
|
categoryData->currentRound = generalResultRound;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
BRRound::BRRoundData BRProviderVl::parseRoundData(QVariantMap rawData) {
|
||||||
|
BRRound::BRRoundData data;
|
||||||
|
this->parseRoundData(&data, rawData);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BRProviderVl::parseRoundData(BRRound::BRRoundData* roundData, QVariantMap rawData) {
|
||||||
|
|
||||||
|
// TODO status
|
||||||
|
|
||||||
|
// clear up
|
||||||
|
qDebug() << "clearing";
|
||||||
|
QList<BRRound*> clearRounds;
|
||||||
|
clearRounds.append(roundData->round);
|
||||||
|
|
||||||
|
if(roundData->round->isGeneralResult()) {
|
||||||
|
// if we are parsing a general result -> clear all rounds
|
||||||
|
clearRounds.append(roundData->round->getCategory()->getRounds());
|
||||||
|
}
|
||||||
|
|
||||||
|
for(BRRound* round : clearRounds) {
|
||||||
|
for(BRResult* result : round->getResults())
|
||||||
|
result->deleteLater();
|
||||||
|
|
||||||
|
BRRound::BRRoundData roundData = round->getData();
|
||||||
|
roundData.results.clear();
|
||||||
|
this->setRoundData(round, roundData);
|
||||||
|
}
|
||||||
|
|
||||||
|
roundData->results.clear();
|
||||||
|
qDebug() << "finished clearing";
|
||||||
|
|
||||||
|
|
||||||
|
// parse Ranking
|
||||||
|
QVariantList resultList = rawData["ranking"].toList();
|
||||||
|
for(QVariant resultVar : resultList) {
|
||||||
|
QVariantMap resultMap = resultVar.toMap();
|
||||||
|
|
||||||
|
// load athlete
|
||||||
|
BRAthlete::BRAthleteData athleteData;
|
||||||
|
// TODO: start number
|
||||||
|
athleteData.firstName = resultMap["firstname"].toString();
|
||||||
|
athleteData.lastName = resultMap["lastname"].toString();
|
||||||
|
athleteData.federation = resultMap["country"].toString();
|
||||||
|
athleteData.nation = resultMap["country"].toString();
|
||||||
|
qDebug() << "--- Adding athlete: " << athleteData.firstName << " " << athleteData.lastName;
|
||||||
|
|
||||||
|
BRAthlete* athlete = this->getAthlete(BRWidget::IFSC, resultMap["athlete_id"].toInt(), athleteData);
|
||||||
|
|
||||||
|
// load result
|
||||||
|
qDebug() << "Adding result: rank: " << resultMap["rank"];
|
||||||
|
BRResult::BRResultData resultData;
|
||||||
|
resultData.rank = resultMap["rank"].toInt();
|
||||||
|
resultData.athlete = athlete;
|
||||||
|
|
||||||
|
// if this is the general result -> parse all other rounds as well
|
||||||
|
if(roundData->round->isGeneralResult()) {
|
||||||
|
qDebug() << "THIS is general result!!";
|
||||||
|
resultData.details = new BRResultDetailsGeneralResult();
|
||||||
|
|
||||||
|
// add results of other rounds
|
||||||
|
for(QVariant subRoundVar : resultMap["rounds"].toList()) {
|
||||||
|
QVariantMap subRoundMap = subRoundVar.toMap();
|
||||||
|
for(BRRound* subRound : roundData->round->getCategory()->getRounds(false)) {
|
||||||
|
if(subRound->getId() == subRoundMap["category_round_id"].toInt()) {
|
||||||
|
BRResult::BRResultData subResultData;
|
||||||
|
subResultData.rank = subRoundMap["rank"].toInt();
|
||||||
|
subResultData.athlete = athlete;
|
||||||
|
subResultData.details = new BRResultDetailsUnknown(subRoundMap["score"].toString());
|
||||||
|
|
||||||
|
|
||||||
|
qDebug() << "Adding subResult: rank: " << resultMap["rank"];
|
||||||
|
|
||||||
|
BRRound::BRRoundData subRoundData = subRound->getData();
|
||||||
|
subRoundData.results.append(this->getResult(subResultData));
|
||||||
|
this->setRoundData(subRound, subRoundData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
resultData.details = new BRResultDetailsUnknown(resultMap["score"].toString());
|
||||||
|
|
||||||
|
BRResult* result = this->getResult(resultData);
|
||||||
|
roundData->results.append(result);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue