GroupDataModel how to search for an item and row

Hi all!

I have a problem with GroupDataModel.

I create and fill out the template as below:


m_model = new GroupDataModel(QStringList() << "displayName", this);
...
QVariantMap entry;
entry["contactId"] = QString::number(contact->getId());
entry["displayName"] = contact->getDisplayName();
entry["icon"] = contact->getSmallPhoto();

m_model->insert(entry);

After I cath some report like contactDeleted (int id) and want to remove the related item of the model:

void ContactsViewModel::onContactDeleted(int id)
{
  //QVariantList indexPath = m_model->lowerBound(QVariantList() << QString::number(id));
  //QVariantList indexPath = m_model->lowerBound(QVariantList() << id);
  //QVariantList indexPath = m_model->find(QVariantList() << QString::number(id));
  QVariantList indexPath = m_model->find(QVariantList() << id);

  if (!indexPath.isEmpty())
  {
    m_model->removeAt(indexPath);
  }
}

But model will always return row to the first article! I used and GroupDataModel::find and GroupDataModel::lowerBound, but result is still the same!

Please help me, how can I find point correct?

Hello

My understanding of the documentation, it is possible to search only the fields that are in sortingKeys.

I think that GroupDataModel is the construction of indexes on these areas.

I did some tests:

If displayName is present in sort keys:

    GroupDataModel *model = new GroupDataModel(QStringList() << "displayName", this);

    QVariantMap entry;
    entry["contactId"] = "100";
    entry["displayName"] = "Alex";
    entry["icon"] = "icon1.png";
    model->insert(entry);

    entry["contactId"] = "200";
    entry["displayName"] = "Andrew";
    entry["icon"] = "icon2.png";
    model->insert(entry);

then by displayName will work correctly:

QVariantList indexPath = model->find(QVariantList() << "Andrew");
qDebug() << "indexPath" << indexPath << "\n";
// this will print (QVariant(int, 0) ,  QVariant(int, 1) ) which is
// section 0, item 1

But research by contactId won't work, because it is not present in sortingKeys.

If you add contactId to sortingKeys:

GroupDataModel *model = new GroupDataModel(QStringList() << "displayName" << "contactId", this);

then by searching only by displayName will no longer work. Find() maps values to keys, it will only return entries with empty contactId. But lowerBound() can be used instead:

QVariantList indexPath = model->lowerBound(QVariantList() << "Andrew");
qDebug() << "indexPath" << indexPath << "\n";
// this will return:
// indexPath (QVariant(int, 0) ,  QVariant(int, 1) )

Please note that the lowerBound is not a complete replacement for find. It returns a suggested for element insertion index. So if she is unable to find a match, it will return (0, 0) like suggested insertion point, but not a row empty.

When you have multiple sort keys the code depending on type of work to find a name:

    GroupDataModel *model = new GroupDataModel(QStringList() << "displayName" << "contactId", this);

    QVariantMap matchMap;
    //matchMap["contactId"] = "200";
    matchMap["displayName"] = "Andrew";
    QVariantList indexPath = model->lowerBound(matchMap);
    qDebug() << "indexPath" << indexPath << "\n";

But if the name is not found lowerBound will return (0, 0) - a proposed insertion point. Is not possible to differentiate the value of return "not found".

But if you try to provide a contactId

    matchMap["contactId"] = "200";
    //matchMap["displayName"] = "Andrew";

It will not work, because it searches in the order in which the sortingKeys have been reported.

In this case, it will try to 'empty' QVariant DisplayName of match, find nothing and will be (0, 0) return as insertion point proposed without even trying to match contactId-s.

The find() function is not appropriate as well because it performs the exact match on all fields and requires that all sortingKeys to be defined.

I hope I have not confused you completely now!

So, the conclusion seems to be:

Find() cannot find an exact match and compared all the keys of the supplied with keys in sortingKeys. If values are omitted it is expected that they are NULL in the model.

lowerBound() returns a suggested insertion or (0, 0) point, if nothing has been put in correspondence. He compares the values passed to it with the sort of keys from left to right (if the first sortingKey did not match it does not compare).

If these methods are not well suited for finding a specific key value. A possible workaround is an iteration model entries manually and by comparing their values, but it's slow.

I suggest to create your own datamodel by inheriting from the class DataModel. It is not very difficult, and you can implement any kind of search in there.

Tags: BlackBerry Developers

Similar Questions

  • need help for where and how to search for apps you want in windows store 8

    I just bought a SAMSUNG ATIV TAB 3 (XE300TZC), it has WINDOWS 8.  I went to the store Windows on my windows 8 to start the download of all my apps that I like and I found some of the apps and downloaded. But many of the apps I want to I don't think because I've noticed that it is not an option or small box for me to be able to get all the apps... I guess my question is how a search for specific applications on my STORE of WINDOWS 8?

    Hi Brandi,

    Thanks for posting your question on the Microsoft community.

    Thank you for details on the issue.

    Please see suggestions from HairyFool said on June 4, 2013 and check.
    http://answers.Microsoft.com/en-us/Windows/Forum/windows_8-Winapps/how-do-i-search-the-Windows-apps-store-on-my/75390438-4DBA-4a77-93cd-aa3b2153efce

    I hope this information helps.

    Please let us know if you need more help.

    Thank you

  • HP Notebook: Remove black search box that says - start typing to search for applications, files and settings

    Remove the black search box that says start typing to search for applications, files, and settings

    Can someone tell me please how to permanently delete this search field that keeps appearing in different applications that I use?

    I have windows 10 on a HP laptop. Often when I'm working in an application and I move the cursor on the screen, this search box - start typing to search for applications, files, and settings - appears. I tried several times to turn it off, but I do not just because I can't seem to get rid of it.

    I would like it removed permanently or turns off permanently so it is not continue to block my view of the application, that I'm trying. Any suggestions would be greatly appreciated.

    Thank you.

    Terry20

    @Terry20

    Found this.

    Click on the Start button and select settings.

    Then select devices.

    Click on the mouse and touch pad and scroll down and select 'extra mouse Options '.

    This will open a box that should have the information and the name of the type of touchpad has your computer.

    Click on settings and then in the new box that opens, you should see a tab that says 'Tapping '.

    Open this tab and you should see 'Three finger Tap' and 'four finger Tap.

    Clear the check boxes, and then click 'apply '.

    REO

  • How to search for extension in the Directory Manager

    Hi, I want to create a directory to handler extension research instead of name search, how can I do this? The basic unit book says you can do this, but does not say how.

    If it is not possible, how can I configure the unit to collect the numbers the caller to input and search for the extension and send to the right destination, if it is an invalid extension, it should return to the main message.

    Thank you.

    The Manager directory for searches in name only - if you know the extension you can just dial it in any home.

    You can dial the extension of a user or a Manager in a call handler or the default greeting Subscriber. so the best way to proceed is to simply dial the extension of the opening home - if it is not valid, you will hear the guest of error and then the opening greeting is replayed.

    If you want to use a different Manager for this and want to make sure after dialing invalid extensions that go you to the greeting for this call handler, update the greeting 'mistake' to go to this Manager instead of opening greeting Manager of appeal. By default the greeting of the error is not visible in the SA - you can make visible by using the advanced configuration tool - or you can do it in BulkEdit if you want, there is a special in there option on the greetings to "loop back to itself" page, which will update all managers or subscribers to have their greetings error restart their own welcome message instead of kicking back to the opening greeting.

  • How to search for a Word document in Windows 8?

    I'm stumbling around Windows 8 that came pre-loaded on my new laptop.  I ordered Windows and Excel to be included in the package.  I saved a number of documents in Word, and now I need to get these documents for a particular.  I looked on the Internet and found a lot of no-help, that is to say, 'go in search of a file'.  Excuse me, but if I could find searching a file, I could probably find out how to search for the file, Huh?  Thus,.

    Could someone please help me with: how to find a Word document (1) and (2) where is the infamous "search"?

    I did the thing 'sweep to the right side of the screen"to get those things shadow to appear, and click on the magnifying glass (which I think the engineers forgot to change when they changed everything!) and if I wanted to search for apps, I'd be in great shape.  But his files I'm looking for, Word documents.  The designers of this 'new' version improved - well, new, in all cases seem to have forgotten those of use who use computers for productive work and not socialize or play games.

    Sorry for the hike and whining, but I'm very frustrated that the tasks that were once very simple are now extremely difficult to fill.

    It's pretty easy, at the beginning screen just type the name of your document and right it will bring the search screen and you select files (files, settings, Apps). Take a look at:

    http://Windows.Microsoft.com/en-us/Windows-8/search-apps-files-settings

  • Please, give me an advise how to search for a number in a file xml (as3.0)

    Hello! Sorry for the troubling.

    Please, give me an advice how to search for a number in a file xml (as3.0)

    Thank you!

    My answer was based on your question to find numbers anywhere in the data to an xml file.  If you know that the data is digital data and the names of the nodes that contains this data, you do not have to check the characters and can only check numerical data using string values...

    function searchXMLFile(Event:MouseEvent):void
    {
    searchDisplay.text = "";
    var pageList:XMLList = xmlFileToSearch.receipt.number;
    searchDisplay.text = "false";
       
    for (var i: int = 0; i< pagelist.length();="">
    {

    If (pageList [i] == searchInput.text) {}
    searchDisplay.text = "true";
    }

    }
    }

    Even if you are looking for individual digital characters in the previous code that you would have always done by a false exit due having the line 'false' always cancel the real line...

    If (t.toString () .indexOf (m_sSearchTerm)! = - 1).

    {

    searchDisplay.text = "true";

    }

    searchDisplay.text = "false";  This will always overwrite the textfield

  • Search for an item of film in a folder item?

    How to find a film element that can be in a folder item?

    for example: I have a model as the first item in my project Panel, then I have a folder containing the three elements of film that belong to this model below.

    in my script, I want to create a variable to store an element of particular film called "background". Although I don't know how to search for it if its content in a folder (named "images").

    can someone pleease help a beginner

    Thank you

    Sam

    Like this:

    var myFootage = null;

    for (var i = 1; i)<= app.project.numitems;="">

    If ((app.project.item (i) instanceof FootageItem) & (app.project.item (i) .name == 'background')) {}

    If (app.project.item (i).parentFolder.name == "footage") {}

    myFootage = app.project.item (i);

    break;

    }

    }

    }

    at this point the myFootage is either your images in background, or null if not found

    Dan

  • How to search for .ico files in Windows?

    I write on behalf of a client.

    She has problems using the search feature in Windows 7. She tries to find its system for all types of files .ico, but has so far only not successful. The file type is not listed as a file type supported for Windows Search, and when she tried several search commands to find on his PC, nothing relevant comes up.

    Is there an order of specific research, it should use or an another workaround to find the types it needs?

    Thank you very much!

    Hello
     

    I imagine the inconvenience that you are experiencing. I will certainly help the question of fixing.
     
     
    I suggest you follow the steps described in the links to search for a file and check the question below:
     
     
     
     
     
    I hope that the information above helps you.
  • How to search for text in all of the PDF files on a mobile device?

    How to search for text in all of the PDF files on a mobile device?

    Not possible on mobile devices.

  • How to search for words and phrases in multiple pdf documents

    Dear Sirs.

    I need to search for words AND phrases in a huge amount of PDF files (over 5000). The problem I found by using the "advanced search" is that I am able to search for single words sentences individual GOLD, but I need to combine a lot of words and multiple expressions in the same search. For example, if I need to look for instances of the word 'Florida' or 'Texas' or 'United States', I can't search for each PDF file that contains the word 'Florida' or 'Texas' or the phrase 'United States', since if I put 'word' in the search options, I will receive all the files that contain the word "Florida" or 'Texas' but also 'solidarity' or 'States' and simple words. I tried placing quotes in the words I need to research such as phrases, but it did not work. I would like to know if there is a way I can search the way I need.

    Thanks in advance.

    Alejandro Araujo.//

    Hello Alejandro,

    Please see this KB doc. helps Acrobat | The search for PDF files, it will be a great help.

    Kind regards

    Nicos

  • How a search for certain content through many files?

    Windows 7 claims to be able to search for certain substances, but it does not work, or is not properly documented. My filenames have the extension "ls2" and are open with Notepad. How can I search for a string in the content of my ls2 files?

    Hello

    Maybe this will help: (mainly those of type "BOLD" )

    Tips for finding files
    http://Windows.Microsoft.com/en-us/Windows-Vista/tips-for-finding-files

    How to use advanced search in Vista Options
    http://www.Vistax64.com/tutorials/75451-advanced-search.html

    How to restore the page button on the Start Menu after installing Vista SP1
    http://www.Vistax64.com/tutorials/145787-Search-start-menu-button-restore-after-SP1.html

    How to restore the context Menu item search after installing Vista SP1
    http://www.Vistax64.com/tutorials/134065-search-context-menu-item-restore-after-Vista-SP1.html

    How to create a shortcut on the desktop search in Vista
    http://www.Vistax64.com/tutorials/126499-search-desktop-shortcut.html

    ----------------------------------------------------------

    Win Key F opens advanced search

    Searching in Windows Vista, part 1
    http://Windows.Microsoft.com/en-us/Windows-Vista/searching-in-Windows-Vista-part-1-secrets-of-the-search-box

    Part 2
    http://Windows.Microsoft.com/en-us/Windows-Vista/searching-in-Windows-Vista-part-2-Start-menu-and-control-panel-search-tips

    Part 3
    http://Windows.Microsoft.com/en-us/Windows-Vista/searching-in-Windows-Vista-part-3-using-advanced-search-for-those-hard-to-find-files

    I hope this helps.

    Rob Brown - MS MVP - Windows Desktop Experience: Bike - Mark Twain said it right.

  • How to search for files in a subfolder

    Hello

    I'm trying to get the files of WebCenter Content11.1.1.8 using RIDC (see the code example).

    IdcClientManager Manager = new IdcClientManager();

    IdcClient idcClient = manager.createClient ("idc://localhost:4444"); ")

    UserContext IdcContext = new IdcContext (username, passwoord); fill the binder with the settings

    DataBinder binding = idcClient.createBinder ();

    binder.putLocal ("IdcService", "GET_SEARCH_RESULTS");

    binder.putLocal ("QueryText", "dDocFullText < contains > < qsch >" + "blah" + "< /qsch >");

    binder.putLocal ("SearchEngineName", "oracletextsearch");

    binder.putLocal ("ResultCount", "20");

    ServiceResponse response = idcClient.sendRequest (userContext, binder);

    DataBinder serverBinder = response.getResponseAsBinder ();

    binding = response.getResponseAsBinder ();

    ResultSet DataResultSet = binder.getResultSet ("SearchResults"); loop through the results

    System.out.println ("found documents:" + "\n" + "");

    {for (DataObject dataObject: {resultSet.getRows ())}

    System.out.println ("title:" + dataObject.get ("dDocTitle"))

    + "," + "Is:" "+ dataObject.get ("dDocAuthor").

    + "," + "Extension is: '" + dataObject.get ("venture"));

    System.out.println("");

    }

    Documents found:

    The title is: blah blah, author is: jcooper, Extension is: docx

    The title is: search for text in the document, author is: jcooper, Extension is: txt

    The title is: is a blah document, the author is: jcooper, Extension is: txt

    Now that I get all the files in the WebCenter.  My question is how can I get the files in a subfolder. (by example/folders/my folder/Test1)?

    Do you have any advice?

    Kind regards
    Rigassi

    Hi Rigassi,

    The text of the query should be changed and made like this:

    binder.putLocal ("IdcService", "GET_SEARCH_RESULTS");

    binder.putLocal ("QueryText', '(xParentFolders '074D286A703B4082DCC6CAF4C86D0853' ) (test)');

    binder.putLocal ("SearchEngineName", "oracletextsearch");

    binder.putLocal ("AdvSearch", "True");

    binder.putLocal ("ResultCount", "20");

    Try this, it will list the content items that are present in the parent folder and its subfolders.

    Thank you

    Srinath

  • HOW to search for an image?

    How to use an image to search for something or someone?

    Google images will allow you to do. Go to images.Google.com and drag the image you want to use in the search box.

  • A folder of bookmarks disappeared, but when I search in the sidebar for some sites, they appear, then how to search for the folder?

    The folder has disappeared from the sidebar and I get each of the other folders, but not luck. Yet when I do a search of bookmarks for entries individually, they appear. But it is essential that find the folder to my work because I don't remember all items [300 or more] and their URLs. The search function does not search for files, which is a real problem.

    Hi, you could have a look at your profile. Or, have you tried to restore from backup - open bookmarks > show all bookmarks > import and backup > restore.

  • How to search for on the labels to my favorites

    I have a long list of bookmarks, organized in folders separated and labeled however I can't find on the labels. So either the labeling is of no use or I would like to learn how to use labels to search for my favorites? Can you help me?

    Thank you.

    -Display the labels of bookmark - file bookmarks to make them easy to find

Maybe you are looking for

  • After installation, bookmarks import/restore will require the password from the previous version

    I tried to set the master password yet appeared that submit or accept was grey and there was no focus confirmation. No PC to use for more than a week (out of the city for the funeral) was subsequently returned to find now need a master and had no ide

  • Recovery BIOS TS140

    After failed BIOS update I tried to follow the chapter "Recovery of a failed BIOS update" the hardware TS140 Maintenance Manual: Downloaded bios_ts140-240-440 - 540_fbkt99a_dos.zip and unzipped the files on a FAT32 format (not bootable) USB drive plu

  • Compatibility with windows 64 bit OS

    Hi, we intend to upgrade our current computer, possibly to a multicore 64-bit with windows OS. Currently, we use C++ as a software platform on a 32-bit Windows XP for the following devices: PCI-6534 PCI 6713 PCI-6071E NEITHER 9205 USB 6501 Most of th

  • ProBook 450 g2: subsequent Security customer hp 8.2 or version Manager

    Hello I have Windows 7 Professional 64 bit OS installed and I downloaded and installed all the drivers hp indicated specifically site against my "HP ProBook 450 G2 NOTEBOOK PC" Device Manager indicates that all drivers are properly installed I instal

  • What could stop the HP Smart DVD loading?

    HP Pavilion dv7-3067nr Notebook PC Windows 7 Ultimate 64 bit. Several months back my program HP Smart DVD would start playing a BluRay disc and then would freeze. I tried to reinstall the program and even remove and completely reinstall Media Smart.