From b6b8271a6d7d39d5e4d68b44a33ae46979282273 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Sun, 8 Dec 2019 18:36:04 +0000 Subject: [PATCH 1/5] Item delegate for SQLite date and time fields --- CMakeLists.txt | 1 + item_delegates/SQLiteDateTimeDelegate.cpp | 40 +++++++++++++++++++++++ item_delegates/SQLiteDateTimeDelegate.hpp | 23 +++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 item_delegates/SQLiteDateTimeDelegate.cpp create mode 100644 item_delegates/SQLiteDateTimeDelegate.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b3a4e010..3147d7c98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -282,6 +282,7 @@ set (wsjt_qt_CXXSRCS item_delegates/MaidenheadLocatorDelegate.cpp item_delegates/FrequencyDelegate.cpp item_delegates/FrequencyDeltaDelegate.cpp + item_delegates/SQLiteDateTimeDelegate.cpp models/CabrilloLog.cpp logbook/AD1CCty.cpp logbook/WorkedBefore.cpp diff --git a/item_delegates/SQLiteDateTimeDelegate.cpp b/item_delegates/SQLiteDateTimeDelegate.cpp new file mode 100644 index 000000000..1cf8ad262 --- /dev/null +++ b/item_delegates/SQLiteDateTimeDelegate.cpp @@ -0,0 +1,40 @@ +#include "SQLiteDateTimeDelegate.hpp" + +#include +#include +#include + +SQLiteDateTimeDelegate::SQLiteDateTimeDelegate (QObject * parent) + : QStyledItemDelegate {parent} +{ +} + +QWidget * SQLiteDateTimeDelegate::createEditor (QWidget * parent, QStyleOptionViewItem const& + , QModelIndex const&) const +{ + auto * editor = new QDateTimeEdit {parent}; + editor->setCalendarPopup (true); + editor->setDisplayFormat (QLocale {}.dateFormat (QLocale::ShortFormat) + " hh:mm:ss"); + editor->setFrame (false); + return editor; +} + +void SQLiteDateTimeDelegate::setEditorData (QWidget * editor, QModelIndex const& index) const +{ + auto const& value = index.model ()->data (index, Qt::EditRole); + if (value.isValid () && !value.isNull ()) + { + static_cast (editor)->setDateTime (QDateTime::fromMSecsSinceEpoch (value.toULongLong () * 1000ull, Qt::UTC)); + } +} + +void SQLiteDateTimeDelegate::setModelData (QWidget * editor, QAbstractItemModel * model, QModelIndex const& index) const +{ + QVariant data; + auto const& value = static_cast (editor)->dateTime (); + if (value.isValid () && !value.isNull ()) + { + data = value.toMSecsSinceEpoch () / 1000ull; + } + model->setData (index, data, Qt::EditRole); +} diff --git a/item_delegates/SQLiteDateTimeDelegate.hpp b/item_delegates/SQLiteDateTimeDelegate.hpp new file mode 100644 index 000000000..183b26d73 --- /dev/null +++ b/item_delegates/SQLiteDateTimeDelegate.hpp @@ -0,0 +1,23 @@ +#ifndef SQLITE_DATE_TIME_DELEGATE_HPP_ +#define SQLITE_DATE_TIME_DELEGATE_HPP_ + +#include + +// +// Class SQLiteDateTimeDelegte +// +// Item delegate for editing a date and time stored as milliseconds +// since the Unix epoch and displayed or edited as a QDateTime +// showing UTC +// +class SQLiteDateTimeDelegate final + : public QStyledItemDelegate +{ +public: + explicit SQLiteDateTimeDelegate (QObject * parent = nullptr); + QWidget * createEditor (QWidget * parent, QStyleOptionViewItem const&, QModelIndex const&) const override; + void setEditorData (QWidget * editor, QModelIndex const&) const override; + void setModelData (QWidget * editor, QAbstractItemModel *, QModelIndex const&) const override; +}; + +#endif From 32c36f566dd2841af4c89b9310cbf88078d4c167 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Sun, 8 Dec 2019 18:37:35 +0000 Subject: [PATCH 2/5] Use DB date time field item delegate to imbue editing in log windows --- models/CabrilloLog.cpp | 19 ++++++++----------- models/FoxLog.cpp | 12 +++--------- widgets/CabrilloLogWindow.cpp | 2 ++ widgets/FoxLogWindow.cpp | 2 ++ 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/models/CabrilloLog.cpp b/models/CabrilloLog.cpp index dfba3d439..b0459e190 100644 --- a/models/CabrilloLog.cpp +++ b/models/CabrilloLog.cpp @@ -50,20 +50,17 @@ public: else { value = QSqlTableModel::data (model_index, role); - if (model_index.column () == fieldIndex ("frequency") && Qt::DisplayRole == role) + if (Qt::DisplayRole == role) { - value = Radio::frequency_MHz_string (value.value (), 3); // kHz precision - } - else if (model_index.column () == fieldIndex ("when") - && (Qt::DisplayRole == role || Qt::EditRole == role)) - { // adjust date/time to Qt format - auto t = QDateTime::fromMSecsSinceEpoch (value.toULongLong () * 1000ull, Qt::UTC); - if (Qt::DisplayRole == role) + if (model_index.column () == fieldIndex ("frequency")) { - QLocale locale; - return locale.toString (t, locale.dateFormat (QLocale::ShortFormat) + " hh:mm:ss"); + value = Radio::frequency_MHz_string (value.value (), 3); // kHz precision + } + else if (model_index.column () == fieldIndex ("when")) + { // adjust date/time to Qt format + QLocale locale; + value = locale.toString (QDateTime::fromMSecsSinceEpoch (value.toULongLong () * 1000ull, Qt::UTC), locale.dateFormat (QLocale::ShortFormat) + " hh:mm:ss"); } - value = t; } } return value; diff --git a/models/FoxLog.cpp b/models/FoxLog.cpp index ad02cd2b8..3ba7d2c23 100644 --- a/models/FoxLog.cpp +++ b/models/FoxLog.cpp @@ -26,16 +26,10 @@ public: QVariant data (QModelIndex const& index, int role) const { auto value = QSqlTableModel::data (index, role); - if (index.column () == fieldIndex ("when") - && (Qt::DisplayRole == role || Qt::EditRole == role)) + if (index.column () == fieldIndex ("when") && Qt::DisplayRole == role) { - auto t = QDateTime::fromMSecsSinceEpoch (value.toULongLong () * 1000ull, Qt::UTC); - if (Qt::DisplayRole == role) - { - QLocale locale; - return locale.toString (t, locale.dateFormat (QLocale::ShortFormat) + " hh:mm:ss"); - } - value = t; + QLocale locale; + value = locale.toString (QDateTime::fromMSecsSinceEpoch (value.toULongLong () * 1000ull, Qt::UTC), locale.dateFormat (QLocale::ShortFormat) + " hh:mm:ss"); } return value; } diff --git a/widgets/CabrilloLogWindow.cpp b/widgets/CabrilloLogWindow.cpp index 6fd753136..5c219fcd7 100644 --- a/widgets/CabrilloLogWindow.cpp +++ b/widgets/CabrilloLogWindow.cpp @@ -9,6 +9,7 @@ #include "item_delegates/FrequencyDelegate.hpp" #include "item_delegates/ForeignKeyDelegate.hpp" #include "item_delegates/CallsignDelegate.hpp" +#include "item_delegates/SQLiteDateTimeDelegate.hpp" #include "pimpl_impl.hpp" #include "ui_CabrilloLogWindow.h" @@ -66,6 +67,7 @@ CabrilloLogWindow::CabrilloLogWindow (QSettings * settings, Configuration const m_->ui_.log_table_view->setModel (&m_->format_model_); set_log_view (m_->ui_.log_table_view); m_->ui_.log_table_view->setItemDelegateForColumn (1, new FrequencyDelegate {this}); + m_->ui_.log_table_view->setItemDelegateForColumn (3, new SQLiteDateTimeDelegate {this}); m_->ui_.log_table_view->setItemDelegateForColumn (4, new CallsignDelegate {this}); auto h_header = m_->ui_.log_table_view->horizontalHeader (); h_header->moveSection (7, 1); // band to first column diff --git a/widgets/FoxLogWindow.cpp b/widgets/FoxLogWindow.cpp index 9c29a30ad..cdbc00486 100644 --- a/widgets/FoxLogWindow.cpp +++ b/widgets/FoxLogWindow.cpp @@ -15,6 +15,7 @@ #include "item_delegates/ForeignKeyDelegate.hpp" #include "item_delegates/CallsignDelegate.hpp" #include "item_delegates/MaidenheadLocatorDelegate.hpp" +#include "item_delegates/SQLiteDateTimeDelegate.hpp" #include "pimpl_impl.hpp" #include "ui_FoxLogWindow.h" @@ -41,6 +42,7 @@ FoxLogWindow::FoxLogWindow (QSettings * settings, Configuration const * configur m_->ui_.setupUi (this); m_->ui_.log_table_view->setModel (m_->log_->model ()); set_log_view (m_->ui_.log_table_view); + m_->ui_.log_table_view->setItemDelegateForColumn (1, new SQLiteDateTimeDelegate {this}); m_->ui_.log_table_view->setItemDelegateForColumn (2, new CallsignDelegate {this}); m_->ui_.log_table_view->setItemDelegateForColumn (3, new MaidenheadLocatorDelegate {this}); m_->ui_.log_table_view->setItemDelegateForColumn (6, new ForeignKeyDelegate {configuration->bands (), 0, this}); From 485f787cef2edc3c9aef321c2baf77520176dd32 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Sun, 8 Dec 2019 18:39:37 +0000 Subject: [PATCH 3/5] Increase maximum SNR filter value in Fox mode to 70dB This change abandons the previous settings file key for this control so that all users pick up the new default of 70dB. --- widgets/mainwindow.cpp | 6 +++--- widgets/mainwindow.ui | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/widgets/mainwindow.cpp b/widgets/mainwindow.cpp index 6dd1f60ab..aa608864b 100644 --- a/widgets/mainwindow.cpp +++ b/widgets/mainwindow.cpp @@ -940,7 +940,7 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple, m_bDisplayedOnce=false; m_wait=0; m_isort=-3; - m_max_dB=30; + m_max_dB=70; m_CQtype="CQ"; if(m_mode.startsWith ("WSPR") and m_pctx>0) { @@ -1072,7 +1072,7 @@ void MainWindow::writeSettings() m_settings->setValue("HoundSort",ui->comboBoxHoundSort->currentIndex()); m_settings->setValue("FoxNlist",ui->sbNlist->value()); m_settings->setValue("FoxNslots",ui->sbNslots->value()); - m_settings->setValue("FoxMaxDB",ui->sbMax_dB->value()); + m_settings->setValue("FoxMaxDB_v2",ui->sbMax_dB->value()); // original key abandoned m_settings->setValue ("SerialNumber",ui->sbSerialNumber->value ()); m_settings->endGroup(); @@ -1152,7 +1152,7 @@ void MainWindow::readSettings() ui->sbNlist->setValue(m_settings->value("FoxNlist",12).toInt()); m_Nslots=m_settings->value("FoxNslots",5).toInt(); ui->sbNslots->setValue(m_Nslots); - ui->sbMax_dB->setValue(m_settings->value("FoxMaxDB",30).toInt()); + ui->sbMax_dB->setValue(m_settings->value("FoxMaxDB_v2",70).toInt()); ui->sbSerialNumber->setValue (m_settings->value ("SerialNumber", 1).toInt ()); m_settings->endGroup(); diff --git a/widgets/mainwindow.ui b/widgets/mainwindow.ui index 75be401d0..c37da3885 100644 --- a/widgets/mainwindow.ui +++ b/widgets/mainwindow.ui @@ -2213,7 +2213,7 @@ list. The list can be maintained in Settings (F2). -15 - 30 + 70 30 From 85b5967d99853ff27b2b8ffc9abe445bbde2ddbb Mon Sep 17 00:00:00 2001 From: Steve Franke Date: Wed, 11 Dec 2019 10:16:48 -0600 Subject: [PATCH 4/5] Fix ncontest initialization and heap storage conflict. --- lib/decoder.f90 | 2 +- lib/ft4/subtractft4.f90 | 2 +- lib/ft4_decode.f90 | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/decoder.f90 b/lib/decoder.f90 index 9f3b12887..042cf906d 100644 --- a/lib/decoder.f90 +++ b/lib/decoder.f90 @@ -61,6 +61,7 @@ subroutine multimode_decoder(ss,id2,params,nfsample) my_ft8%decoded = 0 my_ft4%decoded = 0 + ncontest=iand(params%nexp_decode,7) single_decode=iand(params%nexp_decode,32).ne.0 bVHF=iand(params%nexp_decode,64).ne.0 if(mod(params%nranera,2).eq.0) ntrials=10**(params%nranera/2) @@ -102,7 +103,6 @@ subroutine multimode_decoder(ss,id2,params,nfsample) call timer('decft8 ',0) newdat=params%newdat - ncontest=iand(params%nexp_decode,7) call my_ft8%decode(ft8_decoded,id2,params%nQSOProgress,params%nfqso, & params%nftx,newdat,params%nutc,params%nfa,params%nfb, & params%ndepth,ncontest,logical(params%nagain), & diff --git a/lib/ft4/subtractft4.f90 b/lib/ft4/subtractft4.f90 index ae104ddb3..8fb16532a 100644 --- a/lib/ft4/subtractft4.f90 +++ b/lib/ft4/subtractft4.f90 @@ -16,7 +16,7 @@ subroutine subtractft4(dd,itone,f0,dt) integer itone(103) logical first data first/.true./ - common/heap8/cref(NFRAME),camp(NMAX),cfilt(NMAX),cw(NMAX),xjunk(NFRAME) + common/heap4/cref(NFRAME),camp(NMAX),cfilt(NMAX),cw(NMAX),xjunk(NFRAME) save first nstart=dt*12000+1-NSPS diff --git a/lib/ft4_decode.f90 b/lib/ft4_decode.f90 index c60ee179a..6b561c76b 100644 --- a/lib/ft4_decode.f90 +++ b/lib/ft4_decode.f90 @@ -28,6 +28,7 @@ contains use timer_module, only: timer use packjt77 include 'ft4/ft4_params.f90' + parameter (MAXCAND=100) class(ft4_decoder), intent(inout) :: this procedure(ft4_decode_callback) :: callback parameter (NSS=NSPS/NDOWN,NDMAX=NMAX/NDOWN) @@ -49,7 +50,7 @@ contains real bitmetrics(2*NN,3) real dd(NMAX) real llr(2*ND),llra(2*ND),llrb(2*ND),llrc(2*ND),llrd(2*ND) - real candidate(2,100) + real candidate(2,MAXCAND) real savg(NH1),sbase(NH1) integer apbits(2*ND) @@ -185,7 +186,6 @@ contains mycall0=mycall hiscall0=hiscall endif - maxcand=100 ndecodes=0 decodes=' ' fa=nfa @@ -222,7 +222,7 @@ contains candidate=0.0 ncand=0 call timer('getcand4',0) - call getcandidates4(dd,fa,fb,syncmin,nfqso,maxcand,savg,candidate, & + call getcandidates4(dd,fa,fb,syncmin,nfqso,MAXCAND,savg,candidate, & ncand,sbase) call timer('getcand4',1) dobigfft=.true. From 0f592eb48f8a8b1ced6cc1908bee11deecd59885 Mon Sep 17 00:00:00 2001 From: Steve Franke Date: Wed, 11 Dec 2019 11:18:37 -0600 Subject: [PATCH 5/5] Disallow decoded messages with i3.ge.6 as these are not yet defined. --- lib/77bit/packjt77.f90 | 2 ++ lib/ft4_decode.f90 | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/77bit/packjt77.f90 b/lib/77bit/packjt77.f90 index 1f9ed9a19..90e17add2 100644 --- a/lib/77bit/packjt77.f90 +++ b/lib/77bit/packjt77.f90 @@ -519,6 +519,8 @@ subroutine unpack77(c77,nrx,msg,unpk77_success) ' R'//crpt//' '//cfield if(itu.eq.1 .and. ir.eq.1) msg='TU; '//trim(call_1)//' '//trim(call_2)// & ' R'//crpt//' '//cfield + else if(i3.ge.6) then ! i3 values 6 and 7 are not yet defined + unpk77_success=.false. endif ! if(msg(1:4).eq.'CQ <') unpk77_success=.false. diff --git a/lib/ft4_decode.f90 b/lib/ft4_decode.f90 index 6b561c76b..3e8ed3134 100644 --- a/lib/ft4_decode.f90 +++ b/lib/ft4_decode.f90 @@ -429,7 +429,8 @@ contains message77=mod(message77+rvec,2) ! remove rvec scrambling write(c77,'(77i1)') message77(1:77) call unpack77(c77,1,message,unpk77_success) - if(unpk77_success.and.dosubtract) then + if(.not.unpk77_success) exit + if(dosubtract) then call get_ft4_tones_from_77bits(message77,i4tone) dt=real(ibest)/666.67 call timer('subtract',0)