Hi, I don't know if this is a simple question or whether I should be in the QtProgramming forum ... but I'm a Qt newbie so I'm asking here.
As a learning project, I have implemented a simple program which reads data from an Xml file and displays it in a QTreeView with four columns. I put in a little search box which lets me apply a QRegExp to the first column. So far, so good.
What I want to do, however, is to do much more complex searching on the data. The idea is to have a rule like "match any vowel". So if I search for "bad", it will match "bad", "bed", "bid", "bod" and "bud". This is easy to implement with a regexp ("b[aeiou]d"). But what I want is to have several of these rules -- so maybe "[bp][aeiou]d" -- AND to rank the closest match highest in the list of results.
So in the above example, the results would be something like:
bad (exact match)
pad (one letter change)
bed
bid
bod
bud
ped (two letter changes)
pid
pod
pud
So I'm curious if anyone has some insight about the best implementation. Speed will be important if there are thousands of words and complex rules. I think I could keep track of things in a custom QSortFilterProxyModel::acceptsRow -- but I'm not sure the best way of passing the query to that function (as a customised QString through setFilterWildcard?). Or maybe I'm looking at it in completely the wrong way?
Does anyone have any suggestions as to how I should approach this problem?
Cheers, B.
Bookmarks