[PATCH 1/2] Add boardgame collections
Steve Beattie
sbeattie at suse.de
Tue Oct 3 17:22:31 MDT 2006
This patch adds support for boardgame collections. Examples of the types
of games people collect can be found at boardgamegeek.com.
I'm undecided whether it makes more sense to record the boardgamegeek
URL or just the id number. Boardgamegeek urls are of the form
http://www.boardgamegeek.com/game/<bggid> so you can go from one to the
other. Eventually, I'd like the fetcher update mechanism to key off of
the bggid to grab its update, which it could get from the URL, though
the xmlapi URL would be different.
I don't have a nifty icon to use to represent boardgames and my graphics
skills are pretty weak, so assistance there would be appreciated.
This patch was made mostly via monkey-see-monkey-do programming;
improvements and suggestions welcome.
---
src/collection.h | 3
src/collectionfactory.cpp | 11 ++
src/collections/Makefile.am | 4 -
src/collections/boardgamecollection.cpp | 119 ++++++++++++++++++++++++++++++++
src/collections/boardgamecollection.h | 44 +++++++++++
src/core/tellico_config.kcfg | 26 ++++++
src/core/tellico_config_addons.cpp | 2
src/fetch/execexternalfetcher.cpp | 8 ++
src/mainwindow.cpp | 8 ++
src/tellicoui.rc | 1
tellico.dtd | 16 +++-
11 files changed, 237 insertions(+), 5 deletions(-)
Index: tellico/src/collection.h
===================================================================
--- tellico.orig/src/collection.h
+++ tellico/src/collection.h
@@ -64,7 +64,8 @@ public:
Stamp = 9,
Card = 10,
Game = 11,
- File = 12
+ File = 12,
+ BoardGame = 13,
// if you want to add custom collection types, use a numebr sure to be unique like 101
};
Index: tellico/src/collections/boardgamecollection.h
===================================================================
--- /dev/null
+++ tellico/src/collections/boardgamecollection.h
@@ -0,0 +1,44 @@
+/***************************************************************************
+ copyright : (C) 2005-2006 by Robby Stephenson, Steve Beattie
+ email : robby at periapsis.org, sbeattie at suse.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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
Index: tellico/src/collections/Makefile.am
===================================================================
--- tellico.orig/src/collections/Makefile.am
+++ tellico/src/collections/Makefile.am
@@ -8,7 +8,7 @@ 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
+ filecatalog.cpp boardgamecollection.cpp
####### kdevelop will overwrite this part!!! (end)############
@@ -16,4 +16,4 @@ 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
+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.cpp boardgamecollection.h
Index: tellico/src/collections/boardgamecollection.cpp
===================================================================
--- /dev/null
+++ tellico/src/collections/boardgamecollection.cpp
@@ -0,0 +1,119 @@
+/***************************************************************************
+ copyright : (C) 2005-2006 by Robby Stephenson, Steve Beattie
+ email : robby at periapsis.org, sbeattie at suse.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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_, i18n("BoardGames")) {
+ setTitle(title_.isNull() ? i18n("My BoardGames") : title_);
+ if(addFields_) {
+ addFields(defaultFields());
+ }
+ setDefaultGroupField(QString::fromLatin1("title"));
+}
+
+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("bggid"), i18n("BoardGameGeek ID"), Field::Number);
+ field->setCategory(i18n(boardgame_general));
+ 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(boardgame_personal));
+ field->setFlags(Field::AllowGrouped);
+ field->setProperty(QString::fromLatin1("maximum"), QString::fromLatin1("10"));
+ field->setProperty(QString::fromLatin1("minimum"), QChar('1'));
+ 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"
Index: tellico/tellico.dtd
===================================================================
--- tellico.orig/tellico.dtd
+++ tellico/tellico.dtd
@@ -21,7 +21,7 @@
<!ELEMENT collection (fields | bibtex-preamble | macros | entry |
images | borrowers | filters)+>
<!ATTLIST collection title CDATA #REQUIRED>
-<!ATTLIST collection type (1|2|3|4|5|6|7|8|9|10|11|12) #REQUIRED>
+<!ATTLIST collection type (1|2|3|4|5|6|7|8|9|10|11|12|13) #REQUIRED>
<!ATTLIST collection entryTitle CDATA #IMPLIED>
<!ELEMENT images (image+)>
@@ -96,7 +96,8 @@ producer | appellation | varietal | vint
platform | publishers | developers | completed |url | volume |
mimetype | size | permissions | owner | group | created | modified |
metainfos | icon | amazon | imdb | imdb-rating | alttitle |
-allcertification | address | abstract)+>
+allcertification | address | abstract | designer | bggid |
+mechanism | num-players )+>
<!ATTLIST entry id CDATA #REQUIRED>
<!ELEMENT title (#PCDATA)>
@@ -229,6 +230,17 @@ allcertification | address | abstract)+>
<!ELEMENT developer (#PCDATA)>
<!ELEMENT completed (#PCDATA)>
+<!-- boardgames --?
+<!-- publisher is defined above -->
+<!-- publishers is defined above -->
+<!ELEMENT designers (designer+)>
+<!ELEMENT designer (#PCDATA)>
+<!ELEMENT mechanisms (mechanism+)>
+<!ELEMENT mechanism (#PCDATA)>
+<!ELEMENT bggid (#PCDATA)>
+<!ELEMENT num-players (num-player+)>
+<!ELEMENT num-player (#PCDATA)>
+
<!-- file catalogs -->
<!-- description is above -->
<!ELEMENT url (#PCDATA)>
Index: tellico/src/collectionfactory.cpp
===================================================================
--- tellico.orig/src/collectionfactory.cpp
+++ tellico/src/collectionfactory.cpp
@@ -23,6 +23,7 @@
#include "collections/winecollection.h"
#include "collections/gamecollection.h"
#include "collections/filecatalog.h"
+#include "collections/boardgamecollection.h"
#include "field.h"
#include <kdebug.h>
@@ -65,6 +66,9 @@ Tellico::Data::CollPtr CollectionFactory
case Data::Collection::File:
return new Data::FileCatalog(addFields_);
+ case Data::Collection::BoardGame:
+ return new Data::BoardGameCollection(addFields_);
+
case Data::Collection::Base:
break;
@@ -106,6 +110,8 @@ Tellico::Data::CollPtr CollectionFactory
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;
@@ -125,6 +131,7 @@ Tellico::CollectionNameMap CollectionFac
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("BoardGame Collection");
map[Data::Collection::Base] = i18n("Custom Collection");
return map;
}
@@ -175,6 +182,10 @@ QString CollectionFactory::typeName(int
return QString::fromLatin1("file");
break;
+ case Data::Collection::BoardGame:
+ return QString::fromLatin1("boardgame");
+ break;
+
case Data::Collection::Base:
return QString::fromLatin1("entry");
break;
Index: tellico/src/mainwindow.cpp
===================================================================
--- tellico.orig/src/mainwindow.cpp
+++ tellico/src/mainwindow.cpp
@@ -242,6 +242,14 @@ void MainWindow::initActions() {
connect(action, SIGNAL(activated()), collectionMapper, SLOT(map()));
collectionMapper->setMapping(action, Data::Collection::Game);
+ action = new KAction(actionCollection(), "new_boardgame_collection");
+ action->setText(i18n("New Boardgame Collection"));
+ action->setIconSet(UserIconSet(QString::fromLatin1("boardgame")));
+ action->setToolTip(i18n("Create a new boardgame collection"));
+ fileNewMenu->insert(action);
+ connect(action, SIGNAL(activated()), collectionMapper, SLOT(map()));
+ collectionMapper->setMapping(action, Data::Collection::BoardGame);
+
action = new KAction(actionCollection(), "new_card_collection");
action->setText(i18n("New C&ard Collection"));
action->setIconSet(UserIconSet(QString::fromLatin1("card")));
Index: tellico/src/tellicoui.rc
===================================================================
--- tellico.orig/src/tellicoui.rc
+++ tellico/src/tellicoui.rc
@@ -16,6 +16,7 @@
<Action name="new_card_collection"/>
<Action name="new_wine_collection"/>
<Action name="new_game_collection"/>
+ <Action name="new_boardgame_collection"/>
<Action name="new_file_catalog"/>
<Action name="new_custom_collection"/>
</Menu>
Index: tellico/src/core/tellico_config.kcfg
===================================================================
--- tellico.orig/src/core/tellico_config.kcfg
+++ tellico/src/core/tellico_config.kcfg
@@ -391,6 +391,32 @@
</entry>
</group>
+<group name="Options - boardgame">
+ <entry key="Entry Template" type="String" name="templateBoardGame">
+ <default>Fancy</default>
+ </entry>
+ <entry key="Template Font" type="Font" name="fontBoardGame">
+ <label>Template font</label>
+ <default code="true">KGlobalSettings::generalFont()</default>
+ </entry>
+ <entry key="Template Base Color" type="Color" name="baseColorBoardGame">
+ <label>Template background color</label>
+ <default code="true">KGlobalSettings::baseColor()</default>
+ </entry>
+ <entry key="Template Text Color" type="Color" name="textColorBoardGame">
+ <label>Template text color</label>
+ <default code="true">KGlobalSettings::textColor()</default>
+ </entry>
+ <entry key="Template Highlight Color" type="Color" name="highlightedBaseColorBoardGame">
+ <label>Template highlight color</label>
+ <default code="true">KGlobalSettings::highlightColor()</default>
+ </entry>
+ <entry key="Template Highlighted Text Color" type="Color" name="highlightedTextColorBoardGame">
+ <label>Template highlighted text color</label>
+ <default code="true">KGlobalSettings::highlightedTextColor()</default>
+ </entry>
+</group>
+
<group name="Options - file">
<entry key="Entry Template" type="String" name="templateFile">
<default>Fancy</default>
Index: tellico/src/core/tellico_config_addons.cpp
===================================================================
--- tellico.orig/src/core/tellico_config_addons.cpp
+++ tellico/src/core/tellico_config_addons.cpp
@@ -36,6 +36,7 @@
GET(name, Stamp) \
GET(name, Card) \
GET(name, Game) \
+ GET(name, BoardGame) \
GET(name, File)
#define ALL_SET(name,value) \
SET(name, Base, value) \
@@ -49,6 +50,7 @@
SET(name, Stamp, value) \
SET(name, Card, value) \
SET(name, Game, value) \
+ SET(name, BoardGame, value) \
SET(name, File, value)
namespace {
Index: tellico/src/fetch/execexternalfetcher.cpp
===================================================================
--- tellico.orig/src/fetch/execexternalfetcher.cpp
+++ tellico/src/fetch/execexternalfetcher.cpp
@@ -286,6 +286,14 @@ void ExecExternalFetcher::slotProcessExi
desc = entry->field(QString::fromLatin1("platform"));
break;
+ case Data::Collection::BoardGame:
+ desc = entry->field(QString::fromLatin1("designer"))
+ + QChar('/')
+ + entry->field(QString::fromLatin1("publisher"))
+ + QChar('/')
+ + entry->field(QString::fromLatin1("year"));
+ break;
+
case Data::Collection::ComicBook:
desc = entry->field(QString::fromLatin1("publisher"))
+ QChar('/')
--
Steve Beattie
SUSE Labs, Novell Inc.
<sbeattie at suse.de>
http://NxNW.org/~steve/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://forge.novell.com/pipermail/tellico-users/attachments/20061003/df2d21fa/attachment.pgp
More information about the tellico-users
mailing list