forked from lubuwest/Friendiqa
Version 0.003
This commit is contained in:
parent
9f9a9f618c
commit
10dccdcdbb
572 changed files with 3711 additions and 13631 deletions
220
source-android/qml/contactqml/FriendsTab.qml
Normal file
220
source-android/qml/contactqml/FriendsTab.qml
Normal file
|
@ -0,0 +1,220 @@
|
|||
import QtQuick 2.0
|
||||
import QtQuick.Controls 1.2
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
import "qrc:/js/helper.js" as Helperjs
|
||||
import "qrc:/js/news.js" as Newsjs
|
||||
import "qrc:/qml/contactqml"
|
||||
import "qrc:/qml/genericqml"
|
||||
|
||||
Rectangle {
|
||||
y:1
|
||||
color: "white"
|
||||
|
||||
function showContactdetails(contact){
|
||||
if(contact.isFriend){
|
||||
friendsTabView.currentIndex=0;
|
||||
friendsTabView.contactsSignal(contact)
|
||||
}
|
||||
else{friendsTabView.currentIndex=1;
|
||||
friendsTabView.contactsSignal(contact)
|
||||
}
|
||||
}
|
||||
TabView{
|
||||
id:friendsTabView
|
||||
tabPosition: Qt.TopEdge
|
||||
x:mm
|
||||
y:mm
|
||||
width: root.width-2*mm
|
||||
height: root.height-10*mm
|
||||
currentIndex: 0
|
||||
signal contactsSignal(var contact)
|
||||
signal groupsSignal(var username)
|
||||
onCurrentIndexChanged:{
|
||||
if (currentIndex==0){//print("currentindex 0");
|
||||
contactsSignal("")
|
||||
}
|
||||
else if (currentIndex==1){
|
||||
contactsSignal("")
|
||||
}
|
||||
else if (currentIndex==2){groupsSignal(root.login.username)}
|
||||
}
|
||||
style: TabViewStyle {
|
||||
frameOverlap: 1
|
||||
tab: Rectangle {
|
||||
color: "white"
|
||||
implicitWidth: root.width/3-2*mm
|
||||
implicitHeight: 4*mm
|
||||
Text { id: text
|
||||
anchors.centerIn: parent
|
||||
text: styleData.title
|
||||
color: "dark grey"
|
||||
font.pixelSize:2.5*mm
|
||||
font.bold: styleData.selected
|
||||
}
|
||||
}
|
||||
frame: Rectangle { color: "light grey" }
|
||||
tabsAlignment:Qt.AlignHCenter
|
||||
}
|
||||
|
||||
Tab{
|
||||
title: qsTr("Friends")
|
||||
Rectangle{
|
||||
id: friendsGridTab
|
||||
function makebig(friendindex){print("friendindex"+friendindex);if (friendindex){friendsModel.set(friendindex,{"status":"large"})}}
|
||||
function showFriends(contact,callback){//print("contact"+JSON.stringify(contact));
|
||||
try {friendsModel.clear()} catch(e){print(e)};
|
||||
var friendindex;
|
||||
Helperjs.readData(db,"contacts",root.login.username,function(friendsobject){
|
||||
for (var i=0;i<friendsobject.length;i++){
|
||||
var status="";
|
||||
if(Helperjs.getCount(db,login,"contacts","screen_name",friendsobject[i].screen_name)>1){
|
||||
friendsobject[i].screen_name=friendsobject[i].screen_name+"+"+friendsobject[i].cid
|
||||
}
|
||||
if(contact){if (contact.cid==friendsobject[i].cid){status="large"}}
|
||||
friendsModel.append({"contact":friendsobject[i],"status":status});
|
||||
}
|
||||
|
||||
|
||||
},"isFriend",1,"screen_name ASC");
|
||||
}
|
||||
|
||||
BlueButton {
|
||||
id: updateFriendsButton
|
||||
text: "\uf021"
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: mm
|
||||
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
|
||||
}
|
||||
|
||||
GridView {
|
||||
id: friendsView
|
||||
x:mm
|
||||
y:updateFriendsButton.height+2*mm
|
||||
width:friendsGridTab.width-2*mm
|
||||
height:friendsGridTab.height-updateFriendsButton.height-2*mm
|
||||
clip: true
|
||||
cellHeight: 16*mm
|
||||
cellWidth: 17*mm
|
||||
add: Transition {
|
||||
NumberAnimation { properties: "x,y"; from: 300; duration: 1000 }
|
||||
}
|
||||
model: friendsModel
|
||||
delegate: ContactComponent { }
|
||||
Component.onCompleted: positionViewAtBeginning()
|
||||
}
|
||||
|
||||
ListModel{id:friendsModel}
|
||||
|
||||
Component.onCompleted: {
|
||||
root.friendsSignal.connect(showFriends);
|
||||
friendsTabView.contactsSignal.connect(showFriends);
|
||||
showFriends(root.login.username)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Tab{
|
||||
title: qsTr("Other Contacts")
|
||||
|
||||
Rectangle{
|
||||
id: contactsGridTab
|
||||
function showContacts(contact){
|
||||
try {contactsModel.clear()} catch(e){print(e)};
|
||||
Helperjs.readData(db, "contacts",root.login.username,function(contactsobject){
|
||||
for (var j=0;j<contactsobject.length;j++){
|
||||
var status="";
|
||||
if(contact){if (contact.id==contactsobject[j].id){status="large"}}
|
||||
contactsModel.append({"contact":contactsobject[j],"status":status});
|
||||
}
|
||||
},"isFriend",0,"screen_name ASC");
|
||||
}
|
||||
|
||||
GridView {
|
||||
id: contactsView
|
||||
x:mm
|
||||
y:2*mm
|
||||
width:contactsGridTab.width-2*mm
|
||||
height:contactsGridTab.height-2*mm
|
||||
clip: true
|
||||
cellHeight: 16*mm
|
||||
cellWidth: 17*mm
|
||||
add: Transition {
|
||||
NumberAnimation { properties: "x,y"; from: 300; duration: 1000 }
|
||||
}
|
||||
model: contactsModel
|
||||
delegate: ContactComponent { }
|
||||
Component.onCompleted: positionViewAtBeginning()
|
||||
}
|
||||
|
||||
ListModel{id: contactsModel}
|
||||
Component.onCompleted: {
|
||||
friendsTabView.contactsSignal.connect(showContacts);
|
||||
}
|
||||
}
|
||||
}
|
||||
Tab{
|
||||
title: qsTr("Groups")
|
||||
Rectangle{
|
||||
id: groupsGridTab
|
||||
function showGroups(username){
|
||||
try {groupsModel.clear()} catch(e){print(e)};
|
||||
Helperjs.readData(db, "groups",root.login.username,function(groupsobject){
|
||||
for (var j=0;j<groupsobject.length;j++){
|
||||
groupsModel.append({"group":groupsobject[j]});
|
||||
}})}
|
||||
BlueButton {
|
||||
id: updateGroupsButton
|
||||
text: "\uf021"
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: mm
|
||||
anchors.right: parent.right
|
||||
onClicked: {
|
||||
Newsjs.requestGroups(root.login,root.db,root,function(){
|
||||
showGroups(root.login.username)})}
|
||||
}
|
||||
GridView {
|
||||
id: groupsView
|
||||
x:mm
|
||||
y:updateGroupsButton.height+2*mm
|
||||
width:groupsGridTab.width-2*mm
|
||||
height:groupsGridTab.height-updateGroupsButton.height-2*mm
|
||||
clip: true
|
||||
cellHeight: 16*mm
|
||||
cellWidth: 17*mm
|
||||
add: Transition {
|
||||
NumberAnimation { properties: "x,y"; from: 300; duration: 1000 }
|
||||
}
|
||||
model: groupsModel
|
||||
delegate: GroupComponent { }
|
||||
}
|
||||
ListModel{
|
||||
id: groupsModel
|
||||
}
|
||||
Component.onCompleted: {
|
||||
friendsTabView.groupsSignal.connect(showGroups);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Component.onCompleted: {
|
||||
root.contactdetailsSignal.connect(showContactdetails);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue