blob: c8c073073f0c4bb81181074dedb03a363a640a5f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
|
/***************************************************************************
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 "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 <tdelocale.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(TQString::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 TQString& 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;
}
TQString CollectionFactory::typeName(int type_) {
switch(type_) {
case Data::Collection::Book:
return TQString::fromLatin1("book");
break;
case Data::Collection::Video:
return TQString::fromLatin1("video");
break;
case Data::Collection::Album:
return TQString::fromLatin1("album");
break;
case Data::Collection::Bibtex:
return TQString::fromLatin1("bibtex");
break;
case Data::Collection::ComicBook:
return TQString::fromLatin1("comic");
break;
case Data::Collection::Wine:
return TQString::fromLatin1("wine");
break;
case Data::Collection::Coin:
return TQString::fromLatin1("coin");
break;
case Data::Collection::Stamp:
return TQString::fromLatin1("stamp");
break;
case Data::Collection::Card:
return TQString::fromLatin1("card");
break;
case Data::Collection::Game:
return TQString::fromLatin1("game");
break;
case Data::Collection::File:
return TQString::fromLatin1("file");
break;
case Data::Collection::BoardGame:
return TQString::fromLatin1("boardgame");
break;
case Data::Collection::Base:
return TQString::fromLatin1("entry");
break;
default:
kdWarning() << "CollectionFactory::collection() - collection type not implemented: " << type_ << endl;
return TQString::fromLatin1("entry");
break;
}
}
bool CollectionFactory::isDefaultField(int type_, const TQString& 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;
}
|