File indexing completed on 2024-05-12 05:09:24

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 "winecollection.h"
0026 
0027 #include <KLocalizedString>
0028 
0029 namespace {
0030   static const char* wine_general = I18N_NOOP("General");
0031   static const char* wine_personal = I18N_NOOP("Personal");
0032 }
0033 
0034 using Tellico::Data::WineCollection;
0035 
0036 WineCollection::WineCollection(bool addDefaultFields_, const QString& title_)
0037    : Collection(title_.isEmpty() ? i18n("My Wines") : title_) {
0038   setDefaultGroupField(QStringLiteral("type"));
0039   if(addDefaultFields_) {
0040     addFields(defaultFields());
0041   }
0042 }
0043 
0044 Tellico::Data::FieldList WineCollection::defaultFields() {
0045   FieldList list;
0046   FieldPtr field;
0047 
0048   field = Field::createDefaultField(Field::TitleField);
0049   field->setProperty(QStringLiteral("template"), QStringLiteral("%{vintage} %{producer:1} %{varietal:1}"));
0050   field->setFlags(Field::NoDelete | Field::Derived);
0051   field->setFormatType(FieldFormat::FormatNone);
0052   list.append(field);
0053 
0054   field = new Field(QStringLiteral("producer"), i18nc("Wine Producer", "Producer"));
0055   field->setCategory(i18n(wine_general));
0056   field->setFlags(Field::AllowCompletion | Field::AllowGrouped);
0057   field->setFormatType(FieldFormat::FormatPlain);
0058   list.append(field);
0059 
0060   field = new Field(QStringLiteral("appellation"), i18n("Appellation"));
0061   field->setCategory(i18n(wine_general));
0062   field->setFlags(Field::AllowCompletion | Field::AllowGrouped);
0063   field->setFormatType(FieldFormat::FormatPlain);
0064   list.append(field);
0065 
0066   field = new Field(QStringLiteral("varietal"), i18n("Varietal"));
0067   field->setCategory(i18n(wine_general));
0068   field->setFlags(Field::AllowCompletion | Field::AllowGrouped);
0069   field->setFormatType(FieldFormat::FormatPlain);
0070   list.append(field);
0071 
0072   field = new Field(QStringLiteral("vintage"), i18n("Vintage"), Field::Number);
0073   field->setCategory(i18n(wine_general));
0074   field->setFlags(Field::AllowGrouped);
0075   list.append(field);
0076 
0077   QStringList type;
0078   type << i18n("Red Wine") << i18n("White Wine") << i18n("Sparkling Wine");
0079   field = new Field(QStringLiteral("type"), i18n("Type"), type);
0080   field->setCategory(i18n(wine_general));
0081   field->setFlags(Field::AllowGrouped);
0082   list.append(field);
0083 
0084   field = new Field(QStringLiteral("country"), i18n("Country"));
0085   field->setCategory(i18n(wine_general));
0086   field->setFlags(Field::AllowCompletion | Field::AllowGrouped);
0087   field->setFormatType(FieldFormat::FormatPlain);
0088   list.append(field);
0089 
0090   field = new Field(QStringLiteral("pur_date"), i18n("Purchase Date"));
0091   field->setCategory(i18n(wine_personal));
0092   field->setFormatType(FieldFormat::FormatDate);
0093   list.append(field);
0094 
0095   field = new Field(QStringLiteral("pur_price"), i18n("Purchase Price"));
0096   field->setCategory(i18n(wine_personal));
0097   list.append(field);
0098 
0099   field = new Field(QStringLiteral("location"), i18n("Location"));
0100   field->setCategory(i18n(wine_personal));
0101   field->setFlags(Field::AllowCompletion | Field::AllowGrouped);
0102   list.append(field);
0103 
0104   field = new Field(QStringLiteral("quantity"), i18n("Quantity"), Field::Number);
0105   field->setCategory(i18n(wine_personal));
0106   list.append(field);
0107 
0108   field = new Field(QStringLiteral("drink-by"), i18n("Drink By"), Field::Number);
0109   field->setCategory(i18n(wine_personal));
0110   field->setFlags(Field::AllowGrouped);
0111   list.append(field);
0112 
0113   field = new Field(QStringLiteral("rating"), i18n("Rating"), Field::Rating);
0114   field->setCategory(i18n(wine_personal));
0115   field->setFlags(Field::AllowGrouped);
0116   list.append(field);
0117 
0118   field = new Field(QStringLiteral("gift"), i18n("Gift"), Field::Bool);
0119   field->setCategory(i18n(wine_personal));
0120   list.append(field);
0121 
0122   field = new Field(QStringLiteral("label"), i18n("Label Image"), Field::Image);
0123   list.append(field);
0124 
0125   field = new Field(QStringLiteral("description"), i18n("Description"), Field::Para);
0126   list.append(field);
0127 
0128   field = new Field(QStringLiteral("comments"), i18n("Comments"), Field::Para);
0129   list.append(field);
0130 
0131   list.append(Field::createDefaultField(Field::IDField));
0132   list.append(Field::createDefaultField(Field::CreatedDateField));
0133   list.append(Field::createDefaultField(Field::ModifiedDateField));
0134 
0135   return list;
0136 }