File indexing completed on 2024-05-12 16:45:38
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 QStringList grade = i18nc("Stamp grade levels - " 0093 "Superb,Extremely Fine,Very Fine,Fine,Average,Poor", 0094 "Superb,Extremely Fine,Very Fine,Fine,Average,Poor") 0095 #if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) 0096 .split(QRegularExpression(QLatin1String("\\s*,\\s*")), QString::SkipEmptyParts); 0097 #else 0098 .split(QRegularExpression(QLatin1String("\\s*,\\s*")), Qt::SkipEmptyParts); 0099 #endif 0100 field = new Field(QStringLiteral("grade"), i18n("Grade"), grade); 0101 field->setCategory(i18n(stamp_condition)); 0102 field->setFlags(Field::AllowGrouped); 0103 list.append(field); 0104 0105 field = new Field(QStringLiteral("cancelled"), i18n("Cancelled"), Field::Bool); 0106 field->setCategory(i18n(stamp_condition)); 0107 list.append(field); 0108 0109 /* TRANSLATORS: See https://en.wikipedia.org/wiki/Stamp_hinge */ 0110 field = new Field(QStringLiteral("hinged"), i18n("Hinged")); 0111 field->setCategory(i18n(stamp_condition)); 0112 field->setFlags(Field::AllowCompletion | Field::AllowGrouped); 0113 list.append(field); 0114 0115 field = new Field(QStringLiteral("centering"), i18n("Centering")); 0116 field->setCategory(i18n(stamp_condition)); 0117 field->setFlags(Field::AllowCompletion | Field::AllowGrouped); 0118 list.append(field); 0119 0120 field = new Field(QStringLiteral("gummed"), i18n("Gummed")); 0121 field->setCategory(i18n(stamp_condition)); 0122 field->setFlags(Field::AllowCompletion | Field::AllowGrouped); 0123 list.append(field); 0124 0125 field = new Field(QStringLiteral("pur_date"), i18n("Purchase Date")); 0126 field->setCategory(i18n(stamp_personal)); 0127 field->setFormatType(FieldFormat::FormatDate); 0128 list.append(field); 0129 0130 field = new Field(QStringLiteral("pur_price"), i18n("Purchase Price")); 0131 field->setCategory(i18n(stamp_personal)); 0132 list.append(field); 0133 0134 field = new Field(QStringLiteral("location"), i18n("Location")); 0135 field->setCategory(i18n(stamp_personal)); 0136 field->setFlags(Field::AllowCompletion | Field::AllowGrouped); 0137 field->setFormatType(FieldFormat::FormatPlain); 0138 list.append(field); 0139 0140 field = new Field(QStringLiteral("gift"), i18n("Gift"), Field::Bool); 0141 field->setCategory(i18n(stamp_personal)); 0142 list.append(field); 0143 0144 field = new Field(QStringLiteral("image"), i18n("Image"), Field::Image); 0145 list.append(field); 0146 0147 field = new Field(QStringLiteral("comments"), i18n("Comments"), Field::Para); 0148 list.append(field); 0149 0150 list.append(Field::createDefaultField(Field::IDField)); 0151 list.append(Field::createDefaultField(Field::CreatedDateField)); 0152 list.append(Field::createDefaultField(Field::ModifiedDateField)); 0153 0154 return list; 0155 }