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-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-18 11:55:44 -04:00
|
|
|
ui->header_label2->setText(" N Call Grid Az S/N Freq Tx Age Pts Bands");
|
2022-03-17 09:36:59 -04:00
|
|
|
connect(ui->RecentStationsPlainTextEdit, &QPlainTextEdit::selectionChanged, this, select);
|
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-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-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
|
|
|
}
|