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-19 14:06:46 -04:00
|
|
|
connect(ui->RecentStationsPlainTextEdit, SIGNAL(selectionChanged()), this, SLOT(select()));
|
2022-03-26 10:42:01 -04:00
|
|
|
connect(ui->cbReadyOnly, SIGNAL(toggled(bool)), this, SLOT(on_cbReadyOnly_toggled(bool)));
|
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());
|
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());
|
2022-03-11 13:11:39 -05:00
|
|
|
}
|
|
|
|
|
2022-03-16 14:37:25 -04:00
|
|
|
void ActiveStations::displayRecentStations(QString const& t)
|
|
|
|
{
|
|
|
|
ui->RecentStationsPlainTextEdit->setPlainText(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
int ActiveStations::maxRecent()
|
|
|
|
{
|
|
|
|
return ui->sbMaxRecent->value();
|
|
|
|
}
|
|
|
|
|
|
|
|
int ActiveStations::maxAge()
|
|
|
|
{
|
|
|
|
return ui->sbMaxAge->value();
|
|
|
|
}
|
2022-03-17 09:36:59 -04:00
|
|
|
|
|
|
|
void ActiveStations::select()
|
|
|
|
{
|
2022-03-18 10:39:08 -04:00
|
|
|
if(m_clickOK) {
|
|
|
|
qint64 msec=QDateTime::currentMSecsSinceEpoch();
|
|
|
|
if((msec-m_msec0)<500) return;
|
|
|
|
m_msec0=msec;
|
|
|
|
int nline=ui->RecentStationsPlainTextEdit->textCursor().blockNumber();
|
|
|
|
emit callSandP(nline);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|