diff --git a/CMakeLists.txt b/CMakeLists.txt index 4bafa56..fb25602 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -252,6 +252,7 @@ set (wsjtx_CXXSRCS main.cpp wsprnet.cpp WSPRBandHopping.cpp + TransmitTextEdit.cpp ) set (wsjt_CXXSRCS diff --git a/TransmitTextEdit.cpp b/TransmitTextEdit.cpp new file mode 100644 index 0000000..dddce0e --- /dev/null +++ b/TransmitTextEdit.cpp @@ -0,0 +1,53 @@ +#include "TransmitTextEdit.h" + +#include + +TransmitTextEdit::TransmitTextEdit(QWidget *parent): + QTextEdit(parent) +{ + connect(this, &QTextEdit::selectionChanged, this, &TransmitTextEdit::on_selectionChanged); + connect(this, &QTextEdit::cursorPositionChanged, this, &TransmitTextEdit::on_selectionChanged); +} + +void TransmitTextEdit::markCharsSent(int n){ + // update sent display + auto c = textCursor(); + c.movePosition(QTextCursor::Start); + c.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, n); + + auto ch = c.charFormat(); + ch.setFontStrikeOut(true); + c.mergeCharFormat(ch); + + // keep track + m_sent = n; +} + +// override +void TransmitTextEdit::setPlainText(const QString &text){ + QTextEdit::setPlainText(text); + m_sent = 0; +} + +// override +void TransmitTextEdit::clear(){ + QTextEdit::clear(); + m_sent = 0; +} + +// slot +void TransmitTextEdit::on_selectionChanged(){ + auto c = textCursor(); + int start = c.selectionStart(); + int end = c.selectionEnd(); + if(end < start){ + int x = end; + end = start; + start = x; + } + qDebug() << "selection" << start << end; + + if(start <= m_sent){ + qDebug() << "selection in protected zone" << start << "<=" << m_sent; + } +} diff --git a/TransmitTextEdit.h b/TransmitTextEdit.h new file mode 100644 index 0000000..0360cd7 --- /dev/null +++ b/TransmitTextEdit.h @@ -0,0 +1,22 @@ +#ifndef TRANSMITTEXTEDIT_H +#define TRANSMITTEXTEDIT_H + +#include + +class TransmitTextEdit : public QTextEdit +{ +public: + TransmitTextEdit(QWidget *parent); + + void markCharsSent(int n); + void setPlainText(const QString &text); + void clear(); + +public slots: + void on_selectionChanged(); + +private: + int m_sent; +}; + +#endif // TRANSMITTEXTEDIT_H diff --git a/js8call.pro b/js8call.pro index d978ff4..013ba79 100644 --- a/js8call.pro +++ b/js8call.pro @@ -83,7 +83,8 @@ SOURCES += \ Inbox.cpp \ messagewindow.cpp \ SpotClient.cpp \ - TCPClient.cpp + TCPClient.cpp \ + TransmitTextEdit.cpp HEADERS += qt_helpers.hpp \ pimpl_h.hpp pimpl_impl.hpp \ @@ -118,7 +119,8 @@ HEADERS += qt_helpers.hpp \ messagewindow.h \ SpotClient.h \ TCPClient.h \ - logbook/n3fjp.h + logbook/n3fjp.h \ + TransmitTextEdit.h INCLUDEPATH += qmake_only diff --git a/mainwindow.cpp b/mainwindow.cpp index b79c04c..6852c27 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1918,6 +1918,9 @@ void MainWindow::initializeDummyData(){ c.setCharFormat(f); #endif + ui->extFreeTextMsgEdit->setPlainText("HELLO BRAVE NEW WORLD"); + ui->extFreeTextMsgEdit->markCharsSent(6); + logHeardGraph("KN4CRD", "OH8STN"); logHeardGraph("KN4CRD", "K0OG"); logHeardGraph("K0OG", "KN4CRD"); @@ -5397,9 +5400,18 @@ void MainWindow::startTx2() void MainWindow::stopTx() { Q_EMIT endTransmitMessage (); + auto dt = DecodedText(m_currentMessage.trimmed(), m_currentMessageBits, m_nSubMode); last_tx_label.setText("Last Tx: " + dt.message()); //m_currentMessage.trimmed()); + + // start message marker + // - keep track of the total message sent so far, and mark it having been sent + m_totalTxMessage.append(dt.message()); + ui->extFreeTextMsgEdit->markCharsSent(m_totalTxMessage.length()); + qDebug() << "total sent:\n" << m_totalTxMessage; + // end message marker + m_btxok = false; m_transmitting = false; g_iptt=0; @@ -6224,18 +6236,18 @@ QString MainWindow::createMessageTransmitQueue(QString const& text, bool reset){ auto frames = buildMessageFrames(text); - m_txFrameQueue.append(frames); - m_txFrameCount = frames.length(); - - int freq = currentFreqOffset(); - qDebug() << "creating message for freq" << freq; - QStringList lines; foreach(auto frame, frames){ auto dt = DecodedText(frame.first, frame.second, m_nSubMode); lines.append(dt.message()); } + m_txFrameQueue.append(frames); + m_txFrameCount = frames.length(); + + int freq = currentFreqOffset(); + qDebug() << "creating message for freq" << freq; + // TODO: jsherer - parse outgoing message so we can add it to the inbox as an outgoing message auto joined = Varicode::rstrip(lines.join("")); @@ -6265,6 +6277,9 @@ void MainWindow::resetMessageTransmitQueue(){ m_txFrameCount = 0; m_txFrameQueue.clear(); m_txMessageQueue.clear(); + + // reset the total message sent + m_totalTxMessage.clear(); } QPair MainWindow::popMessageFrame(){ @@ -6382,6 +6397,11 @@ bool MainWindow::prepareNextMessageFrame() auto frame = f.first; auto bits = f.second; + // append this frame to the total message sent so far + // auto dt = DecodedText(frame, bits, m_nSubMode); + // m_totalTxMessage.append(dt.message()); + // qDebug() << "total sent" << m_totalTxMessage; + if(frame.isEmpty()){ ui->nextFreeTextMsg->clear(); updateTxButtonDisplay(); diff --git a/mainwindow.h b/mainwindow.h index 952db2e..e5ae977 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -795,6 +795,7 @@ private: QString m_txTextDirtyLastText; QString m_txTextDirtyLastSelectedCall; QString m_lastTxMessage; + QString m_totalTxMessage; QDateTime m_lastTxTime; int m_timeDeltaMsMMA; int m_timeDeltaMsMMA_N; diff --git a/mainwindow.ui b/mainwindow.ui index 0ea9edd..bb69a9f 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -1133,7 +1133,7 @@ background-color:#6699ff; Incoming and outgoing messages will appear here. - + 4 @@ -5848,6 +5848,11 @@ list. The list can be maintained in Settings (F2). QPushButton
DoubleClickablePushButton.hpp
+ + TransmitTextEdit + QTextEdit +
TransmitTextEdit.h
+
extFreeTextMsgEdit