Advertisement
Guest User

sada

a guest
Mar 26th, 2017
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.   Copyright (C) 2013 Jolla Ltd.
  3.   Contact: Thomas Perl <thomas.perl@jollamobile.com>
  4.   All rights reserved.
  5.  
  6.   You may use this file under the terms of BSD license as follows:
  7.  
  8.   Redistribution and use in source and binary forms, with or without
  9.   modification, are permitted provided that the following conditions are met:
  10.     * Redistributions of source code must retain the above copyright
  11.       notice, this list of conditions and the following disclaimer.
  12.     * Redistributions in binary form must reproduce the above copyright
  13.       notice, this list of conditions and the following disclaimer in the
  14.       documentation and/or other materials provided with the distribution.
  15.     * Neither the name of the Jolla Ltd nor the
  16.       names of its contributors may be used to endorse or promote products
  17.       derived from this software without specific prior written permission.
  18.  
  19.   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  20.   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21.   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  22.   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR
  23.   ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24.   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25.   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  26.   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27.   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28.   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30.  
  31. import QtQuick 2.0
  32. import Sailfish.Silica 1.0
  33.  
  34.  
  35. Page {
  36.     id: page
  37.  
  38.     property var activeId: 0
  39.     function addZero(i) {
  40.         if (i < 10) {
  41.             i = "0" + i;
  42.         }
  43.         return i;
  44.     }
  45.  
  46.     Connections {
  47.         target: Messenger
  48.         onBuddyAdded: {
  49.             listModel.append({"name": name, "fbid": fbid})
  50.             listView.positionViewAtEnd()
  51.         }
  52.         onMessageRecived: {
  53.             var d = new Date()
  54.             chatModel.append({"name": name, "message": message, "time": addZero(d.getHours()) + ":" + addZero(d.getMinutes()), "align": "left"})
  55.             chat.positionViewAtEnd()
  56.         }
  57.         onMessageSend: {
  58.             var d = new Date()
  59.             chatModel.append({"name": name, "message": message, "time": addZero(d.getHours()) + ":" + addZero(d.getMinutes()), "align": "right"})
  60.             chat.positionViewAtEnd()
  61.         }
  62.     }
  63.  
  64.     SilicaListView {
  65.         id: listView
  66.         anchors.fill: parent
  67.         clip: true
  68.         highlightFollowsCurrentItem: false
  69.         currentIndex: count -1
  70.         PageHeader {
  71.             title: qsTr("Contacts")
  72.         }
  73.         PullDownMenu {
  74.             MenuItem {
  75.                 text: qsTr("Settings")
  76.                 onClicked: pageStack.push(Qt.resolvedUrl("SecondPage.qml"))
  77.             }
  78.         }
  79.         model: ListModel {
  80.             id: listModel
  81.         }
  82.         delegate: BackgroundItem {
  83.             x: 5
  84.             height: 24
  85.             width: listView.width
  86.             Row {
  87.                 id: row1
  88.                 anchors.verticalCenter: parent.verticalCenter
  89.                 Text {
  90.                     id: text1
  91.                     text: name
  92.                     color: '#eff0f1'
  93.                     x: Theme.paddingLarge
  94.                 }
  95.                 Text {
  96.                     id: text2
  97.                     text: fbid
  98.                     visible: false
  99.                 }
  100.             }
  101.             onClicked: console.log("Clicked " + index)
  102. //            MouseArea {
  103. //                anchors.fill: parent
  104. //                onClicked: {
  105. //                    listView.currentIndex = index
  106. //                    window.activeId = text2.text
  107. //                }
  108. //            }
  109.         }
  110.         VerticalScrollDecorator {}
  111.     }
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement