diff options
| author | Christoph Berg <myon@debian.org> | 2022-08-08 23:08:31 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2022-08-08 23:08:31 +0200 |
| commit | dca111ba9c5235bb1a16d62c6999939bc1ac4cbe (patch) | |
| tree | 4eec80a7d177c16b0cbfe19219490c5b5c635367 /models/CabrilloLog.cpp | |
| parent | 231d846d6f285b93cf8fa3df50492d6b51446a4c (diff) | |
| parent | 43bebfbad6e7ba026bd3d55720c7d9e12a7ef8ef (diff) | |
Update upstream source from tag 'upstream/2.6.0_rc2+repack'
Update to upstream version '2.6.0~rc2+repack'
with Debian dir 381b71368ce7055e3f42f51abf3971cbbbbbd178
Diffstat (limited to 'models/CabrilloLog.cpp')
| -rwxr-xr-x | models/CabrilloLog.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/models/CabrilloLog.cpp b/models/CabrilloLog.cpp index b0459e19..77166859 100755 --- a/models/CabrilloLog.cpp +++ b/models/CabrilloLog.cpp @@ -73,7 +73,9 @@ public: Configuration const * configuration_; QSqlQuery mutable dupe_query_; QSqlQuery mutable export_query_; + QSqlQuery mutable qso_count_query_; bool adding_row_; + int n_qso(); }; CabrilloLog::impl::impl (CabrilloLog * self, Configuration const * configuration) @@ -109,6 +111,7 @@ CabrilloLog::impl::impl (CabrilloLog * self, Configuration const * configuration { Q_EMIT self_->data_changed (); } + Q_EMIT self_->qso_count_changed(self_->n_qso()); }); SQL_error_check (*this, &QSqlTableModel::select); @@ -132,6 +135,10 @@ CabrilloLog::impl::impl (CabrilloLog * self, Configuration const * configuration " cabrillo_log_v2 " " ORDER BY " " \"when\""); + + SQL_error_check (qso_count_query_, &QSqlQuery::prepare, + "SELECT COUNT(*) FROM cabrillo_log_v2"); + } void CabrilloLog::impl::create_table () @@ -234,8 +241,10 @@ bool CabrilloLog::add_QSO (Frequency frequency, QString const& mode, QDateTime c m_->adding_row_ = true; auto ok = m_->insertRecord (-1, record); transaction.submit (); + m_->adding_row_ = false; m_->setEditStrategy (QSqlTableModel::OnFieldChange); + Q_EMIT this->qso_count_changed(this->n_qso()); return ok; } @@ -256,6 +265,13 @@ bool CabrilloLog::dupe (Frequency frequency, QString const& call) const return false; } +int CabrilloLog::n_qso() +{ + SQL_error_check (m_->qso_count_query_, static_cast<bool (QSqlQuery::*) ()> (&QSqlQuery::exec)); + m_->qso_count_query_.first(); + return m_->qso_count_query_.value(0).toInt(); +} + void CabrilloLog::reset () { // synchronize model |
