16 #include <QApplication>
19 #include <QStandardItem>
20 #include <QStandardItemModel>
21 #include <QStringLiteral>
23 #include <QVBoxLayout>
25 #include "../../backend/btinstallbackend.h"
26 #include "../../backend/config/btconfig.h"
27 #include "../../backend/drivers/cswordmoduleinfo.h"
28 #include "../../backend/language.h"
29 #include "../../backend/managers/cswordbackend.h"
30 #include "../../util/btconnect.h"
35 #pragma GCC diagnostic push
36 #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
37 #include <installmgr.h>
38 #pragma GCC diagnostic pop
54 m_model =
new QStandardItemModel(
this);
61 setTitle(QApplication::translate(
"BookshelfWizard",
"Choose Languages"));
62 setSubTitle(QApplication::translate(
"BookshelfWizard",
63 "Choose one or more languages to "
64 "install works from."));
73 QStringList languages;
76 if (languages.isEmpty())
77 languages = QStringList{tr(
"English")};
83 bool scrolledToFirstSelected =
false;
84 for (
int row = 0; row <
m_model->rowCount(); ++row) {
85 QStandardItem *
const item =
m_model->item(row, 0);
86 if (languages.contains(item->text())) {
87 item->setCheckState(Qt::Checked);
89 if (!scrolledToFirstSelected) {
91 scrolledToFirstSelected =
true;
102 std::set<QString> languages;
103 for (
auto const & sourceName :
btWizard().selectedSources()) {
104 std::unique_ptr<CSwordBackend const>
const backend =
106 for (
auto const * module :
backend->moduleList())
107 languages.insert(module->language()->translatedName());
112 for (
auto const & language : languages) {
113 auto *
const item =
new QStandardItem(language);
114 item->setCheckable(
true);
117 if (languages.size() == 1u)
118 m_model->item(0, 0)->setCheckState(Qt::Checked);
122 {
return m_model->rowCount() == 1; }
130 QStringList languages;
131 for (
int row = 0; row <
m_model->rowCount(); ++row) {
132 QStandardItem *
const item =
m_model->item(row,0);
133 if (item->checkState() == Qt::Checked)
134 languages << item->text();
BtConfig & btConfig()
This is a shortchand for BtConfig::getInstance().
void initializePage() final override
void initializeLanguages()
int nextId() const final override
bool isComplete() const final override
QListView * m_languagesListView
QStringList selectedLanguages() const
BtBookshelfLanguagesPage(QWidget *parent=nullptr)
QVBoxLayout * m_verticalLayout
QStandardItemModel * m_model
bool skipPage() const noexcept
BtBookshelfWizard & btWizard() const noexcept
T value(QString const &key, T const &defaultValue=T()) const
Returns the settings value for the given global key.
sword::InstallSource source(const QString &name)
std::unique_ptr< CSwordBackend > backend(sword::InstallSource const &is)
QString const LanguagesKey