Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Qtmobility Organizer Qml And C++
Forum Updated to NodeBB v4.3 + New Features

Qtmobility Organizer Qml And C++

Scheduled Pinned Locked Moved Mobile and Embedded
10 Posts 4 Posters 3.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • niqtN Offline
    niqtN Offline
    niqt
    wrote on last edited by
    #1

    Hi,
    I defined in my qml
    @
    property OrganizerModel organizer:OrganizerModel{
    id: organizer
    manager:"qtorganizer:memory:id=qml"
    startPeriod:"2012-02-21"
    endPeriod:"2012-02-23"
    autoUpdate:true
    }
    @

    after i call

    @
    onClicked: {

            calendarManager.createEvent(new Date(), new Date(), "dum");
    
            organizer.update();
            console.log("N° item from qml" + organizer.itemCount + " from c++ " + calendarManager.count());
        }
    

    @

    and i see N° item from qml 0 from c++ 1

    in c++ i have

    @
    CalendarManager::CalendarManager(QObject *parent) :
    QObject(parent)
    {
    _manager = QOrganizerManager::fromUri("qtorganizer:memory:id=qml");
    }

    void CalendarManager::createEvent(QDateTime startTime, QDateTime endTime, QString description)
    {
    QOrganizerEvent event;
    event.setStartDateTime(startTime);
    event.setDescription(description);

    if (_manager->saveItem(&event) )
        qDebug() << "save\n";
    else
        qDebug() << "error " << _manager->error() << endl;
    

    }

    int CalendarManager::count()
    {
    QDateTime last(QDate::currentDate());
    QDateTime today(QDate::currentDate());
    last = last.addDays(2);

    return _manager->items(today, last).length();
    

    }
    @

    My question is: why in qml i don't see new item in organizer model?

    1 Reply Last reply
    0
    • G Offline
      G Offline
      GentooXativa
      wrote on last edited by
      #2

      Maybe you should reload the model? Im not sure, i didnt used the QTM calendar :)

      Jose Vicente Giner Sanchez - Senior Mobile Developer

      www.gigigo.com

      C/ Dr. Zamenhof 36bis, 1ºA 28027 Madrid
      T: +34 917431436

      1 Reply Last reply
      0
      • X Offline
        X Offline
        xizzhu
        wrote on last edited by
        #3

        In short, the C++ QOrganizerManager provides synchronous APIs, while the C++ QOrganizerAbstractRequest and the QML OrganizerModel provide asynchronous APIs. Once the model gets updated, the modelChanged signal will be emitted.

        My Blog: http://xzis.me/

        1 Reply Last reply
        0
        • niqtN Offline
          niqtN Offline
          niqt
          wrote on last edited by
          #4

          i force update with organizer.update(); but nothing

          1 Reply Last reply
          0
          • X Offline
            X Offline
            xizzhu
            wrote on last edited by
            #5

            update() is also async, and if you have autoUpdate set to true, you don't need to call update().

            My Blog: http://xzis.me/

            1 Reply Last reply
            0
            • niqtN Offline
              niqtN Offline
              niqt
              wrote on last edited by
              #6

              ok, i don't understand, what's a solution?
              can i create Event in qml? I think no, property is all read-only

              1 Reply Last reply
              0
              • X Offline
                X Offline
                xizzhu
                wrote on last edited by
                #7

                You can create on event like this:
                @Event {
                id: myEvent
                startDateTime: "2012-02-23T00:00:00Z"
                endDateTime: "2012-02-23T08:00:00Z"
                displayLabel: "my event"
                }@

                Then saves it:
                @organizerModel.saveItem(myEvent);@

                My Blog: http://xzis.me/

                1 Reply Last reply
                0
                • niqtN Offline
                  niqtN Offline
                  niqt
                  wrote on last edited by
                  #8

                  yes, but it's true for static event, after can't change a date, ecc.

                  1 Reply Last reply
                  0
                  • X Offline
                    X Offline
                    xizzhu
                    wrote on last edited by
                    #9

                    You can. And you only need to wait until the model is ready, i.e. the modelChanged() signal is emitted.

                    The reason why your code (as shown below) doesn't work is that, the update() function is async, and it returns immediately, so when you call the console.log() function, the model is NOT updated yet.
                    @organizer.update();
                    console.log("N° item from qml" + organizer.itemCount + " from c++ " + calendarManager.count());@

                    My Blog: http://xzis.me/

                    1 Reply Last reply
                    0
                    • I Offline
                      I Offline
                      ikause
                      wrote on last edited by
                      #10

                      Excellent to see interested people around these APIs :)

                      Other possible problem with original implementation is, that you might be having two separate managers. One created in Qml and one in C++. Memory backend is not really intelligent and does not share same data storage with multiple manager instances.

                      But as xizzhu was already pointing out, you don't actually even need to access C++ model, you can create and store events with plain Qml. You can utilise same static event for saving multiple different events to memory or you can create events dynamically.

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved