1 /***************************************************************************
2   misc.cpp
3   -------------------
4   A generic ingredient class
5   -------------------
6   Copyright 1999-2008, David Johnson
7   Please see the header file for copyright and license information
8  ***************************************************************************/
9 
10 #include <QStringList>
11 #include "resource.h"
12 #include "misc.h"
13 
14 using namespace Resource;
15 
16 const QByteArray Misc::YEAST_STRING    = QT_TRANSLATE_NOOP("misc", "Yeast");
17 const QByteArray Misc::FINING_STRING   = QT_TRANSLATE_NOOP("misc", "Fining");
18 const QByteArray Misc::HERB_STRING     = QT_TRANSLATE_NOOP("misc", "Herb");
19 const QByteArray Misc::SPICE_STRING    = QT_TRANSLATE_NOOP("misc", "Spice");
20 const QByteArray Misc::FLAVOR_STRING   = QT_TRANSLATE_NOOP("misc", "Flavor");
21 const QByteArray Misc::ADDITIVE_STRING = QT_TRANSLATE_NOOP("misc", "Additive");
22 const QByteArray Misc::OTHER_STRING    = QT_TRANSLATE_NOOP("misc", "Other");
23 
24 //////////////////////////////////////////////////////////////////////////////
25 // Misc()
26 // ------
27 // constructor
28 
Misc()29 Misc::Misc()
30     : name_(QObject::tr("Generic")), quantity_(), type_(OTHER_STRING), notes_()
31 { ; }
32 
Misc(const QString & name,const Quantity & quantity,const QString & typ,const QString & notes)33 Misc::Misc(const QString &name, const Quantity &quantity, const QString &typ,
34            const QString &notes)
35     : name_(name), quantity_(quantity),  type_(typ),
36       notes_(notes)
37 { ; }
38 
~Misc()39 Misc::~Misc() { ; }
40 
41 //////////////////////////////////////////////////////////////////////////////
42 // Misc()
43 // ------
44 // copy constructor
45 
Misc(const Misc & m)46 Misc::Misc(const Misc &m)
47     : name_(m.name_), quantity_(m.quantity_), type_(m.type_), notes_(m.notes_)
48 { ; }
49 
50 //////////////////////////////////////////////////////////////////////////////
51 // operator=()
52 // -----------
53 // Assignment operator
54 
operator =(const Misc & m)55 Misc Misc::operator=(const Misc &m)
56 {
57     if (this != &m) {
58         name_ = m.name_;
59         quantity_ = m.quantity_;
60         type_ = m.type_;
61         notes_ = m.notes_;
62     }
63     return *this;
64 }
65 
66 //////////////////////////////////////////////////////////////////////////////
67 // operator==()
68 // -----------
69 // Equivalence operator
70 
operator ==(const Misc & m) const71 bool Misc::operator==(const Misc &m) const
72 {
73     return (name_ == m.name_)
74         && (quantity_ == m.quantity_)
75         && (type_ == m.type_)
76         && (notes_ == m.notes_);
77 }
78 
79 ///////////////////////////////////////////////////////////////////////////////
80 // typeStringList()
81 // ----------------
82 // Return string list of misc types
83 
typeStringList()84 QStringList Misc::typeStringList()
85 {
86     return (QStringList()
87             << YEAST_STRING
88             << FINING_STRING
89             << HERB_STRING
90             << SPICE_STRING
91             << FLAVOR_STRING
92             << ADDITIVE_STRING
93             << OTHER_STRING);
94 }
95