Re-use of custom list Designer

Hello

I created a custom to change the itemType of my lists. I would like to do something similar to the example of decorator list (except with different queres) but I was wondering if I can reuse the custom itemType that I created. The example uses the database itself to check the "is_group" (activate the element type), but I really don't want to cluter upward from my database in this way (TOC)...

QString GroupArtistDataModelDecorator::itemType(const QVariantList& indexPath) {
        QVariant data = bb::cascades::datamanager::DataModelDecorator::data(
                indexPath);
        if (data.isValid()) {
            QVariantMap map = data.value<QVariantMap>();
            int isGroup = map["is_group"].toInt();
            // Verifies that this data item is of group and returns the new type.
            if (isGroup) {
                return QString("group");
            }
        }
        return QString("");
    }

Is there a way around it that I might be able to use the card [' ""] to filter the data, and using a switch statement, return an itemType on this basis?

What would be the most effective way to do it?

Is it also possible to add a parameter, for example

QString GroupArtistDataModelDecorator::itemType(const QVariantList& indexPath, string itemTypeParameter)

And then call it in QML:

* I hope I'm not being too imaginative here.

Or y at - it no other choice than to create individual datamodels customized for different model types?

Thanks in advance!

I see no reason why you can't use a switch in the method of itemType rather than add a new field to your DB. Here's a possible scenario for implementation.

Define the subcategory structure in the GroupArtistDataModelDecorator.hpp header file:

    struct SugCategory
    {
        enum Type {
              News = 0,
              Technology = 1,
              Sports = 2,
              ...
        };
    };

And in the itemType method, you can use a switch that activates cases based on the map ["category"] m:System.NET.SocketAddress.ToString () for example

QString GroupArtistDataModelDecorator::itemType(const QVariantList& indexPath) {     QVariant data = bb::cascades::datamanager::DataModelDecorator::data(                indexPath);
     SubCategory::Type category_case;     if (data.isValid()) {         QVariantMap map = data.value();         QString category = map["category"].toString();

         if(category=="News") category_case = SubCategory::News;
         else if(category=="Technology") category_case = SubCategory::Technology;
         else if(category=="Sports") category_case = SubCategory::Sports;
         ....

         switch(category_case)
        {
         case SugCategory::News:
             return QString("News");
             break;

        case SugCategory::Technology:
             return QString("Technology");
             break;

         case SugCategory::Sports:
             return QString("Sports");
             break;

         .....

         default:
             break;
}

Tags: BlackBerry Developers

Similar Questions

  • Accessing the context property of main.qml to a custom list in a file item separate qml

    Hi all

    Sorry if this is already covered somewhere.

    I currently have an application with a list view in my main.qml.  I put a context property for my class app c ++ to be "app" in my main.qml.  My list uses a custom list item that is defined in a file separate qml.  The custom list item has a popup menu.  In this context menu, I want to call Q_INVOKABLE functions that are part of my class from the main application in C++.  What is the best way to be able to do?  Should I just set the context property on my file qml of list item custom like I do with my main.qml or is there a better way?

    Thank you

    I think that this has been repeated several times, but as it is not really intuitive:
    a listitemcomponent lies in a different context, it cannot access the context property of the qml file.
    You can use the reference to the listview to reach outside, see https://developer.blackberry.com/cascades/reference/bb__cascades__listview.html ListItem.view

  • implementation of custom list

    Hi all

    I came across an exercise and I don't know how to do in this regard. It's the first part of the exercise:

    'Create a generic class to a list of oneway named SList, which (for the sake of simplicity) will NOT implement the interface from the list. Each item in the list in the form of a link object must contain a reference to the next element, but NOT hold a reference to the previous item. »

    So, as far as I understand, I'm supposed to set up a custom list in any other way as the use of Collections. I know I could use a table and build a list on it, but the exercise does not say a word on the tables, instead it tells an object to link to the next item. So I think I should put up a sort of chain-link-list. But still, I need to store these objects link somewhere somehow. In the case of a table not then where, how?

    Or: It is possible to create some sort of list of string, based on the link objects that just point to the next element, it does not back up what anyone, I mean otherwise it backs up by a table or any collection? How to make guys go about it?

    So far, I have this class of link, but I don't know how to create a custom on that list:
    class Link {
    
        private Link next;
        //here possibly: private Object contained; so that a Link can actually hold something    
    
        Link() {}
        
        Link(Link next) {
            this.next = next;
        }
        
        public void setNext(Link next) {
            this.next = next;
        }
        
        public Link getNext() {
            return next;
        }   
    }
    Thank you

    PR.

    'Create a generic class to a list of oneway named SList, which (for the sake of simplicity) will NOT implement the interface from the list. Each item in the list in the form of a link object must contain a reference to the next element, but NOT hold a reference to the previous item. »

    (...) Is it possible to create some sort of list of string, based on the link objects that just point to the next element, it does not back up what anyone, I mean otherwise it backs up by a table or any collection? How to make guys go about it?

    Yes, storage of the following link, if any, within each link object.

    So far, I have this class of link, but I don't know how to create a custom on that list:

    It seems that you are halfway already done: o)

    I guess that your class SList is supposed to provide methods ( insert(), getFirst() getlast(),... )?
    Then, simply define the SList class that contains one (and only one) link object. All other link objects are accessible from the first.

    Some design notes:
    -Your link class is package-private visibility (so is not not supposed to be used from outside the package, I guess the same package as SList is in). This sounds great, but then why are public methods? If the data in the list are accessible by the rest of the program, only through the SList class, you can do all the methods of the class link private or package-private (no keyword accessibility before the method's return type)

    -Although it is reasonable to have the SList class provide the 'logic' (course, insertion,...), who can also be implemented in the class Link itself, mainly through the recursive calls. Do not take this into account, I wouldn't confuse you - but I suspect that it's perhaps later in the year.

    Good luck with Java.

    J.

  • Use of custom in Veristand files

    Hi all

    Have not been able to find a lot of documentation related to the use of "Personal files" in Veristand.  I would like to know some examples of the types of files users have set up.  Specifically, I would like to know if you can "call" some types of models or devices personalized (i.e. for databases or configuration settings).

    Thank you very much

    GSinMN

    Hi GSinMN,

    It has custom there some documentation in the help of VeriStand, which deals specifically with files.

    Adding custom files

    http://zone.NI.com/reference/en-XX/help/372846D-01/VeriStand/add_custom_files/

    Although aid is not quite fully reveal the capabilities of this feature. There are two distinct use cases that I could identify for the custom in VeriStand files option. I'm going to the list of people the more detail and show you an example.

    Make easily accessible to the driver files in the development environment.

    When a file is added in the custom files in the project section, it will have its own icon in the project and is included in the project dependencies. Having the file to display in the project is useful if there is a picture of troubleshooting or a specific document (calibration sheet, how to run a test, etc.) that you would like as your operator to have access to. For example, in the sample project, I realized, there is an added file called "TestA1_PreTestSetup.txt". Of the project (on the toolbar), the operator has the option "Open a file" (to view) or "export...". "to investigate his path on the computer of the operator.

    Please note that the file is now added to the dependencies of the project.

    If you start to investigate the project file and lets say you do a right click on it and notice that there is a Properties option. You may notice that the Description of this file is empty. In fact, it can be filled by modifying the XML source of the .nivsproj. It also leads in the second case of the use of custom files.

    Transferring files to the aim of RT which can be used by the VeriStand engine.

    If you were to investigate the .nivsproj XML, you could first find the section of the custom files, then the tags of the element that you configured.

    Here are the relevant tags and a jump down,

    -It points to the source of the custom file. In this case, I added the file in the directory "C:\Users\Public\Documents\National Instruments\NI VeriStand 2011\Test procédures". He is able to solve the first component 'In common Doc Dir' because it's the common directory for VeriStand, and he added then the folder of the test procedures and the name of the file that I created.

    -Fill this tag gives us the opportunity to complete the description information that occurs when we right click on the file in the project.

    -Fill this tag gives you the ability to also send the file to the target deployment. Your VeriStand engine can then access this file during the operation. With respect to the types of files that you want to use, the link in the post above should help guide only.

    Please Note: change the XML of the project offers more customization and functionality of your project, but these changes should not be made whole. An incorrect change tags in the XML file can lead to results and poor execution. Then move forward with caution and only make minor changes at the same time.

    I hope this helps. Have a nice day, GSinMN

  • view the json data in the custom list field

    Hi, I did analysis json and I created the custom list field. Now, I want to display only the data analyzed in my custom list field. I'll post my analyzed data from json and here is the code for my custom list field
    data analyzed.
    I have THREE channels of json and I want to show content tittle and date in the list filed. I'll post the screenshot of my list.

    JSONArray jsnarry = new JSONArray(responce);
                System.out.println("\n--length----- "+jsnarry.length());
                //System.out.println("....................................................=");
                for (int i = 0; i < jsnarry.length(); i++){
    
                    JSONArray inerarray = jsnarry.getJSONArray(i);
                        //System.out.println("\n-inerarray-values----- "+inerarray.getString(i1));
                        String TITTLE = inerarray.getString(1);
                        String CONTENT = inerarray.getString(2);
                        String DATE = inerarray.getString(3);
                                                           System.out.println("TITTLE= "+TITTLE);
                        System.out.println("CONTENT= "+CONTENT);
                        System.out.println("DATE= "+DATE);
    
    }
    

    output

    [0.0] --length----- 2
    [0.0]
    [0.0] -innerarray-length----- 6
    
    [0.0] TITTLE= BJP State President Sanjay Tandon's visit to Amita Shukla's Home
    [0.0] CONTENT=  BJP President Chandigarh Sanjay Tandon at Amita Shukla's Home
    [0.0] DATE= 2013-01-04
    [0.0] ................................................
    [0.0] TITTLE= Sanjay Tandon at mahasamadhi of Satya Shri Sai baba.
    [0.0] CONTENT= BJP Chandigarh President, Sanjay Tandon mahasmadhi of Sri Satya Sai Baba.(Andhra Pradesh)
    [0.0] DATE= 2013-01-13
    

    and my custom list field

           super(NO_VERTICAL_SCROLL);
    
             String TITTLE="TITTLE";
             String CONTENT = "CONTENT";
             String DATE = "DATE";
    
             v.addElement(new ListRander(listThumb, TITTLE, CONTENT,DATE, navBar));
    
             myListView = new CustomListField(v){
    
                 protected boolean navigationClick(int status, int time) {
                     //Dialog.alert(" time in milisec :" + time);
                     return true;
                 }
             };
    

    CustomListField.java

    public class CustomListField extends ListField implements ListFieldCallback {
    
        private Vector _listData;
        private int _MAX_ROW_HEIGHT = 100;
    
        public CustomListField (Vector data) {
    
            _listData = data;
            setSize(_listData.size());
            setSearchable(true);
            setCallback(this);
            setRowHeight(_MAX_ROW_HEIGHT);
    
        }
    
        public int moveFocus (int amount, int status, int time) {
    
            this.invalidate(this.getSelectedIndex());
            return super.moveFocus(amount, status, time);
    
        }
    
        public void onFocus (int direction) {
    
            super.onFocus(direction);
    
        }
    
        protected void onUnFocus () {
    
            this.invalidate(this.getSelectedIndex());
    
        }
    
        public void refresh () {
    
            this.getManager().invalidate();
    
        }
    
        public void drawListRow (ListField listField, Graphics graphics, int index, int y, int w) {
    
            ListRander listRander = (ListRander)_listData.elementAt(index);
            graphics.setGlobalAlpha(255);
            graphics.setFont(Font.getDefault().getFontFamily().getFont(Font.PLAIN, 24));
            final int margin =5;
    
            final Bitmap thumb= listRander.getListThumb();
            final String listHeading = listRander.getListTitle();
            final String listDesc= listRander.getListDesc();
            final String listDesc2= listRander.getListDesc2();
            final Bitmap nevBar = listRander.getNavBar();
    
            //list border
            graphics.setColor(Color.BLACK);
            graphics.drawRect(0, y, w, _MAX_ROW_HEIGHT);
    
            graphics.drawBitmap(margin, y+margin+10, thumb.getWidth(), thumb.getHeight(), thumb, 0, 0);
    
            graphics.drawText(listHeading, 3*margin+thumb.getWidth(), y+margin);
            graphics.setColor(Color.BLACK);
    
            graphics.drawText(listDesc, 3*margin+thumb.getWidth(), y+ margin+30);
            graphics.drawText(listDesc2, 3*margin+thumb.getWidth(), y+ margin+60);
    
        }
    
        public Object get(ListField listField, int index) {
    
            String rowString = (String) _listData.elementAt(index);
            return rowString;
    
        }
    
        public int indexOfList (ListField listField, String prefix, int start) {
    
            for (Enumeration e = _listData.elements(); e.hasMoreElements(); ) {
    
                String rowString = (String) e.nextElement();
                if (rowString.startsWith(prefix)) {
    
                    return _listData.indexOf(rowString);
    
                }
    
            }
    
            return 0;
    
        }
    
        public int getPreferredWidth(ListField listField) {
    
            return 3 * listField.getRowHeight();
    
        }
    
    }
    

    Listrander.Java

    public class ListRander {}

    private bitmap listThumb = null;
    incognito bar Bitmap = null;
    private String listTitle = null;
    private String listDesc = null;
    private String listDesc2 = null;

    public ListRander (Bitmap listThumb, String listTitle, String listDesc, String listDesc2, Bitmap navBar) {}
    this.listDesc = listDesc;
    this.listDesc2 = listDesc2;
    this.listThumb = listThumb;
    this.listTitle = listTitle;
    this.navBar = bar navigation;
    }
    public getListThumb() {Bitmap image
    Return listThumb;
    }
    {} public void setListThumb (listThumb Bitmap)
    this.listThumb = listThumb;
    }
    public getNavBar() {Bitmap image
    return the navigation bar;
    }
    {} public void setNavBar (navigation bar of the Bitmap)
    this.navBar = bar navigation;
    }
    public String getListTitle() {}
    Return listTitle;
    }
    {} public void setListTitle (String listTitle)
    this.listTitle = listTitle;
    }
    public String getListDesc() {}
    Return listDesc;
    }
    {} public void setListDesc (String listDesc)
    this.listDesc = listDesc;
    }
    public String getListDesc2() {}
    Return listDesc2;
    }
    public void setListDesc2 (String listDesc2) {}
    this.listDesc2 = listDesc2;
    }
    }

    You seem to have two problems here and are confusing them.  You must break the problem into two parts

    (1) extract the data from the entry and create the objects you want to display

    2) display in a list, a set of objects.

    Let's get the sorted first premiera.

    I will suggest what to do here, but in practice, you might actually think about this yourself as part of the design phase of your application.  You should do this, not me, because then you will have all the information available.  At the present time, I have just what you said, which is not much.  So maybe what I'm telling you is not correct for your application.  Only you can decide that.  And be blunt here, you should have decided this before you start coding.  Do you want you could lead down the wrong path.  You must think of your application as a home - as the architect must design all the rooms, and how they will be built, before you start building the House.  You do not, then we are building the rooms on the fly.  Who knows if they will be fit at home?

    In this case, I think you need to create an object that represents each of the elements in the internal array of new data.  call this object

    NewsItem

    This object will have attributes, such as its title, content, date, the linked image and so on, each of whom have will get and set methods.  While you treat each inner element fetch you the associated entry and update the object.

    When you have finished the inner loop of processing, you now have a complete

    NewsItem

    Object, so you will add it to a collection, an array of NewsItem objects, call this _newsItems.  You will create it at the beginning - you know how many entries it takes because it is the number of entries in your outdoor table.

    So before you start to deal with JSON, create your table and the 'index' value of 0.

    Once you have created your Newsitem, add this in the table to the position 'index' and increment "index".

    And once you have analyzed all the JSON, you will have a complete picture.  This is part 1 finished!

    And note in your drawListRow, you are given a clue - that is the index in your tables in _newsItems.  So you can easily find which entry to view and display it correctly.  But it is part 2 and is a separate issue.

  • Question of width custom list.

    listItemComponents: [
                        ListItemComponent {
                            type: "item"
                            Container {
                                leftMargin: 5.0
                                topMargin: 5.0
                                layout: StackLayout {
                                    orientation: LayoutOrientation.TopToBottom
                                }
                                horizontalAlignment: HorizontalAlignment.Fill
                                Container {
                                    layout: StackLayout {
                                        orientation: LayoutOrientation.LeftToRight
                                    }
                                    horizontalAlignment: HorizontalAlignment.Fill
                                    Label {
                                        text: ListItemData.agencyName
    
                                        // Apply a text style to create a title-sized font
                                        // with normal weight
                                        multiline: true
                                        horizontalAlignment: HorizontalAlignment.Fill
                                        textStyle {
                                            base: SystemDefaults.TextStyles.TitleText
                                            fontWeight: FontWeight.Normal
                                        }
                                    }
                                    ImageView {
                                        imageSource: ListItemData.statusIcon
                                        verticalAlignment: VerticalAlignment.Center
                                        horizontalAlignment: HorizontalAlignment.Right
                                        preferredWidth: 32.0
                                    }
                                }
                                ProgressIndicator {
                                    fromValue: 100
                                    toValue: 0
                                    value: 50
                                    verticalAlignment: VerticalAlignment.Center
                                    horizontalAlignment: HorizontalAlignment.Left
                                }
                            }
                        }
                    ]
    

    Here, I have a custom list box. With a label on the left, a picture/icon on the right and a progress bar as to each item in the list.

    The problem is, I can't get the icon/image aligned right, it follows right after the text.

    That is to say.

    | This is a test X |

    | ------------------------------- |

    what I want

    | This is a test X |

    | ------------------------------- |

    Maybe my layout, I tried to add the horizontal fill everywhere, no change.

    You can fill a container with the background color to make sure that the external container takes the entire available width.

    If it doesn't, try setting preferredWidth (Infinity)

    HorizontalAlignment.Right won't work in LeftToRight in cause of a bug.

    There are several workarounds:

    -Use DockLayout. This is not very practical because can overlap, but for short strings (menus, etc), it can work. Here is an example in C++:

    http://supportforums.BlackBerry.com/T5/Cascades-development/list-item-image-size/m-p/2064721#M9602

    -Insert an empty container with .spaceQuota (1) between the left and right elements. Divide the right margin of the element left and the left margin of the right item in two (because the average container won't let not their margins overlap).

    PS Fill does not seem to work for StackLayout. Use rather preferredWidth/Height (Infinity).

  • Handle to the line on custom list

    I use the code in this page to display a custom list. The problem I have now is I want to handle each line onFocus event in the list to change its background color. No idea how to do?

    Hello

    You encounter method DrawListRow that you define the color as below

     public void drawListRow(ListField listField, Graphics g, int index, int y,
                int width)
        {
            if (g.isDrawingStyleSet(Graphics.DRAWSTYLE_FOCUS))
            {
                g.setColor(Color.RED);
            } else
            {
                g.setColor(Color.BLUE);
            }
    // then draw rect
    
                    g.drawRect(0, y, width, 80);
    //draw text in list
                    g.drawText("Blackberry", 90, y + 9);
             }
    

    ----------------------------------------------------------
    feel free to press the congratulations on the left side to thank the user who has helped you.
    Please mark as resolved messages if you found a solution.

  • Problem with custom VerticalFieldManager, custom list field Call Back

    I created a custom vertical field Manager and a custom list field. It works very well in JDE 6.0.But when I build the same code in JDE 4.5 it throws the error because the setExtent Sub protected method (int width, int jeight) that I used in my code is final in JDE 4.5.

    so I changed my sublayout custom implemented code in vertical field Manager method. Again, this works very well in JDE 6.0.When I have to generate in JDE 4.5 is not to throw any errors.but when I run my code

    the list field does not have focus.

    I added a text field and a list custom field to the Vertical Field Manager text field focus but custom list field does not receive the focus. And the confusing part is when I click on the arrow to the getSelectedIndex from the scope of the list is changing and when I print listfield is active or not is the wrong impression.

    What is bad code works fine in jde 6.0 but not in jde 4.5, please let me know what I need to do something.

    Me as the ListField focus, but is not in fact poster it seems.  Have you made a

    . getLeafFieldWithFocus()

    to see if indeed he has the focus?

    I think we will have to see the ListField code for help.

  • How to use the trial to design adobe? I was successful to install adobe download wizard

    How to use the trial to design adobe? I was successful to install adobe download wizard

    Once Adobe Download Assistant is installed, you can start at any time and choose a product to download at the bottom of the window. Updates list as new products will be available for download with Adobe Download Assistant.

    Please visit: http://helpx.adobe.com/x-productkb/policy-pricing/download-assistant-faq.html#main_How_do _ I_download_a_trial_version_of_Creative_Suite_or_Elements_software_

  • Insertion of the jpeg/png/gif images custom list styles

    Hello

    I create a list style. I want to use a custom as chip jpeg/png/gif image. Is it possible to do so. If Yes, how should I do that?

    Thank you

    Vinay

    It could be that useful...

    http://forums.Adobe.com/thread/494012?TSTART=0

  • Using a custom converter and textSelectedColor

    Hello

    I use a custom converter and try to figure out how I can capture/set some Label controls located in this converter using the textSelectedColor style property.

    I have a list control, and item converter is essentially this:

    < mx:Canvas >
    < mx:Label id = "someLabel" / >
    < / mx:Canvas >

    With a little more control, but this is the jist of it.

    When an item is selected in the list I want to change the color of the label, now, I tried a number of ways, but none that I like, for example, I can define a handler for the ListEvent.CHANGE and if(this == event.itemRenderer), but if you lose focus for a reason, it is not being updated I must add a focus Manager to... it seems just pirate.

    So my question is how can we check properly style changes in the list send down my item converter? Specifically, the textSelectedColor. Other styles like the alternatingItemColors, selectionColor, etc. work without custom code for it; BTW.

    Thanks for the help.

    -Justin

    Got understood it...

    Protected Overrides function updateDisplayList(unscaledWidth:Number,_unscaledHeight:Number):void
    {
    super.updateDisplayList (unscaledWidth, unscaledHeight);

    If (this.data! = null & this.parent! = null)
    {
    var c:Number = 0;
    var listOwner:List = List (this.owner);

    if(!this.) Enabled)
    {
    c = this.getStyle ("disabledColor");
    }
    Another yew (listOwner.isItemHighlighted (this.data))
    {
    c = this.getStyle ("textRollOverColor");
    }
    Another yew (listOwner.isItemSelected (this.data))
    {
    c = this.getStyle ("textSelectedColor");
    }
    on the other
    {
    c = this.getStyle ("color");
    }

    lblDate.setStyle ("color", c);
    lblInstructorName.setStyle ("color", c);
    lblCourseName.setStyle ("color", c);
    }
    }

  • How to customize the status of the selection of the converter of custom list item?

    I have a list item that uses a custom converter, implemented as a MXML component. When a list item is selected, I want to change the appearance of the text of the item, police characters and color and ideally located in the background of list item to a gradient rather than a solid color.

    How would I go to do this?

    See you soon
    Adam

    I think that should help:

    summer http://butterfliesandbugs.wordpress.com/2007/06/25/How-to-Know-when-my-itemRenderer-is-sel.

  • One of your filters uses a custom header that contains an invalid character.

    When I send an email, you receive the following error message:

    «One of your filters uses a custom header that contains an invalid character, such as ':', a nonprintable character, a non-ascii character or an 8-bit ascii character.» Please change the msgFilterRules.dat file, which contains your filters to remove characters not valid in your custom headers".

    It is followed by a message saying that the email was sent and saved despite the error.

    The problem occurred after the transfer to 10 Windows (from Win 7)

    I deleted all files msgFilterRules.dat and all filters, but the message persists.

    Any suggestions on what else to try?

    Thank you
    Ben

    Problem solved.

    After you delete all files/imap mail entries, the problem disappeared.

  • How can I clear the browser history when you use the custom settings for history?

    When my history option is set to "Use the custom settings for history", the options page has no link to "clear recent history". There was formerly a menu option, but that seems to be gone now with Firefox 29. Is my only option to access the dialog box, clear the history all to change the historical option to history to remember and then change it back? Is there another way to access the option erase history all?

    I think you can get the menu bar by pressing the ALT key. If you want to return permanently, click View > toolbars and check menu bar.

  • I wan to save my history Web sites, but my computer does not record. I go to tools &gt; options &gt; privacy and try to "save history", but it goes back to "use the custom settings for history"... I'm all down on those checked so it should save, but it do

    I wan to save my history Web sites, but my computer does not record. I go to tools > options > privacy and try to "save history", but it goes back to "use the custom settings for history"... I'm all down on those checked so it should save, but it doesn't.

    Thank you for taking the time to help me!

Maybe you are looking for