summaryrefslogtreecommitdiff
path: root/src/frontend/keychooser/cbookkeychooser.h
blob: c01e0e93dc026ff7d212fe646682f340bcfd3749 (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
/*********
*
* In the name of the Father, and of the Son, and of the Holy Spirit.
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/

#ifndef CBOOKKEYCHOOSER_H
#define CBOOKKEYCHOOSER_H

#include "frontend/keychooser/ckeychooser.h"

#include <QList>
#include "frontend/keychooser/ckeychooserwidget.h"


class CSwordBookModuleInfo;
class CSwordKey;
class CSwordTreeKey;

/**
  \brief The keychooser implementation for books.
*/
class CBookKeyChooser: public CKeyChooser {

    Q_OBJECT

public:

    CBookKeyChooser(const QList<const CSwordModuleInfo *> & modules,
                    BTHistory * history,
                    CSwordKey * key = 0,
                    QWidget * parent = 0);

    /**
      Reimplemented from CKeyChooser.
    */
    virtual void refreshContent();

    /**
    * Sets another module to this keychooser
    */
    virtual void setModules(const QList<const CSwordModuleInfo *> & modules,
                            bool refresh = false);
    /**
    * Returns the key of this keychooser
    */
    virtual CSwordKey * key();

    /**
    * Sets a new key to this keychooser
    */
    virtual void setKey(CSwordKey * key);

    /**
    * Sets a new key to this keychooser
    */
    void setKey(CSwordKey * key, const bool emitSignal);

public slots: // Public slots

    /**
    * Updates the keychoosers for the given key but emit no signal.
    */
    void updateKey(CSwordKey * key);

protected: /* Methods: */

    /**
    * Fills the combo given by depth with the items from the key having depth "depth".
    * The parent sibling is given by key.
    */
    void setupCombo(const QString & key, const int depth, const int currentItem);

    /** No descriptions */
    virtual void adjustFont();

protected slots:

    /**
    * A keychooser changed. Update and emit a signal if necessary.
    */
    void keyChooserChanged(int);

    virtual void setKey(const QString & newKey);

private: /* Fields: */

    QList<CKeyChooserWidget *> m_chooserWidgets;
    QList<const CSwordBookModuleInfo *> m_modules;
    CSwordTreeKey * m_key;
    QHBoxLayout * m_layout;

};

#endif