forked from lubuwest/Friendiqa
Version 0.002 code cleanup and event attending
This commit is contained in:
parent
dc7e6cdee5
commit
d8186978e7
42 changed files with 925 additions and 968 deletions
|
@ -1,5 +1,5 @@
|
|||
import QtQuick 2.0
|
||||
import QtQuick.Dialogs 1.2
|
||||
//import QtQuick.Dialogs 1.2
|
||||
import QtQuick.Controls 1.4
|
||||
import QtQml.Models 2.1
|
||||
import "qrc:/js/service.js" as Service
|
||||
|
@ -18,21 +18,17 @@ Rectangle {
|
|||
color: '#fff'
|
||||
property var newimages:[]
|
||||
property int currentimageno: 0
|
||||
//onLoginChanged:{var msg = {'model': photogroupModel,'albums':[],'firstalbum':0,'foreignPicture':false};
|
||||
// photoWorker.sendMessage(msg);
|
||||
//}
|
||||
|
||||
onNewimagesChanged:{
|
||||
if(newimages.length>0){
|
||||
Helperjs.readField("album",root.db,"imageData",root.login.username,function(albums){
|
||||
//print("albums"+JSON.stringify(albums)+JSON.stringify(newimages[currentimageno]));
|
||||
for (var i=0;i<newimages.length;i++){
|
||||
if(albums.indexOf(newimages[i].album)==-1){
|
||||
filesystem.Directory=root.login.imagestore+"/albums";
|
||||
filesystem.makeDir(newimages[i].album)}}
|
||||
if(newimages.length>0){
|
||||
Helperjs.readField("album",root.db,"imageData",root.login.username,function(albums){
|
||||
for (var i=0;i<newimages.length;i++){
|
||||
if(albums.indexOf(newimages[i].album)==-1){
|
||||
filesystem.Directory=root.login.imagestore+"/albums";
|
||||
filesystem.makeDir(newimages[i].album)}}
|
||||
})
|
||||
//print("Current image number"+currentImageNo)
|
||||
Service.dataRequest(root.login,newimages[currentimageno].id,root.db,fotostab);
|
||||
newImagesProgress.visible=true //download first image
|
||||
Service.dataRequest(root.login,newimages[currentimageno].id,root.db,fotostab);
|
||||
newImagesProgress.visible=true //download first image
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,20 +40,21 @@ Rectangle {
|
|||
}
|
||||
|
||||
function showOwnFotos(){
|
||||
try {photogroupModel.clear()}catch (e){print(e)}
|
||||
Helperjs.readField("album",root.db, "imageData",root.login.username,function(albums){
|
||||
if (albums[0]) {
|
||||
var msg = { 'model': photogroupModel,'albums':albums,'firstalbum':0,'foreignPicture': false};
|
||||
photoWorker.sendMessage(msg);
|
||||
};
|
||||
})
|
||||
}
|
||||
Connections{
|
||||
target:root
|
||||
onLoginChanged:{var msg = {'model': photogroupModel,'albums':[],'firstalbum':0,'foreignPicture':false};
|
||||
photoWorker.sendMessage(msg);}
|
||||
try {photogroupModel.clear()}catch (e){print(e)}
|
||||
Helperjs.readField("album",root.db, "imageData",root.login.username,function(albums){
|
||||
if (albums[0]) {
|
||||
var msg = { 'model': photogroupModel,'albums':albums,'firstalbum':0,'foreignPicture': false};
|
||||
photoWorker.sendMessage(msg);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Connections{
|
||||
target:root
|
||||
onLoginChanged:{
|
||||
var msg = {'model': photogroupModel,'albums':[],'firstalbum':0,'foreignPicture':false};
|
||||
photoWorker.sendMessage(msg)}
|
||||
}
|
||||
|
||||
Connections{
|
||||
target:xhr
|
||||
|
@ -72,110 +69,111 @@ Rectangle {
|
|||
|
||||
function onFriendsFotos(friend){
|
||||
fotostab.phototabstatus=friend.screen_name;
|
||||
//print("Friend "+friend.url);
|
||||
try {photogroupModel.clear()}catch (e){print(e)}
|
||||
Service.requestFriendsAlbumPictures(root.login,friend,fotostab,function(albums){
|
||||
var msg = {'model': photogroupModel,'albums':albums,'firstalbum':0,'foreignPicture':true};
|
||||
photoWorker.sendMessage(msg);
|
||||
})
|
||||
}
|
||||
Service.requestFriendsAlbumPictures(root.login,friend,fotostab,function(albums){
|
||||
var msg = {'model': photogroupModel,'albums':albums,'firstalbum':0,'foreignPicture':true}
|
||||
photoWorker.sendMessage(msg);
|
||||
})
|
||||
}
|
||||
|
||||
ProgressBar{
|
||||
id: newImagesProgress
|
||||
width: 15*mm
|
||||
height: updatePhotolist.height
|
||||
anchors.top: parent.top
|
||||
anchors.right:updatePhotolist.left
|
||||
anchors.rightMargin:mm
|
||||
visible: false
|
||||
value: currentimageno/newimages.length
|
||||
}
|
||||
ProgressBar{
|
||||
id: newImagesProgress
|
||||
width: 15*mm
|
||||
height: updatePhotolist.height
|
||||
anchors.top: parent.top
|
||||
anchors.right:updatePhotolist.left
|
||||
anchors.rightMargin:mm
|
||||
visible: false
|
||||
value: currentimageno/newimages.length
|
||||
}
|
||||
|
||||
BlueButton{
|
||||
id: updatePhotolist
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: 0.5*mm
|
||||
anchors.right:phototabstatusButton.left
|
||||
anchors.rightMargin:mm
|
||||
text: qsTr("Update")
|
||||
onClicked: {
|
||||
Service.requestList(root.login,root.db, fotostab,function(obj){
|
||||
newimages=obj;print("newimages"+JSON.stringify(obj))
|
||||
})}}
|
||||
BlueButton{
|
||||
id: updatePhotolist
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: 0.5*mm
|
||||
anchors.right:phototabstatusButton.left
|
||||
anchors.rightMargin:mm
|
||||
text: qsTr("Update")
|
||||
onClicked: {
|
||||
Service.requestList(root.login,root.db, fotostab,function(obj){
|
||||
newimages=obj;print("newimages"+JSON.stringify(obj))
|
||||
})}}
|
||||
|
||||
BlueButton{
|
||||
id: phototabstatusButton
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: 0.5*mm
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin:2*mm
|
||||
text: qsTr(phototabstatus)
|
||||
onClicked: {phototabmenu.popup()}
|
||||
}
|
||||
Menu {
|
||||
id:phototabmenu
|
||||
MenuItem {
|
||||
text: qsTr("Own Images")
|
||||
onTriggered: {
|
||||
phototabstatus="Images";
|
||||
showOwnFotos()}
|
||||
}
|
||||
}
|
||||
DelegateModel{
|
||||
id: visualphotoModel
|
||||
delegate: PhotogroupComponent{}
|
||||
model: photogroupModel
|
||||
}
|
||||
|
||||
ListModel{
|
||||
id: photogroupModel
|
||||
}
|
||||
|
||||
GridView {
|
||||
id: albumgridview
|
||||
cellWidth: 17*mm
|
||||
cellHeight: 17*mm
|
||||
x: mm;y:8*mm
|
||||
width: parent.width-2*mm; height: parent.height-9*mm
|
||||
clip: true
|
||||
model: visualphotoModel.parts.album
|
||||
footer:
|
||||
Rectangle{
|
||||
border.color: "#EEEEEE"
|
||||
border.width: 1
|
||||
width:12*mm
|
||||
height:6*mm
|
||||
Text{
|
||||
font.pixelSize: 1.5*mm
|
||||
anchors.centerIn: parent
|
||||
text:qsTr("More")
|
||||
}
|
||||
MouseArea{anchors.fill:parent
|
||||
onClicked:{
|
||||
var lastalbum_id=photogroupModel.get(photogroupModel.count-1);
|
||||
if(photogroupModel.get(photogroupModel.count-1).foreignPictures==false){Service.requestFriendsAlbumPictures(friend,fotostab,function(albums){
|
||||
var msg = {'model': photogroupModel,'albums':albums,'firstalbum':lastalbum_id+1,'foreignPicture':true};
|
||||
photoWorker.sendMessage(msg); })}
|
||||
else { Helperjs.readField("album",root.db, "imageData",root.login.username,function(albums){
|
||||
var msg = { 'model': photogroupModel,'albums':albums,'foreignPicture': false,'firstalbum':lastalbum_id+1};
|
||||
photoWorker.sendMessage(msg)})}
|
||||
}}}
|
||||
}
|
||||
|
||||
Rectangle { id: photoBackground; color: 'light grey'; width: parent.width; height: parent.height; opacity: 0; visible: opacity != 0.0 }
|
||||
|
||||
ListView { anchors.fill: parent; model: visualphotoModel.parts.browser; interactive: false }
|
||||
|
||||
BlueButton {
|
||||
id: backButton
|
||||
text: qsTr("Back")
|
||||
x: parent.width - backButton.width - 3*mm
|
||||
y: -backButton.height - 4*mm
|
||||
onClicked: {photoBackground.opacity=0}
|
||||
}
|
||||
|
||||
ListView {anchors.fill: parent; model: visualphotoModel.parts.fullscreen; interactive: false }
|
||||
WorkerScript{id: photoWorker;source: "qrc:/js/photoworker.js"}
|
||||
|
||||
Component.onCompleted: { root.fotoSignal.connect(onFriendsFotos);}
|
||||
BlueButton{
|
||||
id: phototabstatusButton
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: 0.5*mm
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin:2*mm
|
||||
text: qsTr(phototabstatus)
|
||||
onClicked: {phototabmenu.popup()}
|
||||
}
|
||||
Menu {
|
||||
id:phototabmenu
|
||||
MenuItem {
|
||||
text: qsTr("Own Images")
|
||||
onTriggered: {
|
||||
phototabstatus="Images";
|
||||
showOwnFotos()}
|
||||
}
|
||||
}
|
||||
|
||||
DelegateModel{
|
||||
id: visualphotoModel
|
||||
delegate: PhotogroupComponent{}
|
||||
model: photogroupModel
|
||||
}
|
||||
|
||||
ListModel{
|
||||
id: photogroupModel
|
||||
}
|
||||
|
||||
GridView {
|
||||
id: albumgridview
|
||||
cellWidth: 17*mm
|
||||
cellHeight: 17*mm
|
||||
x: mm;y:8*mm
|
||||
width: parent.width-2*mm; height: parent.height-9*mm
|
||||
clip: true
|
||||
model: visualphotoModel.parts.album
|
||||
footer:Rectangle{
|
||||
border.color: "#EEEEEE"
|
||||
border.width: 1
|
||||
width:12*mm
|
||||
height:6*mm
|
||||
Text{
|
||||
font.pixelSize: 1.5*mm
|
||||
anchors.centerIn: parent
|
||||
text:qsTr("More")
|
||||
}
|
||||
MouseArea{anchors.fill:parent
|
||||
onClicked:{
|
||||
var lastalbum_id=photogroupModel.get(photogroupModel.count-1);
|
||||
if(photogroupModel.get(photogroupModel.count-1).foreignPictures==false){
|
||||
Service.requestFriendsAlbumPictures(friend,fotostab,function(albums){
|
||||
var msg = {'model': photogroupModel,'albums':albums,'firstalbum':lastalbum_id+1,'foreignPicture':true}
|
||||
photoWorker.sendMessage(msg)
|
||||
})}
|
||||
else{Helperjs.readField("album",root.db, "imageData",root.login.username,function(albums){
|
||||
var msg = { 'model': photogroupModel,'albums':albums,'foreignPicture': false,'firstalbum':lastalbum_id+1};
|
||||
photoWorker.sendMessage(msg)})}
|
||||
}}}
|
||||
}
|
||||
|
||||
Rectangle { id: photoBackground; color: 'light grey'; width: parent.width; height: parent.height; opacity: 0; visible: opacity != 0.0 }
|
||||
|
||||
ListView { anchors.fill: parent; model: visualphotoModel.parts.browser; interactive: false }
|
||||
|
||||
BlueButton {
|
||||
id: backButton
|
||||
text: qsTr("Back")
|
||||
x: parent.width - backButton.width - 3*mm
|
||||
y: -backButton.height - 4*mm
|
||||
onClicked: {photoBackground.opacity=0}
|
||||
}
|
||||
|
||||
ListView {anchors.fill: parent; model: visualphotoModel.parts.fullscreen; interactive: false }
|
||||
WorkerScript{id: photoWorker;source: "qrc:/js/photoworker.js"}
|
||||
|
||||
Component.onCompleted: { root.fotoSignal.connect(onFriendsFotos)}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue