create and delete events

This commit is contained in:
LubuWest 2022-11-15 22:02:09 +01:00
commit 400241ec6a
34 changed files with 1346 additions and 614 deletions

View file

@ -45,9 +45,9 @@ Item{
Layout.fillHeight: true
property int currentContact: 0
function showFriends(contact){
function showFriends(username){
try {friendsModel.clear()} catch(e){};
Helperjs.readData(db,"friendshiprequests",login.username,function(friendrequestsobject){
Helperjs.readData(db,"friendshiprequests",username,function(friendrequestsobject){
for (var i=0;i<friendrequestsobject.length;i++){
if (friendrequestsobject[i].note!=null){
friendrequestsobject[i].description=Qt.atob(friendrequestsobject[i].note);}
@ -73,6 +73,19 @@ Item{
},(searchText.text==""?searchText.preeditText:searchText.text));
}
function showContacts(contact){
try {friendsModel.clear()} catch(e){};
Newsjs.listFriends(login,db,function(contactsobject){
for (var j=0;j<contactsobject.length;j++){
contactsobject[j].description=Qt.atob(contactsobject[j].description);
if(Helperjs.getCount(db,login,"contacts","screen_name",contactsobject[j].screen_name)>1){
contactsobject[j].screen_name=contactsobject[j].screen_name+"+"+contactsobject[j].cid
}
friendsModel.append({"contact":contactsobject[j]});
}
},searchText.text,-1);
}
Connections{
target:xhr
function onDownloaded(type,url,filename,i){
@ -108,11 +121,10 @@ Item{
ProgressBar{
id: newContactsProgress
width: 15*mm
height: updateFriendsButton.height
anchors.top: parent.top
anchors.right:updateFriendsButton.left
anchors.rightMargin:mm
width: friendsView.width
height: 2*mm
x: mm
y: updateFriendsButton.height+mm
visible: (friendsGridTab.currentContact!=(root.newContacts.length))?true:false
value: friendsGridTab.currentContact/root.newContacts.length
}
@ -134,11 +146,30 @@ Item{
selectByMouse: true
cursorVisible: false
placeholderText: "\uf0b0"
onTextChanged: if (text.length>0){showFriends(root.login.username)}
onPreeditTextChanged: {if (preeditText.length>0){showFriends(root.login.username)}}
onTextChanged: {showFriends(root.login.username)}//if (text.length>0)
onPreeditTextChanged: {{showFriends(root.login.username)}}//if (preeditText.length>0)
}
}
ComboBox{
id: friendsCombo
anchors.left: searchComponent.right
anchors.leftMargin: root.fontFactor*osSettings.bigFontSize
y: mm
width: 6*root.fontFactor*osSettings.bigFontSize
height: 1.5*root.fontFactor*osSettings.bigFontSize
font.pointSize: osSettings.systemFontSize
model: [qsTr("Friends"), qsTr("All")]
onCurrentIndexChanged:{
if (currentIndex === 0) {
showFriends(root.login.username);
} else{
showContacts()
}
}
}
Component {
id: sectionHeading
Rectangle {
@ -180,9 +211,9 @@ Item{
ListView{
id: friendsView
x:mm
y:updateFriendsButton.height+mm
y:updateFriendsButton.height+2*mm
width:friendsGridTab.width-2*mm
height:friendsGridTab.height-(updateFriendsButton.height+7*mm)
height:friendsGridTab.height-(updateFriendsButton.height+10*mm)
clip: true
spacing: 2
function processContactSelection(contactobject){showContactdetails(contactobject)}