mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2026-06-05 07:24:38 -04:00
Validate contest QSO details before allowing logging
Basic validation, must have non-empty exchange sent and received. Abstracted log view window widget behaviour into a base class. Turned on auto resize to row height in log view windows and enabled alternating colours. Convert empty fields to NULL when inserting new log table rows to signify missing data. Trap insert row errors when adding to contest log table so that logging can be held back if constraints are not met. Re-factored log QSO processing to try insert row into log table first and pop up a message box if constraints are not met, this pops up the Log QSO window in case it was initiated by an auto log event.
This commit is contained in:
+34
-7
@@ -78,19 +78,46 @@ QAbstractItemModel * CabrilloLog::model ()
|
||||
return &*m_;
|
||||
}
|
||||
|
||||
void CabrilloLog::add_QSO (Frequency frequency, QDateTime const& when, QString const& call
|
||||
namespace
|
||||
{
|
||||
void set_value_maybe_null (QSqlRecord& record, QString const& name, QString const& value)
|
||||
{
|
||||
if (value.size ())
|
||||
{
|
||||
record.setValue (name, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
record.setNull (name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
record.setValue ("when", when.toMSecsSinceEpoch () / 1000ull);
|
||||
record.setValue ("call", call);
|
||||
record.setValue ("exchange_sent", exchange_sent);
|
||||
record.setValue ("exchange_rcvd", exchange_received);
|
||||
record.setValue ("band", m_->configuration_->bands ()->find (frequency));
|
||||
if (!when.isNull ())
|
||||
{
|
||||
record.setValue ("when", when.toMSecsSinceEpoch () / 1000ull);
|
||||
}
|
||||
else
|
||||
{
|
||||
record.setNull ("when");
|
||||
}
|
||||
set_value_maybe_null (record, "call", call);
|
||||
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);
|
||||
transaction.submit ();
|
||||
if (!transaction.submit (false))
|
||||
{
|
||||
transaction.revert ();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CabrilloLog::dupe (Frequency frequency, QString const& call) const
|
||||
|
||||
Reference in New Issue
Block a user