Work in progress on the ActiveStations window.

This commit is contained in:
Joe Taylor 2022-03-16 14:37:25 -04:00
parent 38e65b747a
commit e732c5ba62
4 changed files with 117 additions and 10 deletions

View File

@ -47,11 +47,8 @@ void ActiveStations::setContentFont(QFont const& font)
cursor.mergeCharFormat (charFormat);
cursor.clearSelection ();
cursor.movePosition (QTextCursor::End);
// position so viewport scrolled to left
cursor.movePosition (QTextCursor::Up);
cursor.movePosition (QTextCursor::StartOfLine);
ui->ActiveStationsPlainTextEdit->setTextCursor (cursor);
ui->ActiveStationsPlainTextEdit->ensureCursorVisible ();
}
@ -60,15 +57,34 @@ void ActiveStations::read_settings ()
{
SettingsGroup group {settings_, "ActiveStations"};
restoreGeometry (settings_->value ("window/geometry").toByteArray ());
ui->sbMaxRecent->setValue(settings_->value("MaxRecent",10).toInt());
ui->sbMaxAge->setValue(settings_->value("MaxAge",10).toInt());
}
void ActiveStations::write_settings ()
{
SettingsGroup group {settings_, "ActiveStations"};
settings_->setValue ("window/geometry", saveGeometry ());
settings_->setValue("MaxRecent",ui->sbMaxRecent->value());
settings_->setValue("MaxAge",ui->sbMaxAge->value());
}
void ActiveStations::displayActiveStations(QString const& t)
{
ui->ActiveStationsPlainTextEdit->setPlainText(t);
}
void ActiveStations::displayRecentStations(QString const& t)
{
ui->RecentStationsPlainTextEdit->setPlainText(t);
}
int ActiveStations::maxRecent()
{
return ui->sbMaxRecent->value();
}
int ActiveStations::maxAge()
{
return ui->sbMaxAge->value();
}

View File

@ -20,7 +20,10 @@ public:
explicit ActiveStations(QSettings *, QFont const&, QWidget * parent = 0);
~ActiveStations();
void displayActiveStations(QString const&);
void displayRecentStations(QString const&);
void changeFont (QFont const&);
int maxRecent();
int maxAge();
private:
void read_settings ();

View File

@ -18,11 +18,27 @@
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QPlainTextEdit" name="ActiveStationsPlainTextEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>2</verstretch>
</sizepolicy>
</property>
<property name="lineWrapMode">
<enum>QPlainTextEdit::NoWrap</enum>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPlainTextEdit" name="RecentStationsPlainTextEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="header_label">
<property name="text">
@ -33,6 +49,76 @@
</property>
</widget>
</item>
<item row="3" column="0">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="1">
<widget class="QSpinBox" name="sbMaxAge">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="prefix">
<string>Max Age </string>
</property>
<property name="minimum">
<number>4</number>
</property>
<property name="maximum">
<number>10</number>
</property>
<property name="value">
<number>4</number>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QSpinBox" name="sbMaxRecent">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="prefix">
<string>Max Recent </string>
</property>
<property name="maximum">
<number>20</number>
</property>
<property name="value">
<number>10</number>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
</layout>

View File

@ -3406,12 +3406,14 @@ void MainWindow::ARRL_Digi_Update(DecodedText dt)
if(bCQ or deGrid=="RR73" or deGrid=="73") rc.ready2call=true;
rc.decodeTime=m_latestDecodeTime;
m_recentCall[deCall]=rc;
/*
ac=m_activeCall[deCall];
if(rc.ready2call != bCQ) {
qDebug() << "aa" << deCall << ac.grid4 << ac.az
<< rc.dialFreq/1000000.0 << rc.audioFreq
<< rc.snr << rc.decodeTime << ac.points << rc.ready2call << bCQ;
}
*/
}
}
@ -3421,7 +3423,7 @@ void MainWindow::ARRL_Digi_Display()
QString deCall;
int age=0;
int i=0;
int maxAge=4;
int maxAge=m_ActiveStationsWidget->maxAge();
int points=0;
int maxPoints=0;
int indx[1000];
@ -3433,7 +3435,7 @@ void MainWindow::ARRL_Digi_Display()
deCall=icall.key();
age=int((m_latestDecodeTime - icall.value().decodeTime)/m_TRperiod + 0.5);
if(age>maxAge) {
qDebug() << "bb" << i << deCall << "removed";
// qDebug() << "bb" << i << deCall << "removed";
icall.remove();
} else {
i++;
@ -3443,18 +3445,18 @@ void MainWindow::ARRL_Digi_Display()
QString t1;
t1 = t1.asprintf(" %2d %2d",age,points);
t1 = (deCall + " ").left(6) + " " + m_activeCall[deCall].grid4 + t1;
// qDebug() << "cc" << t1 << m_activeCall.count() << m_recentCall.count() << pts[i-1];
list.append(t1);
}
}
int nmax=i;
indexx_(pts,&nmax,indx);
int maxRecent=qMin(i,m_ActiveStationsWidget->maxRecent());
indexx_(pts,&maxRecent,indx);
QString t;
for(int j=nmax-1; j>=0; j--) {
for(int j=maxRecent-1; j>=0; j--) {
int k=indx[j]-1;
t += (list[k] + "\n");
}
if(m_ActiveStationsWidget!=NULL) m_ActiveStationsWidget->displayActiveStations(t);
if(m_ActiveStationsWidget!=NULL) m_ActiveStationsWidget->displayRecentStations(t);
qDebug() << "dd" << maxRecent << maxAge;
}
void MainWindow::readFromStdout() //readFromStdout