Version 0.002 with working Favorite Combobox

This commit is contained in:
LubuWest 2016-11-14 13:28:23 +01:00
commit 571c9046d0
42 changed files with 1948 additions and 814 deletions

View file

@ -1,6 +1,7 @@
import QtQuick 2.0
import QtQuick.Dialogs 1.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.4
import "qrc:/js/service.js" as Service
import "qrc:/js/helper.js" as Helperjs
import "qrc:/js/news.js" as Newsjs
@ -17,17 +18,35 @@ Rectangle {
tabPosition: Qt.TopEdge
x:mm
y:mm
width: root.width-5*mm
width: root.width-2*mm
height: root.height-10*mm
currentIndex: 0
signal friendsSignal(var username)
signal contactsSignal(var username)
signal groupsSignal(var username)
onCurrentIndexChanged:{
if (currentIndex==0){friendsSignal(root.login.username)}
if (currentIndex==0){root.friendsSignal(root.login.username)}
else if (currentIndex==1){contactsSignal(root.login.username)}
else if (currentIndex==2){groupsSignal(root.login.username)}
}
style: TabViewStyle {
frameOverlap: 1
tab: Rectangle {
color: "white"
//border.color: "light grey"
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")
@ -35,15 +54,16 @@ Rectangle {
id: friendsGridTab
function showFriends(username){
try {friendsModel.clear()} catch(e){print(e)};
Helperjs.readData(db,"contacts",username,function(friends){
for (var i=0;i<friends.length;i++){
friendsModel.append({"friend":friends[i]});
Helperjs.readData(db,"contacts",username,function(friendsobject){
for (var i=0;i<friendsobject.length;i++){
friendsModel.append({"contact":friendsobject[i]});
}},"isFriend",1)
}
Button {
id: updateFriendsButton
text: qsTr("Update")
anchors.top: parent.top
anchors.topMargin: mm
anchors.right: parent.right
onClicked: {
try {friendsModel.clear()} catch(e){print(e)};
@ -67,7 +87,7 @@ Rectangle {
GridView {
id: friendsView
x:mm
y:updateFriendsButton.height+mm
y:updateFriendsButton.height+2*mm
width:friendsGridTab.width-2*mm
height:friendsGridTab.height-updateFriendsButton.height-2*mm
clip: true
@ -77,7 +97,7 @@ Rectangle {
NumberAnimation { properties: "x,y"; from: 300; duration: 1000 }
}
model: friendsModel
delegate: FriendComponent { }
delegate: ContactComponent { }
}
ListModel{id:friendsModel}
@ -85,7 +105,7 @@ Rectangle {
Component.onCompleted: {
friendsTabView.friendsSignal.connect(showFriends);
root.friendsSignal.connect(showFriends);
showFriends(root.login.username)
}
}
@ -98,16 +118,16 @@ Rectangle {
id: contactsGridTab
function showContacts(username){
try {contactsModel.clear()} catch(e){print(e)};
Helperjs.readData(db, "contacts",root.login.username,function(friendsobject){
for (var j=0;j<friendsobject.length;j++){
contactsModel.append({"friend":friendsobject[j]});
Helperjs.readData(db, "contacts",root.login.username,function(contactsobject){
for (var j=0;j<contactsobject.length;j++){
contactsModel.append({"contact":contactsobject[j]});
}
},"isFriend",0)}
GridView {
id: contactsView
x:mm
y:mm
y:2*mm
width:contactsGridTab.width-2*mm
height:contactsGridTab.height-2*mm
clip: true
@ -117,7 +137,7 @@ Rectangle {
NumberAnimation { properties: "x,y"; from: 300; duration: 1000 }
}
model: contactsModel
delegate: FriendComponent { }
delegate: ContactComponent { }
}
ListModel{id: contactsModel}
@ -132,7 +152,6 @@ Rectangle {
id: groupsGridTab
function showGroups(username){
try {groupsModel.clear()} catch(e){print(e)};
print("showGroups"+username);
Helperjs.readData(db, "groups",root.login.username,function(groupsobject){
for (var j=0;j<groupsobject.length;j++){
groupsModel.append({"group":groupsobject[j]});
@ -141,6 +160,7 @@ Rectangle {
id: updateGroupsButton
text: qsTr("Update")
anchors.top: parent.top
anchors.topMargin: mm
anchors.right: parent.right
onClicked: {
print("Update groups");
@ -150,7 +170,7 @@ Rectangle {
GridView {
id: groupsView
x:mm
y:updateGroupsButton.height+mm
y:updateGroupsButton.height+2*mm
width:groupsGridTab.width-2*mm
height:groupsGridTab.height-updateGroupsButton.height-2*mm
clip: true