diff --git a/extensions/regexfilter.ui b/extensions/regexfilter.ui
index add034b..edd6e77 100644
--- a/extensions/regexfilter.ui
+++ b/extensions/regexfilter.ui
@@ -16,6 +16,13 @@
-
+ -
+
+
+ Save
+
+
+
-
@@ -28,13 +35,6 @@
- -
-
-
- Save
-
-
-
-
diff --git a/extensions/removerepeatphrase.cpp b/extensions/removerepeatphrase.cpp
index e24a98b..a23f4d1 100644
--- a/extensions/removerepeatphrase.cpp
+++ b/extensions/removerepeatphrase.cpp
@@ -16,10 +16,10 @@ std::vector GenerateSuffixArray(const std::wstring& text)
eqClasses[suffixArray[0]] = 0;
for (int i = 1; i < text.size(); ++i)
{
- int currentSuffix = suffixArray[i];
- int lastSuffix = suffixArray[i - 1];
+ int currentSuffix = suffixArray[i], lastSuffix = suffixArray[i - 1];
if (currentSuffix + length < text.size() && prevEqClasses[currentSuffix] == prevEqClasses[lastSuffix] &&
- prevEqClasses[currentSuffix + length / 2] == prevEqClasses.at(lastSuffix + length / 2)) // not completely certain that this will stay in range
+ prevEqClasses[currentSuffix + length / 2] == prevEqClasses[lastSuffix + length / 2]
+ )
eqClasses[currentSuffix] = eqClasses[lastSuffix];
else eqClasses[currentSuffix] = i;
}
diff --git a/extensions/threadlinker.cpp b/extensions/threadlinker.cpp
index 3f69000..fb4ff00 100644
--- a/extensions/threadlinker.cpp
+++ b/extensions/threadlinker.cpp
@@ -4,11 +4,12 @@
extern const char* THREAD_LINKER;
extern const char* LINK;
+extern const char* UNLINK;
extern const char* THREAD_LINK_FROM;
extern const char* THREAD_LINK_TO;
extern const char* HEXADECIMAL;
-std::unordered_map> linkedTextHandles;
+std::unordered_map> linkedTextHandles;
std::shared_mutex m;
class Window : public QDialog, Localizer
@@ -17,9 +18,14 @@ public:
Window() : QDialog(nullptr, Qt::WindowMinMaxButtonsHint)
{
connect(&linkButton, &QPushButton::clicked, this, &Window::Link);
+ connect(&unlinkButton, &QPushButton::clicked, this, &Window::Unlink);
layout.addWidget(&linkList);
- layout.addWidget(&linkButton);
+ layout.addLayout(&buttons);
+ buttons.addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding));
+ buttons.addWidget(&linkButton);
+ buttons.addWidget(&unlinkButton);
+ buttons.addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding));
setWindowTitle(THREAD_LINKER);
QMetaObject::invokeMethod(this, &QWidget::show, Qt::QueuedConnection);
@@ -34,14 +40,13 @@ private:
if (ok1 && ok2 && ok3 && ok4)
{
std::scoped_lock lock(m);
- linkedTextHandles[from].insert(to);
- linkList.addItem(QString::number(from, 16) + "->" + QString::number(to, 16));
+ if (linkedTextHandles[from].insert(to).second) linkList.addItem(QString::number(from, 16) + "->" + QString::number(to, 16));
}
}
- void keyPressEvent(QKeyEvent* event) override
+ void Unlink()
{
- if (event->key() == Qt::Key_Delete && linkList.currentItem())
+ if (linkList.currentItem())
{
QStringList link = linkList.currentItem()->text().split("->");
linkList.takeItem(linkList.currentRow());
@@ -50,18 +55,22 @@ private:
}
}
+ void keyPressEvent(QKeyEvent* event) override
+ {
+ if (event->key() == Qt::Key_Delete) Unlink();
+ }
+
QHBoxLayout layout{ this };
+ QVBoxLayout buttons;
QListWidget linkList{ this };
- QPushButton linkButton{ LINK, this };
+ QPushButton linkButton{ LINK, this }, unlinkButton{ UNLINK, this };
} window;
bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
{
std::shared_lock lock(m);
- int64_t textHandle = sentenceInfo["text number"];
-
- for (auto linkedHandle : linkedTextHandles[textHandle])
- ((void(*)(int64_t, const wchar_t*))sentenceInfo["void (*AddText)(int64_t number, const wchar_t* text)"])(linkedHandle, sentence.c_str());
-
+ auto links = linkedTextHandles.find(sentenceInfo["text number"]);
+ if (links != linkedTextHandles.end()) for (auto link : links->second)
+ ((void(*)(int64_t, const wchar_t*))sentenceInfo["void (*AddText)(int64_t number, const wchar_t* text)"])(link, sentence.c_str());
return false;
}
diff --git a/text.cpp b/text.cpp
index 6686a3e..fc9ca82 100644
--- a/text.cpp
+++ b/text.cpp
@@ -221,6 +221,7 @@ Whitespace in original_text is ignored, but replacement_text can contain spaces,
This file must be encoded in Unicode (UTF-16 Little Endian).)";
const char* THREAD_LINKER = u8"Thread Linker";
const char* LINK = u8"Link";
+const char* UNLINK = u8"Unlink";
const char* THREAD_LINK_FROM = u8"Thread number to link from";
const char* THREAD_LINK_TO = u8"Thread number to link to";
const char* HEXADECIMAL = u8"Hexadecimal";