Advertisement
Guest User

problem

a guest
Mar 26th, 2017
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import QtQuick 2.0
  2. import Sailfish.Silica 1.0
  3.  
  4.  
  5. Page {
  6.     id: page
  7.  
  8.     property var activeId: 0
  9.     function addZero(i) {
  10.         if (i < 10) {
  11.             i = "0" + i;
  12.         }
  13.         return i;
  14.     }
  15.  
  16.     Connections {
  17.         target: Messenger
  18.         onBuddyAdded: {
  19.             listView.model.append({"name": name, "fbid": fbid})
  20.             listView.positionViewAtEnd()
  21.         }
  22.         onMessageRecived: {
  23.             var d = new Date()
  24.             chatModel.append({"name": name, "message": message, "time": addZero(d.getHours()) + ":" + addZero(d.getMinutes()), "align": "left"})
  25.             chat.positionViewAtEnd()
  26.         }
  27.         onMessageSend: {
  28.             var d = new Date()
  29.             chatModel.append({"name": name, "message": message, "time": addZero(d.getHours()) + ":" + addZero(d.getMinutes()), "align": "right"})
  30.             chat.positionViewAtEnd()
  31.         }
  32.     }
  33.  
  34.     SilicaListView {
  35.         id: listView
  36.         anchors.fill: parent
  37.         clip: true
  38.         model: 20
  39.         highlightFollowsCurrentItem: false
  40.         currentIndex: count -1
  41.         PageHeader {
  42.             title: qsTr("Contacts")
  43.         }
  44.         PullDownMenu {
  45.             MenuItem {
  46.                 text: qsTr("Settings")
  47.                 onClicked: pageStack.push(Qt.resolvedUrl("SecondPage.qml"))
  48.             }
  49.         }
  50.         delegate: BackgroundItem {
  51.             x: 5
  52.             height: 24
  53.             width: listView.width
  54.             Row {
  55.                 id: row1
  56.                 anchors.verticalCenter: parent.verticalCenter
  57.                 Text {
  58.                     id: text1
  59.                     text: name
  60.                     color: '#eff0f1'
  61.                     x: Theme.paddingLarge
  62.                 }
  63.                 Text {
  64.                     id: text2
  65.                     text: fbid
  66.                     visible: false
  67.                 }
  68.             }
  69.             onClicked: console.log("Clicked " + index)
  70. //            MouseArea {
  71. //                anchors.fill: parent
  72. //                onClicked: {
  73. //                    listView.currentIndex = index
  74. //                    window.activeId = text2.text
  75. //                }
  76. //            }
  77.         }
  78.         VerticalScrollDecorator {}
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement