forked from lubuwest/Friendiqa
create and delete events
This commit is contained in:
parent
27cd83db3c
commit
400241ec6a
34 changed files with 1346 additions and 614 deletions
|
@ -30,7 +30,7 @@
|
|||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick.Controls 2.12
|
||||
import QtQuick.Controls 2.15
|
||||
import QtQuick.Controls.Material 2.12
|
||||
import QtQml 2.2
|
||||
import Qt.labs.calendar 1.0
|
||||
|
@ -42,7 +42,7 @@ import "qrc:/qml/genericqml"
|
|||
|
||||
Rectangle {
|
||||
id:calendarrectangle
|
||||
// y:1
|
||||
// y:1
|
||||
width:parent.width
|
||||
height:parent.height
|
||||
color: Material.backgroundColor
|
||||
|
@ -53,21 +53,21 @@ Rectangle {
|
|||
|
||||
function showEvents(friend){
|
||||
if(friend=="backButton"){Service.eventsfromdb(db,login.username,function(eventArray,dayArray){
|
||||
events=eventArray;
|
||||
events=cleanEvents(eventArray);
|
||||
eventdays=dayArray})
|
||||
}
|
||||
else if (friend!=""){
|
||||
calendartab.calendartabstatus=friend.url.substring(friend.url.lastIndexOf("/")+1,friend.url.length)
|
||||
calendartab.calendartabstatus=friend.url.substring(friend.url.lastIndexOf("/")+1,friend.url.length)
|
||||
Service.newRequestFriendsEvents(login,friend,calendartab,function(eventArray,dayArray){
|
||||
events=eventArray;
|
||||
eventdays=dayArray})
|
||||
events=cleanEvents(eventArray);
|
||||
eventdays=dayArray})
|
||||
}
|
||||
else {calendartab.calendartabstatus="Events";
|
||||
Service.eventsfromdb(db,login.username,function(eventArray,dayArray){
|
||||
events=eventArray;
|
||||
events=cleanEvents(eventArray);
|
||||
eventdays=dayArray;
|
||||
calBusy.running=false
|
||||
|
||||
var currentevents=events;
|
||||
var currentevents=events.filter(event=>(currentTime<=event.end));
|
||||
for (var i=0; i<Math.min(5,currentevents.length);i++){
|
||||
var liststate="";
|
||||
|
@ -77,15 +77,23 @@ Rectangle {
|
|||
}
|
||||
}
|
||||
|
||||
function cleanEvents(events){
|
||||
for (var item in events){
|
||||
events[item].start=events[item].start-offsetTime;
|
||||
if(events[item].end>0){events[item].end=events[item].end-offsetTime};
|
||||
}
|
||||
return events
|
||||
}
|
||||
|
||||
BusyIndicator{
|
||||
id: calBusy
|
||||
anchors.horizontalCenter: calendarView.horizontalCenter
|
||||
anchors.top:calendarView.top
|
||||
anchors.topMargin: 2*mm
|
||||
width:10*mm
|
||||
height: 10*mm
|
||||
running: false
|
||||
}
|
||||
id: calBusy
|
||||
anchors.horizontalCenter: calendarView.horizontalCenter
|
||||
anchors.top:calendarView.top
|
||||
anchors.topMargin: 2*mm
|
||||
width:10*mm
|
||||
height: 10*mm
|
||||
running: false
|
||||
}
|
||||
|
||||
BlueButton{
|
||||
z:2
|
||||
|
@ -127,12 +135,56 @@ Rectangle {
|
|||
}}
|
||||
|
||||
Connections{
|
||||
target: updatenews
|
||||
target: updatenews
|
||||
|
||||
function onSuccess(api){
|
||||
calBusy.running=false;
|
||||
showEvents("")
|
||||
}
|
||||
function onSuccess(api){
|
||||
calBusy.running=false;
|
||||
showEvents("")
|
||||
}
|
||||
}
|
||||
|
||||
Dialog {
|
||||
id: deleteDialog
|
||||
anchors.centerIn: parent
|
||||
property int eventid:0
|
||||
title: qsTr("Delete Event?")
|
||||
standardButtons: Dialog.Ok | Dialog.Cancel
|
||||
modal: true
|
||||
onAccepted: {//print("event.id"+event.id);
|
||||
xhr.setUrl(login.server);
|
||||
xhr.setLogin(login.username+":"+Qt.atob(login.password));
|
||||
xhr.setApi("/api/friendica/event_delete");
|
||||
xhr.clearParams();
|
||||
xhr.setParam("id",eventid);
|
||||
xhr.post();
|
||||
}
|
||||
onRejected: {print("eventid "+eventid);close()}
|
||||
}
|
||||
|
||||
MButton{
|
||||
id: createNewEvent
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: 0.5*mm
|
||||
anchors.right:updateEvents.left
|
||||
anchors.rightMargin:mm
|
||||
width: 2*root.fontFactor*osSettings.bigFontSize;
|
||||
text:"+"
|
||||
onClicked: {
|
||||
rootstackView.push("qrc:/qml/calendarqml/EventCreate.qml")
|
||||
}
|
||||
}
|
||||
|
||||
Connections{
|
||||
target: xhr
|
||||
function onSuccess(text,api){
|
||||
if(api=="/api/friendica/event_create"){
|
||||
calBusy.running=true;
|
||||
updatenews.setDatabase();
|
||||
updatenews.login();
|
||||
updatenews.setSyncAll(false);
|
||||
updatenews.events();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MButton{
|
||||
|
@ -152,7 +204,7 @@ Rectangle {
|
|||
font.pointSize: osSettings.systemFontSize
|
||||
onTriggered: {
|
||||
calendartab.calendartabstatus="Events";
|
||||
// calendartabstatusButton.text=qsTr("own Calendar");
|
||||
// calendartabstatusButton.text=qsTr("own Calendar");
|
||||
showEvents("")}
|
||||
}
|
||||
}
|
||||
|
@ -176,41 +228,41 @@ Rectangle {
|
|||
}
|
||||
delegate:
|
||||
Item{
|
||||
width:Math.min(23*root.fontFactor*osSettings.bigFontSize,calendarView.width)
|
||||
height: parent.height
|
||||
Text{
|
||||
font.bold: true
|
||||
//Layout.fillWidth: true
|
||||
width: parent.width-root.fontFactor*osSettings.bigFontSize
|
||||
horizontalAlignment:Text.AlignHCenter
|
||||
color: Material.primaryTextColor
|
||||
text: model.year
|
||||
font.pointSize: osSettings.systemFontSize
|
||||
}
|
||||
Text{y:1.5*root.fontFactor*osSettings.bigFontSize
|
||||
width: parent.width-osSettings.bigFontSize
|
||||
text: Qt.locale().standaloneMonthName(model.month)
|
||||
//Layout.fillWidth: true
|
||||
color: Material.primaryTextColor
|
||||
horizontalAlignment:Text.AlignHCenter
|
||||
font.pointSize: osSettings.systemFontSize
|
||||
}
|
||||
DayOfWeekRow{y:3*root.fontFactor*osSettings.bigFontSize
|
||||
width: parent.width-root.fontFactor*osSettings.bigFontSize
|
||||
locale: monthgrid.locale
|
||||
//Layout.fillWidth: true
|
||||
font.pointSize: osSettings.systemFontSize
|
||||
}
|
||||
width:Math.min(23*root.fontFactor*osSettings.bigFontSize,calendarView.width)
|
||||
height: parent.height
|
||||
Text{
|
||||
font.bold: true
|
||||
//Layout.fillWidth: true
|
||||
width: parent.width-root.fontFactor*osSettings.bigFontSize
|
||||
horizontalAlignment:Text.AlignHCenter
|
||||
color: Material.primaryTextColor
|
||||
text: model.year
|
||||
font.pointSize: osSettings.systemFontSize
|
||||
}
|
||||
Text{y:1.5*root.fontFactor*osSettings.bigFontSize
|
||||
width: parent.width-osSettings.bigFontSize
|
||||
text: Qt.locale().standaloneMonthName(model.month)
|
||||
//Layout.fillWidth: true
|
||||
color: Material.primaryTextColor
|
||||
horizontalAlignment:Text.AlignHCenter
|
||||
font.pointSize: osSettings.systemFontSize
|
||||
}
|
||||
DayOfWeekRow{y:3*root.fontFactor*osSettings.bigFontSize
|
||||
width: parent.width-root.fontFactor*osSettings.bigFontSize
|
||||
locale: monthgrid.locale
|
||||
//Layout.fillWidth: true
|
||||
font.pointSize: osSettings.systemFontSize
|
||||
}
|
||||
|
||||
MonthGrid {y:5*root.fontFactor*osSettings.bigFontSize
|
||||
id: monthgrid
|
||||
height: parent.height-5*root.fontFactor*osSettings.bigFontSize
|
||||
width: parent.width-root.fontFactor*osSettings.bigFontSize
|
||||
month: model.month
|
||||
year: model.year
|
||||
locale: Qt.locale()
|
||||
delegate: CalendarDay{}
|
||||
}
|
||||
MonthGrid {y:5*root.fontFactor*osSettings.bigFontSize
|
||||
id: monthgrid
|
||||
height: parent.height-5*root.fontFactor*osSettings.bigFontSize
|
||||
width: parent.width-root.fontFactor*osSettings.bigFontSize
|
||||
month: model.month
|
||||
year: model.year
|
||||
locale: Qt.locale()
|
||||
delegate: CalendarDay{}
|
||||
}
|
||||
}
|
||||
ScrollIndicator.horizontal: ScrollIndicator { }
|
||||
Component.onCompleted: positionViewAtBeginning()
|
||||
|
@ -235,4 +287,4 @@ Rectangle {
|
|||
root.eventSignal.connect(showEvents);
|
||||
if (calendartab.calendartabstatus=="Events"){showEvents("")}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue