summaryrefslogtreecommitdiff
path: root/widgets/logqso.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'widgets/logqso.cpp')
-rw-r--r--widgets/logqso.cpp40
1 files changed, 22 insertions, 18 deletions
diff --git a/widgets/logqso.cpp b/widgets/logqso.cpp
index 35f04b13..5a81f145 100644
--- a/widgets/logqso.cpp
+++ b/widgets/logqso.cpp
@@ -3,7 +3,6 @@
#include <QLocale>
#include <QString>
#include <QSettings>
-#include <QStandardPaths>
#include <QStringList>
#include <QDir>
#include <QTimer>
@@ -16,6 +15,8 @@
#include "models/Bands.hpp"
#include "models/CabrilloLog.hpp"
#include "validators/MaidenheadLocatorValidator.hpp"
+#include "qt_helpers.hpp"
+#include "PerformanceTrace.hpp"
#include "ui_logqso.h"
#include "moc_logqso.cpp"
@@ -88,12 +89,12 @@ LogQSO::LogQSO(QString const& programTitle, QSettings * settings
, m_config {config}
, m_log {log}
{
+ PerformanceTrace::Phase construction {"logqso.construct"};
ui->setupUi(this);
setWindowTitle(programTitle + " - Log QSO");
ui->comboBoxSatellite->addItem ("", "");
- QString sat_file_location;
- QDir dataPath {QStandardPaths::writableLocation (QStandardPaths::DataLocation)};
- sat_file_location = dataPath.exists(sat_file_name) ? dataPath.absoluteFilePath(sat_file_name) : m_config->data_dir ().absoluteFilePath (sat_file_name);
+ auto const& sat_file_location = writable_override_or_installed_file_path (m_config->writeable_data_dir (),
+ m_config->data_dir (), sat_file_name);
QFile file {sat_file_location};
QStringList wordList;
QTextStream stream(&file);
@@ -169,8 +170,8 @@ void LogQSO::loadSettings ()
ui->cbFreqRx->setChecked (m_settings->value ("SaveFreqRx", false).toBool ());
QString comments_location; // load the content of comments.txt file to the comments combo box
- QDir dataPath {QStandardPaths::writableLocation (QStandardPaths::DataLocation)};
- comments_location = dataPath.exists("comments.txt") ? dataPath.absoluteFilePath("comments.txt") : m_config->data_dir ().absoluteFilePath ("comments.txt");
+ comments_location = writable_override_or_installed_file_path (m_config->writeable_data_dir (),
+ m_config->data_dir (), "comments.txt");
QFile file2 {comments_location};
QTextStream stream2(&file2);
if(file2.open (QIODevice::ReadOnly | QIODevice::Text)) {
@@ -216,8 +217,8 @@ void LogQSO::initLogQSO(QString const& hisCall, QString const& hisGrid, QString
QDateTime const& dateTimeOn, QDateTime const& dateTimeOff,
Radio::Frequency dialFreq, bool noSuffix, QString xSent, QString xRcvd)
{
- if(!isHidden()) return;
+ if(!isHidden()) return;
QPushButton* okBtn = ui->buttonBox->button(QDialogButtonBox::Ok);
okBtn->setAutoDefault(true);
okBtn->setDefault(true);
@@ -376,8 +377,8 @@ void LogQSO::accept()
m_txPower = ui->txPower->text ();
auto strDialFreq = QString::number (m_dialFreq / 1.e6,'f',6);
auto operator_call = ui->loggedOperator->text ();
- auto xsent = ui->exchSent->text ();
- auto xrcvd = ui->exchRcvd->text ();
+ auto xsent = ui->exchSent->text ().trimmed ();
+ auto xrcvd = ui->exchRcvd->text ().trimmed ();
using SpOp = Configuration::SpecialOperatingActivity;
auto special_op = m_config->special_op_id ();
@@ -387,20 +388,22 @@ void LogQSO::accept()
}
if ((special_op == SpOp::RTTY and xsent!="" and xrcvd!="")) {
- if(rptSent=="" or !xsent.contains(rptSent+" ")) rptSent=xsent.split(" "
+ auto xsent_words = xsent.split(" "
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
- , QString::SkipEmptyParts
+ , QString::SkipEmptyParts
#else
- , Qt::SkipEmptyParts
+ , Qt::SkipEmptyParts
#endif
- ).at(0);
- if(rptRcvd=="" or !xrcvd.contains(rptRcvd+" ")) rptRcvd=xrcvd.split(" "
+ );
+ auto xrcvd_words = xrcvd.split(" "
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
- , QString::SkipEmptyParts
+ , QString::SkipEmptyParts
#else
- , Qt::SkipEmptyParts
+ , Qt::SkipEmptyParts
#endif
- ).at(0);
+ );
+ if(rptSent=="" or !xsent.contains(rptSent+" ")) rptSent=xsent_words.at(0);
+ if(rptRcvd=="" or !xrcvd.contains(rptRcvd+" ")) rptRcvd=xrcvd_words.at(0);
}
// validate
@@ -433,7 +436,8 @@ void LogQSO::accept()
}
m_freqRx = ui->freqRx->text ();
//Log this QSO to file "wsjtx.log"
- static QFile f {QDir {QStandardPaths::writableLocation (QStandardPaths::DataLocation)}.absoluteFilePath ("wsjtx.log")};
+ QFile f {writable_file_path (m_config->writeable_data_dir (), "wsjtx.log")};
+ ensure_parent_directory (f.fileName ());
if(!f.open(QIODevice::Text | QIODevice::Append)) {
MessageBox::warning_message (this, tr ("Log file error"),
tr ("Cannot open \"%1\" for append").arg (f.fileName ()),