mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-25 05:38:46 -05:00
Ensure that pending log table edits do not lock out adding new QSOs
Pending edits are now discarded when adding a new log contest or Fox log record. Also switch to commit on fields change edit strategy so there should be no pending edits now anyway.
This commit is contained in:
parent
dac6a2cc26
commit
d5c59e51c1
@ -51,7 +51,7 @@ CabrilloLog::impl::impl (Configuration const * configuration)
|
|||||||
SQL_error_check (export_query_, &QSqlQuery::prepare,
|
SQL_error_check (export_query_, &QSqlQuery::prepare,
|
||||||
"SELECT frequency, \"when\", exchange_sent, call, exchange_rcvd FROM cabrillo_log ORDER BY \"when\"");
|
"SELECT frequency, \"when\", exchange_sent, call, exchange_rcvd FROM cabrillo_log ORDER BY \"when\"");
|
||||||
|
|
||||||
setEditStrategy (QSqlTableModel::OnRowChange);
|
setEditStrategy (QSqlTableModel::OnFieldChange);
|
||||||
setTable ("cabrillo_log");
|
setTable ("cabrillo_log");
|
||||||
setHeaderData (fieldIndex ("frequency"), Qt::Horizontal, tr ("Freq(kHz)"));
|
setHeaderData (fieldIndex ("frequency"), Qt::Horizontal, tr ("Freq(kHz)"));
|
||||||
setHeaderData (fieldIndex ("when"), Qt::Horizontal, tr ("Date & Time(UTC)"));
|
setHeaderData (fieldIndex ("when"), Qt::Horizontal, tr ("Date & Time(UTC)"));
|
||||||
@ -109,6 +109,10 @@ 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_sent", exchange_sent);
|
||||||
set_value_maybe_null (record, "exchange_rcvd", exchange_received);
|
set_value_maybe_null (record, "exchange_rcvd", exchange_received);
|
||||||
set_value_maybe_null (record, "band", m_->configuration_->bands ()->find (frequency));
|
set_value_maybe_null (record, "band", m_->configuration_->bands ()->find (frequency));
|
||||||
|
if (m_->isDirty ())
|
||||||
|
{
|
||||||
|
m_->revert (); // discard any uncommitted changes
|
||||||
|
}
|
||||||
auto ok = m_->insertRecord (-1, record);
|
auto ok = m_->insertRecord (-1, record);
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
@ -135,7 +139,7 @@ void CabrilloLog::reset ()
|
|||||||
SQL_error_check (*m_, &QSqlTableModel::removeRows, 0, m_->rowCount (), QModelIndex {});
|
SQL_error_check (*m_, &QSqlTableModel::removeRows, 0, m_->rowCount (), QModelIndex {});
|
||||||
transaction.submit ();
|
transaction.submit ();
|
||||||
m_->select (); // to refresh views
|
m_->select (); // to refresh views
|
||||||
m_->setEditStrategy (QSqlTableModel::OnRowChange);
|
m_->setEditStrategy (QSqlTableModel::OnFieldChange);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ FoxLog::impl::impl ()
|
|||||||
SQL_error_check (dupe_query_, &QSqlQuery::prepare,
|
SQL_error_check (dupe_query_, &QSqlQuery::prepare,
|
||||||
"SELECT COUNT(*) FROM fox_log WHERE call = :call AND band = :band");
|
"SELECT COUNT(*) FROM fox_log WHERE call = :call AND band = :band");
|
||||||
|
|
||||||
setEditStrategy (QSqlTableModel::OnRowChange);
|
setEditStrategy (QSqlTableModel::OnFieldChange);
|
||||||
setTable ("fox_log");
|
setTable ("fox_log");
|
||||||
setHeaderData (fieldIndex ("when"), Qt::Horizontal, tr ("Date & Time(UTC)"));
|
setHeaderData (fieldIndex ("when"), Qt::Horizontal, tr ("Date & Time(UTC)"));
|
||||||
setHeaderData (fieldIndex ("call"), Qt::Horizontal, tr ("Call"));
|
setHeaderData (fieldIndex ("call"), Qt::Horizontal, tr ("Call"));
|
||||||
@ -100,6 +100,10 @@ bool FoxLog::add_QSO (QDateTime const& when, QString const& call, QString const&
|
|||||||
set_value_maybe_null (record, "report_sent", report_sent);
|
set_value_maybe_null (record, "report_sent", report_sent);
|
||||||
set_value_maybe_null (record, "report_rcvd", report_received);
|
set_value_maybe_null (record, "report_rcvd", report_received);
|
||||||
set_value_maybe_null (record, "band", band);
|
set_value_maybe_null (record, "band", band);
|
||||||
|
if (m_->isDirty ())
|
||||||
|
{
|
||||||
|
m_->revert (); // discard any uncommitted changes
|
||||||
|
}
|
||||||
auto ok = m_->insertRecord (-1, record);
|
auto ok = m_->insertRecord (-1, record);
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
@ -126,6 +130,6 @@ void FoxLog::reset ()
|
|||||||
SQL_error_check (*m_, &QSqlTableModel::removeRows, 0, m_->rowCount (), QModelIndex {});
|
SQL_error_check (*m_, &QSqlTableModel::removeRows, 0, m_->rowCount (), QModelIndex {});
|
||||||
transaction.submit ();
|
transaction.submit ();
|
||||||
m_->select (); // to refresh views
|
m_->select (); // to refresh views
|
||||||
m_->setEditStrategy (QSqlTableModel::OnRowChange);
|
m_->setEditStrategy (QSqlTableModel::OnFieldChange);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user