String bounded to the listview
I have a property string delimited in a qml which I want to display in the form of a simple list in qml.
I tried arraydatamodel without success.
Any help will be appreciated.
Thank you
Mukesh
Looks like OP is having 2 numbers, or is not quite explain his problem. Since the original post, I thought the same thing as @radwon and believed that OP wanted to build a dataModel off delimited string. But her reply, I think he's trying to access this delimited string of its ListItemComponent, which cannot be done directly, but need to access from its ListView using ListItem.view
Here is a screenshot of the official ListView docs indicating that
Maybe the OP maybe specify exactly what he must do.
Tags: BlackBerry Developers
Similar Questions
-
Pass a variable value set to the selector to the Listview
This was probably picked several times on the forum, but I'm going crazy with research and try to do things with my code.
Everything I'm doing is to expose the variable rssmobileEnabled defined in the SELECTOR, so that I can go and test it in my LISTVIEW onSelectedValueChanged IF statement, according to the code below.
I did the variable in "BOLD" below to indicate. This must be a simple solution, after all how it can be difficult to just define a global variable...
The SELECTOR code:
Picker { id: picker title: "Select Feed" dataModel: XmlDataModel { source: "models/blackberry.xml" } pickerItemComponents: [ PickerItemComponent { type: "rsslink" content: Container { layout: DockLayout { } Label { multiline: false text: pickerItemData.text textStyle { base: SystemDefaults.TextStyles.SubtitleText } } } } ] onSelectedValueChanged: { var rsslinktext = (dataModel.data([ 0, picker.selectedIndex(0) ]).text); var rsslink = (dataModel.data([ 0, picker.selectedIndex(0) ]).rssSource); var rsslinkquery = (dataModel.data([ 0, picker.selectedIndex(0) ]).rssQuery); var rssmobileEnabled = (dataModel.data([ 0, picker.selectedIndex(0)]).mobileEnabled); //Load the selected feed dataSource.load(); } } // Picker
Code of the LISTVIEW:
ListView { id: myListView // Associate the list view with the data model that's defined in the // attachedObjects list dataModel: dataModellist layout: StackListLayout {} listItemComponents: [ ListItemComponent { id: header type: "header" //"item" //custom components used instead of standardlistitem Container { Label { id: emptytextheader text: "" } } }, ListItemComponent { id: item type: "item" //"description" Container { layout: DockLayout {} //custom components used instead of standardlistitem Container { id: itemdetails Label { id: title text: ListItemData.title //textStyle.fontWeight: FontWeight.Bold multiline: true textStyle.color: Color.Cyan } Label { id: pubdate text: ListItemData.pubDate textStyle.color: Color.create("#ff00c200") textStyle.fontSize: FontSize.XSmall } Label { id: description text: ListItemData.description textStyle.fontSize: FontSize.Small multiline: true textStyle.color: Color.Yellow maxHeight: 130.0 } } } } ] onTriggered: { var feedItem = dataModel.data(indexPath); var page = detailsPage.createObject(); if (rssmobileEnabled == "y") { ..... } } }
Hello
"var rssMobileEnabled" declares a local variable, is not available in onTriggered.
Declare it as a property instead:
TopLevelItem { property bool rssMobileEnabled (or 'property string' if it's a character)
reference it without prefix "var":
rssMobileEnabled =...
You can also declare the property on another element (not necessarily higher level) and reference it by id:
elementId.rssMobileEnabled
-
"Index was outside the bounds of the array"
Hello
I installed ESXi to my home server to test and get to know the software, but I ran into a problem.
When I try to deploy a new virtual machine or to change the settings, I get a message saying "Index was outside the bounds of the array".
I have no problem from vSphere, creating a new data store and so on.
But the funny thing is, when I try another account that I have no problem...
At the moment I have installed:
ESXi
version 4.0.0
Generation 5044850
vSphere
version 4.0.0
Generation 496403
vSphere is installed on a computer, Windows 8.
And the logfile viclient says:
2013-07-21 16:55:33.103 [viclient:SoapTran] invoke Start 38, RetrieveContents on PropertyCollector: ha-property-collector [10.0.0.250]. [Appellant: VirtualInfrastructure.PropertyRetriever.InvokePropertyGet]
[viclient:SoapTran] 2013-07-21 16:55:33.118 invoke RetrieveContents on PropertyCollector 38 finish: ha-property-collector [10.0.0.250] - series: 0.001, server: 000.024
[: ShowExcp] 16:55:35.879 2013-07-21 System.IndexOutOfRangeException: Indeksen var utenfor matrisegrensen.
ved VMware.CustomControls.NumericUpdownEx... ctor()
ved VMware.CustomControls.DiskCapControl.InitializeComponent)
ved VMware.CustomControls.DiskCapControl... ctor()
ved VpxClient.VMConfig.BWzVDiskCapPage.InitializeComponent)
ved VpxClient.VMConfig.BWzVDiskCapPage... ctor (TocWizard myBoss)
ved VpxClient.VMConfig.NWz... ctor (NWzModes m)
ved VpxClient.Common.UiCommands.VirtualMachine.NewOrImportVM (import Boolean, forceVmtn Boolean, entity, Service iService ManagedEntity)
Stack trace:
at VirtualInfrastructure.Utils.Log.Trace (String, String, traceCategory)
to VpxClientCommon.Util.Dialogs.ShowException (IWin32Window, String, Exception)
at VpxClientCommon.Util.Dialogs.ShowException (Exception)
VpxClient.Common.UiCommands + VirtualMachine.NewOrImportVM (ManagedEntity, Boolean, Boolean)
at VpxClient.GettingStarted.HostHtmlView.CreateVM)
...
at System.Windows.Forms.Application.Run)
concerning
Thomas Isaksen
Hello
Have you checked this post?
Kind regards
Julien.
-
I have try change item in the ListView. But ListView refreshed only after add a new point.
How can I refresh the ListView?
My code:@Override public void start(Stage stage) throws Exception { buildForm(stage); stage.show(); } //-------------------------------------------- void buildForm(Stage stage) { BorderPane root = new BorderPane(); Scene scene = new Scene(root, 800, 650); stage.setScene(scene); items.add(new SimpleStringProperty("1")); i++; items.add(new SimpleStringProperty("Line" + i)); i++; list.setItems(items); root.setCenter(list); HBox buttons = new HBox(); root.setBottom(buttons); Button buttonChange = new Button("Change"); buttonChange.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { String value = items.get(0).get(); if(value.length() == 1) items.get(0).setValue("-1"); else items.get(0).setValue("1"); //not refresh } }); Button buttonAdd = new Button("Add item"); buttonAdd.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { items.add(new SimpleStringProperty("Line" + i)); i++; //refresh } }); buttons.getChildren().addAll(buttonChange, buttonAdd); }
?
-
Analyzes the string and extract the string delimiter
Hello
Basic questions. Is this possible with the scan of regular expression of the string to extract the string that are in the specified delimiters. Here is an example:
Name of the \\Name of the folder 1\Name to the folder 2\Name to the folder 3\File
Chain analysis can produce the following by specifying the regular expression on the right:
1 folder name
Name of the folder 2
Name of the folder 3
File name
I tried \\\%s\\%s\\%s\\%s but the %s stops on the first white space.
Thank you
Michel
RavensFan suggested the service appropriate for your condition, but you can also use an alternative, which is "spreadsheet of array of strings.
-
I have a string of arbitrary length - say, 1AB1C0 - normal format. I would like to have a function that takes this string in and generates the same accurate, but in hexadecimal characters. If the entry will read 1AB1C0 in the normal string format, and the output will read 1AB1C0 as a hexadecimal string.
I'm doing this because I found that the terminal works better if I send the bytes string hexadecimal vs as an array of U8. Furthermore, I handle a lot of byte stream in my program and I find the chain tools less cumbersome to use against the array of bytes to analysis of analysis tools - however, they operate only on strings as they appear in normal mode. So I have reasons in different parts of my program to have the channel under conditions normal vs formats hexadecimal; but I can't understand anyway elegant remotely to cast from one to the other.
CraigRem wrote:
If the entry will read 1AB1C0 in the normal string format, and the output will read 1AB1C0 as a hexadecimal string.
Well, you must sweep the bytes of the string formatting hexagonal two at a time for a digital U8 and then cast to a string. There are several ways to do it, here are the two possibilities. (Sure to use the correct representation as Mkae labels).
(I still don't understand your reasoning why you need).
-
Doc XML to a string fails when the string length is greater than 512 bytes.
I have been using the following code to write an XML string. If the resulting string is lower to ~ 512 bytes, the string will be created, if > ~ 512 bytes, the routine does not create the string. Assuming that the doc contains an XML document:
Doc CVIXMLDocument = 0;
HDoc MSXMLObj_IXMLDOMDocument = 0;...
cvistatus = CVIXMLSaveDocument (doc, 0, "Test1.xml");
status = CVIXMLGetDocumentActiveXHandle(doc, &hDoc);)hRlt = MSXML_IXMLDOMDocumentGetxml (hDoc, & errInfo & strXml);
The SaveDocument routine still works, the XML file contains the XML, regardless of their size.
The Getxml routine creates only the XML string in strXml when the length of the string is lower to ~ 512 bytes.
Does anyone have an idea of the problem?
Because the string is very long, the ICB debugger cannot display. That's why I was wondering if you were trying to print using put or printf. Because the return value is 0 and the ERRORINFO is also stating the success, I would recheck the chain by printing it to the console or a file.
-
Index is outside the bounds of the array with bcs
I used the bcs connection to connect to Sql server 2008 r2. I developed the code in visual studio 2010 with model. I tested with 3000 data that he was working.
After that I change the data of 50,000 records
It is giving errorMethodInstance with name "ReadList" on the entity (external content Type) with the name "Entity" in the Namespace "Entity.BdcModel1" unexpected failure. The failure occurred in the "ReadList" method defined in the class "Entity.BdcModel1.EntityService" with the message "Index was outside the bounds of the array.".
Update status DocuSign envelopes/_layouts/images/DocuSignFeatureReceiver/DSIcon16x16.gif{SiteUrl}/_layouts/DocuSignSharePointIntegration/DocuSignSend.aspx?userRequest=UpdateEnvelopeStatus&ItemId={ItemId}&ListId={ListId}&ItemURL={ItemUrl}&onFinishURL={Source}0 x 00 x 0List15502300View in Web browser_layouts/VisioWebAccess/VisioWebAccess.aspx? ListGuid = {ListId} & ItemId = {ItemId} & DefaultItemOpen = 10 x 00 x 1File typeVDW255Details of complianceJavaScript:commonShowModalDialog ('{SiteUrl} /_layouts/itemexpiration.aspx?ID= {ItemId} & list = {ListId} ',' Center: 1; dialogHeight:500px; dialogWidth:500px; resizable: Yes; status: no location: No.; menubar:no; help: No. ', function GotoPageAfterClose (pageid) {if (pageid == 'hold') {STSNavigate(unescape(decodeURI('{SiteUrl}'))+'/_layouts/hold.aspx?ID={ItemId}&List={ListId}'}); return false ;} if (pageid == 'audit') {STSNavigate (unescape (decodeURI ('{SiteUrl}')) +'/_layouts/Reporting.aspx? Category = audit & backtype point = & ID = {ItemId} & list = {ListId} ");" return false ;} (Si_(pageid_==_'config') {STSNavigate(unescape(decodeURI('{SiteUrl}'))+'/_layouts/expirationconfig.aspx?ID={ItemId}&List={ListId}'); return false ;}}, null); Returns false;0 x 00 x 1ContentType0x01898Change in the browser/_layouts/images/icxddoc.gif/_layouts/FormServer.aspx? XsnLocation = {ItemUrl} & harvested = browser & Source = {Source}0 x 00 x 1File typexsn255Change in the browser/_layouts/images/icxddoc.gif/_layouts/FormServer.aspx? XmlLocation = {ItemUrl} & harvested = browser & Source = {Source}0 x 00 x 1ProgIdInfoPath.Document255Change in the browser/_layouts/images/icxddoc.gif/_layouts/FormServer.aspx? XmlLocation = {ItemUrl} & harvested = browser & Source = {Source}0 x 00 x 1ProgIdInfoPath.Document.2255Change in the browser/_layouts/images/icxddoc.gif/_layouts/FormServer.aspx? XmlLocation = {ItemUrl} & harvested = browser & Source = {Source}0 x 00 x 1ProgIdInfoPath.Document.3255Change in the browser/_layouts/images/icxddoc.gif/_layouts/FormServer.aspx? XmlLocation = {ItemUrl} & harvested = browser & Source = {Source}0 x 00 x 1ProgIdInfoPath.Document.4255View in browser/_layouts/xlviewer.aspx?ID={ItemUrl}&DefaultItemOpen=10 x 00 x 1File typexlsx255View in browser/_layouts/xlviewer.aspx?ID={ItemUrl}&DefaultItemOpen=10 x 00 x 1File typexlsm255View in browser/_layouts/xlviewer.aspx?ID={ItemUrl}&DefaultItemOpen=10 x 00 x 1File typexlsb255Set Version HistoryJavaScript:SP. USER INTERFACE. ModalDialog.ShowPopupDialog ('{SiteUrl} /_layouts/DocSetVersions.aspx?) List = {ListId} & ID = {ItemId} ")"0 x 00 x 0ContentType0x0120D520330Send in the other placeJavaScript:GoToPage('{SiteUrl}/_layouts/docsetsend.aspx? List = {ListId} & ID = {ItemId} ")"0 x 00 x 0ContentType0x0120D520350I do the connection for the 15 million documents. So please advise me on the connection of BCS.
Thank you
Hello
Your Windows question is better suited in the TechNet forums. You can follow the link to your question:
http://social.technet.Microsoft.com/forums/en-us/category/SQLServer/ -
Specific text of color in the listview element
Hello
I have in my application:
ListView { id: myListViewAya dataModel: dataModelAya listItemComponents: [ ListItemComponent { type: "item" id: listItemComponent_Aya Container { // background: Color.create("#75b5d3") Label { id:label_Aya text: ListItemData.id textStyle.color: Color.Blue } }// end of Container } // end of ListItemComponent ] // end of listItemComponents list }end of ListView
I want the text 'label_Aya' (the second element in the listview) and all other elements of color in 'red '.
Blue
Please help me
Thank you very much
as it works well:
ListView { id: myListViewAya dataModel: dataModelAya listItemComponents: [ ListItemComponent { type: "item" Container { id: listItemComponent_Aya // background: Color.create("#75b5d3") Label { id:label_Aya text: ListItemData.id textStyle.color:(listItemComponent_Aya.ListItem.indexPath[1] == 1) ? Color.Red : Color.Blue } }// end of Container } // end of ListItemComponent ] // end of listItemComponents list }end of ListView
Thank you thank you thank you...
-
Scrolling of the ListView in the end does not work
Hi, when creating completed page, I add items to listview and scrolltoposition (end, smooth) but it does not work. How can I auto-scroll down entering the page?
It's almost a year, but it was the first match in google for my problem.
I solved it by changing the orientation of my layout of the ListView and the sort order of my model.
ListView { layout: StackListLayout { orientation: LayoutOrientation.BottomToTop } }
-
Highlight the item selected in the ListView
Hello guys,.
I have a list view and you want to highlight the element select when I click on it, for all clicked items.Thank you.
esam_tec wrote:
Hello guys,.
I have a list view and you want to highlight the element select when I click on it, for all clicked items.Thank you.
There are different ways to do
eg.:
in your container of ListItem:
background: ListItem.selected || ListItem.active ? Color.Magenta : Color.Transparent
in your onTriggered of the ListView:
// select line myListView.select(indexPath, true)
Remember, if your work has been done:
// clear the selection myListView.clearSelection()
-
To access the values from the row outside the ListView ListItem
Hello
I spent two hours browsing the forums and documentation with no chance of finding a solution on how to access the list item data from outside the listview.
Let explain me my code. It is marked with I work and what does not work and its expected behavior.
Should work behavior
Tapping & getting dataThe arrayDataModel is filled with 4 rows. Firstly the list item, second item in the list... etc.
- Tapping on the order of the day, label with the id of triggeredText displays the value of a threaded list item.
- The index of the tapped icon appears in the label with the id of triggerredIndex.
Incrementing Index using ActionItems onBar
By pressing action items 'previous' and 'next', you can increment the index value to the label with the id of triggeredIndex. The order of the index is 0-4, even as total of the items in the list.
How to extract data from the index when the value of triggeredIndex?
Buttons
The buttons at the bottom of the screen... Select 1, select the 2nd, 3rd Select should select indexes 0,1,2 of the list and display the value in triggeredText and triggeredIndex. They do not work.
How did I pull the values when you click the buttons?
import bb.cascades 1.3 TabbedPane { id: root showTabsOnActionBar: false Tab { id: mainTab title: "Test List" Page { id: mainPage titleBar: TitleBar { title: "List Traversal Test" } actions: [ ActionItem { title: "Previous" ActionBar.placement: ActionBarPlacement.OnBar onTriggered: { // get current selected index from list= var currentIndex = parseInt(triggeredIndex.text); if(currentIndex <= 0){ //do nothing already at first item }else{ // subtract 1 from index ( ci - 1) ? var newIndex = parseInt(triggeredIndex.text) - 1; // show data from new selected index // ??? // triggeredItem.text = XXX // the data // ??? // triggeredIndex.text = X // the current index triggeredIndex.text = newIndex; } } }, ActionItem { title: "Next" ActionBar.placement: ActionBarPlacement.OnBar onTriggered: { // get current selected index from list= var currentIndex = parseInt(triggeredIndex.text); if(currentIndex == 4){ //do nothing already at lastitem }else{ // add 1 to index ( ci + 1) ? var newIndex = parseInt(triggeredIndex.text) + 1 // show data from new selected index // ??? // triggeredItem.text = XXX // the data // ??? // triggeredIndex.text = X // the current index triggeredIndex.text = newIndex; } } }, ActionItem { title: "Clear" ActionBar.placement: ActionBarPlacement.OnBar onTriggered: { // set current index to 0 (top item in list) } } ] Container { preferredHeight: maxHeight layout: StackLayout { orientation: LayoutOrientation.TopToBottom } Label{ id: triggeredItem // value of listitem from current index text: "0" } Label{ id: triggeredIndex // current index text: "0" onTextChanged: { // set triggeredItem.text to contents of selected ListItem with same index // STUCK HERE cannot access ListItem.dataModel(indexPath) from here.... } } Container{ ListView { id: theList objectName: "dalist" dataModel: ArrayDataModel { id: theListModel } listItemComponents: ListItemComponent { StandardListItem { id: itemRoot title: ListItemData } } onTriggered: { var si = dataModel.data(indexPath); triggeredItem.text = "LIST ITEM CONTENT: " + si; //set content when user taps on item triggeredIndex.text = "LIST ITEM INDEX INDEX: " + indexPath; // set index when user taps } onSelectionChanged: { //console.log(selected); } onCreationCompleted: { //add some data to the listview theListModel.append("First List Item"); theListModel.append("Second List Item"); theListModel.append("Third List Item"); theListModel.append("Fourth List Item"); } } } Container{ layout: StackLayout { orientation: LayoutOrientation.LeftToRight } Button{ text: "Select 1st" onClicked: { theList.clearSelection(); theList.select(0); } } Button{ text: "Select 2nd" onClicked: { theList.clearSelection(); theList.select(1); } } Button{ text: "Select 3rd item" onClicked: { //expected behaviour is to show data from Third List Item // triggeredIndex.text = INDEX 3 // triggeredText.text = (DATA FROM THIRD LIST ITEM) // THIS IS NOT WORKING .... theList.clearSelection(); theList.select(2); console.log(theList.dataModel(3)); triggeredItem.text = theListModel.dataModel(3); } } } } } }//tab }
Thank you and have a happy and healthy 2015!
Your help will be greatly appreciated.
I ran and got this:
asset:///main.qml:161: TypeError: Result of expression 'theList.dataModel' [bb::cascades::ArrayDataModel(0x1091a838)] is not a function.
But it works
theListModel.data([3])
But this isn't the solution, you have a more serious problem. You select a value, you trigger. If you add this in onTriggered you select it (and you can see that it changes color when it is selected).
theList.select(indexPath);
If you want to use option to deselect
theList.select(indexPath, !theList.isSelected(indexPath));
And if you want to have that one chose this
theList.clearSelection(); theList.select(indexPath);
Inside the button 'Select the 3rd point' allows to select programmatically
theList.select([2]);
It works but I'm not sure what you're trying to do
-
How to apply filters to the Listview created using GroupDataModel?
Hello
I have created a listview with groupdatamodel, now I want to apply filters for listview. How to do this?
Please help me. (As looking for contacts)
Kind regards
Naresh Kodumuri.
Hello
I found the solution for the application of filters to the listview.
-
[Explanation necessary] Clears the listview data and fill it again with new data
Hello
I correctly filled a listview in c ++, data analysed and does interesting things with it. However, I am drunk stumbling, unable to find a way delete and repopulate my display of the list...
- How can after I insert data in the list view, I clear the list data and run again the same method (init) who populated the list view with the data in the first place?
Here are the docs that I referenced and I don't understand how to implement the methods in my code.
QList - clear() method
https://developer.BlackBerry.com/Cascades/reference/QList.html#clear
Using the data access Code, example
data_access/using_data_sourceGroupDataModel - Clear()
https://developer.BlackBerry.com/Cascades/reference/bb__cascades__groupdatamodel.html#clear
CODE
Here is my code - filling of the display of the list of C++ and display of data in a ListView.MyApp.cpp
MyApp::MyApp(bb::cascades::Application *app) : QObject(app){ // create scene document from main.qml asset // set parent to created document to ensure it exists for the whole application lifetime QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this); AbstractPane *root = qml->createRootObject
(); qml->setContextProperty("yoyo",this); //grab references list_view = root->findChild ("listView"); // set created root object as a scene app->setScene(root); mNetworkAccessManager = new QNetworkAccessManager(this); bool result = connect(mNetworkAccessManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(requestFinished(QNetworkReply*))); Q_ASSERT(result); Q_UNUSED(result); json = new QFile("data/file.json"); } void MyApp::init(){ QNetworkRequest request = QNetworkRequest(); // i call some service here mNetworkAccessManager->get(request); } void MyApp::requestFinished(QNetworkReply *reply){ qDebug() << reply->error(); qDebug() << reply->errorString(); if (reply->error() == QNetworkReply::NoError) { qDebug() << "No error"; QByteArray data = reply->readAll(); if (!json->open(QIODevice::ReadWrite)) { qDebug() << "Failed to open file"; return; } json->write(data); bb::data::JsonDataAccess jda; QVariantMap results = jda.loadFromBuffer(data).toMap(); QVariantList lst = jda.loadFromBuffer(data).toList(); GroupDataModel *m = new GroupDataModel(); m->insertList(lst); m->setGrouping(ItemGrouping::None); if(list_view) list_view->setDataModel(m); }else{ showDialog("Boo",reply->errorString()); } } MyApp.hpp
// Tabbed pane project template #ifndef MyApp_HPP_ #define MyApp_HPP_ #include
#include #include #include #include #include namespace bb { namespace cascades { class Application; } } namespace bb { namespace data { class Application; } } /*! * @brief Application pane object * *Use this object to create and init app UI, to create context objects, to register the new meta types etc. */ class MyApp: public QObject { Q_OBJECT public: MyApp(bb::cascades::Application *app); virtual ~MyApp() { } Q_INVOKABLE void init(); private slots: void requestFinished(QNetworkReply *reply); private: QNetworkAccessManager *mNetworkAccessManager; QNetworkRequest *request; QFile *json; bb::cascades::ListView *list_view; }; #endif /* MyApp_HPP_ */ hand. QML
import bb.cascades 1.0 Page{ Container { background: Color.White ListView { id: listView preferredHeight: maxHeight objectName: "listView" listItemComponents: [ ListItemComponent { type: "item" Container { Container { Label { text: ListItemData.id } } } } ] onTriggered: { console.log("selected_index: " + indexPath) } horizontalAlignment: HorizontalAlignment.Center verticalAlignment: VerticalAlignment.Center } } }
Question 2:
How reference to the ListView object with the name "listView" in different parts of the MyApp.cpp file? Is there anything else I should add to the header file to make the accessible listView?
Question 3:
What happens when you call the clear() method? How the data model is affected? How the user interface is affected? What happens in memory?
Question 4:
How do you verify that the data in the list has been deleted so that you can go ahead and fills again with new data? What is the cheque that I perform?
I would also like to know how you manage multiple views of lists and data sources in your applications. Best practices or ideas?
Thank you
I was able to clear the listview with the following code, if anyone is interested.
listView.dataModel = null
The dataModel must be set to "null".
-
How to refresh the Listview after adding a new item
Hello
I have the following list:
ListView { id: channelsList dataModel: categoryModel listItemComponents: [ ListItemComponent { type: "item" StandardListItem { title: ListItemData.name // Channel name imageSource: ListItemData.imageFile status: ListItemData.id id: channelItemId contextActions: [ ActionSet { //title: contentView.title ActionItem { title: "Add to Favorites" onTriggered: { console.log(ListItemData.id + " will be added to the Favorites"); //categoryModel.addFavorite(ListItemData.name, ListItemData.imageFile, ListItemData.id); channelItemId.ListItem.view.viewTriggered(ListItemData.name, ListItemData.imageFile, ListItemData.id); } } } ] } } ] onTriggered: { var chosenChannel = dataModel.data(indexPath); console.log("indexPath: " + indexPath); var playingPage = playpagedef.createObject(); playingPage.chname = chosenChannel.name; playingPage.cid = chosenChannel.id; playingPage.init(); Qt.nav.push(playingPage); } attachedObjects: [ // The bucket categoryModel is a non visible object so it is set up as an attached object. // The categoryModel itself is a QListDataModel defined in categorymodel.h and registered // as a type in the creation of the application. CategoryModel { id: categoryModel // The path to the JSON file with initial data, this file will be moved to // the data folder on the first launch of the application (in order to // be able to get write access). jsonAssetPath: "models/channels.json" // The filtering is initially set to "Category 1" to show category channels filter: label.text }, ComponentDefinition { id: playpagedef source: "PlayingPage.qml" } ] function viewTriggered(name, imageFile, id) { categoryModel.addFavorite(name, imageFile, id); categoryModel.clear(); } }
and the categoeymodel.h is as follows:
#ifndef _CATEGORYMODEL_H #define _CATEGORYMODEL_H #include
#include #include #include using namespace bb::data; // The category categoryModel is based on the QListDataModel template, which in turn // implements the abstract DataModel class. typedef bb::cascades::QListDataModel CategoryListModel; /* CategoryModel Description: * * CategoryModel class for the Category List application, the data categoryModel * reads and write from a JSON file that keeps all item data * for the list. */ class CategoryModel: public CategoryListModel { Q_OBJECT Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged) Q_PROPERTY(QString jsonAssetPath READ jsonAssetPath WRITE setJsonAssetPath NOTIFY jsonAssetPathChanged) public: /** * Constructor that sets up the recipe * @param parent The parent Container, if not specified, 0 is used */ CategoryModel(QObject *parent = 0); ~CategoryModel(); QString filter(); void setFilter(const QString filter); QString jsonAssetPath(); void setJsonAssetPath(const QString jsonAssetPath); signals: void filterChanged(QString filter); void jsonAssetPathChanged(QString jsonAssetPath); public slots: void addFavorite(QString channelName, QString channelImageFile, int channelId); private: bool jsonToDataFolder(); // Property variables QString mFilter; QString mJsonAssetsPath; QString mJsonDataPath; // A list containing all data read from the JSON file QVariantList mData; //Invocation variables bb::cascades::Invocation* mInvocation; }; #endif // ifndef _CATEGORYMODEL_H My problem is that the listview is not get automatically updated when a new item is added to the datamodel (a favorite channel is added). I have to exit the application and restart to see the updated list.
categoryModel.addFavorite(name, imageFile, id); categoryModel.clear();
categoryModel.clear ();
does not work. I get:
Asset: / / / hand. QML:180: TypeError: result of expression 'categoryModel.clear' [undefined] is not a function.
I would like to know how to achieve using approach "more correct".
QListDataModel does not expose its internal storage directly. It is possible to reconstruct the map by performing an iteration in a loop (with the help of data() and size() methods), the dataModel entries:
http://developer.BlackBerry.com/Cascades/reference/bb__cascades__qlistdatamodel.html
but I don't see how this could help. If the filtered data is changed, it must be merged with the original sort data.
Why the original approach has not worked?
I could not understand from the description appearance of the interface user, please post a screenshot if possible.
Maybe you are looking for
-
Hello quick start windows 8.1 on this tablet cannot be disabled, that is, the tick cannot be rid of equipment/control panel and power sound/Options/System Settings / settings/turn on (recommended) quick start stop. Is it possible to remove the tick a
-
Satellite A300D-13R: battery is not 100%
Satellite A300D-13R: the battery become not complete. Why? Post edited by: Sy
-
Broken left hinge on Satellite Pro A40 - need part number
Can anyone help? I broke the left hinge on my A40. I can't find anywhere to get a replacement and I don't know where I can find the part No. so I don't know, I get the right one. Does anyone not know the part. and where I can buy a hinge?
-
entry point not found qtcore4.dll
does anyone know how and where to load .dll files, the files qtcoree.dll and qtsql4.dll to launch software programs open source?
-
Can not do a homegroup between PC w / Win 7 and laptop w / Win 8
I have a router with wireless capabilities and my PC is connected to it and my laptop is wireless and internet connections are large. I had a successful homegroup before but I had to unplug my PC to clean/redesign for the new office. Now, I can 'cr