18 #include <QHBoxLayout>
19 #include <QStringList>
21 #include <QtAlgorithms>
25 #include "../../backend/config/btconfig.h"
26 #include "../../backend/drivers/btmodulelist.h"
27 #include "../../backend/drivers/cswordbookmoduleinfo.h"
28 #include "../../backend/drivers/cswordmoduleinfo.h"
29 #include "../../backend/keys/cswordkey.h"
30 #include "../../backend/keys/cswordtreekey.h"
31 #include "../../util/btassert.h"
32 #include "../../util/btconnect.h"
36 #define ID_PROPERTY_NAME "CBookKeyChooser_ID"
62 if (oldKey.isEmpty()) {
70 if (
m_key && !oldKey.isEmpty())
71 siblings = oldKey.split(
'/', Qt::SkipEmptyParts);
79 int index = (depth == 0) ? -1 : 0;
106 for (; depth <
m_modules.first()->depth(); ++depth) {
109 chooser->
reset(0, 0,
false);
112 if (oldKey.isEmpty()) {
135 for (
auto const *
const m : modules)
144 m_layout->setContentsMargins(0, 0, 0, 0);
150 for (
int i = 0; i <
m_modules.first()->depth(); ++i) {
157 int totalWidth = 200;
166 int maxWidth =
static_cast<int>(
static_cast<float>(totalWidth)
169 w->
comboBox().setMaximumWidth(maxWidth);
187 for (
int i = 0; i < count; i++) {
191 QWidget::setTabOrder(chooser_prev, chooser);
193 chooser_prev = chooser;
195 QWidget::setTabOrder(chooser,
nullptr);
208 w->comboBox().setFont(font);
219 const int currentItem)
230 items.append(QString());
237 chooserWidget->
reset(items, currentItem,
false);
247 for (
int i = 0; i < max; i++) {
250 const QString currentText = chooser->
comboBox().currentText();
251 if (currentText.isEmpty())
254 items.append(currentText);
BtConfig & btConfig()
This is a shortchand for BtConfig::getInstance().
QList< CSwordModuleInfo const * > BtConstModuleList
FontSettingsPair getFontForLanguage(Language const &language)
Get font for a language.
void refreshContent() final override
void setupCombo(QString const &key, int const depth, int const currentItem)
CSwordKey * key() final override
CBookKeyChooser(BtConstModuleList const &modules, CSwordKey *key=nullptr, QWidget *parent=nullptr)
QList< CKeyChooserWidget * > m_chooserWidgets
void keyChooserChanged(int)
A keychooser changed. Update and emit a signal if necessary.
void setModules(BtConstModuleList const &modules, bool refresh=false) final override
void setKey(CSwordKey *key) final override
QList< CSwordBookModuleInfo const * > m_modules
void updateKey(CSwordKey *key) final override
Updates the keychoosers for the given key but emit no signal.
void keyChanged(CSwordKey *newKey)
Class for generic book support.
CSwordKey implementation for Sword's TreeKey.
bool positionToFirstChild()
bool positionToNextSibling()
QString getLocalNameUnicode()
QString key() const final override
bool setKey(const QString &key) final override
void setOffset(Offset value)