 |
openPilotLog
|
25 #include <QSqlDatabase>
29 #include <QSqlTableModel>
34 #include "src/database/adatabasetypes.h"
35 #include "src/classes/aentry.h"
36 #include "src/classes/apilotentry.h"
37 #include "src/classes/atailentry.h"
38 #include "src/classes/aaircraftentry.h"
39 #include "src/classes/aflightentry.h"
40 #include "src/classes/astandardpaths.h"
41 #include "src/classes/acurrencyentry.h"
43 #define SQLITE_DRIVER QStringLiteral("QSQLITE")
52 #define aDB ADatabase::instance()
58 enum class ADatabaseTarget
61 airport_identifier_icao,
62 airport_identifier_iata,
63 airport_identifier_all,
74 enum class ADatabaseSummaryKey {
105 TableNames_T tableNames;
106 TableColumns_T tableColumns;
110 int checkDbVersion()
const;
114 const QFileInfo databaseFile;
118 void operator=(
const ADatabase&) =
delete;
121 int dbVersion()
const;
166 QVector<QVariant>
customQuery(QString statement,
int return_values);
267 const QMap<QString, RowId_T>
getIdMap(ADatabaseTarget target);
299 QMap<ADatabaseSummaryKey, QString>
databaseSummary(
const QString& db_path);
320 #endif // ADATABASE_H
bool exists(AEntry entry)
Checks if an entry exists in the database, based on position data.
Definition: adatabase.cpp:220
bool restoreBackup(const QString &backup_file)
ADatabase::restoreBackup restores the database from a given backup file and replaces the currently ac...
Definition: adatabase.cpp:752
void updateLayout()
Updates the member variables tableNames and tableColumns with up-to-date layout information if the da...
Definition: adatabase.cpp:65
APilotEntry resolveForeignPilot(RowId_T foreign_key)
Resolves the foreign key in a flight entry.
Definition: adatabase.cpp:623
const QStringList getCompletionList(ADatabaseTarget target)
getCompletionList returns a QStringList of values for a QCompleter based on database values
Definition: adatabase.cpp:461
void disconnect()
closes the database connection.
Definition: adatabase.cpp:122
Definition: aflightentry.h:23
APilotEntry getPilotEntry(RowId_T row_id)
retreives a PilotEntry from the database.
Definition: adatabase.cpp:426
Custom Database Error derived from QSqlError. Extends text() adding "Database Error: " before the tex...
Definition: adatabase.h:89
Definition: apilotentry.h:24
bool connect()
Connect to the database and populate database information.
Definition: adatabase.cpp:103
bool createBackup(const QString &dest_file)
ADatabase::createBackup copies the currently used database to an external backup location provided by...
Definition: adatabase.cpp:724
void connectionReset()
connectionReset is emitted whenever the database connection is reset, for example when creating or re...
const QString sqliteVersion() const
ADatabase::sqliteVersion returns database sqlite version.
Definition: adatabase.cpp:94
void dataBaseUpdated()
updated is emitted whenever the database contents have been updated. This can be either a commit,...
QVector< QVariant > customQuery(QString statement, int return_values)
Can be used to send a complex query to the database.
Definition: adatabase.cpp:633
QMap< ADatabaseSummaryKey, QString > databaseSummary(const QString &db_path)
Return the summary of the DB_PATH as a stringlist.
Definition: adatabase.cpp:658
AEntry getEntry(DataPosition data_position)
retreive an Entry from the database.
Definition: adatabase.cpp:419
ATailEntry getTailEntry(RowId_T row_id)
retreives a TailEntry from the database.
Definition: adatabase.cpp:433
AFlightEntry getFlightEntry(RowId_T row_id)
retreives a flight entry from the database.
Definition: adatabase.cpp:447
QList< RowId_T > getForeignKeyConstraints(RowId_T foreign_row_id, ADatabaseTarget target)
returns a list of ROWID's in the flights table for which foreign key constraints exist.
Definition: adatabase.cpp:586
AAircraftEntry getAircraftEntry(RowId_T row_id)
retreives a TailEntry from the database.
Definition: adatabase.cpp:440
Definition: adatabasetypes.h:44
Definition: atailentry.h:24
static QSqlDatabase database()
Can be used to access the database connection.
Definition: adatabase.cpp:129
The DB class encapsulates the SQL database by providing fast access to hot database data.
Definition: adatabase.h:100
bool remove(AEntry entry)
deletes an entry from the database.
Definition: adatabase.cpp:143
int getLastEntry(ADatabaseTarget target)
returns the ROWID for the newest entry in the respective database.
Definition: adatabase.cpp:558
TableNames_T getTableNames() const
Return the names of all tables in the database.
Definition: adatabase.cpp:60
RowData_T getEntryData(DataPosition data_position)
retreive entry data from the database to create an entry object
Definition: adatabase.cpp:362
bool removeMany(QList< DataPosition >)
deletes a list of entries from the database. Optimised for speed when deleting many entries.
Definition: adatabase.cpp:174
ACurrencyEntry getCurrencyEntry(ACurrencyEntry::CurrencyName currency_name)
Retreives a currency entry from the database.
Definition: adatabase.cpp:454
Definition: aaircraftentry.h:24
Definition: acurrencyentry.h:7
ATailEntry resolveForeignTail(RowId_T foreign_key)
Resolves the foreign key in a flight entry.
Definition: adatabase.cpp:628
const QMap< QString, RowId_T > getIdMap(ADatabaseTarget target)
returns a QMap<QString, RowId_t> of a human-readable database value and its row id....
Definition: adatabase.cpp:510
bool commit(AEntry entry)
commits an entry to the database, calls either insert or update, based on position data
Definition: adatabase.cpp:134
The Entry class encapsulates table metadata(table name, row id) and data for new and existing entries...
Definition: aentry.h:40
bool insert(AEntry new_entry)
Create new entry in the databse based on UserInput.
Definition: adatabase.cpp:316
ColumnNames_T getTableColumns(TableName_T table_name) const
Return the names of a given table in the database.
Definition: adatabase.cpp:55
bool update(AEntry updated_entry)
Updates entry in database from existing entry tweaked by the user.
Definition: adatabase.cpp:280