| 
									
										
										
										
											2022-03-11 15:12:32 -05:00
										 |  |  | #include "activeStations.h"
 | 
					
						
							| 
									
										
										
										
											2022-03-11 13:11:39 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <QSettings>
 | 
					
						
							|  |  |  | #include <QApplication>
 | 
					
						
							|  |  |  | #include <QTextCharFormat>
 | 
					
						
							| 
									
										
										
										
											2022-03-17 16:43:58 -04:00
										 |  |  | #include <QDateTime>
 | 
					
						
							| 
									
										
										
										
											2022-03-26 10:42:01 -04:00
										 |  |  | #include <QDebug>
 | 
					
						
							| 
									
										
										
										
											2022-03-11 13:11:39 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "SettingsGroup.hpp"
 | 
					
						
							|  |  |  | #include "qt_helpers.hpp"
 | 
					
						
							| 
									
										
										
										
											2022-03-11 15:12:32 -05:00
										 |  |  | #include "ui_activeStations.h"
 | 
					
						
							| 
									
										
										
										
											2022-03-11 13:11:39 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-11 15:12:32 -05:00
										 |  |  | #include "moc_activeStations.cpp"
 | 
					
						
							| 
									
										
										
										
											2022-03-11 13:11:39 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-11 14:58:13 -05:00
										 |  |  | ActiveStations::ActiveStations(QSettings * settings, QFont const& font, QWidget *parent) : | 
					
						
							| 
									
										
										
										
											2022-03-11 13:11:39 -05:00
										 |  |  |   QWidget(parent), | 
					
						
							|  |  |  |   settings_ {settings}, | 
					
						
							| 
									
										
										
										
											2022-03-11 14:58:13 -05:00
										 |  |  |   ui(new Ui::ActiveStations) | 
					
						
							| 
									
										
										
										
											2022-03-11 13:11:39 -05:00
										 |  |  | { | 
					
						
							|  |  |  |   ui->setupUi(this); | 
					
						
							| 
									
										
										
										
											2022-03-11 15:03:16 -05:00
										 |  |  |   setWindowTitle (QApplication::applicationName () + " - " + tr ("Active Stations")); | 
					
						
							| 
									
										
										
										
											2022-03-16 15:33:21 -04:00
										 |  |  |   ui->RecentStationsPlainTextEdit->setReadOnly (true); | 
					
						
							| 
									
										
										
										
											2022-03-11 13:11:39 -05:00
										 |  |  |   changeFont (font); | 
					
						
							|  |  |  |   read_settings (); | 
					
						
							| 
									
										
										
										
											2022-03-22 13:27:24 -04:00
										 |  |  |   ui->header_label2->setText("  N   Call    Grid   Az  S/N  Freq Tx Age Pts"); | 
					
						
							| 
									
										
										
										
											2022-03-26 10:42:01 -04:00
										 |  |  |   connect(ui->cbReadyOnly, SIGNAL(toggled(bool)), this, SLOT(on_cbReadyOnly_toggled(bool))); | 
					
						
							| 
									
										
										
										
											2023-03-06 15:18:15 -05:00
										 |  |  |   connect(ui->cbWantedOnly, SIGNAL(toggled(bool)), this, SLOT(on_cbWantedOnly_toggled(bool))); | 
					
						
							| 
									
										
										
										
											2022-12-15 12:14:06 -05:00
										 |  |  |   connect(ui->RecentStationsPlainTextEdit, SIGNAL(cursorPositionChanged()), this, SLOT(on_textEdit_clicked())); | 
					
						
							| 
									
										
										
										
											2022-03-11 13:11:39 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-11 14:58:13 -05:00
										 |  |  | ActiveStations::~ActiveStations() | 
					
						
							| 
									
										
										
										
											2022-03-11 13:11:39 -05:00
										 |  |  | { | 
					
						
							|  |  |  |   write_settings (); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-11 14:58:13 -05:00
										 |  |  | void ActiveStations::changeFont (QFont const& font) | 
					
						
							| 
									
										
										
										
											2022-03-11 13:11:39 -05:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2022-03-16 15:33:21 -04:00
										 |  |  |   ui->header_label2->setStyleSheet (font_as_stylesheet (font)); | 
					
						
							|  |  |  |   ui->RecentStationsPlainTextEdit->setStyleSheet (font_as_stylesheet (font)); | 
					
						
							| 
									
										
										
										
											2022-03-11 13:11:39 -05:00
										 |  |  |   updateGeometry (); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-11 14:58:13 -05:00
										 |  |  | void ActiveStations::read_settings () | 
					
						
							| 
									
										
										
										
											2022-03-11 13:11:39 -05:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2022-03-11 14:58:13 -05:00
										 |  |  |   SettingsGroup group {settings_, "ActiveStations"}; | 
					
						
							| 
									
										
										
										
											2022-03-11 13:11:39 -05:00
										 |  |  |   restoreGeometry (settings_->value ("window/geometry").toByteArray ()); | 
					
						
							| 
									
										
										
										
											2022-03-16 14:37:25 -04:00
										 |  |  |   ui->sbMaxRecent->setValue(settings_->value("MaxRecent",10).toInt()); | 
					
						
							|  |  |  |   ui->sbMaxAge->setValue(settings_->value("MaxAge",10).toInt()); | 
					
						
							| 
									
										
										
										
											2022-03-21 15:52:25 -04:00
										 |  |  |   ui->cbReadyOnly->setChecked(settings_->value("ReadyOnly",false).toBool()); | 
					
						
							| 
									
										
										
										
											2023-12-07 14:38:49 -05:00
										 |  |  |   ui->cbWantedOnly->setChecked(settings_->value("# WantedOnly",false).toBool()); | 
					
						
							| 
									
										
										
										
											2022-03-11 13:11:39 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-11 14:58:13 -05:00
										 |  |  | void ActiveStations::write_settings () | 
					
						
							| 
									
										
										
										
											2022-03-11 13:11:39 -05:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2022-03-11 14:58:13 -05:00
										 |  |  |   SettingsGroup group {settings_, "ActiveStations"}; | 
					
						
							| 
									
										
										
										
											2022-03-11 13:11:39 -05:00
										 |  |  |   settings_->setValue ("window/geometry", saveGeometry ()); | 
					
						
							| 
									
										
										
										
											2022-03-16 14:37:25 -04:00
										 |  |  |   settings_->setValue("MaxRecent",ui->sbMaxRecent->value()); | 
					
						
							|  |  |  |   settings_->setValue("MaxAge",ui->sbMaxAge->value()); | 
					
						
							| 
									
										
										
										
											2022-03-21 15:52:25 -04:00
										 |  |  |   settings_->setValue("ReadyOnly",ui->cbReadyOnly->isChecked()); | 
					
						
							| 
									
										
										
										
											2023-03-06 15:18:15 -05:00
										 |  |  |   settings_->setValue("WantedOnly",ui->cbWantedOnly->isChecked()); | 
					
						
							| 
									
										
										
										
											2022-03-11 13:11:39 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-07 11:45:05 -05:00
										 |  |  | void ActiveStations::displayRecentStations(QString mode, QString const& t) | 
					
						
							| 
									
										
										
										
											2022-03-16 14:37:25 -04:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2023-02-20 14:19:38 -05:00
										 |  |  |   if(mode!=m_mode) { | 
					
						
							|  |  |  |     m_mode=mode; | 
					
						
							| 
									
										
										
										
											2023-12-07 14:38:49 -05:00
										 |  |  |     ui->cbReadyOnly->setText(" Ready only"); | 
					
						
							| 
									
										
										
										
											2023-02-20 14:19:38 -05:00
										 |  |  |     if(m_mode=="Q65") { | 
					
						
							| 
									
										
										
										
											2023-12-07 14:29:27 -05:00
										 |  |  |       ui->header_label2->setText("  N    Frx   Fsked  S/N  Q65  Call     Grid  Tx  Age"); | 
					
						
							| 
									
										
										
										
											2023-02-20 14:19:38 -05:00
										 |  |  |       ui->label->setText("QSOs:"); | 
					
						
							| 
									
										
										
										
											2023-12-07 14:38:49 -05:00
										 |  |  |       ui->cbReadyOnly->setText("* CQ only"); | 
					
						
							| 
									
										
										
										
											2023-02-20 14:19:38 -05:00
										 |  |  |     } else if(m_mode=="Q65-pileup") { | 
					
						
							|  |  |  |       ui->header_label2->setText("  N   Freq  Call    Grid   El   Age(h)"); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |       ui->header_label2->setText("  N   Call    Grid   Az  S/N  Freq Tx Age Pts"); | 
					
						
							|  |  |  |       ui->label->setText("Rate:"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     bool b=(m_mode.left(3)=="Q65"); | 
					
						
							|  |  |  |     ui->bandChanges->setVisible(!b); | 
					
						
							| 
									
										
										
										
											2023-03-01 10:42:44 -05:00
										 |  |  |     ui->cbReadyOnly->setVisible(m_mode!="Q65-pileup"); | 
					
						
							| 
									
										
										
										
											2023-03-06 15:18:15 -05:00
										 |  |  |     ui->cbWantedOnly->setVisible(m_mode!="Q65-pileup"); | 
					
						
							| 
									
										
										
										
											2023-02-20 14:19:38 -05:00
										 |  |  |     ui->label_2->setVisible(!b); | 
					
						
							|  |  |  |     ui->label_3->setVisible(!b); | 
					
						
							|  |  |  |     ui->score->setVisible(!b); | 
					
						
							|  |  |  |     ui->sbMaxRecent->setVisible(!b); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     b=(m_mode!="Q65-pileup"); | 
					
						
							|  |  |  |     ui->sbMaxAge->setVisible(b); | 
					
						
							|  |  |  |     ui->label->setVisible(b); | 
					
						
							|  |  |  |     ui->rate->setVisible(b); | 
					
						
							| 
									
										
										
										
											2022-12-07 11:45:05 -05:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2023-05-25 09:31:17 -04:00
										 |  |  |   bool bClickOK=m_clickOK; | 
					
						
							|  |  |  |   m_clickOK=false; | 
					
						
							| 
									
										
										
										
											2023-05-22 11:57:52 -04:00
										 |  |  |   ui->RecentStationsPlainTextEdit->setPlainText(t); | 
					
						
							| 
									
										
										
										
											2023-12-11 16:07:43 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-20 17:22:05 -05:00
										 |  |  | //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; | 
					
						
							|  |  |  |   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); | 
					
						
							|  |  |  |       fmt.setBackground(QBrush(Qt::yellow)); | 
					
						
							| 
									
										
										
										
											2023-12-28 23:51:09 +01:00
										 |  |  |       fmt.setForeground(QBrush(Qt::black)); | 
					
						
							| 
									
										
										
										
											2023-12-20 17:22:05 -05:00
										 |  |  |     } else { | 
					
						
							|  |  |  |       cursor.setPosition(i0+10); | 
					
						
							|  |  |  |       cursor.select(QTextCursor::LineUnderCursor); | 
					
						
							| 
									
										
										
										
											2023-12-28 23:51:09 +01:00
										 |  |  |       fmt.clearForeground(); | 
					
						
							|  |  |  |       fmt.clearBackground(); | 
					
						
							| 
									
										
										
										
											2023-12-20 17:22:05 -05:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-12-11 16:07:43 -05:00
										 |  |  |     cursor.setCharFormat(fmt); | 
					
						
							| 
									
										
										
										
											2023-12-20 17:22:05 -05:00
										 |  |  |     i0=i1+1; | 
					
						
							| 
									
										
										
										
											2023-12-11 16:07:43 -05:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-25 09:31:17 -04:00
										 |  |  |   m_clickOK=bClickOK; | 
					
						
							| 
									
										
										
										
											2022-03-16 14:37:25 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int ActiveStations::maxRecent() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return ui->sbMaxRecent->value(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int ActiveStations::maxAge() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return ui->sbMaxAge->value(); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-03-17 09:36:59 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-15 12:14:06 -05:00
										 |  |  | void ActiveStations::on_textEdit_clicked() | 
					
						
							| 
									
										
										
										
											2022-03-17 09:36:59 -04:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2022-03-18 10:39:08 -04:00
										 |  |  |   if(m_clickOK) { | 
					
						
							| 
									
										
										
										
											2022-12-15 12:14:06 -05:00
										 |  |  |     QTextCursor cursor; | 
					
						
							|  |  |  |     QString text; | 
					
						
							|  |  |  |     cursor = ui->RecentStationsPlainTextEdit->textCursor(); | 
					
						
							|  |  |  |     cursor.movePosition(QTextCursor::StartOfBlock); | 
					
						
							|  |  |  |     cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor); | 
					
						
							|  |  |  |     text = cursor.selectedText(); | 
					
						
							|  |  |  |     if(text!="") { | 
					
						
							| 
									
										
										
										
											2023-02-28 14:30:50 -05:00
										 |  |  |       int nline=text.left(2).toInt(); | 
					
						
							|  |  |  |       if(QGuiApplication::keyboardModifiers().testFlag(Qt::ControlModifier)) nline=-nline; | 
					
						
							| 
									
										
										
										
											2022-12-15 12:14:06 -05:00
										 |  |  |       emit callSandP(nline); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-03-18 10:39:08 -04:00
										 |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ActiveStations::setClickOK(bool b) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   m_clickOK=b; | 
					
						
							| 
									
										
										
										
											2022-03-17 09:36:59 -04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2022-03-19 16:05:30 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | void ActiveStations::erase() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   ui->RecentStationsPlainTextEdit->clear(); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-03-20 14:16:20 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | bool ActiveStations::readyOnly() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return ui->cbReadyOnly->isChecked(); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-03-26 10:42:01 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | void ActiveStations::on_cbReadyOnly_toggled(bool b) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   m_bReadyOnly=b; | 
					
						
							|  |  |  |   emit activeStationsDisplay(); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-03-26 16:15:04 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-06 15:18:15 -05:00
										 |  |  | bool ActiveStations::wantedOnly() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return ui->cbWantedOnly->isChecked(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ActiveStations::on_cbWantedOnly_toggled(bool b) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   m_bWantedOnly=b; | 
					
						
							|  |  |  |   emit activeStationsDisplay(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-26 16:15:04 -04:00
										 |  |  | void ActiveStations::setRate(int n) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   ui->rate->setText(QString::number(n)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ActiveStations::setScore(int n) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-03-28 11:07:37 -04:00
										 |  |  |   ui->score->setText(QLocale(QLocale::English).toString(n)); | 
					
						
							| 
									
										
										
										
											2022-03-26 16:15:04 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ActiveStations::setBandChanges(int n) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-03-28 17:45:03 -04:00
										 |  |  |   if(n >= 8) { | 
					
						
							|  |  |  |     ui->bandChanges->setStyleSheet("QLineEdit{background: rgb(255, 64, 64)}"); | 
					
						
							|  |  |  |   } else { | 
					
						
							|  |  |  |     ui->bandChanges->setStyleSheet (""); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2022-03-26 16:15:04 -04:00
										 |  |  |   ui->bandChanges->setText(QString::number(n)); | 
					
						
							|  |  |  | } |