replaceItem vs updateItem

What is the difference between the methods replaceItem() , updateItem() or replaceItemAt() and updateItemAt() of the qnx.ui.data.DataProvider class?

Hey David,

the two methods replaceItem() and updateItem replaceItemAt() () and updateItemAt() methods or using one perform the same tasks, respectively. The only difference is the event that these methods (are supposed to) the expedition from the dataprovider. When the replaceItem or replaceItemAt method is called the DataProviderEvent. REPLACE_ITEM is (supposed to be) shipped. When the updatItem or updateItemAt method is called the DataProviderEvent. UPDATE_POINT is (supposed to be) shipped.

now, when I say supposed to, I mean that they do not ship these events right now. whenever the dataprovider is changed somehow the only event that is shipped is the DataProviderEvent. Event DATA_CHANGE . They have not worked around to use the rest of the types of events or they are just sticking with the only event DATA_CHANGE as an umbrella event, I don't know.

so for now, these methods do the same thing and even send the same event. but theoretically, they are supposed to send two different types of events, not the same one.

Here is a list of list of events of the dataprovider:

http://www.BlackBerry.com/developers/docs/airapi/1.0.0/QNX/UI/events/DataProviderEvent.html

hope that helps! Good luck!

Tags: BlackBerry Developers

Similar Questions

  • LCDS application on updateItem error

    Hi all

    I'm having a problem with LCD screens.
    My application is almost copied from the sample application echantillon8-> data management service. I can recover the data to the DataGrid in my MySQL server, but the update does not work. The object returned by the customer is not produced, but for some reason flex.messaging.io.amf.ASObject

    Here the correction of my application:
    Object type: flex.messaging.io.amf.ASObject
    Field1: private boolean flex.messaging.io.amf.ASObject.inHashCode
    Field2: private boolean flex.messaging.io.amf.ASObject.inToString
    field3: java.lang.String flex.messaging.io.amf.ASObject.namedType

    the same debugging for the application of echantillon8:
    Object type: flex.samples.product.Product
    Field1: private java.lang.String flex.samples.product.Product.name
    Field2: private java.lang.String flex.samples.product.Product.description
    field3: private java.lang.String flex.samples.product.Product.image
    Field4: private java.lang.String flex.samples.product.Product.category
    sphere5: private double flex.samples.product.Product.price
    case Field6: private int flex.samples.product.Product.qtyInStock

    so I get a classcastexception for the line in the ProductAssembler.java - function updateItem:
    Boolean success = service.update ((Product) newVersion);

    I think it's ok because the versionnew is not produced, but ASObject.

    But why the versionnew is ASObject and why not the product as in the sample application?

    THX

    I solved the problem... After days of coding...
    First of all, I forgot to add to my MXML file the tag to reference the Product.as, so the client returns the ASObject instead of product.
    After that, I got a stack overflow error. The problem is that I had the same name for Product.as and Product.mxml.
    Renamed the mxml and now the update works correctly.

    Happy coding!

  • GroupDataModel - update the Chronogram of loop without going through a row.

    Hello

    I need to update a child recordset within a GroupDataModel. At first, I update the selected record, but there may be a notebook of the child requiring an update of data in order to take account of the appropriate user interface.

    So I loop trought all of my folders and find those corresponding, but the problem I do face is updateItem() method requires a row position. I guess I have to build the path to the index? Or y at - it another way to update the corresponding records?

      // Extract all records
      QList records = m_dataModel->toListOfMaps();
    
      // Loop and start looking for any possible match
      for (int i = 0 ; i < records.size(); i++)
      {
        QVariant record = records.at(i);
        QVariantMap map = record.toMap();
    
        if ()
        {
          map["myField"] = QVariant("Updated Record");
          // UpdateItem requires an indexPath... but since I'm looping throught       // each item the indexPath is unknown.      //m_dataModel->updateItem(indexPath, itemMap);
        }
      }
    

    OK, thanks for the pointer... I did some research some of the example project, but @ the end I found this thread...

    https://supportforums.BlackBerry.com/T5/native-development/GroupDataModel-how-to-find-an-item-and-GE...

    ... and @ there end, I used this approach:

      // Extract all records  QList records = m_dataModel->toListOfMaps();
    
      // Loop and start looking for any possible match  for (int i = 0 ; i < records.size(); i++)  {    QVariant record = records.at(i);    QVariantMap map = record.toMap();
    
        if ()    {      // Search for this matching record...      QVariantMap matchMap;      matchMap["Field1"] = map.value("Field1").toString();      matchMap["Field2"] = map.value("Field2").toString();      matchMap["Field3"] = map.value("Field3").toInt();      QVariantList indexPath = m_dataModel->lowerBound(matchMap);
    
          // Now that we have determined the index path, we must update the record...      QVariantMap itemMap = m_dataModel->data(indexPath).toMap();      itemMap["FieldToUpdate"] = QVariant("Updated Record"));      m_dataModel->updateItem(indexPath, itemMap);    }  }  
    
  • How to upgrade an item in the ListView ListItemComponent

    Hello

    I have a ListView that uses an ArrayDataModel and a ListItemComponent to display a list of items. One of the elements which is display is a photo that takes place is specified as a URI.  In some cases, this URI is empy and I need to go out and scratch a few location data in real time.  Within the netscrape2:nEffectuer slot, I am trying to take this new found data (URL location to the new location of the photo) and replace it in my ListView. ListItemComponent...

    Any help would be greatly appreciated.  Thanks in advance...

    Container {
                leftPadding: 10.0
                rightPadding: 10.0
                topPadding: 40.0
                ListView {
                    function scrapePicture( ExternalUrl, source, mListItemIndexPath )
                    {
                        console.log("Start Search scrapePicture(): " + ExternalUrl );
                        console.log("Start Search scrapePicture() Index: " + Index );
                        netscrape2.scrapeSite(ExternalUrl, source, mListItemIndexPath );
                    }
                    id: searchListView
                    dataModel: searchDataModel
                    listItemComponents: [
                        ListItemComponent {
                            id: listComponentSearchResultsListItem
                            type: ""    // I do this because its Array datamodel
                            SearchResultsListItem {
                                title: ListItemData.Title
                                pubDate: ListItemData.TimeStamp + " - " + ListItemData.Location
                                previewImage: ( ListItemData.PreviewImage == "" ) ? ListItem.view.scrapePicture( ListItemData.ExternalUrl, ListItemData.Source, ListItem.indexPath ) : ListItemData.PreviewImage
                            }
                        }
                    ]
                    onTriggered: {
                        console.log("Invoke Second Page");
                        var feedItem = searchDataModel.data(indexPath);
                        // invoke second page...
                    }
                    attachedObjects: [
                        ScrapeHttp {
                            id: netscrape2
                            onComplete: {
                                // this is where I want to replace the picture...
    
                                var data =  listComponentSearchResultsListItem.ListItem.view.dataModel.data(netscrape2.mListItemIndexPath);
                                console.log("netscrape2.data: " + data);
                                data.PreviewImage = netscrape2.adImageURL;
                                console.log("netscrape2.data2: " + data);
                                listComponentSearchResultsListItem.ListItem.view.dataModel.replace(0, data);
                            }
                        }
    
                    ]
                } // end of ListView
    

    Why all this way?

    listComponentSearchResultsListItem.ListItem.view.
    

    The above code is only necessary when you want to access the data of ItemComponent, but you try to change DataModel.

    You must change the value in your DataModel, in your case, its ID is searchDataModel. No what you have to do is something like this in your onComplete:

    var tmpData = searchDataModel.data(indexPath);
    tmpData.PreviewImage = netscrape2.adImageURL;
    searchDataModel.updateItem(indexPath, tmpData);
    

    Now I don't know what is ScrapeHttp, but it sounds like a weird way of this row.

    netscrape2.mListItemIndexPath
    
  • Error "Index out of range" on search query

    I have a configuration of search query to clear my listview and insert new results of the query in the listview. The code looks like this:

    {OnDataLoaded}

    _APP. Clearlist

    root. ListView.insertlist (Data)

    }

    {OnQueryChanged}

    Load();

    }

    But unfortunately, whenever I do a query, and as a result appears my query update (triggered from a contextual menu) does not work and gives me the error "Index out of range". Even if the results of the query to fill listview very well and when I tap on a result it shows all data fine as well.

    And FYI the update query does not work when the list is not be searched or filtered so I don't think that there is a problem with my function.

    What I am doing wrong?

    He solved.  The problem is that the update function trying to remove and add the updated item within the filtered datamodel causing problems.  I just got the datamodel to load before performing the functions as described below:

    bool App::updateObject(const QString &id, const QString &name, const QString &description, const QString &datefield, const QString &lat, const QString &lon, const QString &categoryfield, const QString &mapurl, const QString &itempic)
    {
        bool updated = false;
        bool saved = false;
    
    //    if (!validateID(id))
    //        return false;
    
        Location *location = new Location(id, name, description, datefield, lat, lon, categoryfield, mapurl, itempic);
    
        // Find location in the datamodel.
        // Only the id is used by find(). This is because location
        // defines equality (==) as having the same id. (See the definition of "=="
        // in the location class.)
        const QVariantList updateIndexPath = m_dataModel->find(location);
    
        // update the item if found
        if (updateIndexPath.isEmpty()) {
            alert(tr("Object ID not found."));
            updated = false;
        } else {
            load();
            updated = m_dataModel->updateItem(updateIndexPath, location);
        }
    
        // Save the datamodel if we updated something.
        if (updated) {
            m_storage->deleteFromDB(id);
            saved = m_storage->save(m_lastCustomerID, m_dataModel);
            load();
            refreshGroup();
    
        }
    
        return (updated && saved);
    }
    
  • How QMetaObject::invokeMethod solved: no method bb::cascades:QmlListView error?

    Hi all

    When I try to call QMetaObject::invokeMethod at that time where I get error below.

    "QMetaObject::invokeMethod: no such bb::cascades:QmlListView:detailNews (QVariant) method.

    Down here I have attached a code please check and let me know how I can fix this issue?

    ApplicationUI.cpp

    NewsList.cpp

    #include "applicationui.hpp"
    
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    
    using namespace bb::cascades;
    using namespace bb::data;
    
    QString getValueByKey(QVariant qVariant, QString qStrKey);
    QString getValueByKey(QVariant qVariant, QString qStrPath, QString qStrKey);
    QVariantList getListByPath(QVariant qVariant, QString qStrPath);
    
    ApplicationUI::ApplicationUI(bb::cascades::Application *app) :
            QObject(app), root(0)
    {
        // prepare the localization
        m_pTranslator = new QTranslator(this);
        m_pLocaleHandler = new LocaleHandler(this);
    
        bool res = QObject::connect(m_pLocaleHandler, SIGNAL(systemLanguageChanged()), this,
                SLOT(onSystemLanguageChanged()));
        // This is only available in Debug builds
        Q_ASSERT(res);
        // Since the variable is not used in the app, this is added to avoid a
        // compiler warning
        Q_UNUSED(res);
    
        // initial load
        onSystemLanguageChanged();
    
        // Create scene document from main.qml asset, the parent is set
        // to ensure the document gets destroyed properly at shut down.
        /* QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
    
         // Create root object for the UI
         AbstractPane *root = qml->createRootObject();
    
         // Set created root object as the application scene
         Application::instance()->setScene(root);*/
        QmlDocument *qmlLoadingDialog = QmlDocument::create("asset:///LoadingDialog.qml").parent(this);
        dialogLoading = qmlLoadingDialog->createRootObject();
        languageLocalList = languageList();
        home_Page();
    }
    
    void ApplicationUI::onSystemLanguageChanged()
    {
        QCoreApplication::instance()->removeTranslator(m_pTranslator);
        // Initiate, load and install the application translation files.
        QString locale_string = QLocale().name();
        QString file_name = QString("Godfessions_%1").arg(locale_string);
        if (m_pTranslator->load(file_name, "app/native/qm")) {
            QCoreApplication::instance()->installTranslator(m_pTranslator);
        }
    }
    
    void ApplicationUI::home_Page()
    {
        QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
        //QmlDocument *settingqml = QmlDocument::create("asset:///Setting_Page.qml").parent(this);
        qml->setContextProperty("app", this);
        root = qml->createRootObject();
        m_newListView = root->findChild("newsListView");
        root->setParent(this);
        Application::instance()->setScene(root);
    
        showLoadingDialog();
        getCategories("12143");
        newsListWebServices("12143");
        closeLoadingDialog();
    }
    
    void ApplicationUI::detailNews(QString news_Id)
    {
        qDebug() << "Detail News Get" << news_Id;
    }
    
    /** * Prepared by :- Umang Shah * **/#include "NewListItem.hpp"
    
    #include #include #include #include #include #include #include #include 
    
    using namespace bb::cascades;
    
    NewListItem::NewListItem(ListView * listView) : CustomControl(0){ this->listView = listView; QmlDocument *qml = QmlDocument::create("asset:///CustomRowNewsList.qml").parent(this); root = qml->createRootObject(); m_newsName = root->findChild

    It also seems that you have an incorrect class here.  You are detailNews method is in your ApplicationUI class, but you are trying to call on the ListView, not your ApplicationUI object.

    I recommend having a read through our documentation of signals and Slots , which should help you to achieve what you're trying to do.

  • Nasty problem with resizing a list and a class custom CellRenderer

    Create a list (_myList) in a class with a custom CellRenderer class. In the custom CellRenderer class, I draw a rectangle with a gradient in the data() function:

    override public function set data (value:Object) : void
    {
        super.data = value;
    
        var tab_color:Array = this.data.rowColor;
        ...
        _matrix.createGradientBox(this.width, this.height, 90/180*Math.PI);
    
        with (_sprTab.graphics)
        {
            clear();
            beginGradientFill(GradientType.LINEAR, [tab_color[0], tab_color[1], tab_color[2]], [alpha,alpha,alpha], [0,127,255], _matrix);
            drawRoundRectComplex(0, 0, this.width, this.height, 15, 0, 15, 0);
            endFill();
        }
        ...
    }
    

    When policy changes I want to resize the list. Therefore, in a function in the class in which the list is created, I resize the list:

    public function setListSize (w:Number, h:Number) : void
    {
        _myList.setSize(w, h);
    }
    

    And this function is called with the new dimensions on the change of orientation in the main class.

    However, this.width in the custom CellRenderer class does not get the new width of list a reason any.

    No idea why?

    You must refresh the visible items in the list. You can loop through the list and replaceItem (...) of the call and who should do it. You can check that it would work by scrolling through the list of invisible items and they should have picked up the new width.

  • State assets ListItemListener behavior

    I had problems tracking the active status of an item in my list, to keep highlighted.

    In fact, when the user clicks on the element, it is activated after a short period, then when the user slides his finger from the element to over the ActionSet who appeared, the signals of ListItem enable with the parameter 'activate' set to false, and my list item is not (because I put it no, since it is the only signal I can listen to determine its is no longer be pressed).

    However, I saw in the documentation it should probably not the case:

    A list item is "active" while a user is actively pressing the list item or when the item is target for a context menu operation. Once released, or when no longer a context menu target, the item is no longer active. With a StandardListItem, the active visual will have a outline around the item border.
    

    documentation "ListItemListener".

    Activate with 'false' when the user runs the attached menu present my object should not call States and should be inactive when the user is the navigation menu, and releases their finger (which is the behavior I want).

    I have a suspicion that the cause of this is because I you join the ActionSet ListItemListener class itself, but to the ListView. Can someone confirm that it is why it's more treated as active, because the ListView has the ActionSet attached, not the ListItemListener?

    I really don't want to rewrite the code to the ActionSet and move it to a new place, if I do not, but if it will solve this problem, it is well worth.

    I attach ActionSet point in ListItemProvider updateItem() and connect actions to the slots of the element.

    Following is a work of one of my projects. I hope that helps:

    void MovableMenuListItemProvider::updateItem(ListView* list, VisualNode *listItem, const QString &type,
                    const QVariantList &indexPath, const QVariant &data)
    {
        Q_UNUSED(list);
        Q_UNUSED(type);
        Q_UNUSED(indexPath);
    
        MenuDataItem *menuData = data.value();
        MovableMenuListItem *item = static_cast(listItem);
    
        item->setTitle(menuData->getTitle());
        item->setDescription(menuData->getDescription());
        QString image = menuData->getImageSource();
        if (!image.isEmpty())
            item->setImageSource(image);
        else
            item->resetImageSource();    item->removeAllActionSets();
        int childCount = list->dataModel()->childCount(QVariantList());
        //qDebug() << "childCount=" << childCount << ", index=" << indexPath.front().toInt() << "\n";
        item->setDataModel(qobject_cast(list->dataModel()));
        item->setIndexPath(indexPath);
        item->addActionSet(ActionSet::create()
            .title(menuData->getTitle())
            .subtitle("Please choose an action")
            .add(ActionItem::create()
                 .imageSource(QUrl("assets/images/icons/upArrowIcon.png"))
                 .onTriggered(item, SLOT(moveUp()))
                 .enabled(!indexPath.isEmpty() && indexPath.front().toInt() > 0)
                 .title("Move Up"))
            .add(ActionItem::create()
                 .imageSource(QUrl("assets/images/icons/downArrowIcon.png"))
                 .onTriggered(item, SLOT(moveDown()))
                 .enabled(!indexPath.isEmpty() && indexPath.front().toInt() < childCount-1)
                 .title("Move Down"))
            .add(DeleteActionItem::create()
                 .onTriggered(item, SLOT(removeFromFavorites()))
                 .title("Remove as Favorite"))
        );
    }
    
  • Update of GroupDataModel list item for the lazy loading

    I have a ListView of StandardListCompoenet that is created with a GroupDataModel in C++.

    Mail, click on a button, I have to change the text content of a row in the ListView based on the number of line typed by the user in a text box.

    Goes according to the GroupDataModel API - updateItem(indexPath,QVariantMap), it can be done, I am able to build to get the row.

    There is a ListView (QVariantList) trigger method - which refers to the row of the item selected by the user.

    Since, in my code, I don't have the numero_index of the line of the user, is there a way I can build the "row" to "updateItem" of my code itself.

    Or should there be any other strategy that should be chosen instead?

    Found the solution,

    the key is to start finding the QVariantList (s) of the dataModel-> first()

    and then to reach the destination by comparing the values of data.

    Then, it would take to build a data path it would be identical to that received by trigger (QVariantList)

  • Custom list item changes when you click

    I'm having a strange problem.

    When my list of messages is filled first, she checks a property in the json data to see if the message is 'read' or 'unread '. If it is "no read", it will be a different color than those who are already "read" to indicate to the user.

    It works very well, however I added an action context to the list, and when this action is triggered, I'm changing the message "unread". If the color of the list item to change. This works.

    However, after I changed the color of a single item in the listwhen I do scroll down and down, many elements change color. I think it has to do with the rendering of the list of recycling.

    This behavior does not occur after that list first initializes. Regardless of the colors have been queued to initialize their place. Only after that I have an amendment to one of the elements in the list, things go crazy when I scroll. I hope I'm being clear.

    How can I stop this from happening?  This is the code that changes the color of the label in my custom list item.

     listItemComponents: [
                                ListItemComponent {
                                    MessageListItem {
                                        id: messagesListItem
                                        contextActions: ActionSet {
                                            ActionItem {
                                                title: "Mark Unread"
                                                onTriggered: {
                                                    if (messagesListItem.isNew == false) {
                                                        var selectedItem = ListItemData;
                                                        messagesListItem.isNew = true; //property of list item is changed to unread
                                                    }
                                                }
                                            }
                                        }
    

    And inside the MessageListItem.qml

    property bool isNew: ListItemData.data.new
    
       onIsNewChanged: {
            if (isNew == true) {
                subjectLabel.textStyle.color = Color.create("#FF4500");
            } else {
                subjectLabel.textStyle.color = Color.create("#000000");
            }
        }
    

    Please let me know if you have any questions, any help or suggestion is appreciated. Thank you!

    Hello!

    I think that it doesn't because you are not changing 'new' dataModel element variable. In addition, assigning directly control isNew breaks property DataModel is bound to it.

    It should work if you change the dataModel instead.

    An important point to note, however, that it is not possible to change the individual variables of dataModel point. You need to replace the entire item. The code example for GroupDataModel: (not tested, so may require tweaks, tell me please if you need help in getting this work):

    onTriggered: {
      var selectedItem = ListItemData  // get a copy of dataModel's item
      selectedItem.new = !selectedItem.new  // modify it's property
      messagesListItem.ListItem.view.dataModel.updateItem(indexPath, selectedItem) // update the model
    }
    

    For ArrayDataModel, the function is named differently.

    In addition, this line seems suspicious:

    property bool isNew: ListItemData.data.new
    

    Probably, it should be replaced by this one:

    property bool isNew: ListItemData.new
    
  • What signal is emitted in the ListView, when one of its cells appears in or from the screen turns off?

    What signal is emitted in the ListView, when one of its cells appears in or from the screen turns off?

    I created listView with custom listItemComponents

    Is there any signal when listItemComponent go to the screen?

    Currently, it is not possible to detect if the cells turns off the screen. Even if you join LayoutUpdateHandler them they will just stop send updates when you go off the screen. I managed to hack a solution using a timer, but I guess that a cleaner approach would more use a ScrollView with CustomControls instead:

    1. get the dimensions of the ScrollView joining ScrollView LayoutUpdateHandler.

    2. attach the LayoutUpdateHandlers to the CustomControls.

    UPD: It is also viewableArea & viewableAreaChanged event scrollView property.

    3. If the controls that were inside the visible area of the ScrollView went outside, raises the event.

    Of course re-use of cell works that way.

    It's so easy to grab the cell on the screen:

    If you use ListItemProvider, updateItem() function is called when the element appears on the screen:

    https://developer.BlackBerry.com/Cascades/reference/bb__cascades__listitemprovider.html

    It will also be called if the data item are updated in the model.

    When the item is created for the first time, createItem() is called.

  • Loop on the life list

    How can I loop over alistview I have?

    and make a difference in this asyncrhonusly. like here, I want to access the imageview to set the image once that I get them from a certain url.

      ListView {
                layout: StackListLayout {
                    orientation: LayoutOrientation.LeftToRight
                }
                flickMode: FlickMode.SingleItem
                objectName: "customList"
                id: customList
                listItemComponents: [
    
                    ListItemComponent {
    
                       Container {
                           preferredWidth: ListItemData.width
                           Container {
                               background: Color.create("#52c1b1")
                               layout: StackLayout {
    
                               }
                               layoutProperties: StackLayoutProperties {
                                   spaceQuota: 1
                               }
                               horizontalAlignment: HorizontalAlignment.Fill
                               Label {
                                   text:  ListItemData.fieldName
                                   topMargin: 15
                                   horizontalAlignment: HorizontalAlignment.Center
                                   textStyle.color: Color.White
                               }
                               ImageView {
                                   bottomMargin: 15
                                   id: imageFlyer
                                   objectName: "imageFlyer"
                                   horizontalAlignment: HorizontalAlignment.Center
                                   scalingMethod: ScalingMethod.AspectFit
                               }
                           }
                           Container {
                               layout: StackLayout {
    
                               }
                               layoutProperties: StackLayoutProperties {
                                   spaceQuota: 1
                               }
                           }
    
                       }
                    }
                ]
            }
    

    Hi babakar,.

    It depends on the type of the DataModel associated with your ListView. To update an element in a GroupdDataModel for example, you call a function updateItem .

  • Unable to restore the ImageView ListComponent - image of the data folder

    I downloaded an image in the folder data and want to show it in the listView.

    In Listcomponent, I use an ImageView

    "If I put its imagesource:".. /.. /.. "/ data/files/images/123.png".

    The image appears correctly.

    But if I try to put the same path of C++ code in the GroupDataModel, the image doesn't make.

    Hi friends,

    I found the solution. I hope that is useful you.

    . HPP

     

    #include 
    #include 
    #include 
    
    using namespace bb::cascades;
    
    class App: public QObject {
    Q_OBJECT
    
    public:
        App();
    
    public slots:
        void onSelectionChanged(const QVariantList indexPath, bool selected);
    
    private:
        ListView *listView;
    
    };
    

    . CPP

    #include "app.hpp"
    
    #include 
    #include 
    
    #include 
    
    #include 
    #include 
    #include 
    #include 
    #include 
    
    using namespace bb::cascades;
    
    App::App() {
        QmlDocument *qml = QmlDocument::create("main.qml");
        AbstractPane *root = qml->createRootNode();
    
        GroupDataModel *model = new GroupDataModel(
                QStringList() << "firstname" << "surname" << "imagepath");
        model->setGrouping(ItemGrouping::ByFirstChar);
    
        listView = root->findChild("listView");
    
        QVariantMap person;
        person["firstname"] = "John";
        person["surname"] = "Mark";
        person["imagepath"] = "I will set on click.";
        model->insert(person);
        person["firstname"] = "Mark";
        person["surname"] = "Russie";
        person["imagepath"] = "asset:///icon.png";
        model->insert(person);
    
        listView->setDataModel(model);
    
        QObject::connect(listView,
                SIGNAL(selectionChanged(const QVariantList, bool)), this,
                SLOT(onSelectionChanged(const QVariantList, bool)));
    
        Application::setScene(root);
    }
    
    void App::onSelectionChanged(const QVariantList indexPath, bool selected) {    if (selected) {        if (sender()) {            GroupDataModel *stampModel =                    (GroupDataModel *) listView->dataModel();            QVariantMap map = stampModel->data(indexPath).toMap();            //map["imagepath"] = "asset:///icon.png";            map["imagepath"] = "../../../data/icon.png";            stampModel->updateItem(indexPath, map);            fprintf(stderr, "\nSelection Called");        }    }}
    

    . QML

     

    import bb.cascades 1.0
    
    Page {
        content: Container {
            ListView {
                objectName: "listView"
                listItemComponents: [
                    ListItemComponent {
                        type: "header"
                        HeaderListItem {
                            title: ListItemData
                        }
                    },
                    ListItemComponent {
                        type: "item"
                        StandardListItem {
                            id: root
                            title: ListItemData.firstname
                            description: ListItemData.surname
                            imageSource: ListItemData.imagepath
                        }
                    }
                ]
            }
        }
    }
    

    Currently, I put a static image and a rest black. It will have the value during the click on list black image (dynamically).

  • Using a single XML tag for ListView

    Hi all

    I try to fill my ListView with a series of specific tags from my XML file. For example, using this XML file:

    For what it's worth, this is how I solved this:

    1. Add a class ListItemProvider based in your project:

    class ViewerListItemManager: public bb::cascades::ListItemProvider
    {
    public:
        ViewerListItemManager();
    
        VisualNode * createItem(ListView* list, const QString &type);
    
        void updateItem(ListView* list, bb::cascades::VisualNode *listItem,
                const QString &type, const QVariantList &indexPath, const QVariant &data);
    };
    

    2. implementation of the new class:

    ViewerListItemManager::ViewerListItemManager()
    {
    }
    
    VisualNode * ViewerListItemManager::createItem(ListView* list, const QString &type)
    {
        Q_UNUSED(list);
    
        if (type.compare(GroupDataModel::Header) == 0) {
            return new Header();
        } else {
            return new StandardListItem();
        }
    }
    
    void ViewerListItemManager::updateItem(ListView* list, bb::cascades::VisualNode *listItem,
            const QString &type, const QVariantList &indexPath, const QVariant &data)
    {
        Q_UNUSED(list);
        Q_UNUSED(indexPath);
    
        if (type.compare(GroupDataModel::Header) == 0) {
            QString caption = data.value();
            static_cast(listItem)->setTitle(caption);
        } else {
            QVariantMap map = data.value();
            static_cast(listItem)->setTitle(QString("%1").arg(map["firstname"].toString()));
        }
    }
    

    3 assign the ListItemProvider to your list:

    groupDatamodel = new GroupDataModel();
    XmlDataAccess xda;
    QVariant list = xda.load(QDir::currentPath()+"/data/employees.xml", "/root/employee");
    
    groupDatamodel->insertList(list.value());
    listView = new ListView();
    ViewerListItemManager *viewerItemProvider = new ViewerListItemManager();
    listView->setListItemProvider(viewerItemProvider);
    listView->setDataModel(groupDatamodel);
    
  • Error with ListItemProvider - undefined reference to build

    I'm tying to add a ListItemProvider for my project, but without success.

    If I add the following class extends from ListItemProvider to my project, it fails to build - this from the log from the console:

    "o-g/.obj/TripListItemProvider.o.rodata._ZTV20TripListItemProvider [_ZTV20TripListItemProvider](+0x3c): refers to 'TripListItemProvider::updateItem(bb::cascades::ListView*, bb::cascades::VisualNode*, QString const&, QList const&, QVariant const&)' the undefined".

    I tried recreating it from scratch and comment on different things.  I can build OK, if I comment out the function updateItem call, but that's really what I want to use, that kind of defeats the purpose of the ListitemProvider.

    I tried to recreate a number of times and also different levels of SDK.  If I drop the class in a sample as Battambang, island generation fails in a similar way.  But if I have him drop it into C++ Cookbook sample, it compiles OK.  I compared to the building, in particular the included libraries and can not see the difference.  I don't know there is a, only I don't know where to look.

    Any help gratefully received.

    TIA.

    /*
     * TripListItemProvider.cpp
     *
     */
    
    #include "TripListItemProvider.h"
    
    using namespace bb::cascades;
    
    TripListItemProvider::TripListItemProvider() {
        // TODO Auto-generated constructor stub
    
    }
    
    TripListItemProvider::~TripListItemProvider() {
        // TODO Auto-generated destructor stub
    }
    
    bb::cascades::VisualNode * TripListItemProvider::createItem(ListView* list, const QString &type) {
        return NULL;
    }
    
    void updateItem(ListView* list, VisualNode *listItem, const QString &type, const QVariantList &indexPath, const QVariant &data) {
    }
    
    /*
     * TripListItemProvider.h
     *
     */
    
    #ifndef TRIPLISTITEMPROVIDER_H_
    #define TRIPLISTITEMPROVIDER_H_
    
    #include 
    // #include 
    // #include 
    // #include 
    // #include 
    
    using namespace bb::cascades;
    
    class TripListItemProvider: public ListItemProvider {
    public:
        TripListItemProvider();
        virtual ~TripListItemProvider();
    
        bb::cascades::VisualNode * createItem(bb::cascades::ListView* list, const QString &type);
        void updateItem(ListView* list, VisualNode *listItem, const QString &type, const QVariantList &indexPath, const QVariant &data);
    
    };
    
    #endif /* TRIPLISTITEMPROVIDER_H_ */
    

    Hey there...

    My guess would be

    /*
     * TripListItemProvider.cpp
     *
     */
    
    void TripListItemProvider::updateItem(ListView* list, VisualNode *listItem, const QString &type, const QVariantList &indexPath, const QVariant &data) {
    }
    

Maybe you are looking for

  • Problem with iTunes on Windows 10 12.4.1-

    Recently upgraded iTunes to version 12.4.1 and now my older iPod (a classic and a Nano) will not be synchronized.  New devices (iPhone, iPod Touch etc.) seem to be good, but older devices show as 'corrupt' attempts to restore the iPod do not seem to

  • Driver for Dell 3100cn el capitan

    Hello I guess I can use PostScript for IP base for my Dell 3100cn color laser printer network on my new macbook pro El Capitan 10.11.2 but is there a more specific? I use the installer of MFP color Dell 1355 by the suggestion of someone. BTW, how to

  • X 1 carbon - Micro SDHC

    Hello I have X 1 carbon Type 3443. Is it possible to use scandisk micro SDHC? In past (other laptops), I could use the USB to play. Thank you Boushaki

  • My F4135 printer cannot scan and print from a copy

    With the help of windows xp I can't copy a scan and print

  • (Redirected) HitmanPro suspicious file warning

    I have an old desktop Dell Inspiron subject of one year.  I use HitmanPro to virus protection.  Today I got this message and I was wondering if anyone could tell if it's dangerous. C:\WINDOWS\system32\DRIVERS\igdkmd64.sysSize: 6 389 688 bytes... Age: