Basic typeahead working. Need to fix edge cases and text replacement bugs
This commit is contained in:
parent
81e5aa00f0
commit
477adc81ac
@ -121,6 +121,16 @@ void TransmitTextEdit::setPlainText(const QString &text){
|
|||||||
m_sent = 0;
|
m_sent = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
void TransmitTextEdit::replaceUnsentText(const QString &text){
|
||||||
|
auto c = textCursor();
|
||||||
|
c.movePosition(QTextCursor::Start);
|
||||||
|
c.movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor, m_sent);
|
||||||
|
c.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
|
||||||
|
c.removeSelectedText();
|
||||||
|
c.insertText(text);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
void TransmitTextEdit::setFont(QFont f){
|
void TransmitTextEdit::setFont(QFont f){
|
||||||
m_font = f;
|
m_font = f;
|
||||||
@ -202,8 +212,8 @@ void TransmitTextEdit::on_textContentsChanged(int /*pos*/, int rem, int add){
|
|||||||
|
|
||||||
highlight();
|
highlight();
|
||||||
|
|
||||||
qDebug() << "sent:" << sentText();
|
//qDebug() << "sent:" << sentText();
|
||||||
qDebug() << "unsent:" << unsentText();
|
//qDebug() << "unsent:" << unsentText();
|
||||||
|
|
||||||
m_lastText = text;
|
m_lastText = text;
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,8 @@ public:
|
|||||||
|
|
||||||
QString toPlainText() const;
|
QString toPlainText() const;
|
||||||
void setPlainText(const QString &text);
|
void setPlainText(const QString &text);
|
||||||
|
void replaceUnsentText(const QString &text);
|
||||||
|
|
||||||
void setFont(QFont f);
|
void setFont(QFont f);
|
||||||
void setFont(QFont f, QColor fg, QColor bg);
|
void setFont(QFont f, QColor fg, QColor bg);
|
||||||
void clear();
|
void clear();
|
||||||
|
@ -5295,7 +5295,7 @@ void MainWindow::startTx()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// disallow editing of the text while transmitting
|
// disallow editing of the text while transmitting
|
||||||
ui->extFreeTextMsgEdit->setReadOnly(true);
|
// ui->extFreeTextMsgEdit->setReadOnly(true);
|
||||||
update_dynamic_property(ui->extFreeTextMsgEdit, "transmitting", true);
|
update_dynamic_property(ui->extFreeTextMsgEdit, "transmitting", true);
|
||||||
|
|
||||||
// update the tx button display
|
// update the tx button display
|
||||||
@ -5325,13 +5325,13 @@ void MainWindow::stopTx()
|
|||||||
auto dt = DecodedText(m_currentMessage.trimmed(), m_currentMessageBits, m_nSubMode);
|
auto dt = DecodedText(m_currentMessage.trimmed(), m_currentMessageBits, m_nSubMode);
|
||||||
last_tx_label.setText("Last Tx: " + dt.message()); //m_currentMessage.trimmed());
|
last_tx_label.setText("Last Tx: " + dt.message()); //m_currentMessage.trimmed());
|
||||||
|
|
||||||
|
// TODO: uncomment if we want to mark after the frame is sent.
|
||||||
// start message marker
|
//// // start message marker
|
||||||
// - keep track of the total message sent so far, and mark it having been sent
|
//// // - keep track of the total message sent so far, and mark it having been sent
|
||||||
m_totalTxMessage.append(dt.message());
|
//// m_totalTxMessage.append(dt.message());
|
||||||
ui->extFreeTextMsgEdit->setCharsSent(m_totalTxMessage.length());
|
//// ui->extFreeTextMsgEdit->setCharsSent(m_totalTxMessage.length());
|
||||||
qDebug() << "total sent:\n" << m_totalTxMessage;
|
//// qDebug() << "total sent:\n" << m_totalTxMessage;
|
||||||
// end message marker
|
//// // end message marker
|
||||||
|
|
||||||
m_btxok = false;
|
m_btxok = false;
|
||||||
m_transmitting = false;
|
m_transmitting = false;
|
||||||
@ -6113,6 +6113,10 @@ bool MainWindow::ensureNotIdle(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool MainWindow::ensureCreateMessageReady(const QString &text){
|
bool MainWindow::ensureCreateMessageReady(const QString &text){
|
||||||
|
if(text.isEmpty()){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if(!ensureCallsignSet()){
|
if(!ensureCallsignSet()){
|
||||||
on_stopTxButton_clicked();
|
on_stopTxButton_clicked();
|
||||||
return false;
|
return false;
|
||||||
@ -6151,6 +6155,10 @@ QString MainWindow::createMessage(QString const& text){
|
|||||||
return createMessageTransmitQueue(replaceMacros(text, buildMacroValues(), false), true);
|
return createMessageTransmitQueue(replaceMacros(text, buildMacroValues(), false), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString MainWindow::appendMessage(QString const& text){
|
||||||
|
return createMessageTransmitQueue(replaceMacros(text, buildMacroValues(), false), false);
|
||||||
|
}
|
||||||
|
|
||||||
QString MainWindow::createMessageTransmitQueue(QString const& text, bool reset){
|
QString MainWindow::createMessageTransmitQueue(QString const& text, bool reset){
|
||||||
if(reset){
|
if(reset){
|
||||||
resetMessageTransmitQueue();
|
resetMessageTransmitQueue();
|
||||||
@ -6165,13 +6173,14 @@ QString MainWindow::createMessageTransmitQueue(QString const& text, bool reset){
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_txFrameQueue.append(frames);
|
m_txFrameQueue.append(frames);
|
||||||
m_txFrameCount = frames.length();
|
m_txFrameCount += frames.length();
|
||||||
|
|
||||||
int freq = currentFreqOffset();
|
int freq = currentFreqOffset();
|
||||||
qDebug() << "creating message for freq" << freq;
|
qDebug() << "creating message for freq" << freq;
|
||||||
|
|
||||||
// TODO: jsherer - parse outgoing message so we can add it to the inbox as an outgoing message
|
// TODO: jsherer - parse outgoing message so we can add it to the inbox as an outgoing message
|
||||||
|
|
||||||
|
// TODO: jsherer - move this outside of create message transmit queue
|
||||||
auto joined = Varicode::rstrip(lines.join(""));
|
auto joined = Varicode::rstrip(lines.join(""));
|
||||||
displayTextForFreq(QString("%1 %2 ").arg(joined).arg(m_config.eot()), freq, DriftingDateTime::currentDateTimeUtc(), true, true, true);
|
displayTextForFreq(QString("%1 %2 ").arg(joined).arg(m_config.eot()), freq, DriftingDateTime::currentDateTimeUtc(), true, true, true);
|
||||||
|
|
||||||
@ -6183,7 +6192,7 @@ QString MainWindow::createMessageTransmitQueue(QString const& text, bool reset){
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// keep track of the last message text sent
|
// keep track of the last message text sent
|
||||||
m_lastTxMessage = text;
|
m_lastTxMessage += text;
|
||||||
|
|
||||||
return joined;
|
return joined;
|
||||||
}
|
}
|
||||||
@ -6202,6 +6211,9 @@ void MainWindow::resetMessageTransmitQueue(){
|
|||||||
|
|
||||||
// reset the total message sent
|
// reset the total message sent
|
||||||
m_totalTxMessage.clear();
|
m_totalTxMessage.clear();
|
||||||
|
|
||||||
|
// reset the last message sent
|
||||||
|
m_lastTxMessage.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
QPair<QString, int> MainWindow::popMessageFrame(){
|
QPair<QString, int> MainWindow::popMessageFrame(){
|
||||||
@ -6340,14 +6352,28 @@ bool MainWindow::prepareNextMessageFrame()
|
|||||||
{
|
{
|
||||||
m_i3bit = Varicode::JS8Call;
|
m_i3bit = Varicode::JS8Call;
|
||||||
|
|
||||||
|
// typeahead
|
||||||
|
static QString lastText;
|
||||||
|
if(lastText == "" || lastText != ui->extFreeTextMsgEdit->toPlainText()){
|
||||||
|
auto sent = ui->extFreeTextMsgEdit->sentText();
|
||||||
|
auto unsent = ui->extFreeTextMsgEdit->unsentText();
|
||||||
|
qDebug() << "text dirty for typeahead\n" << sent << "\n" << unsent;
|
||||||
|
m_txFrameQueue.clear();
|
||||||
|
m_txFrameCount = 0;
|
||||||
|
auto newUnsent = appendMessage(unsent);
|
||||||
|
ui->extFreeTextMsgEdit->replaceUnsentText(newUnsent);
|
||||||
|
lastText = ui->extFreeTextMsgEdit->toPlainText();
|
||||||
|
}
|
||||||
|
|
||||||
QPair<QString, int> f = popMessageFrame();
|
QPair<QString, int> f = popMessageFrame();
|
||||||
auto frame = f.first;
|
auto frame = f.first;
|
||||||
auto bits = f.second;
|
auto bits = f.second;
|
||||||
|
|
||||||
// append this frame to the total message sent so far
|
// append this frame to the total message sent so far
|
||||||
// auto dt = DecodedText(frame, bits, m_nSubMode);
|
auto dt = DecodedText(frame, bits, m_nSubMode);
|
||||||
// m_totalTxMessage.append(dt.message());
|
m_totalTxMessage.append(dt.message());
|
||||||
// qDebug() << "total sent" << m_totalTxMessage;
|
ui->extFreeTextMsgEdit->setCharsSent(m_totalTxMessage.length());
|
||||||
|
qDebug() << "total sent:\n" << m_totalTxMessage;
|
||||||
|
|
||||||
if(frame.isEmpty()){
|
if(frame.isEmpty()){
|
||||||
ui->nextFreeTextMsg->clear();
|
ui->nextFreeTextMsg->clear();
|
||||||
|
@ -160,6 +160,7 @@ public slots:
|
|||||||
bool ensureNotIdle();
|
bool ensureNotIdle();
|
||||||
bool ensureCreateMessageReady(const QString &text);
|
bool ensureCreateMessageReady(const QString &text);
|
||||||
QString createMessage(QString const& text);
|
QString createMessage(QString const& text);
|
||||||
|
QString appendMessage(QString const& text);
|
||||||
QString createMessageTransmitQueue(QString const& text, bool reset);
|
QString createMessageTransmitQueue(QString const& text, bool reset);
|
||||||
void resetMessageTransmitQueue();
|
void resetMessageTransmitQueue();
|
||||||
QPair<QString, int> popMessageFrame();
|
QPair<QString, int> popMessageFrame();
|
||||||
|
Loading…
Reference in New Issue
Block a user