import QtQuick 2.0 import Sailfish.Silica 1.0 import "../JSONListModel" import Nemo.Notifications 1.0 Page { id: page //property int ny: 0 SilicaListView { id: listView anchors.fill: parent clip: true model: favorites header: PageHeader { id: pHeader title: "Favorites" } delegate: ListItem { id: showDelegate width: ListView.view.width property string f_name: name ? name : "" property string f_summary: summary ? summary : "" property string f_stat: status ? status : "" property string f_premiered: premiered ? premiered : "" property string f_rating: rating ? rating : "" property int f_updated: updated ? updated : "" property string f_imdb: imdb ? imdb : "" property string f_official: official ? official : "" property string f_network: network ? network : "" property string f_image: image ? image : "../No-Image-.png" property string f_next: next ? next : "" property string f_nextse: nextse ? nextse : "" property string f_prev: prev ? prev : "" property bool f_upd: false property bool running: false property bool ended: false property bool max: false contentHeight: showImg.height + showName.height + (Theme.paddingLarge * 4) Notification { id: notification category: "Update" //summary: "Updated tv show" //itemCount: favorites.count //itemCount: favorites.count //expireTimeout: 0 //itemCount: favorites.count } JSONSimple { id: updateFavorite source: "http://api.tvmaze.com/shows/"+showid onReadyChanged: { if (ready) { if (updated !== simple.updated ) { var ne var nese var pr f_upd = true f_name = simple.name f_summary = simple.summary f_stat = simple.status simple.premiered ? f_premiered = simple.premiered : f_premiered = "" f_rating = simple.rating.average f_updated = simple.updated //officialSite ? sofficial = officialSite : "" simple.externals.imdb ? f_imdb = simple.externals.imdb : f_imdb = "" simple.officialSite ? f_official = simple.officialSite : f_official = "" simple.webChannel ? f_network = simple.webChannel.name : f_network = simple.network.name f_image = simple.image.medium simple._links.previousepisode ? pr = simple._links.previousepisode.href : pr = "" simple._links.nextepisode ? ne = simple._links.nextepisode.href : ne = "" // console.log(simple.officialSite) if (pr !== "") { prevshow.showNlink = ne prevshow.showPlink = pr prevshow.source = pr } else { if (next !== ""){ nextshow.source = ne } else { doneUdating = true } } updateFav(showid, f_name, f_image, f_summary, f_stat, f_premiered, f_rating, f_network, f_updated, f_imdb, f_official) } //console.log("IMDB: "+f_imdb) } } } JSONSimple { id: nextshow //property string showid: "" property string showNlink: "" property string ne: "" property string nese: "" onReadyChanged: { if (ready) { console.log(" ---- UPDATING NEXTSHOW") simple.airdate ? ne = simple.airdate : ne = "?" ne !== "?" ? nese = "S"+simple.season+"E"+simple.number : nese = "" f_next = ne f_nextse = nese console.log(f_name+" has been updated. ") updateNext(showid, ne, nese) notification.summary = f_name notification.subText = "Labyrinth" notification.body = "Next episode: "+f_next //notification.text = "Next episode: "+f_next notification.publish() //doneUdating = true } } } JSONSimple { id: prevshow //property string showid: "" property string showPlink: "" property string showNlink: "" property string pr: "" onReadyChanged: { if (ready) { console.log(" ---- UPDATING PREVSHOW") simple.airdate ? pr = simple.airdate : pr = "?" f_prev = pr updatePrev(showid, pr) if (showNlink !== "") { //nextshow.showid = showid //nextShow.showNlink = showNlink nextshow.source = showNlink } else { f_next = "?" f_nextse = "" updateNext(showid, "?", "") //doneUdating = true } } } } function showRemorseItem() { var idx = index remorseAction("Removing "+name+" from favorites!", function() {delFav(showid);listView.model.remove(idx)}) } OpacityRampEffect { sourceItem: showRect direction: OpacityRamp.TopToBottom offset: 0.0 slope: 1.0 } Rectangle { id: showRect anchors.left: parent.left anchors.right: parent.right width: parent.width height: showName.height + Theme.paddingLarge color: Theme.rgba(Theme.highlightBackgroundColor, Theme.highlightBackgroundOpacity) } Image { id: nextIcon anchors.verticalCenter: showRect.verticalCenter anchors.right: showRect.right anchors.rightMargin: Theme.paddingMedium source: "image://theme/icon-m-right" } Image { id: seenIcon visible: false anchors.right: parent.right anchors.bottom: showImg.bottom anchors.rightMargin: Theme.paddingMedium source: "image://theme/icon-m-acknowledge" } Text { id: showName //text: "" text: f_name color: highlighted ? Theme.highlightColor : Theme.primaryColor anchors.leftMargin: Theme.paddingMedium anchors.rightMargin: Theme.paddingMedium anchors.left: parent.left anchors.right: nextIcon.left anchors.verticalCenter: showRect.verticalCenter wrapMode: Text.ElideRight font.pixelSize: Theme.fontSizeLarge maximumLineCount: 1 } Image { id: showImg fillMode: Image.PreserveAspectFit source: f_image anchors.top: showRect.bottom anchors.margins: Theme.paddingLarge anchors.left: parent.left width: height * 0.8 height: (showName.height + showS.height + showP.height + showR.height + showN.height + showPr.height + Theme.paddingLarge) * showImg.scale scale: 1.1 BusyIndicator { id: imgBysy running: showImg.progress !== 1.0 size: BusyIndicatorSize.Large anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter } } Image { id: favIcon anchors.right: parent.right anchors.top: showImg.top anchors.topMargin: Theme.paddingSmall height: showStatus.height + (showStatus.height/2) width: height //anchors.top: showImg.top anchors.rightMargin: Theme.paddingMedium source: getFav(showid) ? "image://theme/icon-m-favorite-selected" : "image://theme/icon-m-favorite" MouseArea { anchors.fill: favIcon onClicked: showRemorseItem()//remorse.executeqsTr("Removing "+name+" from favorites!"), function() {delFav(model.showid)}, 5000) } } //icon-m-refresh Image { id: updIcon anchors.right: favIcon.left anchors.top: showImg.top anchors.topMargin: Theme.paddingSmall height: showStatus.height + (showStatus.height/2) width: height //anchors.top: showImg.top anchors.rightMargin: Theme.paddingMedium mirror: true source: f_upd ? "image://theme/icon-m-notifications" : "" } Text { id: showS text: "Status:" color: highlighted ? Theme.highlightColor : Theme.primaryColor wrapMode: Text.WordWrap anchors.topMargin: Theme.paddingMedium anchors.bottom: showP.top anchors.left: showImg.right anchors.leftMargin: Theme.paddingMedium font.pixelSize: Theme.fontSizeSmall } Text { id: showStatus text: f_stat color: {//highlighted ? Theme.highlightColor : running && f_next !== "?" ? Theme.primaryColor : ended ? Theme.errorColor : Theme.secondaryColor if (highlighted) Theme.highlightColor; else if (f_stat === "Ended") Theme.errorColor; else if (f_stat === "Running" && f_next !== "?") Theme.highlightColor else if (f_stat === "Running" && f_next === "?") Theme.primaryColor else Theme.secondaryColor } wrapMode: Text.WordWrap anchors.topMargin: Theme.paddingMedium anchors.bottom: showP.top anchors.left: showS.right anchors.right: parent.right anchors.leftMargin: Theme.paddingMedium font.pixelSize: Theme.fontSizeSmall font.bold: true } Text { id: showP text: "Premiered:" color: highlighted ? Theme.highlightColor : Theme.primaryColor wrapMode: Text.WordWrap anchors.bottom: showR.top anchors.left: showImg.right anchors.leftMargin: Theme.paddingMedium font.pixelSize: Theme.fontSizeSmall } Text { id: showPrem text: f_premiered color: highlighted ? Theme.highlightColor : Theme.primaryColor wrapMode: Text.WordWrap anchors.bottom: showR.top anchors.left: showP.right anchors.right: parent.right anchors.leftMargin: Theme.paddingMedium font.pixelSize: Theme.fontSizeSmall font.bold: true } Text { id: showR text: "Average rating:" color: highlighted ? Theme.highlightColor : Theme.primaryColor wrapMode: Text.WordWrap anchors.bottom: showN.top anchors.left: showImg.right anchors.leftMargin: Theme.paddingMedium font.pixelSize: Theme.fontSizeSmall } Text { id: showRating text: f_rating color: highlighted ? Theme.highlightColor : Theme.primaryColor wrapMode: Text.WordWrap anchors.bottom: showN.top anchors.left: showR.right anchors.right: parent.right anchors.leftMargin: Theme.paddingMedium font.pixelSize: Theme.fontSizeSmall font.bold: true } Text { id: showN text: "Network:" color: highlighted ? Theme.highlightColor : Theme.primaryColor wrapMode: Text.ElideRight maximumLineCount: 1 anchors.bottom: showPr.top anchors.left: showImg.right anchors.leftMargin: Theme.paddingMedium font.pixelSize: Theme.fontSizeSmall } Text { id: showNetwork text: f_network color: highlighted ? Theme.highlightColor : Theme.primaryColor wrapMode: Text.ElideRight maximumLineCount: 1 anchors.bottom: showPr.top anchors.left: showN.right anchors.right: parent.right anchors.leftMargin: Theme.paddingMedium font.pixelSize: Theme.fontSizeSmall font.bold: true } Text { id: showPr text: "Previous:" color: highlighted ? Theme.highlightColor : Theme.primaryColor wrapMode: Text.ElideRight maximumLineCount: 1 anchors.bottom: showNe.top anchors.left: showImg.right anchors.leftMargin: Theme.paddingMedium font.pixelSize: Theme.fontSizeSmall } Text { id: showPrev text: f_prev color: highlighted ? Theme.highlightColor : Theme.primaryColor wrapMode: Text.ElideRight maximumLineCount: 1 anchors.bottom: showNe.top anchors.left: showPr.right anchors.right: parent.right anchors.leftMargin: Theme.paddingMedium font.pixelSize: Theme.fontSizeSmall font.bold: f_prev !== "Unknown" ? true : false } Text { id: showNe text: f_nextse ? "Next: ("+f_nextse+")" : "Next: " color: highlighted ? Theme.highlightColor : Theme.primaryColor wrapMode: Text.ElideRight maximumLineCount: 1 anchors.bottom: showImg.bottom anchors.bottomMargin: Theme.paddingSmall anchors.left: showImg.right anchors.leftMargin: Theme.paddingMedium font.pixelSize: Theme.fontSizeSmall } Text { id: showNext text: f_next color: highlighted ? Theme.highlightColor : f_stat === "Running" && f_next !== "?" ? Theme.highlightColor : Theme.primaryColor wrapMode: Text.ElideRight maximumLineCount: 1 anchors.bottom: showImg.bottom anchors.bottomMargin: Theme.paddingSmall anchors.left: showNe.right anchors.right: parent.right anchors.leftMargin: Theme.paddingSmall font.pixelSize: Theme.fontSizeSmall font.bold: text !== "Unknown" ? true : false } onPressAndHold: pageStack.push(Qt.resolvedUrl("ShowImg.qml"),{"img": f_image}) onClicked: { //frompage === undefined ? if (f_upd) f_upd = false pageStack.push(Qt.resolvedUrl("../pages/InfoPage.qml"), {"showid": showid,"showname": name, "showimage": showImg.source, "summary": summary, "showstatus": status, "showprem": showPrem.text, "showrating": showRating.text, "shownetwork": showNetwork.text, "showupdated": model.updated, "showprev": showPrev.text, "shownext": showNext.text, "shownextse": nextse, "simdb": f_imdb, "sofficial": f_official}) } } PullDownMenu { MenuItem { text: qsTr("About Labyrinth") onClicked: pageStack.push(Qt.resolvedUrl("About.qml")) } MenuItem { text: qsTr("Popular shows by rating") onClicked: pageStack.replace(Qt.resolvedUrl("PopularPage.qml"),{"showweight": false},PageStackAction.Immediate) } MenuItem { text: qsTr("Popular shows by clicks") onClicked: pageStack.replace(Qt.resolvedUrl("PopularPage.qml"),{"showweight": true},PageStackAction.Immediate) } /* MenuItem { text: qsTr("Refresh Favorites") onClicked: {//pageStack.replace(Qt.resolvedUrl("SearchPage.qml"),{},PageStackAction.Immediate) favorites.clear() pageStack.replace(Qt.resolvedUrl("Favorites.qml"),{},PageStackAction.Immediate) } } */ MenuItem { text: qsTr("Search TV show") onClicked: pageStack.replace(Qt.resolvedUrl("SearchPage.qml"),{},PageStackAction.Immediate) } MenuItem { text: qsTr("Notify") onClicked: notification.publish() } } } Notification { id: notifi category: "x-nemo.example" appName: "Example App" appIcon: "/usr/share/example-app/icon-l-application" summary: "Notification summary" body: "Notification body" previewSummary: "Notification preview summary" previewBody: "Notification preview body" itemCount: 5 timestamp: "2013-02-20 18:21:00" remoteActions: [ { "name": "default", "displayName": "Do something", "icon": "icon-s-do-it", "service": "org.nemomobile.example", "path": "/example", "iface": "org.nemomobile.example", "method": "doSomething", "arguments": [ "argument", 1 ] },{ "name": "ignore", "displayName": "Ignore the problem", "icon": "icon-s-ignore", "input" : { "label": "Please select", "editable": true, "choices": [ "Yes", "No", "Maybe" ] }, "service": "org.nemomobile.example", "path": "/example", "iface": "org.nemomobile.example", "method": "ignore", "arguments": [ "argument", 1 ] } ] onClicked: console.log("Clicked") onClosed: console.log("Closed, reason: " + reason) } /* ViewPlaceholder { enabled: !updateModel.ready || favorites.count === 0//listView.count === 0 //|| jsonModel1.jsonready text: dbcount > 0 ? "Checking TVMAZE for updated TV-shows" : listView.count === 0 ? "Favorites empty" : "" hintText: updateModel.ready === 0 ? "add shows from TVMAZE" : "" Image { id: logo anchors.horizontalCenter: parent.horizontalCenter //anchors.verticalCenter: parent.verticalCenter width: parent.width * 0.4 height: width anchors.bottom: parent.top anchors.bottomMargin: Theme.paddingLarge opacity: 0.2 source: "../harbour-labyrinth.png" } BusyIndicator { id: checking running: !updateModel.ready size: BusyIndicatorSize.Large anchors.horizontalCenter: parent.horizontalCenter anchors.top: parent.bottom anchors.topMargin: Theme.paddingLarge //anchors.centerIn: logo //anchors.horizontalCenter: parent.horizontalCenter //anchors.top: logo.bottom //anchors.topMargin: Theme.paddingLarge //anchors.verticalCenter: parent.verticalCenter } */ /* Button { text: "Search TVMaze" anchors.horizontalCenter: parent.horizontalCenter anchors.bottom: parent.bottom anchors.bottomMargin: Theme.paddingLarge onClicked: pageStack.replace(Qt.resolvedUrl("SearchPage.qml"),{},PageStackAction.Immediate) } */ // } //} }