favorites are working now

This commit is contained in:
Dorian Zedler 2019-07-09 09:11:27 +02:00
parent 323c47f74f
commit 7729ecd994
12 changed files with 83 additions and 29 deletions

View file

@ -1,5 +1,5 @@
<?xml version="1.0"?>
<manifest package="com.itsblue.blueROCK" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.02.1" android:versionCode="9" android:installLocation="auto">
<manifest package="com.itsblue.blueROCKtest" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.02.1" android:versionCode="9" 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>

View file

@ -61,6 +61,8 @@ DataListView {
}
}
compCats.push( {"text": qsTr("Favorites"), "data": {"sort_rank":0, "cat_id":[-1]}} )
compCats.sort(function(a, b) {
return a['data']['sort_rank'] - b['data']['sort_rank'];
});
@ -87,6 +89,7 @@ DataListView {
property int year: new Date().getFullYear()
property var displayedCompCats: []
property var compFavorites: []
anchors.fill: parent
@ -101,6 +104,7 @@ DataListView {
Component.onCompleted: {
initFilters()
initFavorites()
if(model){
control.status = 200
@ -304,7 +308,6 @@ DataListView {
}
function initFilters() {
if(appSettings.read("displayedCompCats"+params.nation) !== "false"){
//console.log(appSettings.read("displayedCompCats"+params.nation))
control.displayedCompCats = JSON.parse(appSettings.read("displayedCompCats"+params.nation))
@ -326,6 +329,34 @@ DataListView {
//console.log(control.displayedCompCats)
}
function editFavorites(favorite, compId) {
if(control.compFavorites.indexOf(compId) >= 0 && !favorite) {
control.compFavorites.splice( control.compFavorites.indexOf(compId), 1)
}
else if(!control.compFavorites.indexOf(compId) >= 0 && favorite) {
control.compFavorites.push(compId)
}
appSettings.write("compFavorites", JSON.stringify(control.compFavorites))
// trigger 'changed' signal
control.compFavorites = control.compFavorites
}
function initFavorites() {
if(appSettings.read("compFavorites") !== "false"){
//console.log(appSettings.read("displayedCompCats"+params.nation))
control.compFavorites = JSON.parse(appSettings.read("compFavorites"))
}
else {
control.compFavorites = []
appSettings.write("compFavorites", JSON.stringify(control.compFavorites))
}
// trigger 'changed' signal
control.compFavorites = control.compFavorites
console.log(control.compFavorites)
}
Connections {
target: parent.selector
onSelectionFinished: {
@ -369,10 +400,12 @@ DataListView {
property var cats: thisData["cats"]
property int catId: thisData["cat_id"] === undefined ? 0:thisData["cat_id"]
property bool includedByFavorites: control.displayedCompCats.indexOf(-1) >= 0 && control.compFavorites.indexOf(parseInt(thisData['WetId'])) >= 0
property bool includedByFilter: control.displayedCompCats.indexOf(parseInt(thisData['cat_id'])) >= 0
property bool thisIsVisible: includedByFavorites || includedByFilter
width: parent.width
height: includedByFilter ? compDelCol.height + 10 : 0
height: thisIsVisible ? compDelCol.height + 10 : 0
enabled: (thisData["cats"] !== undefined && thisData["cats"].length > 0) || competitionDel.thisData["homepage"] !== undefined || getCompInfoUrl(index) !== undefined
//visible: includedByFilter
@ -385,16 +418,20 @@ DataListView {
onDisplayedCompCatsChanged: {
competitionDel.includedByFilter = control.displayedCompCats.indexOf(parseInt(competitionDel.thisData['cat_id'])) >= 0
}
onCompFavoritesChanged: {
competitionDel.includedByFavorites = control.displayedCompCats.indexOf(-1) >= 0 && control.compFavorites.indexOf(parseInt(thisData['WetId'])) >= 0
}
}
onThisDataChanged: {
if(includedByFilter){
if(thisIsVisible){
fadeInPa.start()
}
}
onIncludedByFilterChanged: {
if(includedByFilter){
onThisIsVisibleChanged: {
if(thisIsVisible){
fadeInPa.start()
}
else {
@ -443,6 +480,8 @@ DataListView {
spacing: 10
RowLayout {
width: parent.width
Label {
id: nameLa
@ -453,10 +492,18 @@ DataListView {
wrapMode: Text.WordWrap
text: name
Layout.fillWidth: true
}
Label {
//text: model.month
ToolButton {
icon.name: competitionDel.includedByFavorites ? "bookmarkFilled":"bookmark"
onClicked: {
control.editFavorites(!competitionDel.includedByFavorites, parseInt(thisData['WetId']))
}
Layout.alignment: Layout.Right
}
}
Label {

View file

@ -61,7 +61,7 @@ Window {
'label' : 'World Cups',
'nation' : 'ICC',
'bgcolor' : '#B8C8FF',
'sort_rank': 0,
'sort_rank': 1,
'cat_id' : [69]
},
'youth' : {
@ -71,14 +71,14 @@ Window {
'serie_reg' : '^[0-9]{2,2}_EYC',
'rang_title': '',
'bgcolor' : '#D8E8FF',
'sort_rank': 1,
'sort_rank': 2,
'cat_id' : [71,258]
},
'cont': {
'label' : 'Continental Events',
'nation' : 'ICC',
'bgcolor' : '#B8C8FF',
'sort_rank': 2,
'sort_rank': 3,
'cat_id' : [262]
},
'masters' : {
@ -88,7 +88,7 @@ Window {
// 'serie_reg' : '^[0-9]{2,2}_(WC|TR){1,1}.*',
// 'rang_title': 'CUWR continuously updated WORLDRANKING',
'bgcolor' : '#F0F0F0',
'sort_rank': 3,
'sort_rank': 4,
'cat_id' : [70]
},
'para' : {
@ -96,14 +96,14 @@ Window {
'nation' : 'ICC',
'wettk_reg' : '^[0-9]{2,2}_PE.*',
'bgcolor' : '#F0F0F0',
'sort_rank': 4,
'sort_rank': 5,
'cat_id' : [256,259]
},
'games': {
'label': 'Games',
'nation': 'ICC',
'bgcolor' : '#B8C8FF',
'sort_rank': 5,
'sort_rank': 6,
'cat_id': [68,86]
},
@ -139,7 +139,7 @@ Window {
'label' : 'Deutsche Meisterschaft',
'nation' : 'GER',
'bgcolor' : '#A8F0A8',
'sort_rank': 0,
'sort_rank': 1,
'cat_id' : [57, 59, 60]
},
@ -150,7 +150,7 @@ Window {
'serie_reg' : '^[0-9]{2,2}_JC',
// 'rang_title': 'Deutsche Jugend RANGLISTE',
'bgcolor' : '#D8FFD8',
'sort_rank': 1,
'sort_rank': 2,
'cat_id' : [58]
},
'ger_state' : {
@ -160,7 +160,7 @@ Window {
'serie_reg' : '^[0-9]{2,2}[_J]{1,1}LM.*',
'rang_title': '',
'bgcolor' : '#F0F0F0',
'sort_rank': 2,
'sort_rank': 3,
'cat_id' : [61,56]
},
@ -173,7 +173,7 @@ Window {
'serie_reg' : '.*',
'rang_title': 'SWISS RANKING',
'bgcolor' : '#A8F0A8',
'sort_rank': 0,
'sort_rank': 1,
'cat_id' : [62,63]
},
'sui_jugend' : {
@ -183,7 +183,7 @@ Window {
'serie_reg' : '.*',
'rang_title': 'SWISS RANKING',
'bgcolor' : '#D8FFD8',
'sort_rank': 1,
'sort_rank': 2,
'cat_id' : [65]
},
'sui_local' : {
@ -192,7 +192,7 @@ Window {
'wettk_reg' : '^[0-9]{2,2}_RG_.*',
'rang_title': '',
'bgcolor' : '#F0F0F0',
'sort_rank': 2,
'sort_rank': 3,
'cat_id' : [64]
},
'sui_ice' : {
@ -201,7 +201,7 @@ Window {
'wettk_reg' : '^[0-9]{2,2}_RC_.*',
'rang_title': '',
'bgcolor' : '#F0F0F0',
'sort_rank': 3,
'sort_rank': 4,
'cat_id' : [84]
}
}
@ -566,7 +566,6 @@ Window {
text: "loading..."
}
}
}
function landscape(){

Binary file not shown.

After

Width:  |  Height:  |  Size: 487 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 308 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 534 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 347 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 393 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 704 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 B

View file

@ -46,5 +46,13 @@
<file>icons/bluerock/20x20@2/flowchart.png</file>
<file>icons/bluerock/20x20@3/flowchart.png</file>
<file>icons/bluerock/20x20@4/flowchart.png</file>
<file>icons/bluerock/20x20/bookmark.png</file>
<file>icons/bluerock/20x20/bookmarkFilled.png</file>
<file>icons/bluerock/20x20@2/bookmark.png</file>
<file>icons/bluerock/20x20@2/bookmarkFilled.png</file>
<file>icons/bluerock/20x20@3/bookmark.png</file>
<file>icons/bluerock/20x20@3/bookmarkFilled.png</file>
<file>icons/bluerock/20x20@4/bookmark.png</file>
<file>icons/bluerock/20x20@4/bookmarkFilled.png</file>
</qresource>
</RCC>