15 #include <QContextMenuEvent>
18 #include <QTreeWidget>
19 #include <QTreeWidgetItem>
21 #include "../../backend/config/btconfig.h"
22 #include "../../backend/drivers/cswordmoduleinfo.h"
23 #include "../../backend/keys/cswordkey.h"
24 #include "../../util/btconnect.h"
25 #include "../../util/cresmgr.h"
26 #include "../BtMimeData.h"
27 #include "../cexportmanager.h"
41 setToolTip(tr(
"Search result of the selected work"));
42 setHeaderLabel(tr(
"Results"));
44 setRootIsDecorated(
false );
45 setSelectionMode(QAbstractItemView::ExtendedSelection);
51 m_actions.copyMenu->setIcon(CResMgr::searchdialog::result::foundItems::copyMenu::icon());
53 struct SelectedKeysList :
QList<CSwordKey *> {
55 auto const *
const m =
self.m_module;
56 auto const selectedItems(
self.selectedItems());
57 reserve(selectedItems.size());
59 for (
auto const *
const i :
self.selectedItems()) {
61 last()->setKey(i->text(0));
68 ~SelectedKeysList() noexcept { qDeleteAll(*
this); }
74 SelectedKeysList keys(*this);
75 CExportManager(true, tr(
"Copying search result"))
76 .copyKeyList(keys, CExportManager::Text, false);
80 m_actions.copy.resultWithText =
new QAction(tr(
"Reference with text"),
this);
83 SelectedKeysList keys(*this);
84 CExportManager(true, tr(
"Copying search result"))
85 .copyKeyList(keys, CExportManager::Text, true);
92 m_actions.saveMenu->setIcon(CResMgr::searchdialog::result::foundItems::saveMenu::icon());
97 SelectedKeysList keys(*this);
98 CExportManager(true, tr(
"Saving search result"))
99 .saveKeyList( keys, CExportManager::Text, false);
103 m_actions.save.resultWithText =
new QAction(tr(
"Reference with text"),
this);
107 SelectedKeysList keys(*this);
108 CExportManager(true, tr(
"Saving search result"))
109 .saveKeyList(keys, CExportManager::Text, true);
114 m_actions.printMenu->setIcon(CResMgr::searchdialog::result::foundItems::printMenu::icon());
120 for (auto const * const k : selectedItems())
121 list.append(k->text(0));
122 CExportManager(true, tr(
"Printing search result"))
125 btConfig().getDisplayOptions(),
126 btConfig().getFilterOptions());
136 BT_CONNECT(
this, &CSearchResultView::currentItemChanged,
137 [
this](QTreeWidgetItem *
const current, QTreeWidgetItem *) {
159 setUpdatesEnabled(
false);
161 QTreeWidgetItem* oldItem =
nullptr;
162 QTreeWidgetItem* item =
nullptr;
163 for (
auto const & keyPtr :
result) {
164 item =
new QTreeWidgetItem(
this, oldItem);
165 item->setText(0, QString::fromUtf8(keyPtr->getText()));
169 setUpdatesEnabled(
true);
171 this->setCurrentItem(this->topLevelItem(0), 0);
180 if (vList.empty())
return;
182 setUpdatesEnabled(
false);
184 QTreeWidgetItem* oldItem =
nullptr;
185 QTreeWidgetItem* item =
nullptr;
187 for (
auto const & s : vList) {
188 item =
new QTreeWidgetItem(
this, oldItem);
189 item->setText(0, (s));
193 setUpdatesEnabled(
true);
203 m_popup->exec(event->globalPos());
225 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
233 for (
auto const *
const i : items)
239 {
return QStringList(QStringLiteral(
"BibleTime/Bookmark")); }
QList< BookmarkItem > ItemList
QString const & name() const
void contextMenuEvent(QContextMenuEvent *event) override
void setupStrongsTree(CSwordModuleInfo *, const QStringList &)
CSearchResultView(QWidget *parent)
void keySelected(const QString &)
QStringList mimeTypes() const override
void setupTree(CSwordModuleInfo const *m, CSwordModuleSearch::ModuleResultList const &results)
const CSwordModuleInfo * m_module
QMimeData * mimeData(QList< QTreeWidgetItem * > const &items) const override
struct Search::CSearchResultView::@13 m_actions
std::vector< std::shared_ptr< sword::SWKey const > > ModuleResultList
result append(std::move(e))