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 "stampcollection.h" 0026 0027 #include <KLocalizedString> 0028 0029 namespace { 0030 static const char* stamp_general = I18N_NOOP("General"); 0031 static const char* stamp_condition = I18N_NOOP("Condition"); 0032 static const char* stamp_personal = I18N_NOOP("Personal"); 0033 } 0034 0035 using Tellico::Data::StampCollection; 0036 0037 StampCollection::StampCollection(bool addDefaultFields_, const QString& title_) 0038 : Collection(title_.isEmpty() ? i18n("My Stamps") : title_) { 0039 setDefaultGroupField(QStringLiteral("denomination")); 0040 if(addDefaultFields_) { 0041 addFields(defaultFields()); 0042 } 0043 } 0044 0045 Tellico::Data::FieldList StampCollection::defaultFields() { 0046 FieldList list; 0047 FieldPtr field; 0048 0049 field = Field::createDefaultField(Field::TitleField); 0050 field->setProperty(QStringLiteral("template"), QStringLiteral("%{year} %{description} %{denomination}")); 0051 field->setFlags(Field::NoDelete | Field::Derived); 0052 list.append(field); 0053 0054 field = new Field(QStringLiteral("description"), i18n("Description")); 0055 field->setCategory(i18n(stamp_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(stamp_general)); 0063 field->setFlags(Field::AllowCompletion | Field::AllowGrouped); 0064 list.append(field); 0065 0066 field = new Field(QStringLiteral("currency"), i18n("Currency")); 0067 field->setCategory(i18n(stamp_general)); 0068 field->setFlags(Field::AllowCompletion | Field::AllowGrouped); 0069 field->setFormatType(FieldFormat::FormatPlain); 0070 list.append(field); 0071 0072 field = new Field(QStringLiteral("country"), i18n("Country")); 0073 field->setCategory(i18n(stamp_general)); 0074 field->setFormatType(FieldFormat::FormatPlain); 0075 field->setFlags(Field::AllowGrouped); 0076 list.append(field); 0077 0078 field = new Field(QStringLiteral("year"), i18n("Issue Year"), Field::Number); 0079 field->setCategory(i18n(stamp_general)); 0080 field->setFlags(Field::AllowMultiple | Field::AllowGrouped); 0081 list.append(field); 0082 0083 field = new Field(QStringLiteral("color"), i18n("Color")); 0084 field->setCategory(i18n(stamp_general)); 0085 field->setFlags(Field::AllowCompletion | Field::AllowGrouped); 0086 list.append(field); 0087 0088 field = new Field(QStringLiteral("scott"), i18n("Scott#")); 0089 field->setCategory(i18n(stamp_general)); 0090 list.append(field); 0091 0092 auto grade = FieldFormat::splitValue(i18nc("Stamp grade levels - " 0093 "Superb,Extremely Fine,Very Fine,Fine,Average,Poor", 0094 "Superb,Extremely Fine,Very Fine,Fine,Average,Poor"), 0095 FieldFormat::CommaRegExpSplit); 0096 field = new Field(QStringLiteral("grade"), i18n("Grade"), grade); 0097 field->setCategory(i18n(stamp_condition)); 0098 field->setFlags(Field::AllowGrouped); 0099 list.append(field); 0100 0101 field = new Field(QStringLiteral("cancelled"), i18n("Cancelled"), Field::Bool); 0102 field->setCategory(i18n(stamp_condition)); 0103 list.append(field); 0104 0105 /* TRANSLATORS: See https://en.wikipedia.org/wiki/Stamp_hinge */ 0106 field = new Field(QStringLiteral("hinged"), i18n("Hinged")); 0107 field->setCategory(i18n(stamp_condition)); 0108 field->setFlags(Field::AllowCompletion | Field::AllowGrouped); 0109 list.append(field); 0110 0111 field = new Field(QStringLiteral("centering"), i18n("Centering")); 0112 field->setCategory(i18n(stamp_condition)); 0113 field->setFlags(Field::AllowCompletion | Field::AllowGrouped); 0114 list.append(field); 0115 0116 field = new Field(QStringLiteral("gummed"), i18n("Gummed")); 0117 field->setCategory(i18n(stamp_condition)); 0118 field->setFlags(Field::AllowCompletion | Field::AllowGrouped); 0119 list.append(field); 0120 0121 field = new Field(QStringLiteral("pur_date"), i18n("Purchase Date")); 0122 field->setCategory(i18n(stamp_personal)); 0123 field->setFormatType(FieldFormat::FormatDate); 0124 list.append(field); 0125 0126 field = new Field(QStringLiteral("pur_price"), i18n("Purchase Price")); 0127 field->setCategory(i18n(stamp_personal)); 0128 list.append(field); 0129 0130 field = new Field(QStringLiteral("location"), i18n("Location")); 0131 field->setCategory(i18n(stamp_personal)); 0132 field->setFlags(Field::AllowCompletion | Field::AllowGrouped); 0133 field->setFormatType(FieldFormat::FormatPlain); 0134 list.append(field); 0135 0136 field = new Field(QStringLiteral("gift"), i18n("Gift"), Field::Bool); 0137 field->setCategory(i18n(stamp_personal)); 0138 list.append(field); 0139 0140 field = new Field(QStringLiteral("image"), i18n("Image"), Field::Image); 0141 list.append(field); 0142 0143 field = new Field(QStringLiteral("comments"), i18n("Comments"), Field::Para); 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 }