summaryrefslogtreecommitdiffstats
path: root/src/collectionfactory.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-03-01 19:17:32 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-03-01 19:17:32 +0000
commite38d2351b83fa65c66ccde443777647ef5cb6cff (patch)
tree1897fc20e9f73a81c520a5b9f76f8ed042124883 /src/collectionfactory.cpp
downloadtellico-e38d2351b83fa65c66ccde443777647ef5cb6cff.tar.gz
tellico-e38d2351b83fa65c66ccde443777647ef5cb6cff.zip
Added KDE3 version of Tellico
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/tellico@1097620 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/collectionfactory.cpp')
-rw-r--r--src/collectionfactory.cpp210
1 files changed, 210 insertions, 0 deletions
diff --git a/src/collectionfactory.cpp b/src/collectionfactory.cpp
new file mode 100644
index 0000000..25f9d6f
--- /dev/null
+++ b/src/collectionfactory.cpp
@@ -0,0 +1,210 @@
+/***************************************************************************
+ copyright : (C) 2003-2006 by Robby Stephenson
+ email : robby@periapsis.org
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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 "collectionfactory.h"
+#include "collections/bookcollection.h"
+#include "collections/bibtexcollection.h"
+#include "collections/musiccollection.h"
+#include "collections/videocollection.h"
+#include "collections/comicbookcollection.h"
+#include "collections/coincollection.h"
+#include "collections/stampcollection.h"
+#include "collections/cardcollection.h"
+#include "collections/winecollection.h"
+#include "collections/gamecollection.h"
+#include "collections/filecatalog.h"
+#include "collections/boardgamecollection.h"
+#include "field.h"
+#include "tellico_debug.h"
+
+#include <klocale.h>
+
+using Tellico::CollectionFactory;
+
+// static
+Tellico::Data::CollPtr CollectionFactory::collection(int type_, bool addFields_) {
+ switch(type_) {
+ case Data::Collection::Book:
+ return new Data::BookCollection(addFields_);
+
+ case Data::Collection::Video:
+ return new Data::VideoCollection(addFields_);
+
+ case Data::Collection::Album:
+ return new Data::MusicCollection(addFields_);
+
+ case Data::Collection::Bibtex:
+ return new Data::BibtexCollection(addFields_);
+
+ case Data::Collection::Coin:
+ return new Data::CoinCollection(addFields_);
+
+ case Data::Collection::Card:
+ return new Data::CardCollection(addFields_);
+
+ case Data::Collection::Stamp:
+ return new Data::StampCollection(addFields_);
+
+ case Data::Collection::Wine:
+ return new Data::WineCollection(addFields_);
+
+ case Data::Collection::ComicBook:
+ return new Data::ComicBookCollection(addFields_);
+
+ case Data::Collection::Game:
+ return new Data::GameCollection(addFields_);
+
+ case Data::Collection::File:
+ return new Data::FileCatalog(addFields_);
+
+ case Data::Collection::BoardGame:
+ return new Data::BoardGameCollection(addFields_);
+
+ case Data::Collection::Base:
+ break;
+
+ default:
+ kdWarning() << "CollectionFactory::collection() - collection type not implemented: " << type_ << endl;
+ // fall through
+ }
+
+ Data::CollPtr c = new Data::Collection(i18n("My Collection"));
+ Data::FieldPtr f = new Data::Field(QString::fromLatin1("title"), i18n("Title"));
+ f->setCategory(i18n("General"));
+ f->setFlags(Data::Field::NoDelete);
+ f->setFormatFlag(Data::Field::FormatTitle);
+ c->addField(f);
+ return c;
+}
+
+// static
+Tellico::Data::CollPtr CollectionFactory::collection(const QString& typeName_, bool addFields_) {
+ if(typeName_ == typeName(Data::Collection::Book)) {
+ return new Data::BookCollection(addFields_);
+ } else if(typeName_ == typeName(Data::Collection::Album)) {
+ return new Data::MusicCollection(addFields_);
+ } else if(typeName_ == typeName(Data::Collection::Video)) {
+ return new Data::VideoCollection(addFields_);
+ } else if(typeName_ == typeName(Data::Collection::Bibtex)) {
+ return new Data::BibtexCollection(addFields_);
+ } else if(typeName_ == typeName(Data::Collection::Bibtex)) {
+ return new Data::ComicBookCollection(addFields_);
+ } else if(typeName_ == typeName(Data::Collection::ComicBook)) {
+ return new Data::CardCollection(addFields_);
+ } else if(typeName_ == typeName(Data::Collection::Coin)) {
+ return new Data::CoinCollection(addFields_);
+ } else if(typeName_ == typeName(Data::Collection::Stamp)) {
+ return new Data::StampCollection(addFields_);
+ } else if(typeName_ == typeName(Data::Collection::Wine)) {
+ return new Data::WineCollection(addFields_);
+ } else if(typeName_ == typeName(Data::Collection::Game)) {
+ return new Data::GameCollection(addFields_);
+ } else if(typeName_ == typeName(Data::Collection::File)) {
+ return new Data::FileCatalog(addFields_);
+ } else if(typeName_ == typeName(Data::Collection::BoardGame)) {
+ return new Data::BoardGameCollection(addFields_);
+ } else {
+ kdWarning() << "CollectionFactory::collection() - collection type not implemented: " << typeName_ << endl;
+ return 0;
+ }
+}
+
+Tellico::CollectionNameMap CollectionFactory::nameMap() {
+ CollectionNameMap map;
+ map[Data::Collection::Book] = i18n("Book Collection");
+ map[Data::Collection::Bibtex] = i18n("Bibliography");
+ map[Data::Collection::ComicBook] = i18n("Comic Book Collection");
+ map[Data::Collection::Video] = i18n("Video Collection");
+ map[Data::Collection::Album] = i18n("Music Collection");
+ map[Data::Collection::Coin] = i18n("Coin Collection");
+ map[Data::Collection::Stamp] = i18n("Stamp Collection");
+ map[Data::Collection::Wine] = i18n("Wine Collection");
+ map[Data::Collection::Card] = i18n("Card Collection");
+ map[Data::Collection::Game] = i18n("Game Collection");
+ map[Data::Collection::File] = i18n("File Catalog");
+ map[Data::Collection::BoardGame] = i18n("Board Game Collection");
+ map[Data::Collection::Base] = i18n("Custom Collection");
+ return map;
+}
+
+QString CollectionFactory::typeName(int type_) {
+ switch(type_) {
+ case Data::Collection::Book:
+ return QString::fromLatin1("book");
+ break;
+
+ case Data::Collection::Video:
+ return QString::fromLatin1("video");
+ break;
+
+ case Data::Collection::Album:
+ return QString::fromLatin1("album");
+ break;
+
+ case Data::Collection::Bibtex:
+ return QString::fromLatin1("bibtex");
+ break;
+
+ case Data::Collection::ComicBook:
+ return QString::fromLatin1("comic");
+ break;
+
+ case Data::Collection::Wine:
+ return QString::fromLatin1("wine");
+ break;
+
+ case Data::Collection::Coin:
+ return QString::fromLatin1("coin");
+ break;
+
+ case Data::Collection::Stamp:
+ return QString::fromLatin1("stamp");
+ break;
+
+ case Data::Collection::Card:
+ return QString::fromLatin1("card");
+ break;
+
+ case Data::Collection::Game:
+ return QString::fromLatin1("game");
+ break;
+
+ case Data::Collection::File:
+ return QString::fromLatin1("file");
+ break;
+
+ case Data::Collection::BoardGame:
+ return QString::fromLatin1("boardgame");
+ break;
+
+ case Data::Collection::Base:
+ return QString::fromLatin1("entry");
+ break;
+
+ default:
+ kdWarning() << "CollectionFactory::collection() - collection type not implemented: " << type_ << endl;
+ return QString::fromLatin1("entry");
+ break;
+ }
+}
+
+bool CollectionFactory::isDefaultField(int type_, const QString& name_) {
+ Data::CollPtr coll = collection(type_, true);
+ Data::FieldVec fields = coll->fields();
+ for(Data::FieldVec::Iterator field = fields.begin(); field != fields.end(); ++field) {
+ if(field->name() == name_) {
+ return true;
+ }
+ }
+ return false;
+}