diff options
Diffstat (limited to 'src/collections')
25 files changed, 2656 insertions, 0 deletions
diff --git a/src/collections/Makefile.am b/src/collections/Makefile.am new file mode 100644 index 0000000..21543d0 --- /dev/null +++ b/src/collections/Makefile.am @@ -0,0 +1,32 @@ +####### kdevelop will overwrite this part!!! (begin)########## +noinst_LIBRARIES = libcollections.a + +AM_CPPFLAGS = $(all_includes) + +libcollections_a_METASOURCES = AUTO + +libcollections_a_SOURCES = winecollection.cpp stampcollection.cpp \ + comicbookcollection.cpp cardcollection.cpp coincollection.cpp \ + bibtexcollection.cpp musiccollection.cpp videocollection.cpp \ + bookcollection.cpp gamecollection.cpp filecatalog.cpp \ + boardgamecollection.cpp + +####### kdevelop will overwrite this part!!! (end)############ + +KDE_OPTIONS = noautodist + +CLEANFILES = *~ *.loT + +EXTRA_DIST = \ +bookcollection.cpp bookcollection.h \ +videocollection.cpp videocollection.h \ +musiccollection.cpp musiccollection.h \ +bibtexcollection.cpp bibtexcollection.h \ +coincollection.cpp coincollection.h \ +cardcollection.cpp cardcollection.h \ +comicbookcollection.cpp comicbookcollection.h \ +stampcollection.cpp stampcollection.h \ +winecollection.cpp winecollection.h \ +gamecollection.h gamecollection.cpp \ +filecatalog.h filecatalog.cpp \ +boardgamecollection.h boardgamecollection.cpp diff --git a/src/collections/bibtexcollection.cpp b/src/collections/bibtexcollection.cpp new file mode 100644 index 0000000..f069cc9 --- /dev/null +++ b/src/collections/bibtexcollection.cpp @@ -0,0 +1,400 @@ +/*************************************************************************** + copyright : (C) 2003-2006 by Robby Stephenson + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of version 2 of the GNU General Public License as * + * published by the Free Software Foundation; * + * * + ***************************************************************************/ + +#include "bibtexcollection.h" +#include "../latin1literal.h" +#include "../document.h" +#include "../tellico_debug.h" + +#include <klocale.h> + +using Tellico::Data::BibtexCollection; + +namespace { + static const char* bibtex_general = I18N_NOOP("General"); + static const char* bibtex_publishing = I18N_NOOP("Publishing"); + static const char* bibtex_misc = I18N_NOOP("Miscellaneous"); +} + +BibtexCollection::BibtexCollection(bool addFields_, const QString& title_ /*=null*/) + : Collection(title_.isEmpty() ? i18n("Bibliography") : title_) { + if(addFields_) { + addFields(defaultFields()); + } + setDefaultGroupField(QString::fromLatin1("author")); + + // Bibtex has some default macros for the months + addMacro(QString::fromLatin1("jan"), QString::null); + addMacro(QString::fromLatin1("feb"), QString::null); + addMacro(QString::fromLatin1("mar"), QString::null); + addMacro(QString::fromLatin1("apr"), QString::null); + addMacro(QString::fromLatin1("may"), QString::null); + addMacro(QString::fromLatin1("jun"), QString::null); + addMacro(QString::fromLatin1("jul"), QString::null); + addMacro(QString::fromLatin1("aug"), QString::null); + addMacro(QString::fromLatin1("sep"), QString::null); + addMacro(QString::fromLatin1("oct"), QString::null); + addMacro(QString::fromLatin1("nov"), QString::null); + addMacro(QString::fromLatin1("dec"), QString::null); +} + +Tellico::Data::FieldVec BibtexCollection::defaultFields() { + FieldVec list; + FieldPtr field; + +/******************* General ****************************/ + field = new Field(QString::fromLatin1("title"), i18n("Title")); + field->setProperty(QString::fromLatin1("bibtex"), QString::fromLatin1("title")); + field->setCategory(i18n("General")); + field->setFlags(Field::NoDelete); + field->setFormatFlag(Field::FormatTitle); + list.append(field); + + QStringList types; + types << QString::fromLatin1("article") << QString::fromLatin1("book") + << QString::fromLatin1("booklet") << QString::fromLatin1("inbook") + << QString::fromLatin1("incollection") << QString::fromLatin1("inproceedings") + << QString::fromLatin1("manual") << QString::fromLatin1("mastersthesis") + << QString::fromLatin1("misc") << QString::fromLatin1("phdthesis") + << QString::fromLatin1("proceedings") << QString::fromLatin1("techreport") + << QString::fromLatin1("unpublished") << QString::fromLatin1("periodical") + << QString::fromLatin1("conference"); + field = new Field(QString::fromLatin1("entry-type"), i18n("Entry Type"), types); + field->setProperty(QString::fromLatin1("bibtex"), QString::fromLatin1("entry-type")); + field->setCategory(i18n(bibtex_general)); + field->setFlags(Field::AllowGrouped | Field::NoDelete); + field->setDescription(i18n("These entry types are specific to bibtex. See the bibtex documentation.")); + list.append(field); + + field = new Field(QString::fromLatin1("author"), i18n("Author")); + field->setProperty(QString::fromLatin1("bibtex"), QString::fromLatin1("author")); + field->setCategory(i18n(bibtex_general)); + field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); + field->setFormatFlag(Field::FormatName); + list.append(field); + + field = new Field(QString::fromLatin1("bibtex-key"), i18n("Bibtex Key")); + field->setProperty(QString::fromLatin1("bibtex"), QString::fromLatin1("key")); + field->setCategory(i18n("General")); + field->setFlags(Field::NoDelete); + list.append(field); + + field = new Field(QString::fromLatin1("booktitle"), i18n("Book Title")); + field->setProperty(QString::fromLatin1("bibtex"), QString::fromLatin1("booktitle")); + field->setCategory(i18n(bibtex_general)); + field->setFormatFlag(Field::FormatTitle); + list.append(field); + + field = new Field(QString::fromLatin1("editor"), i18n("Editor")); + field->setProperty(QString::fromLatin1("bibtex"), QString::fromLatin1("editor")); + field->setCategory(i18n(bibtex_general)); + field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); + field->setFormatFlag(Field::FormatName); + list.append(field); + + field = new Field(QString::fromLatin1("organization"), i18n("Organization")); + field->setProperty(QString::fromLatin1("bibtex"), QString::fromLatin1("organization")); + field->setCategory(i18n(bibtex_general)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + field->setFormatFlag(Field::FormatPlain); + list.append(field); + +// field = new Field(QString::fromLatin1("institution"), i18n("Institution")); +// field->setProperty(QString::fromLatin1("bibtex"), QString::fromLatin1("institution")); +// field->setCategory(i18n(bibtex_general)); +// field->setFlags(Field::AllowDelete); +// field->setFormatFlag(Field::FormatTitle); +// list.append(field); + +/******************* Publishing ****************************/ + field = new Field(QString::fromLatin1("publisher"), i18n("Publisher")); + field->setProperty(QString::fromLatin1("bibtex"), QString::fromLatin1("publisher")); + field->setCategory(i18n(bibtex_publishing)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + field->setFormatFlag(Field::FormatPlain); + list.append(field); + + field = new Field(QString::fromLatin1("address"), i18n("Address")); + field->setProperty(QString::fromLatin1("bibtex"), QString::fromLatin1("address")); + field->setCategory(i18n(bibtex_publishing)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("edition"), i18n("Edition")); + field->setProperty(QString::fromLatin1("bibtex"), QString::fromLatin1("edition")); + field->setCategory(i18n(bibtex_publishing)); + field->setFlags(Field::AllowCompletion); + list.append(field); + + // don't make it a nuumber, it could have latex processing commands in it + field = new Field(QString::fromLatin1("pages"), i18n("Pages")); + field->setProperty(QString::fromLatin1("bibtex"), QString::fromLatin1("pages")); + field->setCategory(i18n(bibtex_publishing)); + list.append(field); + + field = new Field(QString::fromLatin1("year"), i18n("Year"), Field::Number); + field->setProperty(QString::fromLatin1("bibtex"), QString::fromLatin1("year")); + field->setCategory(i18n(bibtex_publishing)); + field->setFlags(Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("isbn"), i18n("ISBN#")); + field->setProperty(QString::fromLatin1("bibtex"), QString::fromLatin1("isbn")); + field->setCategory(i18n(bibtex_publishing)); + field->setDescription(i18n("International Standard Book Number")); + list.append(field); + + field = new Field(QString::fromLatin1("journal"), i18n("Journal")); + field->setProperty(QString::fromLatin1("bibtex"), QString::fromLatin1("journal")); + field->setCategory(i18n(bibtex_publishing)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + field->setFormatFlag(Field::FormatPlain); + list.append(field); + + field = new Field(QString::fromLatin1("doi"), i18n("DOI")); + field->setProperty(QString::fromLatin1("bibtex"), QString::fromLatin1("doi")); + field->setCategory(i18n(bibtex_publishing)); + field->setDescription(i18n("Digital Object Identifier")); + list.append(field); + + // could make this a string list, but since bibtex import could have funky values + // keep it an editbox + field = new Field(QString::fromLatin1("month"), i18n("Month")); + field->setProperty(QString::fromLatin1("bibtex"), QString::fromLatin1("month")); + field->setCategory(i18n(bibtex_publishing)); + field->setFlags(Field::AllowCompletion); + list.append(field); + + field = new Field(QString::fromLatin1("number"), i18n("Number"), Field::Number); + field->setProperty(QString::fromLatin1("bibtex"), QString::fromLatin1("number")); + field->setCategory(i18n(bibtex_publishing)); + list.append(field); + + field = new Field(QString::fromLatin1("howpublished"), i18n("How Published")); + field->setProperty(QString::fromLatin1("bibtex"), QString::fromLatin1("howpublished")); + field->setCategory(i18n(bibtex_publishing)); + list.append(field); + +// field = new Field(QString::fromLatin1("school"), i18n("School")); +// field->setProperty(QString::fromLatin1("bibtex"), QString::fromLatin1("school")); +// field->setCategory(i18n(bibtex_publishing)); +// field->setFlags(Field::AllowCompletion | Field::AllowGrouped); +// list.append(field); + +/******************* Classification ****************************/ + field = new Field(QString::fromLatin1("chapter"), i18n("Chapter"), Field::Number); + field->setProperty(QString::fromLatin1("bibtex"), QString::fromLatin1("chapter")); + field->setCategory(i18n(bibtex_misc)); + list.append(field); + + field = new Field(QString::fromLatin1("series"), i18n("Series")); + field->setProperty(QString::fromLatin1("bibtex"), QString::fromLatin1("series")); + field->setCategory(i18n(bibtex_misc)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + field->setFormatFlag(Field::FormatTitle); + list.append(field); + + field = new Field(QString::fromLatin1("volume"), i18n("Volume"), Field::Number); + field->setProperty(QString::fromLatin1("bibtex"), QString::fromLatin1("volume")); + field->setCategory(i18n(bibtex_misc)); + list.append(field); + + field = new Field(QString::fromLatin1("crossref"), i18n("Cross-Reference")); + field->setProperty(QString::fromLatin1("bibtex"), QString::fromLatin1("crossref")); + field->setCategory(i18n(bibtex_misc)); + list.append(field); + +// field = new Field(QString::fromLatin1("annote"), i18n("Annotation")); +// field->setProperty(QString::fromLatin1("bibtex"), QString::fromLatin1("annote")); +// field->setCategory(i18n(bibtex_misc)); +// list.append(field); + + field = new Field(QString::fromLatin1("keyword"), i18n("Keywords")); + field->setProperty(QString::fromLatin1("bibtex"), QString::fromLatin1("keywords")); + field->setCategory(i18n(bibtex_misc)); + field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("url"), i18n("URL"), Field::URL); + field->setProperty(QString::fromLatin1("bibtex"), QString::fromLatin1("url")); + field->setCategory(i18n(bibtex_misc)); + list.append(field); + + field = new Field(QString::fromLatin1("abstract"), i18n("Abstract"), Data::Field::Para); + field->setProperty(QString::fromLatin1("bibtex"), QString::fromLatin1("abstract")); + list.append(field); + + field = new Field(QString::fromLatin1("note"), i18n("Notes"), Field::Para); + field->setProperty(QString::fromLatin1("bibtex"), QString::fromLatin1("note")); + list.append(field); + + return list; +} + +bool BibtexCollection::addField(FieldPtr field_) { + if(!field_) { + return false; + } +// myDebug() << "BibtexCollection::addField()" << endl; + bool success = Collection::addField(field_); + if(success) { + QString bibtex = field_->property(QString::fromLatin1("bibtex")); + if(!bibtex.isEmpty()) { + m_bibtexFieldDict.insert(bibtex, field_); + } + } + return success; +} + +bool BibtexCollection::modifyField(FieldPtr newField_) { + if(!newField_) { + return false; + } +// myDebug() << "BibtexCollection::modifyField()" << endl; + bool success = Collection::modifyField(newField_); + FieldPtr oldField = fieldByName(newField_->name()); + QString oldBibtex = oldField->property(QString::fromLatin1("bibtex")); + QString newBibtex = newField_->property(QString::fromLatin1("bibtex")); + if(!oldBibtex.isEmpty()) { + success &= m_bibtexFieldDict.remove(oldBibtex); + } + if(!newBibtex.isEmpty()) { + oldField->setProperty(QString::fromLatin1("bibtex"), newBibtex); + m_bibtexFieldDict.insert(newBibtex, oldField); + } + return success; +} + +bool BibtexCollection::deleteField(FieldPtr field_, bool force_) { + if(!field_) { + return false; + } +// myDebug() << "BibtexCollection::deleteField()" << endl; + bool success = true; + QString bibtex = field_->property(QString::fromLatin1("bibtex")); + if(!bibtex.isEmpty()) { + success &= m_bibtexFieldDict.remove(bibtex); + } + return success && Collection::removeField(field_, force_); +} + +Tellico::Data::FieldPtr BibtexCollection::fieldByBibtexName(const QString& bibtex_) const { + return m_bibtexFieldDict.isEmpty() ? 0 : m_bibtexFieldDict.find(bibtex_); +} + +// same as BookCollection::sameEntry() +int BibtexCollection::sameEntry(Data::EntryPtr entry1_, Data::EntryPtr entry2_) const { + // equal isbn's or lccn's are easy, give it a weight of 100 + if(Entry::compareValues(entry1_, entry2_, QString::fromLatin1("isbn"), this) > 0 || + Entry::compareValues(entry1_, entry2_, QString::fromLatin1("lccn"), this) > 0 || + Entry::compareValues(entry1_, entry2_, QString::fromLatin1("doi"), this) > 0 || + Entry::compareValues(entry1_, entry2_, QString::fromLatin1("pmid"), this) > 0 || + Entry::compareValues(entry1_, entry2_, QString::fromLatin1("arxiv"), this) > 0) { + return 100; // good match + } + int res = 3*Entry::compareValues(entry1_, entry2_, QString::fromLatin1("title"), this); +// if(res == 0) { +// myDebug() << "BookCollection::sameEntry() - different titles for " << entry1_->title() << " vs. " +// << entry2_->title() << endl; +// } + res += Entry::compareValues(entry1_, entry2_, QString::fromLatin1("author"), this); + res += Entry::compareValues(entry1_, entry2_, QString::fromLatin1("cr_year"), this); + res += Entry::compareValues(entry1_, entry2_, QString::fromLatin1("pub_year"), this); + res += Entry::compareValues(entry1_, entry2_, QString::fromLatin1("binding"), this); + return res; +} + +// static +Tellico::Data::CollPtr BibtexCollection::convertBookCollection(CollPtr coll_) { + const QString bibtex = QString::fromLatin1("bibtex"); + KSharedPtr<BibtexCollection> coll = new BibtexCollection(false, coll_->title()); + FieldVec fields = coll_->fields(); + for(FieldVec::Iterator fIt = fields.begin(); fIt != fields.end(); ++fIt) { + FieldPtr field = new Data::Field(*fIt); + + // if it already has a bibtex property, skip it + if(!field->property(bibtex).isEmpty()) { + coll->addField(field); + continue; + } + + // be sure to set bibtex property before adding it though + QString name = field->name(); + // this first group has bibtex field names the same as their own field name + if(name == Latin1Literal("title") + || name == Latin1Literal("author") + || name == Latin1Literal("editor") + || name == Latin1Literal("edition") + || name == Latin1Literal("publisher") + || name == Latin1Literal("isbn") + || name == Latin1Literal("lccn") + || name == Latin1Literal("url") + || name == Latin1Literal("language") + || name == Latin1Literal("pages") + || name == Latin1Literal("series")) { + field->setProperty(bibtex, name); + } else if(name == Latin1Literal("series_num")) { + field->setProperty(bibtex, QString::fromLatin1("number")); + } else if(name == Latin1Literal("pur_price")) { + field->setProperty(bibtex, QString::fromLatin1("price")); + } else if(name == Latin1Literal("cr_year")) { + field->setProperty(bibtex, QString::fromLatin1("year")); + } else if(name == Latin1Literal("bibtex-id")) { + field->setProperty(bibtex, QString::fromLatin1("key")); + } else if(name == Latin1Literal("keyword")) { + field->setProperty(bibtex, QString::fromLatin1("keywords")); + } else if(name == Latin1Literal("comments")) { + field->setProperty(bibtex, QString::fromLatin1("note")); + } + coll->addField(field); + } + + // also need to add required fields + FieldVec vec = defaultFields(); + for(FieldVec::Iterator it = vec.begin(); it != vec.end(); ++it) { + if(!coll->hasField(it->name()) && (it->flags() & Field::NoDelete)) { + // but don't add a Bibtex Key if there's already a bibtex-id + if(it->property(bibtex) != Latin1Literal("key") + || !coll->hasField(QString::fromLatin1("bibtex-id"))) { + coll->addField(it); + } + } + } + + // set the entry-type to book + FieldPtr field = coll->fieldByBibtexName(QString::fromLatin1("entry-type")); + QString entryTypeName; + if(field) { + entryTypeName = field->name(); + } else { + kdWarning() << "BibtexCollection::convertBookCollection() - there must be an entry type field" << endl; + } + + EntryVec newEntries; + for(EntryVec::ConstIterator entryIt = coll_->entries().begin(); entryIt != coll_->entries().end(); ++entryIt) { + Data::EntryPtr entry = new Entry(*entryIt); + entry->setCollection(coll.data()); + if(!entryTypeName.isEmpty()) { + entry->setField(entryTypeName, QString::fromLatin1("book")); + } + newEntries.append(entry); + } + coll->addEntries(newEntries); + + // now need to make sure all images are transferred + Document::self()->loadAllImagesNow(); + + return coll.data(); +} + +#include "bibtexcollection.moc" diff --git a/src/collections/bibtexcollection.h b/src/collections/bibtexcollection.h new file mode 100644 index 0000000..628cc37 --- /dev/null +++ b/src/collections/bibtexcollection.h @@ -0,0 +1,70 @@ +/*************************************************************************** + copyright : (C) 2003-2006 by Robby Stephenson + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of version 2 of the GNU General Public License as * + * published by the Free Software Foundation; * + * * + ***************************************************************************/ + +#ifndef BIBTEXCOLLECTION_H +#define BIBTEXCOLLECTION_H + +#include "../collection.h" + +namespace Tellico { + namespace Data { + +/** + * A collection specifically for bibliographies, in Bibtex format. + * + * It has the following standard attributes: + * @li Title + * + * @author Robby Stephenson + */ +class BibtexCollection : public Collection { +Q_OBJECT + +public: + /** + * The constructor + * + * @param addFields A boolean indicating whether the default attributes should be added + * @param title The title of the collection + */ + BibtexCollection(bool addFields, const QString& title = QString::null); + /** + */ + virtual ~BibtexCollection() {} + + virtual Type type() const { return Bibtex; } + virtual bool addField(FieldPtr field); + virtual bool modifyField(FieldPtr field); + virtual bool deleteField(FieldPtr field, bool force=false); + + FieldPtr fieldByBibtexName(const QString& name) const; + const QString& preamble() const { return m_preamble; } + void setPreamble(const QString& preamble) { m_preamble = preamble; } + const StringMap& macroList() const { return m_macros; } + void setMacroList(StringMap map) { m_macros = map; } + void addMacro(const QString& key, const QString& value) { m_macros.insert(key, value); } + + virtual int sameEntry(Data::EntryPtr entry1, Data::EntryPtr entry2) const; + + static FieldVec defaultFields(); + static CollPtr convertBookCollection(CollPtr coll); + +private: + QDict<Field> m_bibtexFieldDict; + QString m_preamble; + StringMap m_macros; +}; + + } // end namespace +} // end namespace +#endif diff --git a/src/collections/boardgamecollection.cpp b/src/collections/boardgamecollection.cpp new file mode 100644 index 0000000..4899e0e --- /dev/null +++ b/src/collections/boardgamecollection.cpp @@ -0,0 +1,112 @@ +/*************************************************************************** + copyright : (C) 2005-2006 by Robby Stephenson, Steve Beattie + email : [email protected], [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of version 2 of the GNU General Public License as * + * published by the Free Software Foundation; * + * * + ***************************************************************************/ + +#include "boardgamecollection.h" + +#include <klocale.h> + +namespace { + static const char* boardgame_general = I18N_NOOP("General"); + static const char* boardgame_personal = I18N_NOOP("Personal"); +} + +using Tellico::Data::BoardGameCollection; + +BoardGameCollection::BoardGameCollection(bool addFields_, const QString& title_ /*=null*/) + : Collection(title_.isEmpty() ? i18n("My Board Games") : title_) { + if(addFields_) { + addFields(defaultFields()); + } + setDefaultGroupField(QString::fromLatin1("genre")); +} + +Tellico::Data::FieldVec BoardGameCollection::defaultFields() { + FieldVec list; + FieldPtr field; + + field = new Field(QString::fromLatin1("title"), i18n("Title")); + field->setCategory(i18n(boardgame_general)); + field->setFlags(Field::NoDelete); + field->setFormatFlag(Field::FormatTitle); + list.append(field); + + field = new Field(QString::fromLatin1("genre"), i18n("Genre")); + field->setCategory(i18n(boardgame_general)); + field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); + field->setFormatFlag(Field::FormatPlain); + list.append(field); + + field = new Field(QString::fromLatin1("mechanism"), i18n("Mechanism")); + field->setCategory(i18n(boardgame_general)); + field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); + field->setFormatFlag(Field::FormatPlain); + list.append(field); + + field = new Field(QString::fromLatin1("year"), i18n("Release Year"), Field::Number); + field->setCategory(i18n(boardgame_general)); + field->setFlags(Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("publisher"), i18n("Publisher")); + field->setCategory(i18n(boardgame_general)); + field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); + field->setFormatFlag(Field::FormatPlain); + list.append(field); + + field = new Field(QString::fromLatin1("designer"), i18n("Designer")); + field->setCategory(i18n(boardgame_general)); + field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); + field->setFormatFlag(Field::FormatPlain); + list.append(field); + + field = new Field(QString::fromLatin1("num-player"), i18n("Number of Players"), Field::Number); + field->setCategory(i18n(boardgame_general)); + field->setFlags(Field::AllowMultiple | Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("description"), i18n("Description"), Field::Para); + list.append(field); + + field = new Field(QString::fromLatin1("rating"), i18n("Rating"), Field::Rating); + field->setCategory(i18n(boardgame_personal)); + field->setFlags(Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("pur_date"), i18n("Purchase Date")); + field->setCategory(i18n(boardgame_personal)); + field->setFormatFlag(Field::FormatDate); + list.append(field); + + field = new Field(QString::fromLatin1("gift"), i18n("Gift"), Field::Bool); + field->setCategory(i18n(boardgame_personal)); + list.append(field); + + field = new Field(QString::fromLatin1("pur_price"), i18n("Purchase Price")); + field->setCategory(i18n(boardgame_personal)); + list.append(field); + + field = new Field(QString::fromLatin1("loaned"), i18n("Loaned"), Field::Bool); + field->setCategory(i18n(boardgame_personal)); + list.append(field); + + field = new Field(QString::fromLatin1("cover"), i18n("Cover"), Field::Image); + list.append(field); + + field = new Field(QString::fromLatin1("comments"), i18n("Comments"), Field::Para); + field->setCategory(i18n(boardgame_personal)); + list.append(field); + + return list; +} + +#include "boardgamecollection.moc" diff --git a/src/collections/boardgamecollection.h b/src/collections/boardgamecollection.h new file mode 100644 index 0000000..642fc31 --- /dev/null +++ b/src/collections/boardgamecollection.h @@ -0,0 +1,44 @@ +/*************************************************************************** + copyright : (C) 2005-2006 by Robby Stephenson, Steve Beattie + email : [email protected], [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of version 2 of the GNU General Public License as * + * published by the Free Software Foundation; * + * * + ***************************************************************************/ + +#ifndef BOARDGAMECOLLECTION_H +#define BOARDGAMECOLLECTION_H + +#include "../collection.h" + +namespace Tellico { + namespace Data { + +/** + * A collection for board (not bored) games. + */ +class BoardGameCollection : public Collection { +Q_OBJECT + +public: + /** + * The constructor + * + * @param addFields Whether to add the default attributes + * @param title The title of the collection + */ + BoardGameCollection(bool addFields, const QString& title = QString::null); + + virtual Type type() const { return BoardGame; } + + static FieldVec defaultFields(); +}; + + } // end namespace +} // end namespace +#endif diff --git a/src/collections/bookcollection.cpp b/src/collections/bookcollection.cpp new file mode 100644 index 0000000..0137156 --- /dev/null +++ b/src/collections/bookcollection.cpp @@ -0,0 +1,202 @@ +/*************************************************************************** + copyright : (C) 2003-2006 by Robby Stephenson + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of version 2 of the GNU General Public License as * + * published by the Free Software Foundation; * + * * + ***************************************************************************/ + +#include "bookcollection.h" + +#include <klocale.h> + +namespace { + static const char* book_general = I18N_NOOP("General"); + static const char* book_publishing = I18N_NOOP("Publishing"); + static const char* book_classification = I18N_NOOP("Classification"); + static const char* book_personal = I18N_NOOP("Personal"); +} + +using Tellico::Data::BookCollection; + +BookCollection::BookCollection(bool addFields_, const QString& title_ /*=null*/) + : Collection(title_.isEmpty() ? i18n("My Books") : title_) { + if(addFields_) { + addFields(defaultFields()); + } + setDefaultGroupField(QString::fromLatin1("author")); +} + +Tellico::Data::FieldVec BookCollection::defaultFields() { + FieldVec list; + FieldPtr field; + + field = new Field(QString::fromLatin1("title"), i18n("Title")); + field->setCategory(i18n("General")); + field->setFlags(Field::NoDelete); + field->setFormatFlag(Field::FormatTitle); + list.append(field); + + field = new Field(QString::fromLatin1("subtitle"), i18n("Subtitle")); + field->setCategory(i18n(book_general)); + field->setFormatFlag(Field::FormatTitle); + list.append(field); + + field = new Field(QString::fromLatin1("author"), i18n("Author")); + field->setCategory(i18n(book_general)); + field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); + field->setFormatFlag(Field::FormatName); + list.append(field); + + field = new Field(QString::fromLatin1("editor"), i18n("Editor")); + field->setCategory(i18n(book_general)); + field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); + field->setFormatFlag(Field::FormatName); + list.append(field); + + QStringList binding; + binding << i18n("Hardback") << i18n("Paperback") << i18n("Trade Paperback") + << i18n("E-Book") << i18n("Magazine") << i18n("Journal"); + field = new Field(QString::fromLatin1("binding"), i18n("Binding"), binding); + field->setCategory(i18n(book_general)); + field->setFlags(Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("pur_date"), i18n("Purchase Date")); + field->setCategory(i18n(book_general)); + field->setFormatFlag(Field::FormatDate); + list.append(field); + + field = new Field(QString::fromLatin1("pur_price"), i18n("Purchase Price")); + field->setCategory(i18n(book_general)); + list.append(field); + + field = new Field(QString::fromLatin1("publisher"), i18n("Publisher")); + field->setCategory(i18n(book_publishing)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + field->setFormatFlag(Field::FormatPlain); + list.append(field); + + field = new Field(QString::fromLatin1("edition"), i18n("Edition")); + field->setCategory(i18n(book_publishing)); + field->setFlags(Field::AllowCompletion); + field->setFormatFlag(Field::FormatPlain); + list.append(field); + + field = new Field(QString::fromLatin1("cr_year"), i18n("Copyright Year"), Field::Number); + field->setCategory(i18n(book_publishing)); + field->setFlags(Field::AllowGrouped | Field::AllowMultiple); + list.append(field); + + field = new Field(QString::fromLatin1("pub_year"), i18n("Publication Year"), Field::Number); + field->setCategory(i18n(book_publishing)); + field->setFlags(Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("isbn"), i18n("ISBN#")); + field->setCategory(i18n(book_publishing)); + field->setDescription(i18n("International Standard Book Number")); + list.append(field); + + field = new Field(QString::fromLatin1("lccn"), i18n("LCCN#")); + field->setCategory(i18n(book_publishing)); + field->setDescription(i18n("Library of Congress Control Number")); + list.append(field); + + field = new Field(QString::fromLatin1("pages"), i18n("Pages"), Field::Number); + field->setCategory(i18n(book_publishing)); + list.append(field); + + field = new Field(QString::fromLatin1("translator"), i18n("Translator")); + field->setCategory(i18n(book_publishing)); + field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); + field->setFormatFlag(Field::FormatName); + list.append(field); + + field = new Field(QString::fromLatin1("language"), i18n("Language")); + field->setCategory(i18n(book_publishing)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped | Field::AllowMultiple); + list.append(field); + + field = new Field(QString::fromLatin1("genre"), i18n("Genre")); + field->setCategory(i18n(book_classification)); + field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); + list.append(field); + + // in document versions < 3, this was "keywords" and not "keyword" + // but the title didn't change, only the name + field = new Field(QString::fromLatin1("keyword"), i18n("Keywords")); + field->setCategory(i18n(book_classification)); + field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("series"), i18n("Series")); + field->setCategory(i18n(book_classification)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("series_num"), i18n("Series Number"), Field::Number); + field->setCategory(i18n(book_classification)); + list.append(field); + + QStringList cond; + cond << i18n("New") << i18n("Used"); + field = new Field(QString::fromLatin1("condition"), i18n("Condition"), cond); + field->setCategory(i18n(book_classification)); + list.append(field); + + field = new Field(QString::fromLatin1("signed"), i18n("Signed"), Field::Bool); + field->setCategory(i18n(book_personal)); + list.append(field); + + field = new Field(QString::fromLatin1("read"), i18n("Read"), Field::Bool); + field->setCategory(i18n(book_personal)); + list.append(field); + + field = new Field(QString::fromLatin1("gift"), i18n("Gift"), Field::Bool); + field->setCategory(i18n(book_personal)); + list.append(field); + + field = new Field(QString::fromLatin1("loaned"), i18n("Loaned"), Field::Bool); + field->setCategory(i18n(book_personal)); + list.append(field); + + field = new Field(QString::fromLatin1("rating"), i18n("Rating"), Field::Rating); + field->setCategory(i18n(book_personal)); + field->setFlags(Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("cover"), i18n("Front Cover"), Field::Image); + list.append(field); + + field = new Field(QString::fromLatin1("comments"), i18n("Comments"), Field::Para); + field->setCategory(i18n(book_personal)); + list.append(field); + + return list; +} + +int BookCollection::sameEntry(Data::EntryPtr entry1_, Data::EntryPtr entry2_) const { + // equal isbn's or lccn's are easy, give it a weight of 100 + if(Entry::compareValues(entry1_, entry2_, QString::fromLatin1("isbn"), this) > 0 || + Entry::compareValues(entry1_, entry2_, QString::fromLatin1("lccn"), this) > 0) { + return 100; // good match + } + int res = 3*Entry::compareValues(entry1_, entry2_, QString::fromLatin1("title"), this); +// if(res == 0) { +// myDebug() << "BookCollection::sameEntry() - different titles for " << entry1_->title() << " vs. " +// << entry2_->title() << endl; +// } + res += 2*Entry::compareValues(entry1_, entry2_, QString::fromLatin1("author"), this); + res += Entry::compareValues(entry1_, entry2_, QString::fromLatin1("cr_year"), this); + res += Entry::compareValues(entry1_, entry2_, QString::fromLatin1("pub_year"), this); + res += Entry::compareValues(entry1_, entry2_, QString::fromLatin1("binding"), this); + return res; +} + +#include "bookcollection.moc" diff --git a/src/collections/bookcollection.h b/src/collections/bookcollection.h new file mode 100644 index 0000000..0236dd6 --- /dev/null +++ b/src/collections/bookcollection.h @@ -0,0 +1,74 @@ +/*************************************************************************** + copyright : (C) 2003-2006 by Robby Stephenson + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of version 2 of the GNU General Public License as * + * published by the Free Software Foundation; * + * * + ***************************************************************************/ + +#ifndef BOOKCOLLECTION_H +#define BOOKCOLLECTION_H + +#include "../collection.h" + +namespace Tellico { + namespace Data { + +/** + * A collection for books. + * + * It has the following standard attributes: + * @li Title + * @li Subtitle + * @li Author + * @li Binding + * @li Purchase Date + * @li Purchase Price + * @li Publisher + * @li Edition + * @li Copyright Year + * @li Publication Year + * @li ISBN Number + * @li Library of Congress Catalog Number + * @li Pages + * @li Language + * @li Genre + * @li Keywords + * @li Series + * @li Series Number + * @li Condition + * @li Signed + * @li Read + * @li Gift + * @li Loaned + * @li Rating + * @li Comments + * + * @author Robby Stephenson + */ +class BookCollection : public Collection { +Q_OBJECT + +public: + /** + * The constructor + * + * @param addFields Whether to add the default attributes + * @param title The title of the collection + */ + BookCollection(bool addFields, const QString& title = QString::null); + + virtual Type type() const { return Book; } + virtual int sameEntry(Data::EntryPtr entry1, Data::EntryPtr entry2) const; + + static FieldVec defaultFields(); +}; + + } // end namespace +} // end namespace +#endif diff --git a/src/collections/cardcollection.cpp b/src/collections/cardcollection.cpp new file mode 100644 index 0000000..c29ad7f --- /dev/null +++ b/src/collections/cardcollection.cpp @@ -0,0 +1,121 @@ +/*************************************************************************** + copyright : (C) 2003-2006 by Robby Stephenson + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of version 2 of the GNU General Public License as * + * published by the Free Software Foundation; * + * * + ***************************************************************************/ + +#include "cardcollection.h" + +#include <klocale.h> + +namespace { + static const char* card_general = I18N_NOOP("General"); + static const char* card_personal = I18N_NOOP("Personal"); +} + +using Tellico::Data::CardCollection; + +CardCollection::CardCollection(bool addFields_, const QString& title_ /*=null*/) + : Collection(title_.isEmpty() ? i18n("My Cards") : title_) { + if(addFields_) { + addFields(defaultFields()); + } + setDefaultGroupField(QString::fromLatin1("series")); +} + +Tellico::Data::FieldVec CardCollection::defaultFields() { + FieldVec list; + FieldPtr field; + + field = new Field(QString::fromLatin1("title"), i18n("Title"), Field::Dependent); + field->setCategory(i18n(card_general)); + field->setDescription(QString::fromLatin1("%{year} %{brand} %{player}")); + field->setFlags(Field::NoDelete); + list.append(field); + + field = new Field(QString::fromLatin1("player"), i18n("Player")); + field->setCategory(i18n(card_general)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + field->setFormatFlag(Field::FormatName); + list.append(field); + + field = new Field(QString::fromLatin1("team"), i18n("Team")); + field->setCategory(i18n(card_general)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + field->setFormatFlag(Field::FormatTitle); + list.append(field); + + field = new Field(QString::fromLatin1("brand"), i18n("Brand")); + field->setCategory(i18n(card_general)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + field->setFormatFlag(Field::FormatPlain); + list.append(field); + + // might not be totally numeric! + field = new Field(QString::fromLatin1("number"), i18n("Card Number")); + field->setCategory(i18n(card_general)); + list.append(field); + + field = new Field(QString::fromLatin1("year"), i18n("Year"), Field::Number); + field->setCategory(i18n(card_general)); + field->setFlags(Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("series"), i18n("Series")); + field->setCategory(i18n(card_general)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + field->setFormatFlag(Field::FormatTitle); + list.append(field); + + field = new Field(QString::fromLatin1("type"), i18n("Card Type")); + field->setCategory(i18n(card_general)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("pur_date"), i18n("Purchase Date")); + field->setCategory(i18n(card_personal)); + field->setFormatFlag(Field::FormatDate); + list.append(field); + + field = new Field(QString::fromLatin1("pur_price"), i18n("Purchase Price")); + field->setCategory(i18n(card_personal)); + list.append(field); + + field = new Field(QString::fromLatin1("location"), i18n("Location")); + field->setCategory(i18n(card_personal)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("gift"), i18n("Gift"), Field::Bool); + field->setCategory(i18n(card_personal)); + list.append(field); + + field = new Field(QString::fromLatin1("keyword"), i18n("Keywords")); + field->setCategory(i18n(card_personal)); + field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("quantity"), i18n("Quantity"), Field::Number); + field->setCategory(i18n(card_personal)); + list.append(field); + + field = new Field(QString::fromLatin1("front"), i18n("Front Image"), Field::Image); + list.append(field); + + field = new Field(QString::fromLatin1("back"), i18n("Back Image"), Field::Image); + list.append(field); + + field = new Field(QString::fromLatin1("comments"), i18n("Comments"), Field::Para); + list.append(field); + + return list; +} + +#include "cardcollection.moc" diff --git a/src/collections/cardcollection.h b/src/collections/cardcollection.h new file mode 100644 index 0000000..61fd2b0 --- /dev/null +++ b/src/collections/cardcollection.h @@ -0,0 +1,49 @@ +/*************************************************************************** + copyright : (C) 2003-2006 by Robby Stephenson + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of version 2 of the GNU General Public License as * + * published by the Free Software Foundation; * + * * + ***************************************************************************/ + +#ifndef CARDCOLLECTION_H +#define CARDCOLLECTION_H + +#include "../collection.h" + +namespace Tellico { + namespace Data { + +/** + * A collection for sports cards. + * + * It has the following standard attributes: + * @li Title + * + * @author Robby Stephenson + */ +class CardCollection : public Collection { +Q_OBJECT + +public: + /** + * The constructor + * + * @param addFields A boolean indicating whether the default attributes should be added + * @param title The title of the collection + */ + CardCollection(bool addFields, const QString& title = QString::null); + + virtual Type type() const { return Card; } + + static FieldVec defaultFields(); +}; + + } // end namespace +} // end namespace +#endif diff --git a/src/collections/coincollection.cpp b/src/collections/coincollection.cpp new file mode 100644 index 0000000..1cd2ec0 --- /dev/null +++ b/src/collections/coincollection.cpp @@ -0,0 +1,135 @@ +/*************************************************************************** + copyright : (C) 2003-2006 by Robby Stephenson + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of version 2 of the GNU General Public License as * + * published by the Free Software Foundation; * + * * + ***************************************************************************/ + +#include "coincollection.h" + +#include <klocale.h> + +namespace { + static const char* coin_general = I18N_NOOP("General"); + static const char* coin_personal = I18N_NOOP("Personal"); +} + +using Tellico::Data::CoinCollection; + +CoinCollection::CoinCollection(bool addFields_, const QString& title_ /*=null*/) + : Collection(title_.isEmpty() ? i18n("My Coins") : title_) { + if(addFields_) { + addFields(defaultFields()); + } + setDefaultGroupField(QString::fromLatin1("denomination")); +} + +Tellico::Data::FieldVec CoinCollection::defaultFields() { + FieldVec list; + FieldPtr field; + + field = new Field(QString::fromLatin1("title"), i18n("Title"), Field::Dependent); + field->setCategory(i18n(coin_general)); + // not i18n() + field->setDescription(QString::fromLatin1("%{year}%{mintmark} %{type} %{denomination}")); + field->setFlags(Field::NoDelete); + list.append(field); + + field = new Field(QString::fromLatin1("type"), i18n("Type")); + field->setCategory(i18n(coin_general)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + field->setFormatFlag(Field::FormatTitle); + list.append(field); + + /* TRANSLATORS: denomination refers to the monetary value. */ + field = new Field(QString::fromLatin1("denomination"), i18n("Denomination")); + field->setCategory(i18n(coin_general)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("year"), i18n("Year"), Field::Number); + field->setCategory(i18n(coin_general)); + field->setFlags(Field::AllowMultiple | Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("mintmark"), i18n("Mint Mark")); + field->setCategory(i18n(coin_general)); + field->setFlags(Field::AllowGrouped); + field->setFormatFlag(Field::FormatPlain); + list.append(field); + + field = new Field(QString::fromLatin1("country"), i18n("Country")); + field->setCategory(i18n(coin_general)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + field->setFormatFlag(Field::FormatPlain); + list.append(field); + + field = new Field(QString::fromLatin1("set"), i18n("Coin Set"), Field::Bool); + field->setCategory(i18n(coin_general)); + list.append(field); + + QStringList grade = QStringList::split(QRegExp(QString::fromLatin1("\\s*,\\s*")), + i18n("Coin grade levels - " + "Proof-65,Proof-60,Mint State-65,Mint State-60," + "Almost Uncirculated-55,Almost Uncirculated-50," + "Extremely Fine-40,Very Fine-30,Very Fine-20,Fine-12," + "Very Good-8,Good-4,Fair", + "Proof-65,Proof-60,Mint State-65,Mint State-60," + "Almost Uncirculated-55,Almost Uncirculated-50," + "Extremely Fine-40,Very Fine-30,Very Fine-20,Fine-12," + "Very Good-8,Good-4,Fair"), + false); + field = new Field(QString::fromLatin1("grade"), i18n("Grade"), grade); + field->setCategory(i18n(coin_general)); + field->setFlags(Field::AllowGrouped); + list.append(field); + + QStringList service = QStringList::split(QRegExp(QString::fromLatin1("\\s*,\\s*")), + i18n("Coin grading services - " + "PCGS,NGC,ANACS,ICG,ASA,PCI", + "PCGS,NGC,ANACS,ICG,ASA,PCI"), + false); + field = new Field(QString::fromLatin1("service"), i18n("Grading Service"), service); + field->setCategory(i18n(coin_general)); + field->setFlags(Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("pur_date"), i18n("Purchase Date")); + field->setCategory(i18n(coin_personal)); + field->setFormatFlag(Field::FormatDate); + list.append(field); + + field = new Field(QString::fromLatin1("pur_price"), i18n("Purchase Price")); + field->setCategory(i18n(coin_personal)); + list.append(field); + + field = new Field(QString::fromLatin1("location"), i18n("Location")); + field->setCategory(i18n(coin_personal)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + field->setFormatFlag(Field::FormatPlain); + list.append(field); + + field = new Field(QString::fromLatin1("gift"), i18n("Gift"), Field::Bool); + field->setCategory(i18n(coin_personal)); + list.append(field); + + field = new Field(QString::fromLatin1("obverse"), i18n("Obverse"), Field::Image); + list.append(field); + + field = new Field(QString::fromLatin1("reverse"), i18n("Reverse"), Field::Image); + list.append(field); + + field = new Field(QString::fromLatin1("comments"), i18n("Comments"), Field::Para); + field->setCategory(i18n(coin_personal)); + list.append(field); + + return list; +} + +#include "coincollection.moc" diff --git a/src/collections/coincollection.h b/src/collections/coincollection.h new file mode 100644 index 0000000..d22937d --- /dev/null +++ b/src/collections/coincollection.h @@ -0,0 +1,49 @@ +/*************************************************************************** + copyright : (C) 2003-2006 by Robby Stephenson + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of version 2 of the GNU General Public License as * + * published by the Free Software Foundation; * + * * + ***************************************************************************/ + +#ifndef COINCOLLECTION_H +#define COINCOLLECTION_H + +#include "../collection.h" + +namespace Tellico { + namespace Data { + +/** + * A collection for coins. + * + * It has the following standard attributes: + * @li Title + * + * @author Robby Stephenson + */ +class CoinCollection : public Collection { +Q_OBJECT + +public: + /** + * The constructor + * + * @param addFields Whether to add the default attributes + * @param title The title of the collection + */ + CoinCollection(bool addFields, const QString& title = QString::null); + + virtual Type type() const { return Coin; } + + static FieldVec defaultFields(); +}; + + } // end namespace +} // end namespace +#endif diff --git a/src/collections/comicbookcollection.cpp b/src/collections/comicbookcollection.cpp new file mode 100644 index 0000000..30e1ef0 --- /dev/null +++ b/src/collections/comicbookcollection.cpp @@ -0,0 +1,157 @@ +/*************************************************************************** + copyright : (C) 2003-2006 by Robby Stephenson + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of version 2 of the GNU General Public License as * + * published by the Free Software Foundation; * + * * + ***************************************************************************/ + +#include "comicbookcollection.h" + +#include <klocale.h> + +namespace { + static const char* comic_general = I18N_NOOP("General"); + static const char* comic_publishing = I18N_NOOP("Publishing"); + static const char* comic_classification = I18N_NOOP("Classification"); + static const char* comic_personal = I18N_NOOP("Personal"); +} + +using Tellico::Data::ComicBookCollection; + +ComicBookCollection::ComicBookCollection(bool addFields_, const QString& title_ /*=null*/) + : Collection(title_.isEmpty() ? i18n("My Comic Books") : title_) { + if(addFields_) { + addFields(defaultFields()); + } + setDefaultGroupField(QString::fromLatin1("series")); +} + +Tellico::Data::FieldVec ComicBookCollection::defaultFields() { + FieldVec list; + FieldPtr field; + + field = new Field(QString::fromLatin1("title"), i18n("Title")); + field->setCategory(i18n(comic_general)); + field->setFlags(Field::NoDelete); + field->setFormatFlag(Field::FormatTitle); + list.append(field); + + field = new Field(QString::fromLatin1("subtitle"), i18n("Subtitle")); + field->setCategory(i18n(comic_general)); + field->setFormatFlag(Field::FormatTitle); + list.append(field); + + field = new Field(QString::fromLatin1("writer"), i18n("Writer")); + field->setCategory(i18n(comic_general)); + field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); + field->setFormatFlag(Field::FormatName); + list.append(field); + + field = new Field(QString::fromLatin1("artist"), i18n("Comic Book Illustrator", "Artist")); + field->setCategory(i18n(comic_general)); + field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); + field->setFormatFlag(Field::FormatName); + list.append(field); + + field = new Field(QString::fromLatin1("series"), i18n("Series")); + field->setCategory(i18n(comic_general)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + field->setFormatFlag(Field::FormatTitle); + list.append(field); + + field = new Field(QString::fromLatin1("issue"), i18n("Issue"), Field::Number); + field->setCategory(i18n(comic_general)); + field->setFlags(Field::AllowMultiple); + list.append(field); + + field = new Field(QString::fromLatin1("publisher"), i18n("Publisher")); + field->setCategory(i18n(comic_publishing)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + field->setFormatFlag(Field::FormatPlain); + list.append(field); + + field = new Field(QString::fromLatin1("edition"), i18n("Edition")); + field->setCategory(i18n(comic_publishing)); + field->setFlags(Field::AllowCompletion); + field->setFormatFlag(Field::FormatPlain); + list.append(field); + + field = new Field(QString::fromLatin1("pub_year"), i18n("Publication Year"), Field::Number); + field->setCategory(i18n(comic_publishing)); + field->setFlags(Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("pages"), i18n("Pages"), Field::Number); + field->setCategory(i18n(comic_publishing)); + list.append(field); + + field = new Field(QString::fromLatin1("country"), i18n("Country")); + field->setCategory(i18n(comic_publishing)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped | Field::AllowMultiple); + field->setFormatFlag(Field::FormatPlain); + list.append(field); + + field = new Field(QString::fromLatin1("language"), i18n("Language")); + field->setCategory(i18n(comic_publishing)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped | Field::AllowMultiple); + field->setFormatFlag(Field::FormatPlain); + list.append(field); + + field = new Field(QString::fromLatin1("genre"), i18n("Genre")); + field->setCategory(i18n(comic_classification)); + field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); + field->setFormatFlag(Field::FormatPlain); + list.append(field); + + field = new Field(QString::fromLatin1("keyword"), i18n("Keywords")); + field->setCategory(i18n(comic_classification)); + field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); + list.append(field); + + QStringList cond = QStringList::split(QRegExp(QString::fromLatin1("\\s*,\\s*")), + i18n("Comic book grade levels - " + "Mint,Near Mint,Very Fine,Fine,Very Good,Good,Fair,Poor", + "Mint,Near Mint,Very Fine,Fine,Very Good,Good,Fair,Poor"), + false); + field = new Field(QString::fromLatin1("condition"), i18n("Condition"), cond); + field->setCategory(i18n(comic_classification)); + list.append(field); + + field = new Field(QString::fromLatin1("pur_date"), i18n("Purchase Date")); + field->setCategory(i18n(comic_personal)); + field->setFormatFlag(Field::FormatDate); + list.append(field); + + field = new Field(QString::fromLatin1("pur_price"), i18n("Purchase Price")); + field->setCategory(i18n(comic_personal)); + list.append(field); + + field = new Field(QString::fromLatin1("signed"), i18n("Signed"), Field::Bool); + field->setCategory(i18n(comic_personal)); + list.append(field); + + field = new Field(QString::fromLatin1("gift"), i18n("Gift"), Field::Bool); + field->setCategory(i18n(comic_personal)); + list.append(field); + + field = new Field(QString::fromLatin1("loaned"), i18n("Loaned"), Field::Bool); + field->setCategory(i18n(comic_personal)); + list.append(field); + + field = new Field(QString::fromLatin1("cover"), i18n("Front Cover"), Field::Image); + list.append(field); + + field = new Field(QString::fromLatin1("comments"), i18n("Comments"), Field::Para); + field->setCategory(i18n(comic_personal)); + list.append(field); + + return list; +} + +#include "comicbookcollection.moc" diff --git a/src/collections/comicbookcollection.h b/src/collections/comicbookcollection.h new file mode 100644 index 0000000..36302c2 --- /dev/null +++ b/src/collections/comicbookcollection.h @@ -0,0 +1,48 @@ +/*************************************************************************** + copyright : (C) 2003-2006 by Robby Stephenson + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of version 2 of the GNU General Public License as * + * published by the Free Software Foundation; * + * * + ***************************************************************************/ + +#ifndef COMICBOOKCOLLECTION_H +#define COMICBOOKCOLLECTION_H + +#include "../collection.h" + +namespace Tellico { + namespace Data { + +/** + * A collection for comic books. + * + * It has the following standard attributes: + * @li Title + * + * @author Robby Stephenson + */ +class ComicBookCollection : public Collection { +Q_OBJECT + +public: + /** + * The constructor + * + * @param title The title of the collection + */ + ComicBookCollection(bool addFields, const QString& title = QString::null); + + virtual Type type() const { return ComicBook; } + + static FieldVec defaultFields(); +}; + + } // end namespace +} // end namespace +#endif diff --git a/src/collections/filecatalog.cpp b/src/collections/filecatalog.cpp new file mode 100644 index 0000000..8d375be --- /dev/null +++ b/src/collections/filecatalog.cpp @@ -0,0 +1,105 @@ +/*************************************************************************** + copyright : (C) 2005-2006 by Robby Stephenson + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of version 2 of the GNU General Public License as * + * published by the Free Software Foundation; * + * * + ***************************************************************************/ + +#include "filecatalog.h" + +#include <klocale.h> + +namespace { + static const char* file_general = I18N_NOOP("General"); +} + +using Tellico::Data::FileCatalog; + +FileCatalog::FileCatalog(bool addFields_, const QString& title_ /*=null*/) + : Collection(title_.isEmpty() ? i18n("My Files") : title_) { + if(addFields_) { + addFields(defaultFields()); + } + setDefaultGroupField(QString::fromLatin1("volume")); +} + +Tellico::Data::FieldVec FileCatalog::defaultFields() { + FieldVec list; + FieldPtr field; + + field = new Field(QString::fromLatin1("title"), i18n("Name")); + field->setCategory(i18n(file_general)); + field->setFlags(Field::NoDelete); + list.append(field); + + field = new Field(QString::fromLatin1("url"), i18n("URL"), Field::URL); + field->setCategory(i18n(file_general)); + list.append(field); + + field = new Field(QString::fromLatin1("description"), i18n("Description")); + field->setCategory(i18n(file_general)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("volume"), i18n("Volume")); + field->setCategory(i18n(file_general)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("folder"), i18n("Folder")); + field->setCategory(i18n(file_general)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("mimetype"), i18n("Mimetype")); + field->setCategory(i18n(file_general)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("size"), i18n("Size")); + field->setCategory(i18n(file_general)); + list.append(field); + + field = new Field(QString::fromLatin1("permissions"), i18n("Permissions")); + field->setCategory(i18n(file_general)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("owner"), i18n("Owner")); + field->setCategory(i18n(file_general)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("group"), i18n("Group")); + field->setCategory(i18n(file_general)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + list.append(field); + + // these dates are string fields, not dates, since the time is included + field = new Field(QString::fromLatin1("created"), i18n("Created")); + field->setCategory(i18n(file_general)); + list.append(field); + + field = new Field(QString::fromLatin1("modified"), i18n("Modified")); + field->setCategory(i18n(file_general)); + list.append(field); + + field = new Field(QString::fromLatin1("metainfo"), i18n("Meta Info"), Field::Table); + field->setProperty(QString::fromLatin1("columns"), QChar('2')); + field->setProperty(QString::fromLatin1("column1"), i18n("Property")); + field->setProperty(QString::fromLatin1("column2"), i18n("Value")); + list.append(field); + + field = new Field(QString::fromLatin1("icon"), i18n("Icon"), Field::Image); + list.append(field); + + return list; +} + +#include "filecatalog.moc" diff --git a/src/collections/filecatalog.h b/src/collections/filecatalog.h new file mode 100644 index 0000000..aa7a82c --- /dev/null +++ b/src/collections/filecatalog.h @@ -0,0 +1,38 @@ +/*************************************************************************** + copyright : (C) 2005-2006 by Robby Stephenson + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of version 2 of the GNU General Public License as * + * published by the Free Software Foundation; * + * * + ***************************************************************************/ + +#ifndef TELLICO_DATA_FILECATALOG_H +#define TELLICO_DATA_FILECATALOG_H + +#include "../collection.h" + +namespace Tellico { + namespace Data { + +/** + * @author Robby Stephenson + */ +class FileCatalog : public Collection { +Q_OBJECT + +public: + FileCatalog(bool addFields, const QString& title = QString::null); + + virtual Type type() const { return File; } + + static FieldVec defaultFields(); +}; + + } // end namespace +} // end namespace +#endif diff --git a/src/collections/gamecollection.cpp b/src/collections/gamecollection.cpp new file mode 100644 index 0000000..b93176f --- /dev/null +++ b/src/collections/gamecollection.cpp @@ -0,0 +1,126 @@ +/*************************************************************************** + copyright : (C) 2005-2006 by Robby Stephenson + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of version 2 of the GNU General Public License as * + * published by the Free Software Foundation; * + * * + ***************************************************************************/ + +#include "gamecollection.h" + +#include <klocale.h> + +namespace { + static const char* game_general = I18N_NOOP("General"); + static const char* game_personal = I18N_NOOP("Personal"); +} + +using Tellico::Data::GameCollection; + +GameCollection::GameCollection(bool addFields_, const QString& title_ /*=null*/) + : Collection(title_.isEmpty() ? i18n("My Games") : title_) { + if(addFields_) { + addFields(defaultFields()); + } + setDefaultGroupField(QString::fromLatin1("platform")); +} + +Tellico::Data::FieldVec GameCollection::defaultFields() { + FieldVec list; + FieldPtr field; + + field = new Field(QString::fromLatin1("title"), i18n("Title")); + field->setCategory(i18n(game_general)); + field->setFlags(Field::NoDelete); + field->setFormatFlag(Field::FormatTitle); + list.append(field); + + QStringList platform; + platform << i18n("Xbox 360") << i18n("Xbox") + << i18n("PlayStation3") << i18n("PlayStation2") << i18n("PlayStation") << i18n("PlayStation Portable", "PSP") + << i18n("Nintendo Wii") << i18n("Nintendo DS") << i18n("GameCube") << i18n("Dreamcast") + << i18n("Game Boy Advance") << i18n("Game Boy Color") << i18n("Game Boy") + << i18n("Windows Platform", "Windows") << i18n("Mac OS") << i18n("Linux"); + field = new Field(QString::fromLatin1("platform"), i18n("Platform"), platform); + field->setCategory(i18n(game_general)); + field->setFlags(Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("genre"), i18n("Genre")); + field->setCategory(i18n(game_general)); + field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); + field->setFormatFlag(Field::FormatPlain); + list.append(field); + + field = new Field(QString::fromLatin1("year"), i18n("Release Year"), Field::Number); + field->setCategory(i18n(game_general)); + field->setFlags(Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("publisher"), i18n("Games - Publisher", "Publisher")); + field->setCategory(i18n(game_general)); + field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); + field->setFormatFlag(Field::FormatPlain); + list.append(field); + + field = new Field(QString::fromLatin1("developer"), i18n("Developer")); + field->setCategory(i18n(game_general)); + field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); + field->setFormatFlag(Field::FormatPlain); + list.append(field); + + QStringList cert = QStringList::split(QRegExp(QString::fromLatin1("\\s*,\\s*")), + i18n("Video game ratings - " + "Unrated, Adults Only, Mature, Teen, Everyone, Early Childhood, Pending", + "Unrated, Adults Only, Mature, Teen, Everyone, Early Childhood, Pending"), + false); + field = new Field(QString::fromLatin1("certification"), i18n("ESRB Rating"), cert); + field->setCategory(i18n(game_general)); + field->setFlags(Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("description"), i18n("Description"), Field::Para); + list.append(field); + + field = new Field(QString::fromLatin1("rating"), i18n("Personal Rating"), Field::Rating); + field->setCategory(i18n(game_personal)); + field->setFlags(Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("completed"), i18n("Completed"), Field::Bool); + field->setCategory(i18n(game_personal)); + list.append(field); + + field = new Field(QString::fromLatin1("pur_date"), i18n("Purchase Date")); + field->setCategory(i18n(game_personal)); + field->setFormatFlag(Field::FormatDate); + list.append(field); + + field = new Field(QString::fromLatin1("gift"), i18n("Gift"), Field::Bool); + field->setCategory(i18n(game_personal)); + list.append(field); + + field = new Field(QString::fromLatin1("pur_price"), i18n("Purchase Price")); + field->setCategory(i18n(game_personal)); + list.append(field); + + field = new Field(QString::fromLatin1("loaned"), i18n("Loaned"), Field::Bool); + field->setCategory(i18n(game_personal)); + list.append(field); + + field = new Field(QString::fromLatin1("cover"), i18n("Cover"), Field::Image); + list.append(field); + + field = new Field(QString::fromLatin1("comments"), i18n("Comments"), Field::Para); + field->setCategory(i18n(game_personal)); + list.append(field); + + return list; +} + +#include "gamecollection.moc" diff --git a/src/collections/gamecollection.h b/src/collections/gamecollection.h new file mode 100644 index 0000000..7d6ce92 --- /dev/null +++ b/src/collections/gamecollection.h @@ -0,0 +1,44 @@ +/*************************************************************************** + copyright : (C) 2005-2006 by Robby Stephenson + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of version 2 of the GNU General Public License as * + * published by the Free Software Foundation; * + * * + ***************************************************************************/ + +#ifndef GAMECOLLECTION_H +#define GAMECOLLECTION_H + +#include "../collection.h" + +namespace Tellico { + namespace Data { + +/** + * A collection for games. + */ +class GameCollection : public Collection { +Q_OBJECT + +public: + /** + * The constructor + * + * @param addFields Whether to add the default attributes + * @param title The title of the collection + */ + GameCollection(bool addFields, const QString& title = QString::null); + + virtual Type type() const { return Game; } + + static FieldVec defaultFields(); +}; + + } // end namespace +} // end namespace +#endif diff --git a/src/collections/musiccollection.cpp b/src/collections/musiccollection.cpp new file mode 100644 index 0000000..d3c0445 --- /dev/null +++ b/src/collections/musiccollection.cpp @@ -0,0 +1,132 @@ +/*************************************************************************** + copyright : (C) 2003-2006 by Robby Stephenson + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of version 2 of the GNU General Public License as * + * published by the Free Software Foundation; * + * * + ***************************************************************************/ + +#include "musiccollection.h" + +#include <klocale.h> + +namespace { + static const char* music_general = I18N_NOOP("General"); + static const char* music_personal = I18N_NOOP("Personal"); +} + +using Tellico::Data::MusicCollection; + +MusicCollection::MusicCollection(bool addFields_, const QString& title_ /*=null*/) + : Collection(title_.isEmpty() ? i18n("My Music") : title_) { + if(addFields_) { + addFields(defaultFields()); + } + setDefaultGroupField(QString::fromLatin1("artist")); +} + +Tellico::Data::FieldVec MusicCollection::defaultFields() { + FieldVec list; + FieldPtr field; + + field = new Field(QString::fromLatin1("title"), i18n("Album")); + field->setCategory(i18n(music_general)); + field->setFlags(Field::NoDelete | Field::AllowCompletion); + field->setFormatFlag(Field::FormatTitle); + list.append(field); + + QStringList media; + media << i18n("Compact Disc") << i18n("DVD") << i18n("Cassette") << i18n("Vinyl"); + field = new Field(QString::fromLatin1("medium"), i18n("Medium"), media); + field->setCategory(i18n(music_general)); + field->setFlags(Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("artist"), i18n("Artist")); + field->setCategory(i18n(music_general)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped | Field::AllowMultiple); + field->setFormatFlag(Field::FormatTitle); // don't use FormatName + list.append(field); + + field = new Field(QString::fromLatin1("label"), i18n("Label")); + field->setCategory(i18n(music_general)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped | Field::AllowMultiple); + field->setFormatFlag(Field::FormatPlain); + list.append(field); + + field = new Field(QString::fromLatin1("year"), i18n("Year"), Field::Number); + field->setCategory(i18n(music_general)); + field->setFlags(Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("genre"), i18n("Genre")); + field->setCategory(i18n(music_general)); + field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); + field->setFormatFlag(Field::FormatPlain); + list.append(field); + + field = new Field(QString::fromLatin1("track"), i18n("Tracks"), Field::Table); + field->setFormatFlag(Field::FormatTitle); + field->setProperty(QString::fromLatin1("columns"), QChar('3')); + field->setProperty(QString::fromLatin1("column1"), i18n("Title")); + field->setProperty(QString::fromLatin1("column2"), i18n("Artist")); + field->setProperty(QString::fromLatin1("column3"), i18n("Length")); + list.append(field); + + field = new Field(QString::fromLatin1("rating"), i18n("Rating"), Field::Rating); + field->setCategory(i18n(music_personal)); + field->setFlags(Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("pur_date"), i18n("Purchase Date")); + field->setCategory(i18n(music_personal)); + field->setFormatFlag(Field::FormatDate); + list.append(field); + + field = new Field(QString::fromLatin1("gift"), i18n("Gift"), Field::Bool); + field->setCategory(i18n(music_personal)); + list.append(field); + + field = new Field(QString::fromLatin1("pur_price"), i18n("Purchase Price")); + field->setCategory(i18n(music_personal)); + list.append(field); + + field = new Field(QString::fromLatin1("loaned"), i18n("Loaned"), Field::Bool); + field->setCategory(i18n(music_personal)); + list.append(field); + + field = new Field(QString::fromLatin1("keyword"), i18n("Keywords")); + field->setCategory(i18n(music_personal)); + field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("cover"), i18n("Cover"), Field::Image); + list.append(field); + + field = new Field(QString::fromLatin1("comments"), i18n("Comments"), Field::Para); + field->setCategory(i18n(music_personal)); + list.append(field); + + return list; +} + +int MusicCollection::sameEntry(Data::EntryPtr entry1_, Data::EntryPtr entry2_) const { + // not enough for title to be equal, must also have another field + int res = 2*Entry::compareValues(entry1_, entry2_, QString::fromLatin1("title"), this); +// if(res == 0) { +// myDebug() << "MusicCollection::sameEntry() - different titles for " << entry1_->title() << " vs. " +// << entry2_->title() << endl; +// } + res += 2*Entry::compareValues(entry1_, entry2_, QString::fromLatin1("artist"), this); + res += Entry::compareValues(entry1_, entry2_, QString::fromLatin1("year"), this); + res += Entry::compareValues(entry1_, entry2_, QString::fromLatin1("label"), this); + res += Entry::compareValues(entry1_, entry2_, QString::fromLatin1("medium"), this); + return res; +} + +#include "musiccollection.moc" diff --git a/src/collections/musiccollection.h b/src/collections/musiccollection.h new file mode 100644 index 0000000..ddada5b --- /dev/null +++ b/src/collections/musiccollection.h @@ -0,0 +1,55 @@ +/*************************************************************************** + copyright : (C) 2003-2006 by Robby Stephenson + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of version 2 of the GNU General Public License as * + * published by the Free Software Foundation; * + * * + ***************************************************************************/ + +#ifndef MUSICCOLLECTION_H +#define MUSICCOLLECTION_H + +#include "../collection.h" + +namespace Tellico { + namespace Data { + +/** + * A collection for music, like CD's and cassettes. + * + * It has the following standard attributes: + * @li Title + * @li Artist + * @li Album + * @li Year + * @li Genre + * @li Comments + * + * @author Robby Stephenson + */ +class MusicCollection : public Collection { +Q_OBJECT + +public: + /** + * The constructor + * + * @param addFields Whether to add the default attributes + * @param title The title of the collection + */ + MusicCollection(bool addFields, const QString& title = QString::null); + + virtual Type type() const { return Album; } + virtual int sameEntry(Data::EntryPtr, Data::EntryPtr) const; + + static FieldVec defaultFields(); +}; + + } // end namespace +} // end namespace +#endif diff --git a/src/collections/stampcollection.cpp b/src/collections/stampcollection.cpp new file mode 100644 index 0000000..c26da9a --- /dev/null +++ b/src/collections/stampcollection.cpp @@ -0,0 +1,133 @@ +/*************************************************************************** + copyright : (C) 2003-2006 by Robby Stephenson + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of version 2 of the GNU General Public License as * + * published by the Free Software Foundation; * + * * + ***************************************************************************/ + +#include "stampcollection.h" + +#include <klocale.h> + +namespace { + static const char* stamp_general = I18N_NOOP("General"); + static const char* stamp_condition = I18N_NOOP("Condition"); + static const char* stamp_personal = I18N_NOOP("Personal"); +} + +using Tellico::Data::StampCollection; + +StampCollection::StampCollection(bool addFields_, const QString& title_ /*=null*/) + : Collection(title_.isEmpty() ? i18n("My Stamps") : title_) { + if(addFields_) { + addFields(defaultFields()); + } + setDefaultGroupField(QString::fromLatin1("denomination")); +} + +Tellico::Data::FieldVec StampCollection::defaultFields() { + FieldVec list; + FieldPtr field; + + field = new Field(QString::fromLatin1("title"), i18n("Title"), Field::Dependent); + field->setCategory(i18n(stamp_general)); + field->setDescription(QString::fromLatin1("%{year} %{description} %{denomination}")); + field->setFlags(Field::NoDelete); + list.append(field); + + field = new Field(QString::fromLatin1("description"), i18n("Description")); + field->setCategory(i18n(stamp_general)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + field->setFormatFlag(Field::FormatTitle); + list.append(field); + + field = new Field(QString::fromLatin1("denomination"), i18n("Denomination")); + field->setCategory(i18n(stamp_general)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("country"), i18n("Country")); + field->setCategory(i18n(stamp_general)); + field->setFormatFlag(Field::FormatPlain); + field->setFlags(Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("year"), i18n("Issue Year"), Field::Number); + field->setCategory(i18n(stamp_general)); + field->setFlags(Field::AllowMultiple | Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("color"), i18n("Color")); + field->setCategory(i18n(stamp_general)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("scott"), i18n("Scott#")); + field->setCategory(i18n(stamp_general)); + list.append(field); + + QStringList grade = QStringList::split(QRegExp(QString::fromLatin1("\\s*,\\s*")), + i18n("Stamp grade levels - " + "Superb,Extremely Fine,Very Fine,Fine,Average,Poor", + "Superb,Extremely Fine,Very Fine,Fine,Average,Poor"), + false); + field = new Field(QString::fromLatin1("grade"), i18n("Grade"), grade); + field->setCategory(i18n(stamp_condition)); + field->setFlags(Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("cancelled"), i18n("Cancelled"), Field::Bool); + field->setCategory(i18n(stamp_condition)); + list.append(field); + + /* TRANSLATORS: See http://en.wikipedia.org/wiki/Stamp_hinge */ + field = new Field(QString::fromLatin1("hinged"), i18n("Hinged")); + field->setCategory(i18n(stamp_condition)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("centering"), i18n("Centering")); + field->setCategory(i18n(stamp_condition)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("gummed"), i18n("Gummed")); + field->setCategory(i18n(stamp_condition)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("pur_date"), i18n("Purchase Date")); + field->setCategory(i18n(stamp_personal)); + field->setFormatFlag(Field::FormatDate); + list.append(field); + + field = new Field(QString::fromLatin1("pur_price"), i18n("Purchase Price")); + field->setCategory(i18n(stamp_personal)); + list.append(field); + + field = new Field(QString::fromLatin1("location"), i18n("Location")); + field->setCategory(i18n(stamp_personal)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + field->setFormatFlag(Field::FormatPlain); + list.append(field); + + field = new Field(QString::fromLatin1("gift"), i18n("Gift"), Field::Bool); + field->setCategory(i18n(stamp_personal)); + list.append(field); + + field = new Field(QString::fromLatin1("image"), i18n("Image"), Field::Image); + list.append(field); + + field = new Field(QString::fromLatin1("comments"), i18n("Comments"), Field::Para); + list.append(field); + + return list; +} + +#include "stampcollection.moc" diff --git a/src/collections/stampcollection.h b/src/collections/stampcollection.h new file mode 100644 index 0000000..8b81623 --- /dev/null +++ b/src/collections/stampcollection.h @@ -0,0 +1,66 @@ +/*************************************************************************** + copyright : (C) 2003-2006 by Robby Stephenson + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of version 2 of the GNU General Public License as * + * published by the Free Software Foundation; * + * * + ***************************************************************************/ + +#ifndef STAMPCOLLECTION_H +#define STAMPCOLLECTION_H + +#include "../collection.h" + +namespace Tellico { + namespace Data { + +/** + * A stamp collection. + * + * It has the following standard attributes: + * @li Title + * @li Description + * @li Denomination + * @li Country + * @li Year + * @li Color + * @li Scott + * @li Grade + * @li Cancelled + * @li Hinged + * @li Centering + * @li Gummed + * @li Pur_date + * @li Pur_price + * @li Location + * @li Gift + * @li Image + * @li Comments + * + * @author Robby Stephenson + */ +class StampCollection : public Collection { +Q_OBJECT + +public: + /** + * The constructor + * + * @param addFields A boolean indicating whether the default attributes should be added + * @param title The title of the collection + */ + StampCollection(bool addFields, const QString& title = QString::null); + + virtual Type type() const { return Stamp; } + + static FieldVec defaultFields(); +}; + + } // end namespace +} // end namespace +#endif diff --git a/src/collections/videocollection.cpp b/src/collections/videocollection.cpp new file mode 100644 index 0000000..ad83b5f --- /dev/null +++ b/src/collections/videocollection.cpp @@ -0,0 +1,236 @@ +/*************************************************************************** + copyright : (C) 2003-2006 by Robby Stephenson + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of version 2 of the GNU General Public License as * + * published by the Free Software Foundation; * + * * + ***************************************************************************/ + +#include "videocollection.h" + +#include <klocale.h> + +namespace { + static const char* video_general = I18N_NOOP("General"); + static const char* video_people = I18N_NOOP("Other People"); + static const char* video_features = I18N_NOOP("Features"); + static const char* video_personal = I18N_NOOP("Personal"); +} + +using Tellico::Data::VideoCollection; + +VideoCollection::VideoCollection(bool addFields_, const QString& title_ /*=null*/) + : Collection(title_.isEmpty() ? i18n("My Videos") : title_) { + if(addFields_) { + addFields(defaultFields()); + } + setDefaultGroupField(QString::fromLatin1("genre")); +} + +Tellico::Data::FieldVec VideoCollection::defaultFields() { + FieldVec list; + FieldPtr field; + + field = new Field(QString::fromLatin1("title"), i18n("Title")); + field->setCategory(i18n("General")); + field->setFlags(Field::NoDelete); + field->setFormatFlag(Field::FormatTitle); + list.append(field); + + QStringList media; + media << i18n("DVD") << i18n("VHS") << i18n("VCD") << i18n("DivX") << i18n("Blu-ray") << i18n("HD DVD"); + field = new Field(QString::fromLatin1("medium"), i18n("Medium"), media); + field->setCategory(i18n(video_general)); + field->setFlags(Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("year"), i18n("Production Year"), Field::Number); + field->setCategory(i18n(video_general)); + field->setFlags(Field::AllowGrouped); + list.append(field); + + QStringList cert = QStringList::split(QRegExp(QString::fromLatin1("\\s*,\\s*")), + i18n("Movie ratings - " + "G (USA),PG (USA),PG-13 (USA),R (USA), U (USA)", + "G (USA),PG (USA),PG-13 (USA),R (USA), U (USA)"), + false); + field = new Field(QString::fromLatin1("certification"), i18n("Certification"), cert); + field->setCategory(i18n(video_general)); + field->setFlags(Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("genre"), i18n("Genre")); + field->setCategory(i18n(video_general)); + field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); + field->setFormatFlag(Field::FormatPlain); + list.append(field); + + QStringList region; + region << i18n("Region 1") + << i18n("Region 2") + << i18n("Region 3") + << i18n("Region 4") + << i18n("Region 5") + << i18n("Region 6") + << i18n("Region 7") + << i18n("Region 8"); + field = new Field(QString::fromLatin1("region"), i18n("Region"), region); + field->setCategory(i18n(video_general)); + field->setFlags(Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("nationality"), i18n("Nationality")); + field->setCategory(i18n(video_general)); + field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); + field->setFormatFlag(Field::FormatPlain); + list.append(field); + + QStringList format; + format << i18n("NTSC") << i18n("PAL") << i18n("SECAM"); + field = new Field(QString::fromLatin1("format"), i18n("Format"), format); + field->setCategory(i18n(video_general)); + field->setFlags(Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("cast"), i18n("Cast"), Field::Table); + field->setProperty(QString::fromLatin1("columns"), QChar('2')); + field->setProperty(QString::fromLatin1("column1"), i18n("Actor/Actress")); + field->setProperty(QString::fromLatin1("column2"), i18n("Role")); + field->setFormatFlag(Field::FormatName); + field->setFlags(Field::AllowGrouped); + field->setDescription(i18n("A table for the cast members, along with the roles they play")); + list.append(field); + + field = new Field(QString::fromLatin1("director"), i18n("Director")); + field->setCategory(i18n(video_people)); + field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); + field->setFormatFlag(Field::FormatName); + list.append(field); + + field = new Field(QString::fromLatin1("producer"), i18n("Producer")); + field->setCategory(i18n(video_people)); + field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); + field->setFormatFlag(Field::FormatName); + list.append(field); + + field = new Field(QString::fromLatin1("writer"), i18n("Writer")); + field->setCategory(i18n(video_people)); + field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); + field->setFormatFlag(Field::FormatName); + list.append(field); + + field = new Field(QString::fromLatin1("composer"), i18n("Composer")); + field->setCategory(i18n(video_people)); + field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); + field->setFormatFlag(Field::FormatName); + list.append(field); + + field = new Field(QString::fromLatin1("studio"), i18n("Studio")); + field->setCategory(i18n(video_people)); + field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); + field->setFormatFlag(Field::FormatPlain); + list.append(field); + + field = new Field(QString::fromLatin1("language"), i18n("Language Tracks")); + field->setCategory(i18n(video_features)); + field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); + field->setFormatFlag(Field::FormatPlain); + list.append(field); + + field = new Field(QString::fromLatin1("subtitle"), i18n("Subtitle Languages")); + field->setCategory(i18n(video_features)); + field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); + field->setFormatFlag(Field::FormatPlain); + list.append(field); + + field = new Field(QString::fromLatin1("audio-track"), i18n("Audio Tracks")); + field->setCategory(i18n(video_features)); + field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); + field->setFormatFlag(Field::FormatPlain); + list.append(field); + + field = new Field(QString::fromLatin1("running-time"), i18n("Running Time"), Field::Number); + field->setCategory(i18n(video_features)); + field->setDescription(i18n("The running time of the video (in minutes)")); + list.append(field); + + field = new Field(QString::fromLatin1("aspect-ratio"), i18n("Aspect Ratio")); + field->setCategory(i18n(video_features)); + field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("widescreen"), i18n("Widescreen"), Field::Bool); + field->setCategory(i18n(video_features)); + list.append(field); + + QStringList color; + color << i18n("Color") << i18n("Black & White"); + field = new Field(QString::fromLatin1("color"), i18n("Color Mode"), color); + field->setCategory(i18n(video_features)); + field->setFlags(Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("directors-cut"), i18n("Director's Cut"), Field::Bool); + field->setCategory(i18n(video_features)); + list.append(field); + + field = new Field(QString::fromLatin1("plot"), i18n("Plot Summary"), Field::Para); + list.append(field); + + field = new Field(QString::fromLatin1("rating"), i18n("Personal Rating"), Field::Rating); + field->setCategory(i18n(video_personal)); + field->setFlags(Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("pur_date"), i18n("Purchase Date")); + field->setCategory(i18n(video_personal)); + field->setFormatFlag(Field::FormatDate); + list.append(field); + + field = new Field(QString::fromLatin1("gift"), i18n("Gift"), Field::Bool); + field->setCategory(i18n(video_personal)); + list.append(field); + + field = new Field(QString::fromLatin1("pur_price"), i18n("Purchase Price")); + field->setCategory(i18n(video_personal)); + list.append(field); + + field = new Field(QString::fromLatin1("loaned"), i18n("Loaned"), Field::Bool); + field->setCategory(i18n(video_personal)); + list.append(field); + + field = new Field(QString::fromLatin1("keyword"), i18n("Keywords")); + field->setCategory(i18n(video_personal)); + field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("cover"), i18n("Cover"), Field::Image); + list.append(field); + + field = new Field(QString::fromLatin1("comments"), i18n("Comments"), Field::Para); + list.append(field); + + return list; +} + +int VideoCollection::sameEntry(Data::EntryPtr entry1_, Data::EntryPtr entry2_) const { + // not enough for title to be equal, must also have another field + // ever possible for a studio to do two movies with identical titles? + int res = 3*Entry::compareValues(entry1_, entry2_, QString::fromLatin1("title"), this); +// if(res == 0) { +// myDebug() << "VideoCollection::sameEntry() - different titles for " << entry1_->title() << " vs. " +// << entry2_->title() << endl; +// } + res += Entry::compareValues(entry1_, entry2_, QString::fromLatin1("year"), this); + res += Entry::compareValues(entry1_, entry2_, QString::fromLatin1("director"), this); + res += Entry::compareValues(entry1_, entry2_, QString::fromLatin1("studio"), this); + res += Entry::compareValues(entry1_, entry2_, QString::fromLatin1("medium"), this); + return res; +} + +#include "videocollection.moc" diff --git a/src/collections/videocollection.h b/src/collections/videocollection.h new file mode 100644 index 0000000..58f729c --- /dev/null +++ b/src/collections/videocollection.h @@ -0,0 +1,54 @@ +/*************************************************************************** + copyright : (C) 2003-2006 by Robby Stephenson + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of version 2 of the GNU General Public License as * + * published by the Free Software Foundation; * + * * + ***************************************************************************/ + +#ifndef VIDEOCOLLECTION_H +#define VIDEOCOLLECTION_H + +#include "../collection.h" + +namespace Tellico { + namespace Data { + +/** + * A collection for videos. + * + * It has the following standard attributes: + * @li Title + * @li Year + * @li Genre + * @li Medium + * @li Comments + * + * @author Robby Stephenson + */ +class VideoCollection : public Collection { +Q_OBJECT + +public: + /** + * The constructor + * + * @param addFields Whether to add the default attributes + * @param title The title of the collection + */ + VideoCollection(bool addFields, const QString& title = QString::null); + + virtual Type type() const { return Video; } + virtual int sameEntry(Data::EntryPtr, Data::EntryPtr) const; + + static FieldVec defaultFields(); +}; + + } // end namespace +} // end namespace +#endif diff --git a/src/collections/winecollection.cpp b/src/collections/winecollection.cpp new file mode 100644 index 0000000..31bc5d0 --- /dev/null +++ b/src/collections/winecollection.cpp @@ -0,0 +1,120 @@ +/*************************************************************************** + copyright : (C) 2003-2006 by Robby Stephenson + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of version 2 of the GNU General Public License as * + * published by the Free Software Foundation; * + * * + ***************************************************************************/ + +#include "winecollection.h" + +#include <klocale.h> + +namespace { + static const char* wine_general = I18N_NOOP("General"); + static const char* wine_personal = I18N_NOOP("Personal"); +} + +using Tellico::Data::WineCollection; + +WineCollection::WineCollection(bool addFields_, const QString& title_ /*=null*/) + : Collection(title_.isEmpty() ? i18n("My Wines") : title_) { + if(addFields_) { + addFields(defaultFields()); + } + setDefaultGroupField(QString::fromLatin1("type")); +} + +Tellico::Data::FieldVec WineCollection::defaultFields() { + FieldVec list; + FieldPtr field; + + field = new Field(QString::fromLatin1("title"), i18n("Title"), Field::Dependent); + field->setCategory(i18n(wine_general)); + field->setDescription(QString::fromLatin1("%{vintage} %{producer} %{varietal}")); + field->setFlags(Field::NoDelete); + list.append(field); + + field = new Field(QString::fromLatin1("producer"), i18n("Producer")); + field->setCategory(i18n(wine_general)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + field->setFormatFlag(Field::FormatPlain); + list.append(field); + + field = new Field(QString::fromLatin1("appellation"), i18n("Appellation")); + field->setCategory(i18n(wine_general)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + field->setFormatFlag(Field::FormatPlain); + list.append(field); + + field = new Field(QString::fromLatin1("varietal"), i18n("Varietal")); + field->setCategory(i18n(wine_general)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + field->setFormatFlag(Field::FormatPlain); + list.append(field); + + field = new Field(QString::fromLatin1("vintage"), i18n("Vintage"), Field::Number); + field->setCategory(i18n(wine_general)); + field->setFlags(Field::AllowGrouped); + list.append(field); + + QStringList type; + type << i18n("Red Wine") << i18n("White Wine") << i18n("Sparkling Wine"); + field = new Field(QString::fromLatin1("type"), i18n("Type"), type); + field->setCategory(i18n(wine_general)); + field->setFlags(Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("country"), i18n("Country")); + field->setCategory(i18n(wine_general)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + field->setFormatFlag(Field::FormatPlain); + list.append(field); + + field = new Field(QString::fromLatin1("pur_date"), i18n("Purchase Date")); + field->setCategory(i18n(wine_personal)); + field->setFormatFlag(Field::FormatDate); + list.append(field); + + field = new Field(QString::fromLatin1("pur_price"), i18n("Purchase Price")); + field->setCategory(i18n(wine_personal)); + list.append(field); + + field = new Field(QString::fromLatin1("location"), i18n("Location")); + field->setCategory(i18n(wine_personal)); + field->setFlags(Field::AllowCompletion | Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("quantity"), i18n("Quantity"), Field::Number); + field->setCategory(i18n(wine_personal)); + list.append(field); + + field = new Field(QString::fromLatin1("drink-by"), i18n("Drink By"), Field::Number); + field->setCategory(i18n(wine_personal)); + field->setFlags(Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("rating"), i18n("Rating"), Field::Rating); + field->setCategory(i18n(wine_personal)); + field->setFlags(Field::AllowGrouped); + list.append(field); + + field = new Field(QString::fromLatin1("gift"), i18n("Gift"), Field::Bool); + field->setCategory(i18n(wine_personal)); + list.append(field); + + field = new Field(QString::fromLatin1("label"), i18n("Label Image"), Field::Image); + list.append(field); + + field = new Field(QString::fromLatin1("comments"), i18n("Comments"), Field::Para); + list.append(field); + + return list; +} + +#include "winecollection.moc" diff --git a/src/collections/winecollection.h b/src/collections/winecollection.h new file mode 100644 index 0000000..236a9cd --- /dev/null +++ b/src/collections/winecollection.h @@ -0,0 +1,54 @@ +/*************************************************************************** + copyright : (C) 2003-2006 by Robby Stephenson + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of version 2 of the GNU General Public License as * + * published by the Free Software Foundation; * + * * + ***************************************************************************/ + +#ifndef WINECOLLECTION_H +#define WINECOLLECTION_H + +#include "../collection.h" + +namespace Tellico { + namespace Data { + +/** + * A wine collection. + * + * It has the following standard attributes: + * @li Title + * @li Artist + * @li Album + * @li Year + * @li Genre + * @li Comments + * + * @author Robby Stephenson + */ +class WineCollection : public Collection { +Q_OBJECT + +public: + /** + * The constructor + * + * @param addFields A boolean indicating whether the default attributes should be added + * @param title The title of the collection + */ + WineCollection(bool addFields, const QString& title = QString::null); + + virtual Type type() const { return Wine; } + + static FieldVec defaultFields(); +}; + + } // end namespace +} // end namespace +#endif |