Revert the message averaging window to it's original single personality

This commit is contained in:
Bill Somerville 2018-11-12 22:03:39 +00:00
parent 26438d59e6
commit 552df2d520
3 changed files with 17 additions and 204 deletions

View File

@ -14,33 +14,16 @@ MessageAveraging::MessageAveraging(QSettings * settings, QFont const& font, QWid
ui(new Ui::MessageAveraging)
{
ui->setupUi(this);
// setWindowTitle (QApplication::applicationName () + " - " + tr ("Message Averaging"));
setWindowTitle (QApplication::applicationName () + " - " + tr ("Message Averaging"));
ui->msgAvgPlainTextEdit->setReadOnly (true);
changeFont (font);
read_settings ();
if(m_title_.contains("Fox")) {
ui->header_label->setText(" Date Time Call Grid Sent Rcvd Band");
} else if(m_title_.contains("Contest")) {
ui->header_label->setText(" Date UTC Band Call Sent Rcvd");
ui->lab1->setText("QSOs: 0");
ui->lab2->setText("Mults: 0");
ui->lab3->setText("Score: 0");
ui->lab4->setText("Rate: 0");
} else {
ui->header_label->setText(" UTC Sync DT Freq ");
ui->lab1->setVisible(false);
ui->lab2->setVisible(false);
ui->lab3->setVisible(false);
ui->lab4->setVisible(false);
}
setWindowTitle(m_title_);
m_nLogged_=0;
ui->header_label->setText(" UTC Sync DT Freq ");
}
MessageAveraging::~MessageAveraging()
{
if (isVisible ()) write_settings ();
write_settings ();
}
void MessageAveraging::changeFont (QFont const& font)
@ -70,90 +53,19 @@ void MessageAveraging::setContentFont(QFont const& font)
ui->msgAvgPlainTextEdit->ensureCursorVisible ();
}
void MessageAveraging::closeEvent (QCloseEvent * e)
{
write_settings ();
QWidget::closeEvent (e);
}
void MessageAveraging::read_settings ()
{
SettingsGroup group {settings_, "MessageAveraging"};
restoreGeometry (settings_->value ("window/geometry").toByteArray ());
m_title_=settings_->value("window/title","Message Averaging").toString();
m_nContest_=settings_->value("nContest",0).toInt();
}
void MessageAveraging::write_settings ()
{
SettingsGroup group {settings_, "MessageAveraging"};
settings_->setValue ("window/geometry", saveGeometry ());
settings_->setValue("window/title",m_title_);
settings_->setValue("nContest",m_nContest_);
}
void MessageAveraging::displayAvg(QString const& t)
{
ui->msgAvgPlainTextEdit->setPlainText(t);
}
void MessageAveraging::foxLogSetup(int nContest)
{
if(nContest==5) {
m_title_=QApplication::applicationName () + " - Fox Log";
setWindowTitle(m_title_);
ui->header_label->setText(" Date Time Call Grid Sent Rcvd Band");
}
if(nContest>0 and nContest<5) {
m_title_=QApplication::applicationName () + " - Contest Log";
setWindowTitle(m_title_);
ui->header_label->setText(" Date UTC Band Call Sent Rcvd");
}
m_nContest_=nContest;
}
void MessageAveraging::foxLabCallers(int n)
{
QString t;
t.sprintf("Callers: %3d",n);
ui->lab1->setText(t);
}
void MessageAveraging::foxLabQueued(int n)
{
QString t;
t.sprintf("In progress: %3d",n);
ui->lab2->setText(t);
}
void MessageAveraging::foxLabRate(int n)
{
QString t;
t.sprintf("Rate: %3d",n);
ui->lab4->setText(t);
}
void MessageAveraging::foxAddLog(QString logLine)
{
ui->msgAvgPlainTextEdit->appendPlainText(logLine);
m_nLogged_++;
QString t;
t.sprintf("Logged: %d",m_nLogged_);
ui->lab3->setText(t);
}
void MessageAveraging::contestAddLog(qint32 nContest, QString logLine)
{
m_nContest_=nContest;
ui->msgAvgPlainTextEdit->appendPlainText(logLine);
m_nLogged_++;
QString t;
t.sprintf("QSOs: %d",m_nLogged_);
ui->lab1->setText(t);
if(m_mult_<1) m_mult_=1;
t.sprintf("Mults: %d",m_mult_);
ui->lab2->setText(t);
int score=m_mult_*m_nLogged_;
t.sprintf("Score: %d",score);
ui->lab3->setText(t);
}

View File

@ -1,5 +1,6 @@
#ifndef MESSAGEAVERAGING_H
#define MESSAGEAVERAGING_H
// -*- Mode: C++ -*-
#ifndef MESSAGEAVERAGING_H_
#define MESSAGEAVERAGING_H_
#include <QWidget>
@ -10,34 +11,22 @@ namespace Ui {
class MessageAveraging;
}
class MessageAveraging : public QWidget
class MessageAveraging
: public QWidget
{
public:
explicit MessageAveraging(QSettings *, QFont const&, QWidget * parent = 0);
~MessageAveraging();
void displayAvg(QString const&);
void changeFont (QFont const&);
void foxLogSetup(int nContest);
void foxLabCallers(int n);
void foxLabQueued(int n);
void foxLabRate(int n);
void foxAddLog(QString logLine);
void contestAddLog(qint32 nContest, QString logLine);
protected:
void closeEvent (QCloseEvent *) override;
private:
void read_settings ();
void write_settings ();
void setContentFont (QFont const&);
QSettings * settings_;
QString m_title_;
qint32 m_nLogged_=0;
qint32 m_mult_=0;
qint32 m_nContest_;
QScopedPointer<Ui::MessageAveraging> ui;
};
#endif // MESSAGEAVERAGING_H
#endif

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>354</width>
<width>405</width>
<height>268</height>
</rect>
</property>
@ -16,6 +16,13 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QPlainTextEdit" name="msgAvgPlainTextEdit">
<property name="lineWrapMode">
<enum>QPlainTextEdit::NoWrap</enum>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="header_label">
<property name="text">
@ -26,101 +33,6 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPlainTextEdit" name="msgAvgPlainTextEdit">
<property name="lineWrapMode">
<enum>QPlainTextEdit::NoWrap</enum>
</property>
</widget>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="lab1">
<property name="minimumSize">
<size>
<width>77</width>
<height>20</height>
</size>
</property>
<property name="text">
<string>Callers: 0</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lab2">
<property name="minimumSize">
<size>
<width>77</width>
<height>20</height>
</size>
</property>
<property name="text">
<string>In progress: 0</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>25</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="lab3">
<property name="minimumSize">
<size>
<width>77</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Logged: 0</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lab4">
<property name="minimumSize">
<size>
<width>77</width>
<height>20</height>
</size>
</property>
<property name="text">
<string>Rate: 0</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>