BibleTime
ckeychooser.cpp
Go to the documentation of this file.
1 /*********
2 *
3 * In the name of the Father, and of the Son, and of the Holy Spirit.
4 *
5 * This file is part of BibleTime's source code, https://bibletime.info/
6 *
7 * Copyright 1999-2021 by the BibleTime developers.
8 * The BibleTime source code is licensed under the GNU General Public License
9 * version 2.0.
10 *
11 **********/
12 
13 #include "ckeychooser.h"
14 
15 #include <QAction>
16 #include "../../backend/drivers/cswordmoduleinfo.h"
17 #include "../../backend/keys/cswordkey.h"
18 #include "../../util/btassert.h"
19 #include "cbookkeychooser.h"
20 #include "clexiconkeychooser.h"
22 
23 
25 
27  CSwordKey * key,
28  QWidget * parent)
29 {
30  BT_ASSERT(!modules.empty());
31  BT_ASSERT(modules.first()->type() == CSwordModuleInfo::Commentary
32  || modules.first()->type() == CSwordModuleInfo::Bible
33  || modules.first()->type() == CSwordModuleInfo::Lexicon
34  || modules.first()->type() == CSwordModuleInfo::GenericBook);
35 
36  switch (modules.first()->type()) {
37 
39  /* Fall thru - Bibles and commentaries use the same key chooser */
40 
42  return new CBibleKeyChooser(modules, key, parent);
43 
45  return new CLexiconKeyChooser(modules, key, parent);
46 
48  return new CBookKeyChooser(modules, key, parent);
49 
50  default:
51  abort();
52 
53  }
54 }
55 
56 void CKeyChooser::handleHistoryMoved(QString const & newKey) {
57  auto * const k = key();
58  k->setKey(newKey);
59  setKey(k);
60 }
#define BT_ASSERT(...)
Definition: btassert.h:17
QList< CSwordModuleInfo const * > BtConstModuleList
Definition: btmodulelist.h:21
A key chooser for bibles and commentaries.
void handleHistoryMoved(QString const &newKey)
Definition: ckeychooser.cpp:56
static CKeyChooser * createInstance(const BtConstModuleList &modules, CSwordKey *key, QWidget *parent)
Definition: ckeychooser.cpp:26
virtual void setKey(CSwordKey *key)=0
CKeyChooser(QWidget *parent=nullptr)
Definition: ckeychooser.cpp:24
virtual CSwordKey * key()=0