Skip to content

Commit

Permalink
Generate the second lookup table on the fly
Browse files Browse the repository at this point in the history
  • Loading branch information
xorz57 committed Mar 4, 2024
1 parent d44c06d commit c72be42
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 57 deletions.
4 changes: 4 additions & 0 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
#include <QTextStream>

MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
for (auto it = lookUpTable1.begin(); it != lookUpTable1.end(); ++it) {
lookUpTable2.insert(it.value(), it.key());
}

ui->setupUi(this);

connect(ui->inputPlainTextEdit, SIGNAL(textChanged()), this, SLOT(translate()));
Expand Down
58 changes: 1 addition & 57 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,63 +82,7 @@ private slots:
{'@', ".--.-."},
};

const QMap<QString, QChar> lookUpTable2{
{".-", 'A'},
{"-...", 'B'},
{"-.-.", 'C'},
{"-..", 'D'},
{".", 'E'},
{"..-.", 'F'},
{"--.", 'G'},
{"....", 'H'},
{"..", 'I'},
{".---", 'J'},
{"-.-", 'K'},
{".-..", 'L'},
{"--", 'M'},
{"-.", 'N'},
{"---", 'O'},
{".--.", 'P'},
{"--.-", 'Q'},
{".-.", 'R'},
{"...", 'S'},
{"-", 'T'},
{"..-", 'U'},
{"...-", 'V'},
{".--", 'W'},
{"-..-", 'X'},
{"-.--", 'Y'},
{"--..", 'Z'},
{"-----", '0'},
{".----", '1'},
{"..---", '2'},
{"...--", '3'},
{"....-", '4'},
{".....", '5'},
{"-....", '6'},
{"--...", '7'},
{"---..", '8'},
{"----.", '9'},
{"/", ' '},
{"--..--", ','},
{".-.-.-", '.'},
{"..--..", '?'},
{".----.", '\''},
{"-.-.--", '!'},
{"-..-.", '/'},
{"-.--.", '('},
{"-.--.-", ')'},
{".-...", '&'},
{"---...", ':'},
{"-.-.-.", ';'},
{"-...-", '='},
{".-.-.", '+'},
{"-....-", '-'},
{"..--.-", '_'},
{".-..-.", '"'},
{"...-..-", '$'},
{".--.-.", '@'},
};
QMap<QString, QChar> lookUpTable2;

std::shared_ptr<Ui::MainWindow> ui = std::make_shared<Ui::MainWindow>();
};

0 comments on commit c72be42

Please sign in to comment.