File indexing completed on 2024-05-12 05:09:23
0001 /*************************************************************************** 0002 Copyright (C) 2003-2009 Robby Stephenson <robby@periapsis.org> 0003 ***************************************************************************/ 0004 0005 /*************************************************************************** 0006 * * 0007 * This program is free software; you can redistribute it and/or * 0008 * modify it under the terms of the GNU General Public License as * 0009 * published by the Free Software Foundation; either version 2 of * 0010 * the License or (at your option) version 3 or any later version * 0011 * accepted by the membership of KDE e.V. (or its successor approved * 0012 * by the membership of KDE e.V.), which shall act as a proxy * 0013 * defined in Section 14 of version 3 of the license. * 0014 * * 0015 * This program is distributed in the hope that it will be useful, * 0016 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0018 * GNU General Public License for more details. * 0019 * * 0020 * You should have received a copy of the GNU General Public License * 0021 * along with this program. If not, see <http://www.gnu.org/licenses/>. * 0022 * * 0023 ***************************************************************************/ 0024 0025 #include "coincollection.h" 0026 0027 #include <KLocalizedString> 0028 0029 namespace { 0030 static const char* coin_general = I18N_NOOP("General"); 0031 static const char* coin_personal = I18N_NOOP("Personal"); 0032 } 0033 0034 using Tellico::Data::CoinCollection; 0035 0036 CoinCollection::CoinCollection(bool addDefaultFields_, const QString& title_) 0037 : Collection(title_.isEmpty() ? i18n("My Coins") : title_) { 0038 setDefaultGroupField(QStringLiteral("denomination")); 0039 if(addDefaultFields_) { 0040 addFields(defaultFields()); 0041 } 0042 } 0043 0044 Tellico::Data::FieldList CoinCollection::defaultFields() { 0045 FieldList list; 0046 FieldPtr field; 0047 0048 field = Field::createDefaultField(Field::TitleField); 0049 field->setProperty(QStringLiteral("template"), QStringLiteral("%{year}%{mintmark} %{type} %{denomination}")); 0050 field->setFlags(Field::NoDelete | Field::Derived); 0051 field->setFormatType(FieldFormat::FormatNone); 0052 list.append(field); 0053 0054 field = new Field(QStringLiteral("type"), i18n("Type")); 0055 field->setCategory(i18n(coin_general)); 0056 field->setFlags(Field::AllowCompletion | Field::AllowGrouped); 0057 field->setFormatType(FieldFormat::FormatTitle); 0058 list.append(field); 0059 0060 /* TRANSLATORS: denomination refers to the monetary value. */ 0061 field = new Field(QStringLiteral("denomination"), i18nc("monetary denomination", "Denomination")); 0062 field->setCategory(i18n(coin_general)); 0063 field->setFlags(Field::AllowCompletion | Field::AllowGrouped); 0064 list.append(field); 0065 0066 field = new Field(QStringLiteral("year"), i18n("Year"), Field::Number); 0067 field->setCategory(i18n(coin_general)); 0068 field->setFlags(Field::AllowMultiple | Field::AllowGrouped); 0069 list.append(field); 0070 0071 field = new Field(QStringLiteral("mintmark"), i18n("Mint Mark")); 0072 field->setCategory(i18n(coin_general)); 0073 field->setFlags(Field::AllowGrouped); 0074 field->setFormatType(FieldFormat::FormatPlain); 0075 list.append(field); 0076 0077 field = new Field(QStringLiteral("country"), i18n("Country")); 0078 field->setCategory(i18n(coin_general)); 0079 field->setFlags(Field::AllowCompletion | Field::AllowGrouped); 0080 field->setFormatType(FieldFormat::FormatPlain); 0081 list.append(field); 0082 0083 field = new Field(QStringLiteral("currency"), i18n("Currency")); 0084 field->setCategory(i18n(coin_general)); 0085 field->setFlags(Field::AllowCompletion | Field::AllowGrouped); 0086 field->setFormatType(FieldFormat::FormatPlain); 0087 list.append(field); 0088 0089 field = new Field(QStringLiteral("set"), i18n("Coin Set"), Field::Bool); 0090 field->setCategory(i18n(coin_general)); 0091 list.append(field); 0092 0093 auto grade = FieldFormat::splitValue(i18nc("Coin grade levels - " 0094 "Proof-65,Proof-60,Mint State-65,Mint State-60," 0095 "Almost Uncirculated-55,Almost Uncirculated-50," 0096 "Extremely Fine-40,Very Fine-30,Very Fine-20,Fine-12," 0097 "Very Good-8,Good-4,Fair", 0098 "Proof-65,Proof-60,Mint State-65,Mint State-60," 0099 "Almost Uncirculated-55,Almost Uncirculated-50," 0100 "Extremely Fine-40,Very Fine-30,Very Fine-20,Fine-12," 0101 "Very Good-8,Good-4,Fair"), 0102 FieldFormat::CommaRegExpSplit); 0103 field = new Field(QStringLiteral("grade"), i18n("Grade"), grade); 0104 field->setCategory(i18n(coin_general)); 0105 field->setFlags(Field::AllowGrouped); 0106 list.append(field); 0107 0108 auto service = FieldFormat::splitValue(i18nc("Coin grading services - " 0109 "PCGS,NGC,ANACS,ICG,ASA,PCI", 0110 "PCGS,NGC,ANACS,ICG,ASA,PCI"), 0111 FieldFormat::CommaRegExpSplit); 0112 field = new Field(QStringLiteral("service"), i18n("Grading Service"), service); 0113 field->setCategory(i18n(coin_general)); 0114 field->setFlags(Field::AllowGrouped); 0115 list.append(field); 0116 0117 field = new Field(QStringLiteral("pur_date"), i18n("Purchase Date")); 0118 field->setCategory(i18n(coin_personal)); 0119 field->setFormatType(FieldFormat::FormatDate); 0120 list.append(field); 0121 0122 field = new Field(QStringLiteral("pur_price"), i18n("Purchase Price")); 0123 field->setCategory(i18n(coin_personal)); 0124 list.append(field); 0125 0126 field = new Field(QStringLiteral("location"), i18n("Location")); 0127 field->setCategory(i18n(coin_personal)); 0128 field->setFlags(Field::AllowCompletion | Field::AllowGrouped); 0129 field->setFormatType(FieldFormat::FormatPlain); 0130 list.append(field); 0131 0132 field = new Field(QStringLiteral("gift"), i18n("Gift"), Field::Bool); 0133 field->setCategory(i18n(coin_personal)); 0134 list.append(field); 0135 0136 field = new Field(QStringLiteral("obverse"), i18n("Obverse"), Field::Image); 0137 list.append(field); 0138 0139 field = new Field(QStringLiteral("reverse"), i18n("Reverse"), Field::Image); 0140 list.append(field); 0141 0142 field = new Field(QStringLiteral("comments"), i18n("Comments"), Field::Para); 0143 field->setCategory(i18n(coin_personal)); 0144 list.append(field); 0145 0146 list.append(Field::createDefaultField(Field::IDField)); 0147 list.append(Field::createDefaultField(Field::CreatedDateField)); 0148 list.append(Field::createDefaultField(Field::ModifiedDateField)); 0149 0150 return list; 0151 }