1 /***************************************************************************
2     Copyright (C) 2005-2009 Robby Stephenson <robby@periapsis.org>
3     Copyright (C) 2005-2009 Steve Beattie <sbeattie@suse.de>
4  ***************************************************************************/
5 
6 /***************************************************************************
7  *                                                                         *
8  *   This program is free software; you can redistribute it and/or         *
9  *   modify it under the terms of the GNU General Public License as        *
10  *   published by the Free Software Foundation; either version 2 of        *
11  *   the License or (at your option) version 3 or any later version        *
12  *   accepted by the membership of KDE e.V. (or its successor approved     *
13  *   by the membership of KDE e.V.), which shall act as a proxy            *
14  *   defined in Section 14 of version 3 of the license.                    *
15  *                                                                         *
16  *   This program is distributed in the hope that it will be useful,       *
17  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
18  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
19  *   GNU General Public License for more details.                          *
20  *                                                                         *
21  *   You should have received a copy of the GNU General Public License     *
22  *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
23  *                                                                         *
24  ***************************************************************************/
25 
26 #include "boardgamecollection.h"
27 
28 #include <KLocalizedString>
29 
30 namespace {
31   static const char* boardgame_general = I18N_NOOP("General");
32   static const char* boardgame_personal = I18N_NOOP("Personal");
33 }
34 
35 using Tellico::Data::BoardGameCollection;
36 
BoardGameCollection(bool addDefaultFields_,const QString & title_)37 BoardGameCollection::BoardGameCollection(bool addDefaultFields_, const QString& title_)
38    : Collection(title_.isEmpty() ? i18n("My Board Games") : title_) {
39   setDefaultGroupField(QStringLiteral("genre"));
40   if(addDefaultFields_) {
41     addFields(defaultFields());
42   }
43 }
44 
defaultFields()45 Tellico::Data::FieldList BoardGameCollection::defaultFields() {
46   FieldList list;
47   FieldPtr field;
48 
49   list.append(Field::createDefaultField(Field::TitleField));
50 
51   field = new Field(QStringLiteral("genre"), i18n("Genre"));
52   field->setCategory(i18n(boardgame_general));
53   field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped);
54   field->setFormatType(FieldFormat::FormatPlain);
55   list.append(field);
56 
57   field = new Field(QStringLiteral("mechanism"), i18n("Mechanism"));
58   field->setCategory(i18n(boardgame_general));
59   field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped);
60   field->setFormatType(FieldFormat::FormatPlain);
61   list.append(field);
62 
63   field = new Field(QStringLiteral("year"), i18n("Release Year"), Field::Number);
64   field->setCategory(i18n(boardgame_general));
65   field->setFlags(Field::AllowGrouped);
66   list.append(field);
67 
68   field = new Field(QStringLiteral("publisher"), i18n("Publisher"));
69   field->setCategory(i18n(boardgame_general));
70   field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped);
71   field->setFormatType(FieldFormat::FormatPlain);
72   list.append(field);
73 
74   field = new Field(QStringLiteral("designer"), i18n("Designer"));
75   field->setCategory(i18n(boardgame_general));
76   field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped);
77   field->setFormatType(FieldFormat::FormatPlain);
78   list.append(field);
79 
80   field = new Field(QStringLiteral("num-player"), i18n("Number of Players"), Field::Number);
81   field->setCategory(i18n(boardgame_general));
82   field->setFlags(Field::AllowMultiple | Field::AllowGrouped);
83   list.append(field);
84 
85   field = new Field(QStringLiteral("playing-time"), i18n("Playing Time"), Field::Number);
86   field->setCategory(i18n(boardgame_general));
87   field->setFlags(Field::AllowGrouped);
88   list.append(field);
89 
90   field = new Field(QStringLiteral("minimum-age"), i18n("Minimum Age"), Field::Number);
91   field->setCategory(i18n(boardgame_general));
92   field->setFlags(Field::AllowGrouped);
93   list.append(field);
94 
95   field = new Field(QStringLiteral("description"), i18n("Description"), Field::Para);
96   list.append(field);
97 
98   field = new Field(QStringLiteral("rating"), i18n("Rating"), Field::Rating);
99   field->setCategory(i18n(boardgame_personal));
100   field->setFlags(Field::AllowGrouped);
101   list.append(field);
102 
103   field = new Field(QStringLiteral("pur_date"), i18n("Purchase Date"));
104   field->setCategory(i18n(boardgame_personal));
105   field->setFormatType(FieldFormat::FormatDate);
106   list.append(field);
107 
108   field = new Field(QStringLiteral("gift"), i18n("Gift"), Field::Bool);
109   field->setCategory(i18n(boardgame_personal));
110   list.append(field);
111 
112   field = new Field(QStringLiteral("pur_price"), i18n("Purchase Price"));
113   field->setCategory(i18n(boardgame_personal));
114   list.append(field);
115 
116   field = new Field(QStringLiteral("loaned"), i18n("Loaned"), Field::Bool);
117   field->setCategory(i18n(boardgame_personal));
118   list.append(field);
119 
120   field = new Field(QStringLiteral("cover"), i18n("Cover"), Field::Image);
121   list.append(field);
122 
123   field = new Field(QStringLiteral("comments"), i18n("Comments"), Field::Para);
124   field->setCategory(i18n(boardgame_personal));
125   list.append(field);
126 
127   list.append(Field::createDefaultField(Field::IDField));
128   list.append(Field::createDefaultField(Field::CreatedDateField));
129   list.append(Field::createDefaultField(Field::ModifiedDateField));
130 
131   return list;
132 }
133