18 #include <QPushButton>
19 #include <QSizePolicy>
21 #include <QRegularExpression>
22 #include <QVBoxLayout>
25 #include "../../backend/config/btconfig.h"
26 #include "../../backend/cswordmodulesearch.h"
27 #include "../../backend/drivers/cswordmoduleinfo.h"
28 #include "../../util/btassert.h"
29 #include "../../util/btconnect.h"
30 #include "../../util/cresmgr.h"
31 #include "../btmoduleindexdialog.h"
32 #include "../messagedialog.h"
47 setWindowIcon(CResMgr::searchdialog::icon());
48 setWindowTitle(tr(
"Search"));
49 setAttribute(Qt::WA_DeleteOnClose);
52 QVBoxLayout* verticalLayout =
new QVBoxLayout(
this);
53 setLayout(verticalLayout);
62 QLabel* hint =
new QLabel(tr(
"Drag any verse reference onto an open Bible window"),
this);
63 verticalLayout->addWidget(hint);
65 QHBoxLayout* horizontalLayout =
new QHBoxLayout();
67 QSpacerItem* spacerItem =
new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum);
68 horizontalLayout->addItem(spacerItem);
71 m_analyseButton->setToolTip(tr(
"Show a graphical analysis of the search result"));
83 verticalLayout->addLayout(horizontalLayout);
93 this, &CSearchDialog::close);
110 QString TestString(originalSearchText);
111 static QRegularExpression
const ReservedWords(
112 QStringLiteral(
"heading:|footnote:|morph:|strong:"));
113 if (TestString.replace(ReservedWords, QString()).simplified().isEmpty()) {
128 for (
auto const *
const m : searchModules)
132 if (unindexedModules.size() > 0) {
134 QStringList moduleNameList;
135 for (
auto const *
const m : unindexedModules)
136 moduleNameList.append(m->name());
142 tr(
"Missing indices"),
143 QStringLiteral(
"%1<br><center>%2</center><br>%3")
144 .arg(tr(
"The following modules need to be indexed before "
145 "they can be searched in:"),
146 moduleNameList.join(QStringLiteral(
", ")),
147 tr(
"Indexing could take a long time. Click \"Yes\" to "
148 "index the modules and start the search, or \"No\" "
149 "to cancel the search.")),
150 QMessageBox::Yes | QMessageBox::No,
154 if ((result & (QMessageBox::Yes | QMessageBox::Default)) == 0x0) {
167 setCursor(Qt::WaitCursor);
180 }
catch (std::exception
const & e) {
183 msg = tr(
"<UNKNOWN EXCEPTION>");
187 tr(
"Search aborted"),
188 tr(
"An internal error occurred while executing "
189 "your search:<br/><br/>%1").arg(msg));
192 setCursor(Qt::ArrowCursor);
197 if (!searchResult.empty()) {
199 std::move(searchResult));
209 setCursor(Qt::ArrowCursor);
218 auto const haveModules = !modules.isEmpty();
229 if (haveModules && !searchText.isEmpty())
BtConfig & btConfig()
This is a shortchand for BtConfig::getInstance().
QList< CSwordModuleInfo const * > BtConstModuleList
void setValue(QString const &key, T const &value)
Sets a value for a key.
static bool indexAllModules(QList< CSwordModuleInfo * > const &modules)
void setSearchText(const QString &text)
sword::ListKey searchScope()
BtConstModuleList const & modules() const
QString searchText() const
void setModules(const BtConstModuleList &modules)
CSwordModuleSearch::SearchType searchType()
void addToHistory(const QString &text)
void setSearchResult(QString searchedText, CSwordModuleSearch::Results results)
BtSearchOptionsArea * m_searchOptionsArea
QPushButton * m_closeButton
CSearchDialog(QWidget *parent)
BtSearchResultArea * m_searchResultArea
QPushButton * m_analyseButton
QPushButton * m_manageIndexes
~CSearchDialog() override
void reset(BtConstModuleList modules, QString const &searchText)
QString prepareSearchText(QString const &orig, SearchType const searchType)
Results search(QString const &searchText, BtConstModuleList const &modules, sword::ListKey scope)
std::vector< ModuleSearchResult > Results
const QString GeometryKey
QMessageBox::StandardButton showQuestion(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton)
QMessageBox::StandardButton showWarning(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton)