16 #include <QAbstractItemView>
17 #include <QApplication>
22 #include <QHBoxLayout>
23 #include <QHeaderView>
27 #include <QNonConstOverload>
29 #include <QSizePolicy>
30 #include <QStringList>
31 #include <QStringLiteral>
33 #include <QToolButton>
34 #include <QVBoxLayout>
37 #include "../../backend/btinstallbackend.h"
38 #include "../../backend/bookshelfmodel/btbookshelfmodel.h"
39 #include "../../backend/bookshelfmodel/btbookshelffiltermodel.h"
40 #include "../../backend/bookshelfmodel/btbookshelftreemodel.h"
41 #include "../../backend/config/btconfig.h"
42 #include "../../backend/drivers/btmoduleset.h"
43 #include "../../backend/drivers/cswordmoduleinfo.h"
44 #include "../../backend/language.h"
45 #include "../../backend/managers/cswordbackend.h"
46 #include "../../util/btassert.h"
47 #include "../../util/btconnect.h"
48 #include "../btbookshelfgroupingmenu.h"
49 #include "../btbookshelfview.h"
54 #pragma GCC diagnostic push
55 #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
56 #include <installmgr.h>
58 #include <swversion.h>
59 #pragma GCC diagnostic pop
65 "GUI/BookshelfWizard/InstallPage/installPathIndex");
68 QStringList
const & languages,
73 && languages.contains(mInfo->
language()->translatedName());
76 using CSV = sword::SWVersion
const;
77 CSMI
const *
const installedModule =
79 return installedModule
80 && (CSV(installedModule->config(CSMI::ModuleVersion).toLatin1())
81 < CSV(mInfo->
config(CSMI::ModuleVersion).toLatin1()));
103 QVBoxLayout *
const verticalLayout =
new QVBoxLayout(
this);
105 QHBoxLayout * horizontalLayout =
new QHBoxLayout;
111 verticalLayout->addLayout(horizontalLayout);
116 QHeaderView::ResizeToContents);
120 m_msgLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
124 QHBoxLayout *
const pathLayout =
new QHBoxLayout();
129 QComboBox::AdjustToMinimumContentsLengthWithIcon);
131 QSizePolicy::Minimum);
132 m_pathCombo->view()->setTextElideMode(Qt::ElideMiddle);
138 pathLayout->setContentsMargins(0, 8, 0, 0);
142 pathLayout->addStretch();
154 verticalLayout->addLayout(pathLayout);
189 this, &BtBookshelfWorksPage::completeChanged);
201 setTitle(QApplication::translate(
"BookshelfWizard",
"Install Works"));
202 setSubTitle(QApplication::translate(
"BookshelfWizard",
203 "Choose one or more works to "
205 setButtonText(QWizard::NextButton,tr(
"Install Works >"));
207 setTitle(QApplication::translate(
"BookshelfWizard",
"Update Works"));
208 setSubTitle(QApplication::translate(
"BookshelfWizard",
209 "Choose one or more works to "
211 setButtonText(QWizard::NextButton,tr(
"Update Works >"));
214 setTitle(QApplication::translate(
"BookshelfWizard",
"Remove Works"));
215 setSubTitle(QApplication::translate(
"BookshelfWizard",
216 "Choose one or more works to "
218 setButtonText(QWizard::NextButton,tr(
"Remove Works >"));
223 m_pathCombo->setToolTip(tr(
"The folder where the new works will be "
228 m_msgLabel->setText(tr(
"There are no works to update."));
230 m_msgLabel->setText(tr(
"No works are currently installed so they "
231 "cannot be removed."));
235 tr(
"No works can be installed with the current selection of "
236 "remote libraries and languages. Please go back and make a "
237 "different selection."));
243 tr(
"Change the grouping of items in the bookshelf."));
255 QStringList languages;
267 for (
auto const & sourceName : sources) {
268 sword::InstallSource
const source =
270 std::unique_ptr<CSwordBackend const>
backend(
272 bool backendUsed =
false;
273 for (
auto *
const module :
backend->moduleList()) {
275 QString
const & moduleName = module->name();
276 if (addedModuleNames.contains(moduleName))
278 addedModuleNames.insert(moduleName);
280 module->setProperty(
"installSourceName",
281 QString(
source.caption.c_str()));
291 bool const noWorks = (addedModuleNames.count() == 0);
302 if (languages.count() == 1) {
338 QDir
const dir(path);
339 if (!dir.exists() || !dir.isReadable())
341 return QFileInfo(dir.canonicalPath()).isWritable();
346 bool haveUsableTargets =
false;
349 m_pathCombo->addItem(QDir::toNativeSeparators(target));
350 haveUsableTargets =
true;
356 if (haveUsableTargets) {
361 m_pathCombo->setCurrentIndex(cfgValue > lastIdx ? lastIdx : cfgValue);
static bool installPathIsUsable(QString const &path)
BtConfig & btConfig()
This is a shortchand for BtConfig::getInstance().
void setNameFilterFixedString(QString const &nameFilter)
static std::shared_ptr< BtBookshelfModel > newInstance()
void saveTo(BtConfigCore &config, QString const &key) const
void groupingOrderChanged(BtBookshelfTreeModel::Grouping newGrouping)
void setDefaultChecked(CheckedBehavior b)
void setGroupingOrder(const BtBookshelfTreeModel::Grouping &groupingOrder, bool emitSignal=true)
BtModuleSet const & checkedModules() const
void setSourceModel(std::shared_ptr< QAbstractItemModel > sourceModel)
void moduleChecked(CSwordModuleInfo *module, bool checked)
BtBookshelfWizard & btWizard() const noexcept
QStringList selectedSources() const
QStringList selectedLanguages() const
QToolButton * m_groupingButton
bool isComplete() const final override
void initializePage() final override
QLineEdit * m_nameFilterEdit
std::shared_ptr< BtBookshelfModel > m_bookshelfModel
std::vector< std::unique_ptr< CSwordBackend const > > m_usedBackends
void slotGroupingActionTriggered(BtBookshelfTreeModel::Grouping const &grouping)
BtModuleSet const & checkedModules() const
int nextId() const final override
QString installPath() const
QLabel * m_nameFilterLabel
void slotGroupingOrderChanged(BtBookshelfTreeModel::Grouping const &g)
WizardTaskType const m_taskType
BtBookshelfTreeModel::Grouping m_groupingOrder
void slotPathChanged(int const index)
BtBookshelfGroupingMenu * m_groupingMenu
BtBookshelfWorksPage(WizardTaskType iType, QWidget *parent=nullptr)
QMenu * m_itemContextMenu
BtBookshelfView * m_bookshelfView
BtInstallPageModel * m_installPageModel
T value(QString const &key, T const &defaultValue=T()) const
Returns the settings value for the given global key.
void setValue(QString const &key, T const &value)
Sets a value for a key.
CSwordModuleInfo * findModuleByName(const QString &name) const
Searches for a module with the given name.
static CSwordBackend & instance() noexcept
void sigSwordSetupChanged()
QString config(const CSwordModuleInfo::ConfigEntry entry) const
std::shared_ptr< Language const > language() const
QString const & name() const
sword::InstallSource source(const QString &name)
QStringList sourceNameList()
std::unique_ptr< CSwordBackend > backend(sword::InstallSource const &is)
QString const groupingOrderKey("GUI/BookshelfWizard/InstallPage/grouping")
QString const installPathKey("GUI/BookshelfWizard/InstallPage/installPathIndex")
bool filter(WizardTaskType const taskType, QStringList const &languages, CSwordModuleInfo const *const mInfo)