import QtQuick 2.0 import "../AppLink/Com" import "../windowsList.js" as WindowsList import "../layoutList.js" as Layout import "../AppLink/settingLib.js" as SettingsType HMIWindow { id: news_NewsClass property bool bConnected : false//true property bool bLoading : true //true,good false,bad property bool bNeedReflesh:false property int iShowTip: 0 title:qsTr("新闻") + applinkControl.qsEmptyString //windowImgSource:imagePath + "M8X_full-screen_bk.png" onVisibleChanged:{ if(news_NewsClass.visible == true) { applinkControl.QML_NotifyAppLinkDisplayOK() bNeedReflesh = false gridview.height = 800 applinkControl.QML_NIF_NET_DeleteImage() if(!applinkControl.QML_GetNewsChannelcount()||gridview.model == "") { bLoading = true bConnected = false } } //gridview.model = applinkControl.news_GetchannelListModel } onSignal_returnClick:{ //applinkControl.QML_RemoveNewsChannel() applinkControl.QML_NIF_NET_CancelRequest() gridview.model = "" ScreenManager.backward(Layout.APPLINK,WindowsList.APP_HOME) } Item { visible:!bConnected && !bLoading anchors.left: parent.left anchors.leftMargin: 65 anchors.top: parent.top anchors.topMargin: 81 width:830+10 height:1041-81//598+10+142+10 HMILabel{ id:lablereflesh anchors.top: parent.top anchors.topMargin: 0 anchors.left: parent.left anchors.leftMargin: 0 font.pixelSize: 26 text: qsTr("正在刷新,请稍候…") + applinkControl.qsEmptyString width:SettingsType.SETTING_CONTENT_W height:SettingsType.SETTING_CONTENT_Y color: "white" clip:true visible: bNeedReflesh } /*HMILabel{ id:lablereflesh1 anchors.top: parent.top anchors.topMargin: 0 anchors.left: parent.left anchors.leftMargin: 0 font.pixelSize: 26 text: "下拉可刷新" width:SettingsType.SETTING_CONTENT_W height:SettingsType.SETTING_CONTENT_Y color: "white" clip:true visible: iShowTip == 1 z:-1 } HMILabel{ id:lablereflesh2 anchors.top: parent.top anchors.topMargin: 0 anchors.left: parent.left anchors.leftMargin: 0 font.pixelSize: 26 text: "松开以刷新" width:SettingsType.SETTING_CONTENT_W height:SettingsType.SETTING_CONTENT_Y color: "white" clip:true visible: iShowTip == 2 z: -1 }*/ GridView{ id: gridview clip: true //anchors.fill: parent anchors.top: parent.top anchors.topMargin: bNeedReflesh ? SettingsType.SETTING_CONTENT_Y : 0 anchors.left: parent.left anchors.leftMargin: 0//SettingsType.SETTING_CONTENT_X cellWidth: 270+10 cellHeight: 142+10 width: 840 height: bNeedReflesh ? 1041-81-80:1041-81//720 : 800 snapMode:GridView.SnapOneRow delegate:settinglistdelegate boundsBehavior: Flickable.DragAndOvershootBounds //model:channelslistmodel onDragEnded: { // 下拉刷新判断逻辑:已经到头了,还下拉一定距离 if (contentY < originY){ var dy = contentY - originY if (dy < -80){ if(false == bNeedReflesh){ iShowTip = 0 bNeedReflesh = true applinkControl.QML_NIF_NEWS_RequestNewsChannels() } } } } onContentYChanged: { if (contentY < originY){ var dy = contentY - originY if (dy < -80){ iShowTip = 2 } } } } Component{ id:settinglistdelegate Item{ width:gridview.cellWidth-10//270 height:gridview.cellHeight-10//142 HMIButton{ id:cell_id btnImg: imagePath + "Common/M8X_Button_h142_w270.png" btnImgOnPressed: imagePath + "Common/M8X_Button_h142_w270_p.png" HMILabel{ id:cell_name x: 5 y: 58 height: 26 width: 260 font.pixelSize: 26 text: col0 clip:true } onClicked: { //console.log("---------lvchangxin------------------------------",index); applinkControl.QML_NIF_NEWS_RequestNewsDetail(index,1) ScreenManager.forward(Layout.APPLINK,WindowsList.APP_NEWSLIST) } } } } HMIListViewBar{ id: listViewBar anchors.left: gridview.right anchors.leftMargin: 16 anchors.top: gridview.top height: gridview.height listView:gridview scrollBarX:x scrollBarY:y visible: gridview.count<=15?false:true clip:true } } //底部动能栏 Row{ id: functionArea y:1041-160 HMIButton{ id: quitBtn btnImgOnPressed: imagePath +"Common/M8X_Function_close_Button_p.png" btnImg: imagePath+"Common/M8X_Function_close_Button.png" btnIcon: imagePath+"Common/M8X_icon_close.png" onClicked:{ applinkControl.QML_CloseAppLink() //ScreenManager.changeForm(Layout.FM_CLOSE,WindowsList.APP_NEWSCLASS) } } HMIButton{ id: nosw enabled: false btnImgOnPressed: imagePath +"M8X_Function_1_Button_NoSwitch_p.png" btnImg: imagePath+"M8X_Function_1_Button_NoSwitch.png" } } App_HMILoadFailed{ visible:bConnected imagePath: news_NewsClass.imagePath onSignal_refreshClick:{ //bConnected = !bConnected //just a test bLoading = true bConnected = false applinkControl.QML_NIF_NEWS_RequestNewsChannels() } } App_Loading{ id:loadingIcon loadingPath: imagePath+"Common/Loading_60/" surname: "M8X_Loading_60_" anchors.horizontalCenter:parent.horizontalCenter anchors.top: parent.top anchors.topMargin: 450 visible:bLoading } Connections{ target:applinkControl onSignal_GetChannelsDataEnd:{ if(news_NewsClass.visible == true) { //console.log("-----qml--------lvchangxin----------------onSignal_GetChannelsDataEnd----------------") bNeedReflesh = false gridview.model = applinkControl.news_GetchannelListModel bLoading = false bConnected = false //applinkControl.QML_NIF_NET_GetImage("http://n.sinaimg.cn/news/transform/20161026/ojfu-fxwztru7195793.jpg", 67) //applinkControl.QML_NIF_NET_GetImage("http://fdfs.xmcdn.com/group12/M0A/23/9B/wKgDW1bqDkaxrMLjAASp9W8aGkc534_web_meduim.jpg", 85) } } onSignal_GetChannelsDataNoRes:{ if(news_NewsClass.visible == true) { //console.log("-----qml--------lvchangxin----------------onSignal_GetChannelsDataNoRes----------------") bNeedReflesh = false bLoading = false bConnected = true } } } }