mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2026-06-05 07:24:38 -04:00
Move Fox log reset action to Fox log window context menu and allow deletes of QSOs
Move to OnRowChange edit strategy for log tables so that deletes from view can be implemented cleanly. Improve layout of log view tables by resizing to contents.
This commit is contained in:
@@ -52,7 +52,7 @@ CabrilloLog::impl::impl (Configuration const * configuration)
|
||||
SQL_error_check (export_query_, &QSqlQuery::prepare,
|
||||
"SELECT frequency, \"when\", exchange_sent, call, exchange_rcvd FROM cabrillo_log ORDER BY \"when\"");
|
||||
|
||||
setEditStrategy (QSqlTableModel::OnManualSubmit);
|
||||
setEditStrategy (QSqlTableModel::OnRowChange);
|
||||
setTable ("cabrillo_log");
|
||||
setHeaderData (fieldIndex ("frequency"), Qt::Horizontal, tr ("Freq(kHz)"));
|
||||
setHeaderData (fieldIndex ("when"), Qt::Horizontal, tr ("Date & Time(UTC)"));
|
||||
@@ -73,7 +73,7 @@ CabrilloLog::~CabrilloLog ()
|
||||
{
|
||||
}
|
||||
|
||||
QAbstractItemModel * CabrilloLog::model ()
|
||||
QSqlTableModel * CabrilloLog::model ()
|
||||
{
|
||||
return &*m_;
|
||||
}
|
||||
@@ -96,7 +96,6 @@ namespace
|
||||
bool CabrilloLog::add_QSO (Frequency frequency, QDateTime const& when, QString const& call
|
||||
, QString const& exchange_sent, QString const& exchange_received)
|
||||
{
|
||||
ConditionalTransaction transaction {*m_};
|
||||
auto record = m_->record ();
|
||||
record.setValue ("frequency", frequency / 1000ull); // kHz
|
||||
if (!when.isNull ())
|
||||
@@ -111,13 +110,12 @@ bool CabrilloLog::add_QSO (Frequency frequency, QDateTime const& when, QString c
|
||||
set_value_maybe_null (record, "exchange_sent", exchange_sent);
|
||||
set_value_maybe_null (record, "exchange_rcvd", exchange_received);
|
||||
set_value_maybe_null (record, "band", m_->configuration_->bands ()->find (frequency));
|
||||
SQL_error_check (*m_, &QSqlTableModel::insertRecord, -1, record);
|
||||
if (!transaction.submit (false))
|
||||
auto ok = m_->insertRecord (-1, record);
|
||||
if (ok)
|
||||
{
|
||||
transaction.revert ();
|
||||
return false;
|
||||
m_->select (); // to refresh views
|
||||
}
|
||||
return true;
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool CabrilloLog::dupe (Frequency frequency, QString const& call) const
|
||||
@@ -133,9 +131,12 @@ void CabrilloLog::reset ()
|
||||
{
|
||||
if (m_->rowCount ())
|
||||
{
|
||||
m_->setEditStrategy (QSqlTableModel::OnManualSubmit);
|
||||
ConditionalTransaction transaction {*m_};
|
||||
SQL_error_check (*m_, &QSqlTableModel::removeRows, 0, m_->rowCount (), QModelIndex {});
|
||||
transaction.submit ();
|
||||
m_->select (); // to refresh views
|
||||
m_->setEditStrategy (QSqlTableModel::OnRowChange);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user