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 "cardcollection.h"
26
27 #include <KLocalizedString>
28
29 namespace {
30 static const char* card_general = I18N_NOOP("General");
31 static const char* card_personal = I18N_NOOP("Personal");
32 }
33
34 using Tellico::Data::CardCollection;
35
CardCollection(bool addDefaultFields_,const QString & title_)36 CardCollection::CardCollection(bool addDefaultFields_, const QString& title_)
37 : Collection(title_.isEmpty() ? i18n("My Cards") : title_) {
38 setDefaultGroupField(QStringLiteral("series"));
39 if(addDefaultFields_) {
40 addFields(defaultFields());
41 }
42 }
43
defaultFields()44 Tellico::Data::FieldList CardCollection::defaultFields() {
45 FieldList list;
46 FieldPtr field;
47
48 field = Field::createDefaultField(Field::TitleField);
49 field->setProperty(QStringLiteral("template"), QStringLiteral("%{year} %{brand} %{player}"));
50 field->setFlags(Field::NoDelete | Field::Derived);
51 field->setFormatType(FieldFormat::FormatNone);
52 list.append(field);
53
54 field = new Field(QStringLiteral("player"), i18n("Player"));
55 field->setCategory(i18n(card_general));
56 field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped);
57 field->setFormatType(FieldFormat::FormatName);
58 list.append(field);
59
60 field = new Field(QStringLiteral("team"), i18n("Team"));
61 field->setCategory(i18n(card_general));
62 field->setFlags(Field::AllowCompletion | Field::AllowGrouped);
63 field->setFormatType(FieldFormat::FormatTitle);
64 list.append(field);
65
66 field = new Field(QStringLiteral("brand"), i18n("Brand"));
67 field->setCategory(i18n(card_general));
68 field->setFlags(Field::AllowCompletion | Field::AllowGrouped);
69 field->setFormatType(FieldFormat::FormatPlain);
70 list.append(field);
71
72 // might not be totally numeric!
73 field = new Field(QStringLiteral("number"), i18n("Card Number"));
74 field->setCategory(i18n(card_general));
75 list.append(field);
76
77 field = new Field(QStringLiteral("year"), i18n("Year"), Field::Number);
78 field->setCategory(i18n(card_general));
79 field->setFlags(Field::AllowGrouped);
80 list.append(field);
81
82 field = new Field(QStringLiteral("series"), i18n("Series"));
83 field->setCategory(i18n(card_general));
84 field->setFlags(Field::AllowCompletion | Field::AllowGrouped);
85 field->setFormatType(FieldFormat::FormatTitle);
86 list.append(field);
87
88 field = new Field(QStringLiteral("type"), i18n("Card Type"));
89 field->setCategory(i18n(card_general));
90 field->setFlags(Field::AllowCompletion | Field::AllowGrouped);
91 list.append(field);
92
93 field = new Field(QStringLiteral("pur_date"), i18n("Purchase Date"));
94 field->setCategory(i18n(card_personal));
95 field->setFormatType(FieldFormat::FormatDate);
96 list.append(field);
97
98 field = new Field(QStringLiteral("pur_price"), i18n("Purchase Price"));
99 field->setCategory(i18n(card_personal));
100 list.append(field);
101
102 field = new Field(QStringLiteral("location"), i18n("Location"));
103 field->setCategory(i18n(card_personal));
104 field->setFlags(Field::AllowCompletion | Field::AllowGrouped);
105 list.append(field);
106
107 field = new Field(QStringLiteral("gift"), i18n("Gift"), Field::Bool);
108 field->setCategory(i18n(card_personal));
109 list.append(field);
110
111 field = new Field(QStringLiteral("keyword"), i18n("Keywords"));
112 field->setCategory(i18n(card_personal));
113 field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped);
114 list.append(field);
115
116 field = new Field(QStringLiteral("quantity"), i18n("Quantity"), Field::Number);
117 field->setCategory(i18n(card_personal));
118 list.append(field);
119
120 field = new Field(QStringLiteral("front"), i18n("Front Image"), Field::Image);
121 list.append(field);
122
123 field = new Field(QStringLiteral("back"), i18n("Back Image"), Field::Image);
124 list.append(field);
125
126 field = new Field(QStringLiteral("comments"), i18n("Comments"), Field::Para);
127 list.append(field);
128
129 list.append(Field::createDefaultField(Field::IDField));
130 list.append(Field::createDefaultField(Field::CreatedDateField));
131 list.append(Field::createDefaultField(Field::ModifiedDateField));
132
133 return list;
134 }
135