From 04db5b75ba593c517a3ec313e37b175ddb36b208 Mon Sep 17 00:00:00 2001
From: Hannes Matuschek
Date: Fri, 11 Dec 2020 14:19:49 +0100
Subject: [PATCH] Fixed typos.
---
snapcraft.yaml | 10 ++--
src/tutor.cc | 146 ++++++++++++++++++++++++-------------------------
src/tutor.hh | 28 +++++-----
3 files changed, 92 insertions(+), 92 deletions(-)
diff --git a/snapcraft.yaml b/snapcraft.yaml
index d3d417b..73e65b3 100644
--- a/snapcraft.yaml
+++ b/snapcraft.yaml
@@ -1,8 +1,8 @@
name: kochmorse
-#version: git
-#grade: devel
-version: 3.5.0
-grade: stable
+version: git
+grade: devel
+#version: 3.5.0
+#grade: stable
summary: A simple Morse tutor.
description: |
Kochmorse is a simple to use morse-code tutor using the so called Koch mehtod. It can not only
@@ -41,7 +41,7 @@ parts:
- qt5dxcb-plugin
source: https://github.com/hmatuschek/kochmorse.git
source-type: git
- source-tag: "v$SNAPCRAFT_PROJECT_VERSION"
+ #source-tag: "v$SNAPCRAFT_PROJECT_VERSION"
configflags:
- "-DCMAKE_INSTALL_PREFIX=/usr"
- "-DCMAKE_BUILD_TYPE=Release"
diff --git a/src/tutor.cc b/src/tutor.cc
index 8f75f05..bf9dc40 100644
--- a/src/tutor.cc
+++ b/src/tutor.cc
@@ -81,7 +81,7 @@ KochTutor::KochTutor(MorseEncoder *encoder, int lesson, bool prefLastChars, bool
_repeatLastChar(repeatLastChar), _minGroupSize(std::min(minGroupSize, maxGroupSize)),
_maxGroupSize(std::max(minGroupSize, maxGroupSize)), _lines(lines), _linecount(0),
_showSummary(showSummary), _verify(verify), _hideOutput(hideOutput),
- _threshold(successThreshold), _text(), _chars_send(0), _words_send(0), _lines_send(0)
+ _threshold(successThreshold), _text(), _chars_sent(0), _words_sent(0), _lines_sent(0)
{
// Init random number generator
srand(time(nullptr));
@@ -153,15 +153,15 @@ QString
KochTutor::summary() const {
if (! _showSummary)
return "";
- int threshold = int(_chars_send*(100-_threshold))/100;
+ int threshold = int(_chars_sent*(100-_threshold))/100;
if (_lesson < (_lessons.size()-1))
return tr("\n\nSent %1 chars in %2 words and %3 lines. "
"If you have less than %4 mistakes, you can proceed to lesson %5.")
- .arg(_chars_send).arg(_words_send).arg(_lines_send).arg(threshold).arg(_lesson+1);
+ .arg(_chars_sent).arg(_words_sent).arg(_lines_sent).arg(threshold).arg(_lesson+1);
else
return tr("\n\nSent %1 chars in %2 words and %3 lines. "
"If you have less than %4 mistakes, you completed the course!")
- .arg(_chars_send).arg(_words_send).arg(_lines_send).arg(threshold);
+ .arg(_chars_sent).arg(_words_sent).arg(_lines_sent).arg(threshold);
}
void
@@ -199,10 +199,10 @@ KochTutor::reset()
}
_text.push_back('\n');
}
- _sendText.clear();
- _chars_send = 0;
- _words_send = 0;
- _lines_send = 0;
+ _sentText.clear();
+ _chars_sent = 0;
+ _words_sent = 0;
+ _lines_sent = 0;
// sample a line of text.
_nextline();
}
@@ -225,17 +225,17 @@ KochTutor::isOutputHidden() const {
int
KochTutor::verify(const QString &text, QString &summary) {
QVector mistakes;
- int err = textCompare(_sendText.toLower(), text.toLower(), mistakes);
+ int err = textCompare(_sentText.toLower(), text.toLower(), mistakes);
// Format Send text
QString tx, rx;
QTextStream buffer(&tx);
- for (int i=0; i<_sendText.size(); i++) {
- if ('\n' == _sendText.at(i))
+ for (int i=0; i<_sentText.size(); i++) {
+ if ('\n' == _sentText.at(i))
buffer << "
";
else if (mistakes.contains(i))
- buffer << "" << _sendText.at(i) << "";
+ buffer << "" << _sentText.at(i) << "";
else
- buffer << _sendText.at(i);
+ buffer << _sentText.at(i);
}
buffer.setString(&rx);
for (int i=0; iText send:
%1
"
+ int correct = 100*double(_chars_sent-err)/_chars_sent;
+ summary = tr("Text sent:
%1
"
"Text entered:
%2
"
- "Summary:
Characters/Words/Lines send: %3/%4/%5
"
+ "
Summary:
Characters/Words/Lines sent: %3/%4/%5
"
"Mistakes: %6
"
- "Accuracy: %7%
").arg(tx).arg(rx).arg(_chars_send)
- .arg(_words_send).arg(_lines_send).arg(err).arg(correct);
+ "Accuracy: %7%
").arg(tx).arg(rx).arg(_chars_sent)
+ .arg(_words_sent).arg(_lines_sent).arg(err).arg(correct);
if (correct >= _threshold) {
summary.append(tr("You achieved an accuracy of %1% >= %2%. "
"You may advance to the next lesson!
").arg(correct).arg(_threshold));
@@ -294,21 +294,21 @@ KochTutor::_nextline() {
idx = _lesson*double(rand())/RAND_MAX;
}
_text.push_back(_lessons[idx]);
- _sendText.push_back(_lessons[idx]);
- _chars_send++;
+ _sentText.push_back(_lessons[idx]);
+ _chars_sent++;
}
i += n;
_text.push_back(' ');
- _sendText.push_back(' ');
- _words_send++;
+ _sentText.push_back(' ');
+ _words_sent++;
}
_text.push_back('=');
_text.push_back(' ');
_text.push_back(' ');
_text.push_back('\n');
- _sendText.push_back('\n');
+ _sentText.push_back('\n');
_linecount++;
- _lines_send++;
+ _lines_sent++;
}
const QVector &
@@ -323,7 +323,7 @@ KochTutor::lessons() {
RandomTutor::RandomTutor(MorseEncoder *encoder, size_t minGroupSize, size_t maxGroupSize, int lines, bool showSummary, bool verify, bool hideOutput, QObject *parent)
: Tutor(encoder, parent), _minGroupSize(minGroupSize), _maxGroupSize(maxGroupSize),
_lines(lines), _linecount(0), _showSummary(showSummary), _verify(verify),
- _hideOutput(hideOutput), _text(), _chars(), _chars_send(0), _words_send(0), _lines_send(0)
+ _hideOutput(hideOutput), _text(), _chars(), _chars_sent(0), _words_sent(0), _lines_sent(0)
{
// Init random number generator
srand(time(nullptr));
@@ -349,7 +349,7 @@ RandomTutor::RandomTutor(MorseEncoder *encoder, const QSet &chars, size_t
bool hideOutput, QObject *parent)
: Tutor(encoder, parent), _minGroupSize(minGroupSize), _maxGroupSize(maxGroupSize), _lines(lines),
_showSummary(showSummary), _verify(verify), _hideOutput(hideOutput), _text(), _chars(),
- _chars_send(0), _words_send(0), _lines_send(0)
+ _chars_sent(0), _words_sent(0), _lines_sent(0)
{
// Init random number generator
srand(time(nullptr));
@@ -369,9 +369,9 @@ QString
RandomTutor::summary() const {
if (! _showSummary)
return "";
- int chars_send = _chars_send;
- int words_send = _words_send;
- int lines_send = _lines_send;
+ int chars_send = _chars_sent;
+ int words_send = _words_sent;
+ int lines_send = _lines_sent;
return tr("\n\nSent %1 chars in %2 words and %3 lines.")
.arg(chars_send).arg(words_send).arg(lines_send);
}
@@ -414,13 +414,13 @@ RandomTutor::reset()
{
// Empty current session
_text.clear();
- _sendText.clear();
+ _sentText.clear();
// If empty char set -> done.
if (0 == _chars.size()) { return; }
// Reset linecount
_linecount = 0;
// reset char, word & line count
- _chars_send = _words_send = _lines_send = 0;
+ _chars_sent = _words_sent = _lines_sent = 0;
// Insert "vvv\n"
_text.push_back('v'); _text.push_back('v'); _text.push_back('v'); _text.push_back('\n');
// sample a line
@@ -453,17 +453,17 @@ RandomTutor::isOutputHidden() const {
int
RandomTutor::verify(const QString &text, QString &summary) {
QVector mistakes;
- int err = textCompare(_sendText.toLower(), text.toLower(), mistakes);
- // Format Send text
+ int err = textCompare(_sentText.toLower(), text.toLower(), mistakes);
+ // Format Sent text
QString tx, rx;
QTextStream buffer(&tx);
- for (int i=0; i<_sendText.size(); i++) {
- if ('\n' == _sendText.at(i))
+ for (int i=0; i<_sentText.size(); i++) {
+ if ('\n' == _sentText.at(i))
buffer << "
";
else if (mistakes.contains(i))
- buffer << "" << _sendText.at(i) << "";
+ buffer << "" << _sentText.at(i) << "";
else
- buffer << _sendText.at(i);
+ buffer << _sentText.at(i);
}
buffer.setString(&rx);
for (int i=0; iText send:
%1
"
+ int correct = 100*double(_chars_sent-err)/_chars_sent;
+ summary = tr("Text sent:
%1
"
"Text entered:
%2
"
- "Summary:
Characters/Words/Lines send: %3/%4/%5
"
+ "
Summary:
Characters/Words/Lines sent: %3/%4/%5
"
"Mistakes: %6
"
- "Accuracy: %7%
").arg(tx).arg(rx).arg(_chars_send)
- .arg(_words_send).arg(_lines_send).arg(err).arg(correct);
+ "Accuracy: %7%").arg(tx).arg(rx).arg(_chars_sent)
+ .arg(_words_sent).arg(_lines_sent).arg(err).arg(correct);
emit sessionVerified("rand", _chars.size(), correct);
return err;
@@ -493,20 +493,20 @@ RandomTutor::_nextline() {
// Sample char from chars
size_t idx = _chars.size()*double(rand())/RAND_MAX;
_text.push_back(_chars[idx]);
- _sendText.push_back(_chars[idx]);
- _chars_send++;
+ _sentText.push_back(_chars[idx]);
+ _chars_sent++;
}
i += n;
_text.push_back(' ');
- _sendText.push_back(' ');
- _words_send++;
+ _sentText.push_back(' ');
+ _words_sent++;
}
_text.push_back('=');
_text.push_back(' ');
_text.push_back('\n');
- _sendText.push_back('\n');
+ _sentText.push_back('\n');
_linecount++;
- _lines_send++;
+ _lines_sent++;
}
QSet
@@ -564,7 +564,7 @@ WordsworthTutor::WordsworthTutor(
: Tutor(encoder, parent), _lesson(lesson), _prefLastWords(prefLastWords),
_repeatLastWord(repeatLastWord), _lines(lines), _linecount(0),
_showSummary(showSummary), _verify(verify), _hideOutput(hideOutput),
- _threshold(successThreshold), _text(), _chars_send(0), _words_send(0), _lines_send(0)
+ _threshold(successThreshold), _text(), _chars_sent(0), _words_sent(0), _lines_sent(0)
{
// Init random number generator
srand(time(nullptr));
@@ -636,15 +636,15 @@ QString
WordsworthTutor::summary() const {
if (! _showSummary)
return "";
- int threshold = int(_chars_send*(100-_threshold))/100;
+ int threshold = int(_chars_sent*(100-_threshold))/100;
if (_lesson < (_lessons.size()-1))
return tr("\n\nSent %1 chars in %2 words and %3 lines. "
"If you have less than %4 mistakes, you can proceed to lesson %5.")
- .arg(_chars_send).arg(_words_send).arg(_lines_send).arg(threshold).arg(_lesson+1);
+ .arg(_chars_sent).arg(_words_sent).arg(_lines_sent).arg(threshold).arg(_lesson+1);
else
return tr("\n\nSent %1 chars in %2 words and %3 lines. "
"If you have less than %4 mistakes, you completed the course!")
- .arg(_chars_send).arg(_words_send).arg(_lines_send).arg(threshold);
+ .arg(_chars_sent).arg(_words_sent).arg(_lines_sent).arg(threshold);
}
void
@@ -684,10 +684,10 @@ WordsworthTutor::reset()
}
_text.push_back('\n');
}
- _sendText.clear();
- _chars_send = 0;
- _words_send = 0;
- _lines_send = 0;
+ _sentText.clear();
+ _chars_sent = 0;
+ _words_sent = 0;
+ _lines_sent = 0;
// sample a line of text.
_nextline();
}
@@ -710,17 +710,17 @@ WordsworthTutor::isOutputHidden() const {
int
WordsworthTutor::verify(const QString &text, QString &summary) {
QVector mistakes;
- int err = textCompare(_sendText.toLower(), text.toLower(), mistakes);
- // Format Send text
+ int err = textCompare(_sentText.toLower(), text.toLower(), mistakes);
+ // Format text
QString tx, rx;
QTextStream buffer(&tx);
- for (int i=0; i<_sendText.size(); i++) {
- if ('\n' == _sendText.at(i))
+ for (int i=0; i<_sentText.size(); i++) {
+ if ('\n' == _sentText.at(i))
buffer << "
";
else if (mistakes.contains(i))
- buffer << "" << _sendText.at(i) << "";
+ buffer << "" << _sentText.at(i) << "";
else
- buffer << _sendText.at(i);
+ buffer << _sentText.at(i);
}
buffer.setString(&rx);
for (int i=0; iText send:
%1
"
+ int correct = 100*double(_chars_sent-err)/_chars_sent;
+ summary = tr("Text sent:
%1
"
"Text entered:
%2
"
- "Summary:
Characters/Words/Lines send: %3/%4/%5
"
+ "
Summary:
Characters/Words/Lines sent: %3/%4/%5
"
"Mistakes: %6
"
- "Accuracy: %7%
").arg(tx).arg(rx).arg(_chars_send)
- .arg(_words_send).arg(_lines_send).arg(err).arg(correct);
+ "Accuracy: %7%").arg(tx).arg(rx).arg(_chars_sent)
+ .arg(_words_sent).arg(_lines_sent).arg(err).arg(correct);
if (correct >= _threshold) {
summary.append(tr("You achieved an accuracy of %1% >= %2%. "
"You may advance to the next lesson!
").arg(correct).arg(_threshold));
@@ -776,19 +776,19 @@ WordsworthTutor::_nextline() {
}
for (int j=0; j<_lessons[idx].size(); j++)
_text.push_back(_lessons[idx][j]);
- _sendText.push_back(_lessons[idx]);
- _chars_send += _lessons[idx].size();
+ _sentText.push_back(_lessons[idx]);
+ _chars_sent += _lessons[idx].size();
_text.push_back(' ');
- _sendText.push_back(' ');
- _words_send++;
+ _sentText.push_back(' ');
+ _words_sent++;
}
_text.push_back('=');
_text.push_back(' ');
_text.push_back(' ');
_text.push_back('\n');
- _sendText.push_back('\n');
+ _sentText.push_back('\n');
_linecount++;
- _lines_send++;
+ _lines_sent++;
}
const QVector &
diff --git a/src/tutor.hh b/src/tutor.hh
index 5be3983..5336a31 100644
--- a/src/tutor.hh
+++ b/src/tutor.hh
@@ -148,10 +148,10 @@ protected:
QList _text;
/** The vector of symbols for each lesson. */
static QVector _lessons;
- size_t _chars_send;
- size_t _words_send;
- size_t _lines_send;
- QString _sendText;
+ size_t _chars_sent;
+ size_t _words_sent;
+ size_t _lines_sent;
+ QString _sentText;
};
@@ -225,10 +225,10 @@ protected:
QList _text;
/** Vector of chars to choose from. */
QVector _chars;
- QString _sendText;
- size_t _chars_send;
- size_t _words_send;
- size_t _lines_send;
+ QString _sentText;
+ size_t _chars_sent;
+ size_t _words_sent;
+ size_t _lines_sent;
};
@@ -308,9 +308,9 @@ protected:
bool _prefLastWords;
/** The "repeat last word" flag. */
bool _repeatLastWord;
- /** The number of lines to send, if negative send an infinite number of lines. */
+ /** The number of lines to send. If negative, send an infinite number of lines. */
int _lines;
- /** The number of lines send. */
+ /** The number of lines sent. */
int _linecount;
bool _showSummary;
bool _verify;
@@ -320,10 +320,10 @@ protected:
QList _text;
/** The vector of words for each lesson. */
static QVector _lessons;
- size_t _chars_send;
- size_t _words_send;
- size_t _lines_send;
- QString _sendText;
+ size_t _chars_sent;
+ size_t _words_sent;
+ size_t _lines_sent;
+ QString _sentText;
};