1 /***************************************************************************
2 Copyright (C) 2003-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 #include "coincollection.h"
26
27 #include <KLocalizedString>
28
29 namespace {
30 static const char* coin_general = I18N_NOOP("General");
31 static const char* coin_personal = I18N_NOOP("Personal");
32 }
33
34 using Tellico::Data::CoinCollection;
35
CoinCollection(bool addDefaultFields_,const QString & title_)36 CoinCollection::CoinCollection(bool addDefaultFields_, const QString& title_)
37 : Collection(title_.isEmpty() ? i18n("My Coins") : title_) {
38 setDefaultGroupField(QStringLiteral("denomination"));
39 if(addDefaultFields_) {
40 addFields(defaultFields());
41 }
42 }
43
defaultFields()44 Tellico::Data::FieldList CoinCollection::defaultFields() {
45 FieldList list;
46 FieldPtr field;
47
48 field = Field::createDefaultField(Field::TitleField);
49 field->setProperty(QStringLiteral("template"), QStringLiteral("%{year}%{mintmark} %{type} %{denomination}"));
50 field->setFlags(Field::NoDelete | Field::Derived);
51 field->setFormatType(FieldFormat::FormatNone);
52 list.append(field);
53
54 field = new Field(QStringLiteral("type"), i18n("Type"));
55 field->setCategory(i18n(coin_general));
56 field->setFlags(Field::AllowCompletion | Field::AllowGrouped);
57 field->setFormatType(FieldFormat::FormatTitle);
58 list.append(field);
59
60 /* TRANSLATORS: denomination refers to the monetary value. */
61 field = new Field(QStringLiteral("denomination"), i18nc("monetary denomination", "Denomination"));
62 field->setCategory(i18n(coin_general));
63 field->setFlags(Field::AllowCompletion | Field::AllowGrouped);
64 list.append(field);
65
66 field = new Field(QStringLiteral("year"), i18n("Year"), Field::Number);
67 field->setCategory(i18n(coin_general));
68 field->setFlags(Field::AllowMultiple | Field::AllowGrouped);
69 list.append(field);
70
71 field = new Field(QStringLiteral("mintmark"), i18n("Mint Mark"));
72 field->setCategory(i18n(coin_general));
73 field->setFlags(Field::AllowGrouped);
74 field->setFormatType(FieldFormat::FormatPlain);
75 list.append(field);
76
77 field = new Field(QStringLiteral("country"), i18n("Country"));
78 field->setCategory(i18n(coin_general));
79 field->setFlags(Field::AllowCompletion | Field::AllowGrouped);
80 field->setFormatType(FieldFormat::FormatPlain);
81 list.append(field);
82
83 field = new Field(QStringLiteral("currency"), i18n("Currency"));
84 field->setCategory(i18n(coin_general));
85 field->setFlags(Field::AllowCompletion | Field::AllowGrouped);
86 field->setFormatType(FieldFormat::FormatPlain);
87 list.append(field);
88
89 field = new Field(QStringLiteral("set"), i18n("Coin Set"), Field::Bool);
90 field->setCategory(i18n(coin_general));
91 list.append(field);
92
93 QStringList grade = i18nc("Coin grade levels - "
94 "Proof-65,Proof-60,Mint State-65,Mint State-60,"
95 "Almost Uncirculated-55,Almost Uncirculated-50,"
96 "Extremely Fine-40,Very Fine-30,Very Fine-20,Fine-12,"
97 "Very Good-8,Good-4,Fair",
98 "Proof-65,Proof-60,Mint State-65,Mint State-60,"
99 "Almost Uncirculated-55,Almost Uncirculated-50,"
100 "Extremely Fine-40,Very Fine-30,Very Fine-20,Fine-12,"
101 "Very Good-8,Good-4,Fair")
102 #if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
103 .split(QRegularExpression(QLatin1String("\\s*,\\s*")), QString::SkipEmptyParts);
104 #else
105 .split(QRegularExpression(QLatin1String("\\s*,\\s*")), Qt::SkipEmptyParts);
106 #endif
107 field = new Field(QStringLiteral("grade"), i18n("Grade"), grade);
108 field->setCategory(i18n(coin_general));
109 field->setFlags(Field::AllowGrouped);
110 list.append(field);
111
112 QStringList service = i18nc("Coin grading services - "
113 "PCGS,NGC,ANACS,ICG,ASA,PCI",
114 "PCGS,NGC,ANACS,ICG,ASA,PCI")
115 #if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
116 .split(QRegularExpression(QLatin1String("\\s*,\\s*")), QString::SkipEmptyParts);
117 #else
118 .split(QRegularExpression(QLatin1String("\\s*,\\s*")), Qt::SkipEmptyParts);
119 #endif
120 field = new Field(QStringLiteral("service"), i18n("Grading Service"), service);
121 field->setCategory(i18n(coin_general));
122 field->setFlags(Field::AllowGrouped);
123 list.append(field);
124
125 field = new Field(QStringLiteral("pur_date"), i18n("Purchase Date"));
126 field->setCategory(i18n(coin_personal));
127 field->setFormatType(FieldFormat::FormatDate);
128 list.append(field);
129
130 field = new Field(QStringLiteral("pur_price"), i18n("Purchase Price"));
131 field->setCategory(i18n(coin_personal));
132 list.append(field);
133
134 field = new Field(QStringLiteral("location"), i18n("Location"));
135 field->setCategory(i18n(coin_personal));
136 field->setFlags(Field::AllowCompletion | Field::AllowGrouped);
137 field->setFormatType(FieldFormat::FormatPlain);
138 list.append(field);
139
140 field = new Field(QStringLiteral("gift"), i18n("Gift"), Field::Bool);
141 field->setCategory(i18n(coin_personal));
142 list.append(field);
143
144 field = new Field(QStringLiteral("obverse"), i18n("Obverse"), Field::Image);
145 list.append(field);
146
147 field = new Field(QStringLiteral("reverse"), i18n("Reverse"), Field::Image);
148 list.append(field);
149
150 field = new Field(QStringLiteral("comments"), i18n("Comments"), Field::Para);
151 field->setCategory(i18n(coin_personal));
152 list.append(field);
153
154 list.append(Field::createDefaultField(Field::IDField));
155 list.append(Field::createDefaultField(Field::CreatedDateField));
156 list.append(Field::createDefaultField(Field::ModifiedDateField));
157
158 return list;
159 }
160