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 "winecollection.h"
26
27 #include <KLocalizedString>
28
29 namespace {
30 static const char* wine_general = I18N_NOOP("General");
31 static const char* wine_personal = I18N_NOOP("Personal");
32 }
33
34 using Tellico::Data::WineCollection;
35
WineCollection(bool addDefaultFields_,const QString & title_)36 WineCollection::WineCollection(bool addDefaultFields_, const QString& title_)
37 : Collection(title_.isEmpty() ? i18n("My Wines") : title_) {
38 setDefaultGroupField(QStringLiteral("type"));
39 if(addDefaultFields_) {
40 addFields(defaultFields());
41 }
42 }
43
defaultFields()44 Tellico::Data::FieldList WineCollection::defaultFields() {
45 FieldList list;
46 FieldPtr field;
47
48 field = Field::createDefaultField(Field::TitleField);
49 field->setProperty(QStringLiteral("template"), QStringLiteral("%{vintage} %{producer:1} %{varietal:1}"));
50 field->setFlags(Field::NoDelete | Field::Derived);
51 field->setFormatType(FieldFormat::FormatNone);
52 list.append(field);
53
54 field = new Field(QStringLiteral("producer"), i18nc("Wine Producer", "Producer"));
55 field->setCategory(i18n(wine_general));
56 field->setFlags(Field::AllowCompletion | Field::AllowGrouped);
57 field->setFormatType(FieldFormat::FormatPlain);
58 list.append(field);
59
60 field = new Field(QStringLiteral("appellation"), i18n("Appellation"));
61 field->setCategory(i18n(wine_general));
62 field->setFlags(Field::AllowCompletion | Field::AllowGrouped);
63 field->setFormatType(FieldFormat::FormatPlain);
64 list.append(field);
65
66 field = new Field(QStringLiteral("varietal"), i18n("Varietal"));
67 field->setCategory(i18n(wine_general));
68 field->setFlags(Field::AllowCompletion | Field::AllowGrouped);
69 field->setFormatType(FieldFormat::FormatPlain);
70 list.append(field);
71
72 field = new Field(QStringLiteral("vintage"), i18n("Vintage"), Field::Number);
73 field->setCategory(i18n(wine_general));
74 field->setFlags(Field::AllowGrouped);
75 list.append(field);
76
77 QStringList type;
78 type << i18n("Red Wine") << i18n("White Wine") << i18n("Sparkling Wine");
79 field = new Field(QStringLiteral("type"), i18n("Type"), type);
80 field->setCategory(i18n(wine_general));
81 field->setFlags(Field::AllowGrouped);
82 list.append(field);
83
84 field = new Field(QStringLiteral("country"), i18n("Country"));
85 field->setCategory(i18n(wine_general));
86 field->setFlags(Field::AllowCompletion | Field::AllowGrouped);
87 field->setFormatType(FieldFormat::FormatPlain);
88 list.append(field);
89
90 field = new Field(QStringLiteral("pur_date"), i18n("Purchase Date"));
91 field->setCategory(i18n(wine_personal));
92 field->setFormatType(FieldFormat::FormatDate);
93 list.append(field);
94
95 field = new Field(QStringLiteral("pur_price"), i18n("Purchase Price"));
96 field->setCategory(i18n(wine_personal));
97 list.append(field);
98
99 field = new Field(QStringLiteral("location"), i18n("Location"));
100 field->setCategory(i18n(wine_personal));
101 field->setFlags(Field::AllowCompletion | Field::AllowGrouped);
102 list.append(field);
103
104 field = new Field(QStringLiteral("quantity"), i18n("Quantity"), Field::Number);
105 field->setCategory(i18n(wine_personal));
106 list.append(field);
107
108 field = new Field(QStringLiteral("drink-by"), i18n("Drink By"), Field::Number);
109 field->setCategory(i18n(wine_personal));
110 field->setFlags(Field::AllowGrouped);
111 list.append(field);
112
113 field = new Field(QStringLiteral("rating"), i18n("Rating"), Field::Rating);
114 field->setCategory(i18n(wine_personal));
115 field->setFlags(Field::AllowGrouped);
116 list.append(field);
117
118 field = new Field(QStringLiteral("gift"), i18n("Gift"), Field::Bool);
119 field->setCategory(i18n(wine_personal));
120 list.append(field);
121
122 field = new Field(QStringLiteral("label"), i18n("Label Image"), Field::Image);
123 list.append(field);
124
125 field = new Field(QStringLiteral("description"), i18n("Description"), Field::Para);
126 list.append(field);
127
128 field = new Field(QStringLiteral("comments"), i18n("Comments"), Field::Para);
129 list.append(field);
130
131 list.append(Field::createDefaultField(Field::IDField));
132 list.append(Field::createDefaultField(Field::CreatedDateField));
133 list.append(Field::createDefaultField(Field::ModifiedDateField));
134
135 return list;
136 }
137