JS8Call-Improved master
Loading...
Searching...
No Matches
ActivityDB.h
Go to the documentation of this file.
1
5#pragma once
6
7#include <QDateTime>
8#include <QList>
9#include <QString>
10
46
47struct sqlite3;
48struct sqlite3_stmt;
49
50class ActivityDB {
51public:
57 struct CallRecord {
58 QString callsign;
59 QString through;
60 int snr = 0;
61 QString grid;
62 quint64 dial = 0;
63 int offset = 0;
64 int bits = 0;
65 float tdrift = 0.0f;
66 QDateTime cqTimestamp;
67 QDateTime ackTimestamp;
68 QDateTime utcTimestamp;
69 int submode = 0;
70 };
71
72 explicit ActivityDB(const QString &path);
73 ~ActivityDB();
74
75 ActivityDB(const ActivityDB &) = delete;
76 ActivityDB &operator=(const ActivityDB &) = delete;
77
78 bool open();
79 void close();
80
89 bool isOpen() const;
90
99 QString error() const;
100
108 bool begin();
109
117 bool commit();
118
120 void rollback();
121
123 bool inTransaction() const { return inTransaction_; }
124
125 // Call activity
126 bool upsertCall(const QString &config, const QString &band,
127 const CallRecord &record);
137 bool deleteCall(const QString &config, const QString &band,
138 const QString &callsign);
139 bool deleteCalls(const QString &config, const QString &band);
140
149 QList<CallRecord> loadCalls(const QString &config, const QString &band,
150 bool *ok = nullptr);
151
152 // RX text history (one HTML document per configuration + band)
153 bool saveRxText(const QString &config, const QString &band,
154 const QString &html);
155 QString loadRxText(const QString &config, const QString &band,
156 bool *ok = nullptr);
157 bool clearRxText(const QString &config, const QString &band);
158
165 bool hasImported(const QString &config, bool *ok = nullptr);
166
175 bool markImported(const QString &config);
176
186 bool clearConfig(const QString &config);
187
206 bool copyConfig(const QString &from, const QString &to);
207
208private:
209 void captureError();
210 bool noteResult(bool ok);
211 void noteFailureCaptured();
212
213 QString path_;
214 sqlite3 *db_;
215 QString lastError_;
216 bool inTransaction_;
217 bool pendingClose_; // third strike landed mid-transaction
218 int consecutiveFailures_;
220 sqlite3_stmt *upsertCallStmt_;
221 sqlite3_stmt *saveRxTextStmt_;
222};
QList< CallRecord > loadCalls(const QString &config, const QString &band, bool *ok=nullptr)
Load a band's stored calls.
Definition ActivityDB.cpp:437
bool copyConfig(const QString &from, const QString &to)
Copy everything stored for one configuration under a second configuration's id.
Definition ActivityDB.cpp:694
bool begin()
Batch several writes into a single transaction (legacy import, QSY offset rewrites).
Definition ActivityDB.cpp:274
bool inTransaction() const
Whether a transaction is currently open.
Definition ActivityDB.h:123
bool hasImported(const QString &config, bool *ok=nullptr)
Whether the legacy .ini import has run for a configuration.
Definition ActivityDB.cpp:589
bool clearConfig(const QString &config)
Wipe everything stored for a configuration.
Definition ActivityDB.cpp:640
void rollback()
Roll the open transaction back.
Definition ActivityDB.cpp:323
bool deleteCall(const QString &config, const QString &band, const QString &callsign)
Remove one stored call from a band.
Definition ActivityDB.cpp:377
bool markImported(const QString &config)
Record that the legacy .ini import has run.
Definition ActivityDB.cpp:618
bool open()
Open the store, creating or validating its schema.
Definition ActivityDB.cpp:194
bool isOpen() const
Whether the handle is usable.
Definition ActivityDB.cpp:270
bool commit()
Commit the open transaction.
Definition ActivityDB.cpp:304
QString error() const
The message captured at the most recent failure.
Definition ActivityDB.cpp:272
Definition qpriorityqueue.h:39
One persisted Call Activity row - the full CallDetail field set, so a band round-trip within a sessio...
Definition ActivityDB.h:57