MCPcopy Create free account
hub / github.com/Artikash/Textractor / Window

Class Window

extensions/threadlinker.cpp:18–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16concurrency::reader_writer_lock m;
17
18class Window : public QDialog, Localizer
19{
20public:
21 Window() : QDialog(nullptr, Qt::WindowMinMaxButtonsHint)
22 {
23 ui.setupUi(this);
24 ui.linkButton->setText(LINK);
25 ui.unlinkButton->setText(UNLINK);
26 connect(ui.linkButton, &QPushButton::clicked, this, &Window::Link);
27 connect(ui.unlinkButton, &QPushButton::clicked, this, &Window::Unlink);
28
29 setWindowTitle(THREAD_LINKER);
30 QMetaObject::invokeMethod(this, &QWidget::show, Qt::QueuedConnection);
31 }
32
33private:
34 void Link()
35 {
36 bool ok1, ok2, ok3, ok4;
37 QString fromInput = QInputDialog::getText(this, THREAD_LINK_FROM, HEXADECIMAL, QLineEdit::Normal, "All", &ok1, Qt::WindowCloseButtonHint);
38 int from = fromInput.toInt(&ok2, 16);
39 if (ok1 && (fromInput == "All" || ok2))
40 {
41 int to = QInputDialog::getText(this, THREAD_LINK_TO, HEXADECIMAL, QLineEdit::Normal, "", &ok3, Qt::WindowCloseButtonHint).toInt(&ok4, 16);
42 if (ok3 && ok4)
43 {
44 std::scoped_lock lock(m);
45 if ((ok2 ? links[from] : universalLinks).insert(to).second)
46 ui.linkList->addItem((ok2 ? QString::number(from, 16) : "All") + "->" + QString::number(to, 16));
47 }
48 }
49 }
50
51 void Unlink()
52 {
53 if (ui.linkList->currentItem())
54 {
55 QStringList link = ui.linkList->currentItem()->text().split("->");
56 ui.linkList->takeItem(ui.linkList->currentRow());
57 std::scoped_lock lock(m);
58 (link[0] == "All" ? universalLinks : links[link[0].toInt(nullptr, 16)]).erase(link[1].toInt(nullptr, 16));
59 }
60 }
61
62 void keyPressEvent(QKeyEvent* event) override
63 {
64 if (event->key() == Qt::Key_Delete) Unlink();
65 }
66
67 Ui::LinkWindow ui;
68} window;
69
70bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
71{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected