Basic sword integration, verse at time keys, very basic\!
[kworship.git] / kworship / bible / KwBibleManager.cpp
blobb583f6eced2fccf726d3095dc70a14177b70266c
1 /***************************************************************************
2 * This file is part of KWorship. *
3 * Copyright 2008 James Hogan <james@albanarts.com> *
4 * *
5 * KWorship is free software: you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation, either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * KWorship is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with KWorship. If not, write to the Free Software Foundation, *
17 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
20 /**
21 * @file KwBibleManager.cpp
22 * @brief A bible manager (analagous to a SWORD manager).
23 * @author James Hogan <james@albanarts.com>
26 #include "KwBibleManager.h"
27 #include "KwBibleModule.h"
29 #include <swmgr.h>
30 #include <swmodule.h>
31 #include <markupfiltmgr.h>
34 * Static variables
37 /// Singleton object.
38 KwBibleManager* KwBibleManager::s_self = 0;
41 * Singletonhood
44 /// Get the singleton object.
45 KwBibleManager* KwBibleManager::self()
47 if (0 == s_self)
49 s_self = new KwBibleManager;
51 return s_self;
55 * Constructors + destructor
58 /// Default constructor.
59 KwBibleManager::KwBibleManager()
60 : m_manager(new sword::SWMgr(new sword::MarkupFilterMgr(sword::FMT_HTMLHREF)))
61 , m_modules()
63 sword::ModMap::iterator modIterator;
65 for (modIterator = m_manager->Modules.begin(); modIterator != m_manager->Modules.end(); ++modIterator)
67 sword::SWBuf modName = (*modIterator).first;
68 sword::SWModule* module = (*modIterator).second;
69 m_modules[QLatin1String(modName)] = new KwBibleModule(module);
73 /// Destructor.
74 KwBibleManager::~KwBibleManager()
76 foreach (KwBibleModule* module, m_modules)
78 delete module;
80 delete m_manager;
84 * Main interface
87 /// Get a module by name.
88 KwBibleModule* KwBibleManager::module(const QString& name) const
90 QMap<QString, KwBibleModule*>::const_iterator it = m_modules.constFind(name);
91 if (it != m_modules.constEnd())
93 return *it;
95 else
97 return 0;
101 /// Get the list of modules.
102 QList<KwBibleModule*> KwBibleManager::modules() const
104 return m_modules.values();