From 7729ecd99407040e63f55260a884ad60450e5c7b Mon Sep 17 00:00:00 2001 From: dorian Date: Tue, 9 Jul 2019 09:11:27 +0200 Subject: [PATCH] favorites are working now --- android-sources/AndroidManifest.xml | 2 +- resources/qml/Widgets/CalendarWidget.qml | 75 ++++++++++++++---- resources/qml/main.qml | 27 +++---- .../shared/icons/bluerock/20x20/bookmark.png | Bin 0 -> 487 bytes .../icons/bluerock/20x20/bookmarkFilled.png | Bin 0 -> 308 bytes .../icons/bluerock/20x20@2/bookmark.png | Bin 0 -> 534 bytes .../icons/bluerock/20x20@2/bookmarkFilled.png | Bin 0 -> 347 bytes .../icons/bluerock/20x20@3/bookmark.png | Bin 0 -> 626 bytes .../icons/bluerock/20x20@3/bookmarkFilled.png | Bin 0 -> 393 bytes .../icons/bluerock/20x20@4/bookmark.png | Bin 0 -> 704 bytes .../icons/bluerock/20x20@4/bookmarkFilled.png | Bin 0 -> 439 bytes resources/shared/shared.qrc | 8 ++ 12 files changed, 83 insertions(+), 29 deletions(-) create mode 100644 resources/shared/icons/bluerock/20x20/bookmark.png create mode 100644 resources/shared/icons/bluerock/20x20/bookmarkFilled.png create mode 100644 resources/shared/icons/bluerock/20x20@2/bookmark.png create mode 100644 resources/shared/icons/bluerock/20x20@2/bookmarkFilled.png create mode 100644 resources/shared/icons/bluerock/20x20@3/bookmark.png create mode 100644 resources/shared/icons/bluerock/20x20@3/bookmarkFilled.png create mode 100644 resources/shared/icons/bluerock/20x20@4/bookmark.png create mode 100644 resources/shared/icons/bluerock/20x20@4/bookmarkFilled.png diff --git a/android-sources/AndroidManifest.xml b/android-sources/AndroidManifest.xml index 2ddab60..e838794 100644 --- a/android-sources/AndroidManifest.xml +++ b/android-sources/AndroidManifest.xml @@ -1,5 +1,5 @@ - + diff --git a/resources/qml/Widgets/CalendarWidget.qml b/resources/qml/Widgets/CalendarWidget.qml index a7b58bc..1811c7a 100644 --- a/resources/qml/Widgets/CalendarWidget.qml +++ b/resources/qml/Widgets/CalendarWidget.qml @@ -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,20 +480,30 @@ DataListView { spacing: 10 - Label { - id: nameLa - + RowLayout { width: parent.width + Label { + id: nameLa - font.bold: true + width: parent.width - wrapMode: Text.WordWrap + font.bold: true - text: name - } + wrapMode: Text.WordWrap - Label { - //text: model.month + text: name + + Layout.fillWidth: true + } + + ToolButton { + icon.name: competitionDel.includedByFavorites ? "bookmarkFilled":"bookmark" + onClicked: { + control.editFavorites(!competitionDel.includedByFavorites, parseInt(thisData['WetId'])) + } + + Layout.alignment: Layout.Right + } } Label { diff --git a/resources/qml/main.qml b/resources/qml/main.qml index cd03a5e..604968b 100644 --- a/resources/qml/main.qml +++ b/resources/qml/main.qml @@ -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(){ diff --git a/resources/shared/icons/bluerock/20x20/bookmark.png b/resources/shared/icons/bluerock/20x20/bookmark.png new file mode 100644 index 0000000000000000000000000000000000000000..c01e7bf24de77e63ffc7251d424f1852acdd62a9 GIT binary patch literal 487 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc3?z4jzqMyzU^EKw32_B-M*&G8u;>7$Z;5&wU(F{ea2OaaVC9(8sdA!2X4?)X ZS%$1snTOnk0iY;l@O1TaS?83{1OQbQEgb*= literal 0 HcmV?d00001 diff --git a/resources/shared/icons/bluerock/20x20/bookmarkFilled.png b/resources/shared/icons/bluerock/20x20/bookmarkFilled.png new file mode 100644 index 0000000000000000000000000000000000000000..db854f9b5e1e4db1fb0cf8b34128704b2d562de7 GIT binary patch literal 308 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc3?z4jzqJQaT>(BJu0VQ_0AVH$eV|hqOM?7@ z862M7NCR<_yxm;OkH}&M25w;xW@MN(M*=9wUgGKN%Kn(0lg)xF;dP}W zP)OO+#W6(Ua&m$K=L;pq(43}Si<<%*%h-4vdBm8li*7vPDq)z|q^!R$bPG^51B0il KpUXO@geCyy3?|S3 literal 0 HcmV?d00001 diff --git a/resources/shared/icons/bluerock/20x20@2/bookmark.png b/resources/shared/icons/bluerock/20x20@2/bookmark.png new file mode 100644 index 0000000000000000000000000000000000000000..47d18cb929260a4205024c10214a1c3158c4cbf9 GIT binary patch literal 534 zcmeAS@N?(olHy`uVBq!ia0vp^8X(NU3?z3ec*HX>Fd7B;gt!8^qkyCk*z@UI9Z&;f zNswPKgTu2MX&_FLx4R2N2dk_Hki%Kv5n0T@z%2~Ij105pNB{-dOFVsD*&nlWvYBzF zC$g3TgKF}$QB|(0{ z3=Yq3q=7g|-tI089jvk*Kn`btM`SSr1Gg{;GcwGYBLNg-FY)wsWq-`h$!2bLLPnAk zDCFho;uvCaIypgtr6E$BJK=c1v6bD-D;8;9Im+oK+NUKGYOzXSwo_%{BM~NUHMv7v yA3GH|g~gb;xRSI@SPeusCF{pkmay;ZU}yMqsW)tyYu-tqsSKX3elF{r5}E)TMKe|a literal 0 HcmV?d00001 diff --git a/resources/shared/icons/bluerock/20x20@3/bookmark.png b/resources/shared/icons/bluerock/20x20@3/bookmark.png new file mode 100644 index 0000000000000000000000000000000000000000..ca812b183a0ded7ce09dcdd72f5b31ba3501f60b GIT binary patch literal 626 zcmeAS@N?(olHy`uVBq!ia0vp^HXzKw3=&b&bYNg$Gz#zuaRqWm0ZAdS=hL@3pa#a0 zAirP+hi5m^K%69RcNc~ZR#^`qhqJ&VvY3H^TNs2H8D`Cq01C2~c>21sKW67-Gu5Bx zc-b2$wA0hYF~s9|a)Jcw6o$zmdm4_)F86yKqSTIt|ns!$2 zhLq5en`ioO@my4KHBQrR>y|is(sKpx{DPFc92vi}LNB%%er9%c?#%XDn90}B={{-I zOiBO80{hcs*IaU{Fzt4D^5f%jeVbXFTaRxo%uaiveq&a;dd@+O1Dp&erV8&CzMP~8 P^aO*atDnm{r-UW|C$?{i literal 0 HcmV?d00001 diff --git a/resources/shared/icons/bluerock/20x20@3/bookmarkFilled.png b/resources/shared/icons/bluerock/20x20@3/bookmarkFilled.png new file mode 100644 index 0000000000000000000000000000000000000000..0dfcd818ee48b01f96c7a6e9deafab69032f3be6 GIT binary patch literal 393 zcmeAS@N?(olHy`uVBq!ia0vp^HXzKw3=&b&bO2Ia0X`wFKzfh>VI~fJpi>x2g8YIR z9G=}s196hP-CYpzwK71xP{6V9%>V!M`1G7EFMF%9$69U9U&-buDGSN3 zi)11%swRY$y1iX>SmtOnw^{-OJUC?gnSGDGyRO>rm|EF)_kM?Tz5HENB{O%MW9wRz ruDRzQSlS*xtdYFwrs;du9+SI)2km^epL=*0=mrK)S3j3^P6uz#4@q;SiD>(jK03r|GLb#*9o?Q#)xDbZMT|uIt>`!8TH2M9%-FN_aa6A21WwZh4$l{Sv8o6N+2g2qjw?Tu z<%?(nkHr!HX}6y0@onKev)ng<*yybQZpuJM22$YFRP5MjT;6)54oO-Z8T z;U29G^Uda++wy0kc~_bAe&@WWw;z98W1*3~bFR~a?{ZH(^Ei0+#YZY6y?K?sukw4l z*qgui`)8i1*88#Xg#Cvte*f?Hd`c)Q+M>@oE9T#W3kgfAj=IaUEt{;xx0XlY0>8r6 uv?ojlCo~#YzH)3f_Q`Sixg;RvCqw(8U(dL;B`SfT#Ng@b=d#Wzp$P!89h@!z literal 0 HcmV?d00001 diff --git a/resources/shared/icons/bluerock/20x20@4/bookmarkFilled.png b/resources/shared/icons/bluerock/20x20@4/bookmarkFilled.png new file mode 100644 index 0000000000000000000000000000000000000000..a0214397588002da6d2c4db8a895f0c96a4ad635 GIT binary patch literal 439 zcmeAS@N?(olHy`uVBq!ia0vp^0U*r53?z4+XPOVBx&nMcT!Hi;0m4ii`aq{JmIV0) zGdMiEkp|)#QI+2w27iX7c+Re`njxgN@xNA8F6Sc literal 0 HcmV?d00001 diff --git a/resources/shared/shared.qrc b/resources/shared/shared.qrc index babeb75..c2756cd 100644 --- a/resources/shared/shared.qrc +++ b/resources/shared/shared.qrc @@ -46,5 +46,13 @@ icons/bluerock/20x20@2/flowchart.png icons/bluerock/20x20@3/flowchart.png icons/bluerock/20x20@4/flowchart.png + icons/bluerock/20x20/bookmark.png + icons/bluerock/20x20/bookmarkFilled.png + icons/bluerock/20x20@2/bookmark.png + icons/bluerock/20x20@2/bookmarkFilled.png + icons/bluerock/20x20@3/bookmark.png + icons/bluerock/20x20@3/bookmarkFilled.png + icons/bluerock/20x20@4/bookmark.png + icons/bluerock/20x20@4/bookmarkFilled.png