summaryrefslogtreecommitdiff
path: root/models/CabrilloLog.cpp
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2022-08-08 23:08:17 +0200
committerChristoph Berg <myon@debian.org>2022-08-08 23:08:17 +0200
commit43bebfbad6e7ba026bd3d55720c7d9e12a7ef8ef (patch)
treefac973fdc7378510849f4d749cd311176c023ebb /models/CabrilloLog.cpp
parentd47341d71ff3df889c1180eb7bfb4fc0272eb26b (diff)
New upstream version 2.6.0~rc2+repackupstream/2.6.0_rc2+repack
Diffstat (limited to 'models/CabrilloLog.cpp')
-rwxr-xr-xmodels/CabrilloLog.cpp16
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