BibleTime
btsearchmodulechooserdialog.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 
14 
15 #include <QAction>
16 #include <QToolButton>
17 #include "../../backend/bookshelfmodel/btbookshelftreemodel.h"
18 #include "../../backend/config/btconfig.h"
19 #include "../../backend/drivers/btconstmoduleset.h"
20 #include "../../backend/drivers/btmoduleset.h"
21 #include "../../backend/managers/cswordbackend.h"
22 #include "../../util/btconnect.h"
23 #include "../../util/tool.h"
24 #include "../btbookshelfwidget.h"
25 #include "../btmodulechooserdialog.h"
26 
27 
28 namespace {
29 auto const groupingOrderKey(
30  QStringLiteral("GUI/SearchDialog/ModuleChooserDialog/grouping"));
31 }
32 
34  Qt::WindowFlags flags)
35  : BtModuleChooserDialog(parent, flags)
36 {
37  // Initialize the tree model:
39  BtBookshelfTreeModel *treeModel = new BtBookshelfTreeModel(grouping, this);
40  treeModel->setCheckable(true);
42  [](BtBookshelfTreeModel::Grouping const & grouping)
43  { grouping.saveTo(btConfig(), groupingOrderKey); });
44 
45  // Initialize the bookshelf widget:
46  bookshelfWidget()->showHideAction()->setVisible(false);
47  bookshelfWidget()->showHideButton()->hide();
48  bookshelfWidget()->setTreeModel(treeModel);
50 
51  retranslateUi();
52 }
53 
55  BtConstModuleSet const & modules)
57 
59 { return bookshelfWidget()->treeModel()->checkedModules(); }
60 
62  setWindowTitle(tr("Works to Search in"));
64  tr("Select the works which should be searched."));
65 }
BtConfig & btConfig()
This is a shortchand for BtConfig::getInstance().
Definition: btconfig.h:305
#define BT_CONNECT(...)
Definition: btconnect.h:20
void saveTo(BtConfigCore &config, QString const &key) const
void groupingOrderChanged(BtBookshelfTreeModel::Grouping newGrouping)
void setCheckable(bool checkable)
void setCheckedModules(BtConstModuleSet const &modules)
BtModuleSet const & checkedModules() const
QToolButton * showHideButton() const
void setTreeModel(BtBookshelfTreeModel *model)
BtBookshelfTreeModel * treeModel() const
void setSourceModel(std::shared_ptr< QAbstractItemModel > model)
QAction * showHideAction() const
BtBookshelfWidget * bookshelfWidget() const
void setCheckedModules(BtConstModuleSet const &modules)
BtSearchModuleChooserDialog(QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::WindowFlags())
static CSwordBackend & instance() noexcept
Definition: cswordbackend.h:98
auto const groupingOrderKey(QStringLiteral("GUI/SearchDialog/ModuleChooserDialog/grouping"))
void initExplanationLabel(QLabel *const label, const QString &heading, const QString &text)
Initializes a QLabel to explain difficult things of dialogs.
Definition: tool.cpp:116