summaryrefslogtreecommitdiff
path: root/src/frontend/displaywindow/btmodulechooserbar.h
blob: 024bc0828c9de2a2c1d9cddf34c28d477f277f69 (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
/*********
*
* 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 BT_MODULECHOOSERBAR
#define BT_MODULECHOOSERBAR

#include "btwindowmodulechooser.h"
#include "backend/drivers/cswordmoduleinfo.h"
#include <QToolBar>
#include <QStringList>

class CReadWindow;
class BtModuleChooserButton;

class BtModuleChooserBar: public QToolBar, public BtWindowModuleChooser {
        Q_OBJECT
    public:
        BtModuleChooserBar(QWidget* parent);
        /** Initialize with module list.*/
        void setModules( QStringList useModules,CSwordModuleInfo::ModuleType type, CReadWindow* window);

    public slots:
        /**
        * The backend module list was updated, module list and widgets must be updated.
        * The signal comes from the window, not from the backend. The new list can
        * be shorter but not longer than the old list.
        */
        void slotBackendModulesChanged();

        /**
        * The window module list was changed, i.e. 1 module added, removed or replaced.
        */
        void slotWindowModulesChanged();

    private:
        /** Adds an empty button to the toolbar.*/
        BtModuleChooserButton* addButton();
        /** Updates every button's menu without recreating it.*/
        void updateButtonMenus();
        /**
        * Removes or adds buttons so that the count matches the limit.
        * If given limit is -1 the module count is the limit.
        */
        void adjustButtonCount(bool adjustToZero = false);

    private:
        int m_idCounter;
        CReadWindow* m_window;
        CSwordModuleInfo::ModuleType m_moduleType;
        QList<BtModuleChooserButton*> m_buttonList;
};

#endif