summaryrefslogtreecommitdiff
path: root/widgets/activeStations.cpp
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2026-06-22 12:03:44 +0200
committerChristoph Berg <myon@debian.org>2026-06-22 12:03:44 +0200
commitd83a420f0517d7fc47aeb288a6a0cf4891784fcc (patch)
tree6d9c83527c56458a8360ba080bf5f4ca73d526dc /widgets/activeStations.cpp
parent4b089ae3f7e9e2d5662f718f663b26a4e8ee63ca (diff)
New upstream version 3.0.2+dfsgupstream/3.0.2+dfsg
Diffstat (limited to 'widgets/activeStations.cpp')
-rw-r--r--widgets/activeStations.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/widgets/activeStations.cpp b/widgets/activeStations.cpp
index 7353501c..067d36b5 100644
--- a/widgets/activeStations.cpp
+++ b/widgets/activeStations.cpp
@@ -125,31 +125,37 @@ void ActiveStations::displayRecentStations(QString mode, QString const& t)
m_clickOK=false;
ui->RecentStationsPlainTextEdit->setPlainText(t);
-//White background for Q65-60x decodes, yellow for Q65-30x:
int i0=0;
int i1=0;
- int npos=0;
int nlines=t.count("\n");
QTextCursor cursor=ui->RecentStationsPlainTextEdit->textCursor();
QTextCharFormat fmt;
+
+ // Use a regular expression matcher to find the text pattern within each line bounds
+ QRegularExpression regex(" 30[ABCD] ");
+
for(int i=0; i<nlines; i++) {
i1=t.indexOf("\n",i0);
- npos=t.indexOf(QRegularExpression(" 30[ABCD] "), i0);
- if(npos>0) {
- cursor.setPosition(npos);
- cursor.select(QTextCursor::LineUnderCursor);
+ // Isolate the current line to check for the match
+ QString currentLine = t.mid(i0, i1 - i0);
+ bool hasMatch = currentLine.contains(regex);
+
+ // Move the cursor to the current line we are processing
+ cursor.setPosition(i0);
+ cursor.select(QTextCursor::LineUnderCursor);
+
+ if(hasMatch) {
fmt.setBackground(QBrush(Qt::yellow));
fmt.setForeground(QBrush(Qt::black));
} else {
- cursor.setPosition(i0+10);
- cursor.select(QTextCursor::LineUnderCursor);
- fmt.clearForeground();
- fmt.clearBackground();
+ // Explicitly force the background back to white
+ fmt.setBackground(QBrush(Qt::white));
+ fmt.setForeground(QBrush(Qt::black));
}
+
cursor.setCharFormat(fmt);
i0=i1+1;
}
-
m_clickOK=bClickOK;
}