16 #include <QDialogButtonBox>
19 #include <QHBoxLayout>
23 #include <QListWidget>
24 #include <QListWidgetItem>
26 #include <QPushButton>
29 #include <QVBoxLayout>
30 #include "../../backend/config/btconfig.h"
31 #include "../../backend/drivers/cswordmoduleinfo.h"
32 #include "../../backend/managers/cswordbackend.h"
33 #include "../../util/btassert.h"
34 #include "../../util/btconnect.h"
35 #include "../messagedialog.h"
38 #pragma GCC diagnostic push
39 #pragma GCC diagnostic ignored "-Wextra-semi"
40 #pragma GCC diagnostic ignored "-Wsuggest-override"
41 #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
43 #pragma clang diagnostic push
44 #pragma clang diagnostic ignored "-Wsuggest-destructor-override"
51 #pragma clang diagnostic pop
53 #pragma GCC diagnostic pop
59 m_scopeModules(scopeModules)
68 for (
auto it = map.begin(); it != map.end(); ++it)
94 hSeparatorLine->setFrameShape(QFrame::HLine);
95 hSeparatorLine->setFrameShadow(QFrame::Sunken);
99 m_buttonBox->setStandardButtons(QDialogButtonBox::Ok
100 | QDialogButtonBox::Cancel
101 | QDialogButtonBox::RestoreDefaults);
104 QHBoxLayout *rangeButtonsLayout =
new QHBoxLayout();
108 QVBoxLayout* rangeListLayout =
new QVBoxLayout;
111 rangeListLayout->addLayout(rangeButtonsLayout);
113 QHBoxLayout* nameEditLayout =
new QHBoxLayout();
117 QVBoxLayout* rangeEditLayout =
new QVBoxLayout();
118 rangeEditLayout->addLayout(nameEditLayout);
124 QHBoxLayout *topLayout =
new QHBoxLayout;
125 topLayout->addLayout(rangeListLayout);
126 topLayout->addLayout(rangeEditLayout);
128 QVBoxLayout *vboxLayout =
new QVBoxLayout(
this);
129 vboxLayout->addLayout(topLayout);
130 vboxLayout->addWidget(hSeparatorLine);
148 static QRegularExpression
const re(
149 QStringLiteral(R
"PCRE(\s*-\s*)PCRE"));
153 QStringLiteral(
"-"));
157 auto *
const module =
158 backend.findModuleByName(moduleName);
163 module->swordModule().getKey())
165 range.toUtf8().constData(),
168 if (verses.getCount() > 0) {
169 for (
int i = 0; i < verses.getCount(); i++) {
170 auto const *
const elementText =
171 verses.getElement(i)->getRangeText();
173 QString::fromUtf8(elementText),
185 this, &CRangeChooserDialog::reject);
204 QPushButton * defaultsButton =
m_buttonBox->button(QDialogButtonBox::RestoreDefaults);
205 BT_CONNECT(defaultsButton, &QPushButton::clicked,
210 btConfig().getSearchScopesForCurrentLocale(
212 for (
auto it = map.begin(); it != map.end(); ++it)
220 setWindowTitle(tr(
"Setup Search Scopes"));
223 m_rangeList->setToolTip(tr(
"Select a scope from the list to edit the search"
228 "appropriate name, then edit the search "
235 m_nameEdit->setToolTip(tr(
"Change the name of the selected search scope"));
238 m_rangeEdit->setToolTip(tr(
"Change the search ranges of the selected search"
239 "scope item. Have a look at the predefined "
240 "search scopes to see how search ranges are "
244 m_resultList->setToolTip(tr(
"The search ranges which will be used for the "
245 "search, parsed to the canonical form"));
276 if (currentItem !=
nullptr) {
295 const bool e = !newText.isEmpty() ||
m_rangeList->count() <= 0;
296 m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(e);
BtConfig & btConfig()
This is a shortchand for BtConfig::getInstance().
QMap< QString, QString > StringMap
void setSearchScopesWithCurrentLocale(const QStringList &scopeModules, StringMap searchScopes)
void deleteSearchScopesWithCurrentLocale()
StringMap getSearchScopesForCurrentLocale(const QStringList &scopeModules)
static CSwordBackend & instance() noexcept
QString const & range() const
void setCaption(QString const &caption)
void setRange(QString const &range)
QLabel * m_rangeEditLabel
QListWidget * m_rangeList
CRangeChooserDialog(const QStringList &rangeScopeModule, QWidget *parentDialog=nullptr)
QListWidget * m_resultList
QStringList m_scopeModules
QDialogButtonBox * m_buttonBox
void saveCurrentToRange(RangeItem *i)
QPushButton * m_newRangeButton
QLabel * m_resultListLabel
void nameEditTextChanged(const QString &newText)
QLabel * m_rangeListLabel
QPushButton * m_deleteRangeButton
std::unique_ptr< CSwordBackend > backend(sword::InstallSource const &is)
void prepareDialogBox(QDialogButtonBox *box)