Forums

OverviewV-Play Plugins Support › Database Calendar

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #19542
    #19547

    Günther
    V-Play Team

    Hi Edward,

    the Firebase Database works best with JSON-based data structures. This is convenient, as you can easily create and work with JSON data objects in your V-Play app. For example, you can create a data object like this:

    import VPlayApps 1.0
    import QtQuick 2.0
    
    App {
    
      property var userData: {
        "selectedDates": [
              { "date": "utc-timestamp", "details": "meeting xy" },
              { "date": "utc-timestamp", "details": "another event" }
            ]
      }
    
      AppButton {
        text: "Add date"
        anchors.centerIn: parent
        onClicked: {
          userData.selectedDates.push({ "date": "utc-timestamp-of-chosen-date", "details": "some info" });
          console.log(JSON.stringify(userData));
        }
      }
    
    }
    

    Best,
    Günther

    #19840

    Edward

    Hey,

    I’ve been working on implementing this into my app but am really struggling :(

    I tried using the above code, adding to the onClicked event;

    firebaseDb.setValue({ “date”: “utc-timestamp-of-chosen-date”, “details”: “some info” })

    and received the following error:

    Error: Unable to determine callable overload. Candidates are: setUserValue(QString,QVariant,QJSValue) setUserValue(QString,QVariant)

    I adjusted the onClicked event too:

    firebaseDb.setValue(“groups/CanaryWharf/Departments/Reception/members”, “date:” + Date())

     

    and it writes the current date/time to the database but not the selected date!

    it also just writes one entry, when save is clicked again overwrites, not an individual entry for each user/day selected?

    HELP!!

     

    Thanks

    Edd

    #19863

    Edward

    ************UPDATE**************

    (still seeking help haha)

    I amended the line

    firebaseDb.setValue(“groups/CanaryWharf/Departments/Reception/members”, “date:” + Date())

     

    to the following:

     

          AppButton {
              id: saveButton
              text: "Save & Request"
              anchors.right: parent.right
              textColor: "#4e4e4e"
              backgroundColor: "#d1d1d1"
              onClicked: {
                userData.selectedDates.push({ "date": calendar.selectedDate});
                console.log(JSON.stringify(userData));
                firebaseDb.setValue(“groups/CanaryWharf/Departments/Reception/members”, "date:" + calendar.selectedDate)
              }
          }
        }    
        property var userData: {      
          "selectedDates": [         
                { "date": calendar.selectedDate}
              ]
        }

     

    which writes the selected date to the calendar, when I click a new date, writes to the database, but overwrites the previously written date, how would I allow it to each date selected and saved??

     

    Thanks

    Edd

    #19865

    Günther
    V-Play Team

    Hi Edd,

    in firebase, each key (path) can hold one value entry. The value can also be a data structure, which means you can store the userData.selectedDates array of your app directly to firebase with:

    firebaseDb.setValue("groups/CanaryWharf/Departments/Reception/members", { "date": userData.selectedDates } )

     

    Best,
    Günther from V-Play

    #20789

    Edward

    Hi Gunther,

    I thought id’ reply here save starting a new post!

    I am asking about the multiple selection of calendar cells, what i want to be able to do is visually highlight selected cells which then can be batch saved,

     

    I know using the above method i can Append each date to JSON to batch save to firebase, but i also want this to be visual for the user, so each date tapped on is highlighted then on the save button pressed they are all saved to the database.

    I know there options such as datePicker from fluid (which i am having install issues) and i would rather avoid a datePicker if possible anyway, the ability to multiple highlight visually and save is what i would like.

     

    If this is a possibility what would be the best approach to starting this off?

     

    Is this realistically a possibility and if so where could i start to do this

    #20792

    Günther
    V-Play Team

    Hi,

    the check whether and how to highlight cells in your view is something, that I would add as a property for the UI item:

    Item {
      id: myCellItem
    
      property bool highlight: false
    
      Rectangle {
        anchors.fill: parent
        opacity: myCellItem.highlight ? 1 : 0
        color: "orange"
      }
    }

    You can then set the highlight state for each cell as you require it. In case you fill your view based on a model, you can also add an expression to determine the highlight state for each delegate with a binding:

      property bool highlight: isSelected(modelData.date) 
    
    function isSelected(date) {
       var selected = false;
       // check if date is selected and set selected variable accordingly
       return selected ? true : false
    }

     

     

Viewing 7 posts - 1 through 7 (of 7 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support