67 lines
1.9 KiB
QML
67 lines
1.9 KiB
QML
|
import QtQuick 2.0
|
||
|
import QtQuick.Dialogs 1.2
|
||
|
import QtQuick.Controls 1.2
|
||
|
import "qrc:/js/service.js" as Service
|
||
|
import "qrc:/js/helper.js" as Helperjs
|
||
|
import "qrc:/js/news.js" as Newsjs
|
||
|
import "qrc:/qml"
|
||
|
|
||
|
Rectangle {
|
||
|
function showFriends(username){try {friendsModel.clear()} catch(e){print(e)};
|
||
|
Helperjs.readData(db, "contacts",function(friendsobject){
|
||
|
for (var j=0;j<friendsobject.length;j++){
|
||
|
friendsModel.append({"friend":friendsobject[j]});
|
||
|
}},"username", username)
|
||
|
}
|
||
|
|
||
|
color: "white"
|
||
|
Button {
|
||
|
id: updateFriendsButton
|
||
|
text: qsTr("Update")
|
||
|
anchors.top: parent.top
|
||
|
anchors.right: parent.right
|
||
|
onClicked: {
|
||
|
try {friendsModel.clear()} catch(e){print(e)};
|
||
|
root.contactLoadType="friends";
|
||
|
Newsjs.requestFriends(root.login,db,root,function(nc){
|
||
|
root.newContacts=nc
|
||
|
})}
|
||
|
}
|
||
|
ProgressBar{
|
||
|
id: newContactsProgress
|
||
|
width: 15*mm
|
||
|
height: updateFriendsButton.height
|
||
|
anchors.top: parent.top
|
||
|
anchors.right:updateFriendsButton.left
|
||
|
anchors.rightMargin:mm
|
||
|
visible: (root.currentContact!=root.newContacts.length)?true:false
|
||
|
value: root.currentContact/root.newContacts.length
|
||
|
}
|
||
|
|
||
|
Rectangle{
|
||
|
x: 2*mm; y:updateFriendsButton.height+2*mm
|
||
|
width:root.width-5*mm
|
||
|
height:root.height-5*mm
|
||
|
GridView {
|
||
|
id: friendsView
|
||
|
anchors.fill: parent
|
||
|
anchors.bottomMargin: 12*mm
|
||
|
clip: true
|
||
|
cellHeight: 16*mm
|
||
|
cellWidth: 17*mm
|
||
|
add: Transition {
|
||
|
NumberAnimation { properties: "x,y"; from: 300; duration: 1000 }
|
||
|
}
|
||
|
model: friendsModel
|
||
|
delegate: FriendComponent { }
|
||
|
}
|
||
|
}
|
||
|
ListModel{
|
||
|
id: friendsModel
|
||
|
}
|
||
|
Component.onCompleted: {
|
||
|
root.friendsSignal.connect(showFriends);
|
||
|
showFriends(login.username)
|
||
|
}
|
||
|
}
|