File indexing completed on 2024-05-12 05:09:22
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 "cardcollection.h" 0026 0027 #include <KLocalizedString> 0028 0029 namespace { 0030 static const char* card_general = I18N_NOOP("General"); 0031 static const char* card_personal = I18N_NOOP("Personal"); 0032 } 0033 0034 using Tellico::Data::CardCollection; 0035 0036 CardCollection::CardCollection(bool addDefaultFields_, const QString& title_) 0037 : Collection(title_.isEmpty() ? i18n("My Cards") : title_) { 0038 setDefaultGroupField(QStringLiteral("series")); 0039 if(addDefaultFields_) { 0040 addFields(defaultFields()); 0041 } 0042 } 0043 0044 Tellico::Data::FieldList CardCollection::defaultFields() { 0045 FieldList list; 0046 FieldPtr field; 0047 0048 field = Field::createDefaultField(Field::TitleField); 0049 field->setProperty(QStringLiteral("template"), QStringLiteral("%{year} %{brand} %{player}")); 0050 field->setFlags(Field::NoDelete | Field::Derived); 0051 field->setFormatType(FieldFormat::FormatNone); 0052 list.append(field); 0053 0054 field = new Field(QStringLiteral("player"), i18n("Player")); 0055 field->setCategory(i18n(card_general)); 0056 field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); 0057 field->setFormatType(FieldFormat::FormatName); 0058 list.append(field); 0059 0060 field = new Field(QStringLiteral("team"), i18n("Team")); 0061 field->setCategory(i18n(card_general)); 0062 field->setFlags(Field::AllowCompletion | Field::AllowGrouped); 0063 field->setFormatType(FieldFormat::FormatTitle); 0064 list.append(field); 0065 0066 field = new Field(QStringLiteral("brand"), i18n("Brand")); 0067 field->setCategory(i18n(card_general)); 0068 field->setFlags(Field::AllowCompletion | Field::AllowGrouped); 0069 field->setFormatType(FieldFormat::FormatPlain); 0070 list.append(field); 0071 0072 // might not be totally numeric! 0073 field = new Field(QStringLiteral("number"), i18n("Card Number")); 0074 field->setCategory(i18n(card_general)); 0075 list.append(field); 0076 0077 field = new Field(QStringLiteral("year"), i18n("Year"), Field::Number); 0078 field->setCategory(i18n(card_general)); 0079 field->setFlags(Field::AllowGrouped); 0080 list.append(field); 0081 0082 field = new Field(QStringLiteral("series"), i18n("Series")); 0083 field->setCategory(i18n(card_general)); 0084 field->setFlags(Field::AllowCompletion | Field::AllowGrouped); 0085 field->setFormatType(FieldFormat::FormatTitle); 0086 list.append(field); 0087 0088 field = new Field(QStringLiteral("type"), i18n("Card Type")); 0089 field->setCategory(i18n(card_general)); 0090 field->setFlags(Field::AllowCompletion | Field::AllowGrouped); 0091 list.append(field); 0092 0093 field = new Field(QStringLiteral("pur_date"), i18n("Purchase Date")); 0094 field->setCategory(i18n(card_personal)); 0095 field->setFormatType(FieldFormat::FormatDate); 0096 list.append(field); 0097 0098 field = new Field(QStringLiteral("pur_price"), i18n("Purchase Price")); 0099 field->setCategory(i18n(card_personal)); 0100 list.append(field); 0101 0102 field = new Field(QStringLiteral("location"), i18n("Location")); 0103 field->setCategory(i18n(card_personal)); 0104 field->setFlags(Field::AllowCompletion | Field::AllowGrouped); 0105 list.append(field); 0106 0107 field = new Field(QStringLiteral("gift"), i18n("Gift"), Field::Bool); 0108 field->setCategory(i18n(card_personal)); 0109 list.append(field); 0110 0111 field = new Field(QStringLiteral("keyword"), i18n("Keywords")); 0112 field->setCategory(i18n(card_personal)); 0113 field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); 0114 list.append(field); 0115 0116 field = new Field(QStringLiteral("quantity"), i18n("Quantity"), Field::Number); 0117 field->setCategory(i18n(card_personal)); 0118 list.append(field); 0119 0120 field = new Field(QStringLiteral("front"), i18n("Front Image"), Field::Image); 0121 list.append(field); 0122 0123 field = new Field(QStringLiteral("back"), i18n("Back Image"), Field::Image); 0124 list.append(field); 0125 0126 field = new Field(QStringLiteral("comments"), i18n("Comments"), Field::Para); 0127 list.append(field); 0128 0129 list.append(Field::createDefaultField(Field::IDField)); 0130 list.append(Field::createDefaultField(Field::CreatedDateField)); 0131 list.append(Field::createDefaultField(Field::ModifiedDateField)); 0132 0133 return list; 0134 }