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, http://www.bibletime.info/.
6 *
7 * Copyright 1999-2016 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 "frontend/searchdialog/btsearchmodulechooserdialog.h"
14 
15 #include <QAction>
16 #include <QToolButton>
17 #include "backend/bookshelfmodel/btbookshelftreemodel.h"
18 #include "backend/managers/cswordbackend.h"
19 #include "util/btconnect.h"
20 #include "util/tool.h"
21 
22 
23 namespace {
24 const QString groupingOrderKey("GUI/SearchDialog/ModuleChooserDialog/grouping");
25 }
26 
BtSearchModuleChooserDialog(QWidget * parent,Qt::WindowFlags flags)27 BtSearchModuleChooserDialog::BtSearchModuleChooserDialog(QWidget *parent,
28                                                          Qt::WindowFlags flags)
29     : BtModuleChooserDialog(parent, flags)
30 {
31     // Initialize the tree model:
32     BtBookshelfTreeModel::Grouping grouping(groupingOrderKey);
33     BtBookshelfTreeModel *treeModel = new BtBookshelfTreeModel(grouping, this);
34     treeModel->setCheckable(true);
35     BT_CONNECT(treeModel,
36                SIGNAL(groupingOrderChanged(BtBookshelfTreeModel::Grouping)),
37                this,
38                SLOT(slotGroupingOrderChanged(
39                             BtBookshelfTreeModel::Grouping const &)));
40 
41     // Initialize the bookshelf widget:
42     bookshelfWidget()->showHideAction()->setVisible(false);
43     bookshelfWidget()->showHideButton()->hide();
44     bookshelfWidget()->setTreeModel(treeModel);
45     bookshelfWidget()->setSourceModel(CSwordBackend::instance()->model());
46 
47     retranslateUi();
48 }
49 
retranslateUi()50 void BtSearchModuleChooserDialog::retranslateUi() {
51     setWindowTitle(tr("Works to Search in"));
52     util::tool::initExplanationLabel(label(), QString::null,
53                                      tr("Select the works which should be searched."));
54 }
55 
slotGroupingOrderChanged(const BtBookshelfTreeModel::Grouping & g)56 void BtSearchModuleChooserDialog::slotGroupingOrderChanged(const BtBookshelfTreeModel::Grouping &g) {
57     g.saveTo(groupingOrderKey);
58 }
59