# HG changeset patch # User Chris Cannam # Date 1222177165 0 # Node ID 14521503f1961d1d4ce628f3ed895006b4cc90ef # Parent 381ec750eeeec3acf45f112540fb71422a41d196 * Start work on TransformFinder dialog diff -r 381ec750eeee -r 14521503f196 transform/TransformFactory.cpp --- 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; +} + diff -r 381ec750eeee -r 14521503f196 transform/TransformFactory.h --- 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 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 SearchResults;