diff options
Diffstat (limited to 'src/frontend/keychooser/ckeychooser.cpp')
-rw-r--r-- | src/frontend/keychooser/ckeychooser.cpp | 52 |
1 files changed, 32 insertions, 20 deletions
diff --git a/src/frontend/keychooser/ckeychooser.cpp b/src/frontend/keychooser/ckeychooser.cpp index 905e125..4d58298 100644 --- a/src/frontend/keychooser/ckeychooser.cpp +++ b/src/frontend/keychooser/ckeychooser.cpp @@ -2,7 +2,7 @@ * * This file is part of BibleTime's source code, http://www.bibletime.info/. * -* Copyright 1999-2008 by the BibleTime developers. +* Copyright 1999-2011 by the BibleTime developers. * The BibleTime source code is licensed under the GNU General Public License version 2.0. * **********/ @@ -22,37 +22,49 @@ #include "frontend/keychooser/versekeychooser/cbiblekeychooser.h" -CKeyChooser::CKeyChooser(QList<CSwordModuleInfo*>, CSwordKey *, QWidget *parent) +CKeyChooser::CKeyChooser(const QList<const CSwordModuleInfo*> &, BTHistory* historyPtr, + CSwordKey *, QWidget *parent) : QWidget(parent), - m_history(0) { + m_history(historyPtr) { //qDebug() << "CKeyChooser::CKeyChooser"; - m_history = new BTHistory(this); - QObject::connect(history(), SIGNAL(historyMoved(QString&)), this, SLOT(setKey(QString&))); + bool ok = QObject::connect(history(), SIGNAL(historyMoved(QString&)), this, SLOT(setKey(QString&))); + Q_ASSERT(ok); } -CKeyChooser::~CKeyChooser() {} - -CKeyChooser* CKeyChooser::createInstance(QList<CSwordModuleInfo*> modules, CSwordKey *key, QWidget *parent) { +CKeyChooser* CKeyChooser::createInstance( + const QList<const CSwordModuleInfo*> &modules, BTHistory *historyPtr, + CSwordKey *key, QWidget *parent) +{ if (!modules.count()) { + /** + \todo Verify and document that we need to return 0 here rather than + fail with an assertion. + */ return 0; } - switch ( modules.first()->type() ) { - case CSwordModuleInfo::Commentary: //Bibles and commentaries use the same key chooser + CSwordModuleInfo::ModuleType typeOfModules = modules.first()->type(); + +#ifdef BT_DEBUG + Q_FOREACH (const CSwordModuleInfo *module, modules) { + Q_ASSERT(module->type() == typeOfModules); + } +#endif + + switch (typeOfModules) { + case CSwordModuleInfo::Commentary: + /* Fall thru - Bibles and commentaries use the same key chooser */ case CSwordModuleInfo::Bible: - return new CBibleKeyChooser(modules, key, parent); - break; + return new CBibleKeyChooser(modules, historyPtr, key, parent); case CSwordModuleInfo::Lexicon: - return new CLexiconKeyChooser(modules, key, parent); + return new CLexiconKeyChooser(modules, historyPtr, key, parent); case CSwordModuleInfo::GenericBook: - return new CBookKeyChooser(modules, key, parent); + return new CBookKeyChooser(modules, historyPtr, key, parent); default: + /** + \todo Verify and document that we need to return 0 here rather + than fail with an assertion. + */ return 0; } } - - -BTHistory* CKeyChooser::history() { - return m_history; -} - |