1 /*************************************************************************** 2 Copyright (C) 2009 Robby Stephenson <robby@periapsis.org> 3 ***************************************************************************/ 4 5 /*************************************************************************** 6 * * 7 * This program is free software; you can redistribute it and/or * 8 * modify it under the terms of the GNU General Public License as * 9 * published by the Free Software Foundation; either version 2 of * 10 * the License or (at your option) version 3 or any later version * 11 * accepted by the membership of KDE e.V. (or its successor approved * 12 * by the membership of KDE e.V.), which shall act as a proxy * 13 * defined in Section 14 of version 3 of the license. * 14 * * 15 * This program is distributed in the hope that it will be useful, * 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 18 * GNU General Public License for more details. * 19 * * 20 * You should have received a copy of the GNU General Public License * 21 * along with this program. If not, see <http://www.gnu.org/licenses/>. * 22 * * 23 ***************************************************************************/ 24 25 #ifndef TELLICO_ENTRYCOMPARISON_H 26 #define TELLICO_ENTRYCOMPARISON_H 27 28 #include "datavectors.h" 29 30 #include <QUrl> 31 32 namespace Tellico { 33 34 class EntryComparison { 35 public: 36 /** 37 * Set the url for comparing relative url field values 38 * this is totally not the way the comparison should be done, but it's too expensive to include 39 * a connection to document.h here 40 */ 41 static void setDocumentUrl(const QUrl& url); 42 43 static int score(const Data::EntryPtr& entry1, const Data::EntryPtr& entry2, Data::FieldPtr field); 44 static int score(const Data::EntryPtr& entry1, const Data::EntryPtr& entry2, const QString& field, const Data::Collection* coll); 45 46 // match scores for individual fields 47 enum MatchValue { 48 MATCH_VALUE_NONE = 0, 49 MATCH_VALUE_WEAK = 3, 50 MATCH_VALUE_STRONG = 5 51 }; 52 53 // weights for which individual fields get marked 54 enum MatchWeight { 55 MATCH_WEIGHT_LOW = 1, 56 MATCH_WEIGHT_MED = 2, 57 MATCH_WEIGHT_HIGH = 3 58 }; 59 60 // these are the total values that should be compared against 61 // the result from Collection::sameEntry() ../entrycomparison.cpp 62 enum EntryMatchValue { 63 ENTRY_BAD_MATCH = 0, 64 ENTRY_GOOD_MATCH = 10, 65 ENTRY_PERFECT_MATCH = 20 66 }; 67 68 private: 69 static QUrl s_documentUrl; 70 }; 71 72 } // namespace 73 #endif 74