Mercurial > hg > svcore
changeset 444:14521503f196
* Start work on TransformFinder dialog
author | Chris Cannam |
---|---|
date | Tue, 23 Sep 2008 13:39:25 +0000 |
parents | 381ec750eeee |
children | 55cff2c6e4a0 |
files | transform/TransformFactory.cpp transform/TransformFactory.h |
diffstat | 2 files changed, 30 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/transform/TransformFactory.cpp Mon Sep 22 15:44:03 2008 +0000 +++ b/transform/TransformFactory.cpp Tue Sep 23 13:39:25 2008 +0000 @@ -914,8 +914,31 @@ } if (fragment != "") { - fragment = tr("%1: %2").arg(textType).arg(fragment); - match.fragments << fragment; + match.fragments[textType] = fragment; } } +bool +TransformFactory::Match::operator<(const Match &m) const +{ + if (score != m.score) { + return score < m.score; + } + if (transform != m.transform) { + return transform < m.transform; + } + if (fragments.size() != m.fragments.size()) { + return fragments.size() < m.fragments.size(); + } + + for (FragmentMap::const_iterator + i = fragments.begin(), + j = m.fragments.begin(); + i != fragments.end(); ++i, ++j) { + if (i->first != j->first) return i->first < j->first; + if (i->second != j->second) return i->second < j->second; + } + + return false; +} +
--- a/transform/TransformFactory.h Mon Sep 22 15:44:03 2008 +0000 +++ b/transform/TransformFactory.h Tue Sep 23 13:39:25 2008 +0000 @@ -46,28 +46,14 @@ { TransformId transform; int score; - QStringList fragments; + typedef std::map<QString, QString> FragmentMap; + FragmentMap fragments; Match() : score(0) { } - Match(const Match &m) : transform(m.transform), - score(m.score), fragments(m.fragments) { } + Match(const Match &m) : + transform(m.transform), score(m.score), fragments(m.fragments) { } - bool operator<(const Match &m) { - if (score != m.score) { - return score < m.score; - } else if (transform != m.transform) { - return transform < m.transform; - } else if (fragments.size() != m.fragments.size()) { - return fragments.size() < m.fragments.size(); - } else { - for (int i = 0; i < fragments.size(); ++i) { - if (fragments[i] != m.fragments[i]) { - return fragments[i] < m.fragments[i]; - } - } - } - return false; - } + bool operator<(const Match &m) const; }; typedef std::map<TransformId, Match> SearchResults;