16 #include <QApplication>
18 #include <QMouseEvent>
19 #include "../backend/keys/cswordkey.h"
20 #include "../backend/managers/referencemanager.h"
21 #include "../backend/managers/cswordbackend.h"
27 { setTextInteractionFlags(Qt::TextSelectableByMouse); }
30 QTextBrowser::keyPressEvent(event);
31 if (event->isAccepted())
36 if (event->buttons() == Qt::LeftButton) {
42 QTextBrowser::mousePressEvent(event);
47 QTextBrowser::mouseReleaseEvent(event);
52 auto const dragManhattanLength =
54 if (dragManhattanLength >= qApp->startDragDistance()) {
57 if (
auto const decodedLink =
61 std::make_unique<BTMimeData>(
63 decodedLink->module->name(),
68 if (
auto const *
const module =
70 decodedLink->module->name()))
72 std::unique_ptr<CSwordKey> key(module->createKey());
73 key->setKey(decodedLink->key);
74 mimedata->setText(key->strippedText());
77 auto *
const drag =
new QDrag(
this);
78 drag->setMimeData(mimedata.release());
79 drag->exec(Qt::CopyAction, Qt::CopyAction);
84 QTextBrowser::mouseMoveEvent(event);
QList< BookmarkItem > ItemList
BtTextBrowser(QWidget *parent=nullptr)
void mouseReleaseEvent(QMouseEvent *event) override
void mouseMoveEvent(QMouseEvent *event) override
void mousePressEvent(QMouseEvent *event) override
void keyPressEvent(QKeyEvent *event) override
static CSwordBackend & instance() noexcept
std::optional< DecodedHyperlink > decodeHyperlink(QString const &hyperlink)