mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-12-23 19:25:37 -05:00
Make sure database models are synchronized before using QSqlTableModel::rowCount()
This is necessary as the cached model will not reflect a correct row count if there are un-fetched rows.
This commit is contained in:
parent
ff1d3efab4
commit
12b6efb189
@ -46,10 +46,25 @@ CabrilloLog::impl::impl (Configuration const * configuration)
|
||||
}
|
||||
|
||||
SQL_error_check (dupe_query_, &QSqlQuery::prepare,
|
||||
"SELECT COUNT(*) FROM cabrillo_log WHERE call = :call AND band = :band");
|
||||
"SELECT "
|
||||
" COUNT(*) "
|
||||
" FROM "
|
||||
" cabrillo_log "
|
||||
" WHERE "
|
||||
" call = :call "
|
||||
" AND band = :band");
|
||||
|
||||
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::OnFieldChange);
|
||||
setTable ("cabrillo_log");
|
||||
@ -138,6 +153,8 @@ bool CabrilloLog::dupe (Frequency frequency, QString const& call) const
|
||||
|
||||
void CabrilloLog::reset ()
|
||||
{
|
||||
// synchronize model
|
||||
while (m_->canFetchMore ()) m_->fetchMore ();
|
||||
if (m_->rowCount ())
|
||||
{
|
||||
m_->setEditStrategy (QSqlTableModel::OnManualSubmit);
|
||||
|
@ -46,10 +46,26 @@ FoxLog::impl::impl (Configuration const * configuration)
|
||||
}
|
||||
|
||||
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");
|
||||
|
||||
SQL_error_check (export_query_, &QSqlQuery::prepare,
|
||||
"SELECT band, \"when\", call, grid, report_sent, report_rcvd FROM fox_log ORDER BY \"when\"");
|
||||
"SELECT "
|
||||
" band"
|
||||
" , \"when\""
|
||||
" , call"
|
||||
" , grid"
|
||||
" , report_sent"
|
||||
" , report_rcvd "
|
||||
" FROM "
|
||||
" fox_log "
|
||||
" ORDER BY "
|
||||
" \"when\"");
|
||||
|
||||
setEditStrategy (QSqlTableModel::OnFieldChange);
|
||||
setTable ("fox_log");
|
||||
@ -141,6 +157,8 @@ bool FoxLog::dupe (QString const& call, QString const& band) const
|
||||
|
||||
void FoxLog::reset ()
|
||||
{
|
||||
// synchronize model
|
||||
while (m_->canFetchMore ()) m_->fetchMore ();
|
||||
if (m_->rowCount ())
|
||||
{
|
||||
m_->setEditStrategy (QSqlTableModel::OnManualSubmit);
|
||||
|
Loading…
Reference in New Issue
Block a user