2017-03-24 07:02:13 -04:00
|
|
|
/*
|
|
|
|
* RetroShare Android QML App
|
|
|
|
* Copyright (C) 2017 Gioacchino Mazzurco <gio@eigenlab.org>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2017-04-16 08:46:43 -04:00
|
|
|
import QtQuick 2.7
|
2017-04-20 10:05:15 -04:00
|
|
|
import QtQuick.Controls 2.0
|
2017-03-24 07:02:13 -04:00
|
|
|
|
|
|
|
Item
|
|
|
|
{
|
2017-05-13 06:52:45 -04:00
|
|
|
id: delegateRoot
|
2017-03-24 07:02:13 -04:00
|
|
|
height: 40
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
MouseArea
|
|
|
|
{
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked:
|
|
|
|
{
|
2017-05-08 14:35:15 -04:00
|
|
|
console.log("GxsIntentityDelegate onclicked:", model.name,
|
2017-03-24 07:02:13 -04:00
|
|
|
model.gxs_id)
|
|
|
|
contactsView.searching = false
|
|
|
|
if(model.own) contactsView.own_gxs_id = model.gxs_id
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var jsonData = { "own_gxs_hex": contactsView.own_gxs_id,
|
|
|
|
"remote_gxs_hex": model.gxs_id }
|
|
|
|
rsApi.request("/chat/initiate_distant_chat",
|
|
|
|
JSON.stringify(jsonData),
|
|
|
|
contactsView.startChatCallback)
|
|
|
|
}
|
|
|
|
}
|
2017-05-08 14:35:15 -04:00
|
|
|
|
2017-05-13 06:52:45 -04:00
|
|
|
onPressAndHold: showDetails()
|
2017-05-08 14:35:15 -04:00
|
|
|
|
|
|
|
ColorHash
|
2017-03-24 07:02:13 -04:00
|
|
|
{
|
|
|
|
id: colorHash
|
2017-05-08 14:35:15 -04:00
|
|
|
|
|
|
|
hash: model.gxs_id
|
2017-03-24 07:02:13 -04:00
|
|
|
height: parent.height - 4
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 2
|
2017-05-13 06:52:45 -04:00
|
|
|
|
|
|
|
MouseArea
|
|
|
|
{
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: delegateRoot.showDetails()
|
|
|
|
}
|
2017-03-24 07:02:13 -04:00
|
|
|
}
|
2017-05-08 14:35:15 -04:00
|
|
|
|
2017-03-24 07:02:13 -04:00
|
|
|
Text
|
|
|
|
{
|
|
|
|
id: nickText
|
|
|
|
color: model.own ? "blue" : "black"
|
|
|
|
text: model.name
|
|
|
|
anchors.left: colorHash.right
|
|
|
|
anchors.leftMargin: 5
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
}
|
|
|
|
|
2017-04-20 10:05:15 -04:00
|
|
|
Row
|
|
|
|
{
|
2017-03-24 07:02:13 -04:00
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: 10
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
height: parent.height - 10
|
2017-05-17 09:33:10 -04:00
|
|
|
spacing: 4
|
2017-03-24 07:02:13 -04:00
|
|
|
|
2017-04-20 10:05:15 -04:00
|
|
|
Rectangle
|
|
|
|
{
|
|
|
|
visible: model.unread_count > 0
|
|
|
|
|
|
|
|
color: "cornflowerblue"
|
|
|
|
antialiasing: true
|
|
|
|
border.color: "blue"
|
|
|
|
border.width: 1
|
2017-05-17 09:33:10 -04:00
|
|
|
height: parent.height - 4
|
2017-04-20 10:05:15 -04:00
|
|
|
radius: height/2
|
|
|
|
width: height
|
2017-05-17 09:33:10 -04:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2017-04-20 10:05:15 -04:00
|
|
|
|
|
|
|
Text
|
|
|
|
{
|
|
|
|
color: "white"
|
|
|
|
font.bold: true
|
2017-05-17 09:33:10 -04:00
|
|
|
text: model.unread_count
|
2017-04-20 10:05:15 -04:00
|
|
|
anchors.centerIn: parent
|
|
|
|
}
|
2017-03-24 07:02:13 -04:00
|
|
|
}
|
2017-05-08 14:35:15 -04:00
|
|
|
|
|
|
|
Image
|
|
|
|
{
|
|
|
|
source: model.is_contact ?
|
|
|
|
"qrc:/icons/rating.png" :
|
|
|
|
"qrc:/icons/rating-unrated.png"
|
|
|
|
height: parent.height - 4
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
}
|
2017-03-24 07:02:13 -04:00
|
|
|
}
|
|
|
|
}
|
2017-05-13 06:52:45 -04:00
|
|
|
|
|
|
|
function showDetails()
|
|
|
|
{
|
|
|
|
console.log("showDetails()", index)
|
|
|
|
contactsView.searching = false
|
|
|
|
stackView.push(
|
|
|
|
"qrc:/ContactDetails.qml",
|
|
|
|
{md: contactsListView.model.get(index)})
|
|
|
|
}
|
2017-03-24 07:02:13 -04:00
|
|
|
}
|