openPilotLog
experimental::ADatabase Class Reference

The DB class encapsulates the SQL database by providing fast access to hot database data. More...

#include <adatabase.h>

Inheritance diagram for experimental::ADatabase:

Signals

void dataBaseUpdated ()
 updated is emitted whenever the database contents have been updated. This can be either a commit, update or remove. This signal should be used to trigger an update to the models of the views displaying database contents in the user interface so that a user is always presented with up-to-date information.
 

Public Member Functions

 ADatabase (const ADatabase &)=delete
 
void operator= (const ADatabase &)=delete
 
bool connect ()
 Connect to the database and populate database information.
 
void disconnect ()
 closes the database connection.
 
QVector< QString > customQuery (QString statement, int return_values)
 Can be used to send a complex query to the database. More...
 
bool exists (AEntry entry)
 Checks if an entry exists in the database, based on position data.
 
bool exists (DataPosition data_position)
 
bool commit (AEntry entry)
 commits an entry to the database, calls either insert or update, based on position data
 
bool insert (AEntry new_entry)
 Create new entry in the databse based on UserInput.
 
bool update (AEntry updated_entry)
 Updates entry in database from existing entry tweaked by the user.
 
bool remove (AEntry entry)
 deletes an entry from the database.
 
bool removeMany (QList< DataPosition >)
 deletes a list of entries from the database. Optimised for speed when deleting many entries.
 
TableData getEntryData (DataPosition data_position)
 retreive entry data from the database to create an entry object
 
AEntry getEntry (DataPosition data_position)
 retreive an Entry from the database.
 
APilotEntry getPilotEntry (RowId row_id)
 retreives a PilotEntry from the database. More...
 
ATailEntry getTailEntry (RowId row_id)
 retreives a TailEntry from the database. More...
 
AAircraftEntry getAircraftEntry (RowId row_id)
 retreives a TailEntry from the database. More...
 
AFlightEntry getFlightEntry (RowId row_id)
 retreives a flight entry from the database. More...
 
const QStringList getCompletionList (ADatabaseTarget)
 getCompletionList returns a QStringList of values for a QCompleter based on database values
 
const QMap< QString, int > getIdMap (ADatabaseTarget)
 returns a QMap<QString, int> of a human-readable database value and its row id. Used in the Dialogs to map user input to unique database entries.
 
int getLastEntry (ADatabaseTarget)
 returns the ROWID for the newest entry in the respective database.
 
QList< int > getForeignKeyConstraints (int foreign_row_id, ADatabaseTarget target)
 returns a list of ROWID's in the flights table for which foreign key constraints exist.
 

Static Public Member Functions

static ADatabasegetInstance ()
 
static QSqlDatabase database ()
 Can be used to access the database connection. More...
 

Public Attributes

ADatabaseError lastError
 

Detailed Description

The DB class encapsulates the SQL database by providing fast access to hot database data.

Member Function Documentation

◆ customQuery()

QVector< QString > experimental::ADatabase::customQuery ( QString  statement,
int  return_values 
)

Can be used to send a complex query to the database.

Parameters
query- the full sql query statement
returnValues- the number of return values

◆ database()

QSqlDatabase experimental::ADatabase::database ( )
static

Can be used to access the database connection.

Returns
The QSqlDatabase object pertaining to the connection.

◆ getAircraftEntry()

AAircraftEntry experimental::ADatabase::getAircraftEntry ( RowId  row_id)

retreives a TailEntry from the database.

This function is a wrapper for DataBase::getEntry(DataPosition), where the table is already set and which returns an AAircraftEntry instead of an AEntry. It allows for easy access to an aircraft entry with only the RowId required as input.

◆ getFlightEntry()

AFlightEntry experimental::ADatabase::getFlightEntry ( RowId  row_id)

retreives a flight entry from the database.

This function is a wrapper for DataBase::getEntry(DataPosition), where the table is already set and which returns an AFlightEntry instead of an AEntry. It allows for easy access to a flight entry with only the RowId required as input.

◆ getPilotEntry()

APilotEntry experimental::ADatabase::getPilotEntry ( RowId  row_id)

retreives a PilotEntry from the database.

This function is a wrapper for DataBase::getEntry(DataPosition), where the table is already set and which returns a PilotEntry instead of an Entry. It allows for easy access to a pilot entry with only the RowId required as input.

◆ getTailEntry()

ATailEntry experimental::ADatabase::getTailEntry ( RowId  row_id)

retreives a TailEntry from the database.

This function is a wrapper for DataBase::getEntry(DataPosition), where the table is already set and which returns a TailEntry instead of an Entry. It allows for easy access to a tail entry with only the RowId required as input.


The documentation for this class was generated from the following files: