2
0

ADatabase.3 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. .TH "ADatabase" 3 "Tue May 4 2021" "openPilotLog" \" -*- nroff -*-
  2. .ad l
  3. .nh
  4. .SH NAME
  5. ADatabase \- The DB class encapsulates the SQL database by providing fast access to hot database data\&.
  6. .SH SYNOPSIS
  7. .br
  8. .PP
  9. .PP
  10. \fC#include <adatabase\&.h>\fP
  11. .PP
  12. Inherits QObject\&.
  13. .SS "Signals"
  14. .in +1c
  15. .ti -1c
  16. .RI "void \fBdataBaseUpdated\fP ()"
  17. .br
  18. .RI "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\&. "
  19. .ti -1c
  20. .RI "void \fBconnectionReset\fP ()"
  21. .br
  22. .RI "connectionReset is emitted whenever the database connection is reset, for example when creating or restoring a backup\&. "
  23. .in -1c
  24. .SS "Public Member Functions"
  25. .in +1c
  26. .ti -1c
  27. .RI "\fBADatabase\fP (const \fBADatabase\fP &)=delete"
  28. .br
  29. .ti -1c
  30. .RI "void \fBoperator=\fP (const \fBADatabase\fP &)=delete"
  31. .br
  32. .ti -1c
  33. .RI "int \fBdbRevision\fP () const"
  34. .br
  35. .RI "dbRevision returns the database Revision Number\&. The Revision refers to what iteration of the database layout is used\&. For the sqlite version of the database refer to \fBsqliteVersion()\fP "
  36. .ti -1c
  37. .RI "TableNames_T \fBgetTableNames\fP () const"
  38. .br
  39. .RI "Return the names of all tables in the database\&. "
  40. .ti -1c
  41. .RI "ColumnNames_T \fBgetTableColumns\fP (TableName_T table_name) const"
  42. .br
  43. .RI "Return the names of a given table in the database\&. "
  44. .ti -1c
  45. .RI "void \fBupdateLayout\fP ()"
  46. .br
  47. .RI "Updates the member variables tableNames and tableColumns with up-to-date layout information if the database has been altered\&. This function is normally only required during database setup or maintenance\&. "
  48. .ti -1c
  49. .RI "const QString \fBsqliteVersion\fP () const"
  50. .br
  51. .RI "\fBADatabase::sqliteVersion\fP returns the database sqlite version\&. See also \fBdbRevision()\fP "
  52. .ti -1c
  53. .RI "bool \fBconnect\fP ()"
  54. .br
  55. .RI "Connect to the database and populate database information\&. "
  56. .ti -1c
  57. .RI "void \fBdisconnect\fP ()"
  58. .br
  59. .RI "closes the database connection\&. "
  60. .ti -1c
  61. .RI "QVector< QVariant > \fBcustomQuery\fP (QString statement, int return_values)"
  62. .br
  63. .RI "Can be used to send a complex query to the database\&. "
  64. .ti -1c
  65. .RI "bool \fBexists\fP (\fBAEntry\fP entry)"
  66. .br
  67. .RI "Checks if an entry exists in the database, based on position data\&. "
  68. .ti -1c
  69. .RI "bool \fBexists\fP (\fBDataPosition\fP data_position)"
  70. .br
  71. .ti -1c
  72. .RI "bool \fBcommit\fP (\fBAEntry\fP entry)"
  73. .br
  74. .RI "commits an entry to the database, calls either insert or update, based on position data "
  75. .ti -1c
  76. .RI "bool \fBinsert\fP (\fBAEntry\fP new_entry)"
  77. .br
  78. .RI "Create new entry in the databse based on UserInput\&. "
  79. .ti -1c
  80. .RI "bool \fBupdate\fP (\fBAEntry\fP updated_entry)"
  81. .br
  82. .RI "Updates entry in database from existing entry tweaked by the user\&. "
  83. .ti -1c
  84. .RI "bool \fBremove\fP (\fBAEntry\fP entry)"
  85. .br
  86. .RI "deletes an entry from the database\&. "
  87. .ti -1c
  88. .RI "bool \fBremoveMany\fP (QList< \fBDataPosition\fP >)"
  89. .br
  90. .RI "deletes a list of entries from the database\&. Optimised for speed when deleting many entries\&. "
  91. .ti -1c
  92. .RI "RowData_T \fBgetEntryData\fP (\fBDataPosition\fP data_position)"
  93. .br
  94. .RI "retreive entry data from the database to create an entry object "
  95. .ti -1c
  96. .RI "\fBAEntry\fP \fBgetEntry\fP (\fBDataPosition\fP data_position)"
  97. .br
  98. .RI "retreive an Entry from the database\&. "
  99. .ti -1c
  100. .RI "\fBAPilotEntry\fP \fBgetPilotEntry\fP (RowId_T row_id)"
  101. .br
  102. .RI "retreives a PilotEntry from the database\&. "
  103. .ti -1c
  104. .RI "\fBATailEntry\fP \fBgetTailEntry\fP (RowId_T row_id)"
  105. .br
  106. .RI "retreives a TailEntry from the database\&. "
  107. .ti -1c
  108. .RI "\fBAAircraftEntry\fP \fBgetAircraftEntry\fP (RowId_T row_id)"
  109. .br
  110. .RI "retreives a TailEntry from the database\&. "
  111. .ti -1c
  112. .RI "\fBAFlightEntry\fP \fBgetFlightEntry\fP (RowId_T row_id)"
  113. .br
  114. .RI "retreives a flight entry from the database\&. "
  115. .ti -1c
  116. .RI "\fBACurrencyEntry\fP \fBgetCurrencyEntry\fP (ACurrencyEntry::CurrencyName currency_name)"
  117. .br
  118. .RI "Retreives a currency entry from the database\&. "
  119. .ti -1c
  120. .RI "const QStringList \fBgetCompletionList\fP (ADatabaseTarget target)"
  121. .br
  122. .RI "getCompletionList returns a QStringList of values for a QCompleter based on database values "
  123. .ti -1c
  124. .RI "const QMap< QString, RowId_T > \fBgetIdMap\fP (ADatabaseTarget target)"
  125. .br
  126. .RI "returns a QMap<QString, RowId_t> of a human-readable database value and its row id\&. Used in the Dialogs to map user input to unique database entries\&. "
  127. .ti -1c
  128. .RI "int \fBgetLastEntry\fP (ADatabaseTarget target)"
  129. .br
  130. .RI "returns the ROWID for the newest entry in the respective database\&. "
  131. .ti -1c
  132. .RI "QList< RowId_T > \fBgetForeignKeyConstraints\fP (RowId_T foreign_row_id, ADatabaseTarget target)"
  133. .br
  134. .RI "returns a list of ROWID's in the flights table for which foreign key constraints exist\&. "
  135. .ti -1c
  136. .RI "\fBAPilotEntry\fP \fBresolveForeignPilot\fP (RowId_T foreign_key)"
  137. .br
  138. .RI "Resolves the foreign key in a flight entry\&. "
  139. .ti -1c
  140. .RI "\fBATailEntry\fP \fBresolveForeignTail\fP (RowId_T foreign_key)"
  141. .br
  142. .RI "Resolves the foreign key in a flight entry\&. "
  143. .ti -1c
  144. .RI "QMap< ADatabaseSummaryKey, QString > \fBdatabaseSummary\fP (const QString &db_path)"
  145. .br
  146. .RI "Return a summary of a database\&. "
  147. .ti -1c
  148. .RI "const QString \fBdatabaseSummaryString\fP (const QString &db_path)"
  149. .br
  150. .RI "returns a short summary string of the database, containing total time and date of last flight\&. "
  151. .ti -1c
  152. .RI "bool \fBrestoreBackup\fP (const QString &backup_file)"
  153. .br
  154. .RI "\fBADatabase::restoreBackup\fP restores the database from a given backup file and replaces the currently active database\&. "
  155. .ti -1c
  156. .RI "bool \fBcreateBackup\fP (const QString &dest_file)"
  157. .br
  158. .RI "\fBADatabase::createBackup\fP copies the currently used database to an external backup location provided by the user\&. "
  159. .in -1c
  160. .SS "Static Public Member Functions"
  161. .in +1c
  162. .ti -1c
  163. .RI "static \fBADatabase\fP * \fBinstance\fP ()"
  164. .br
  165. .ti -1c
  166. .RI "static QSqlDatabase \fBdatabase\fP ()"
  167. .br
  168. .RI "Can be used to access the database connection\&. "
  169. .in -1c
  170. .SS "Public Attributes"
  171. .in +1c
  172. .ti -1c
  173. .RI "\fBADatabaseError\fP \fBlastError\fP"
  174. .br
  175. .RI "lastError extends QSqlError\&. Holds information about the last error that ocurred during a SQL operation\&. "
  176. .ti -1c
  177. .RI "const QFileInfo \fBdatabaseFile\fP"
  178. .br
  179. .in -1c
  180. .SH "Detailed Description"
  181. .PP
  182. The DB class encapsulates the SQL database by providing fast access to hot database data\&.
  183. .SH "Member Function Documentation"
  184. .PP
  185. .SS "bool ADatabase::createBackup (const QString & dest_file)"
  186. .PP
  187. \fBADatabase::createBackup\fP copies the currently used database to an external backup location provided by the user\&.
  188. .PP
  189. \fBParameters\fP
  190. .RS 4
  191. \fIdest_file\fP This is the full path and filename of where the backup will be created, e\&.g\&. 'home/Sully/myBackups/backupFromOpl\&.db'
  192. .RE
  193. .PP
  194. .SS "QVector< QVariant > ADatabase::customQuery (QString statement, int return_values)"
  195. .PP
  196. Can be used to send a complex query to the database\&.
  197. .PP
  198. \fBParameters\fP
  199. .RS 4
  200. \fIquery\fP - the full sql query statement
  201. .br
  202. \fIreturnValues\fP - the number of return values
  203. .RE
  204. .PP
  205. .SS "QSqlDatabase ADatabase::database ()\fC [static]\fP"
  206. .PP
  207. Can be used to access the database connection\&.
  208. .PP
  209. \fBReturns\fP
  210. .RS 4
  211. The QSqlDatabase object pertaining to the connection\&.
  212. .RE
  213. .PP
  214. .SS "QMap< ADatabaseSummaryKey, QString > ADatabase::databaseSummary (const QString & db_path)"
  215. .PP
  216. Return a summary of a database\&. Creates a summary of the database giving a quick overview of the relevant contents\&. The function runs several specialised SQL queries to create a QMap<ADatabaseSummaryKey, QString> containing Total Flight Time, Number of unique aircraft and pilots, as well as the date of last flight\&. Uses a temporary database connection separate from the default connection in order to not tamper with the currently active database connection\&.
  217. .SS "int ADatabase::dbRevision () const"
  218. .PP
  219. dbRevision returns the database Revision Number\&. The Revision refers to what iteration of the database layout is used\&. For the sqlite version of the database refer to \fBsqliteVersion()\fP
  220. .PP
  221. \fBReturns\fP
  222. .RS 4
  223. .RE
  224. .PP
  225. .SS "\fBAAircraftEntry\fP ADatabase::getAircraftEntry (RowId_T row_id)"
  226. .PP
  227. 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 \fBAAircraftEntry\fP instead of an \fBAEntry\fP\&. It allows for easy access to an aircraft entry with only the RowId required as input\&.
  228. .SS "\fBAFlightEntry\fP ADatabase::getFlightEntry (RowId_T row_id)"
  229. .PP
  230. 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 \fBAFlightEntry\fP instead of an \fBAEntry\fP\&. It allows for easy access to a flight entry with only the RowId required as input\&.
  231. .SS "const QMap< QString, RowId_T > ADatabase::getIdMap (ADatabaseTarget target)"
  232. .PP
  233. returns a QMap<QString, RowId_t> of a human-readable database value and its row id\&. Used in the Dialogs to map user input to unique database entries\&.
  234. .PP
  235. \fBTodo\fP
  236. .RS 4
  237. What is this QString semantically? As i understand its a 'QueryResult' QVariant cast to QString
  238. .RE
  239. .PP
  240. .SS "\fBAPilotEntry\fP ADatabase::getPilotEntry (RowId_T row_id)"
  241. .PP
  242. 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\&.
  243. .SS "\fBATailEntry\fP ADatabase::getTailEntry (RowId_T row_id)"
  244. .PP
  245. 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\&.
  246. .SS "\fBAPilotEntry\fP ADatabase::resolveForeignPilot (RowId_T foreign_key)"
  247. .PP
  248. Resolves the foreign key in a flight entry\&.
  249. .PP
  250. \fBReturns\fP
  251. .RS 4
  252. The Pilot Entry referencted by the foreign key\&.
  253. .RE
  254. .PP
  255. .SS "\fBATailEntry\fP ADatabase::resolveForeignTail (RowId_T foreign_key)"
  256. .PP
  257. Resolves the foreign key in a flight entry\&.
  258. .PP
  259. \fBReturns\fP
  260. .RS 4
  261. The Tail Entry referencted by the foreign key\&.
  262. .RE
  263. .PP
  264. .SS "bool ADatabase::restoreBackup (const QString & backup_file)"
  265. .PP
  266. \fBADatabase::restoreBackup\fP restores the database from a given backup file and replaces the currently active database\&.
  267. .PP
  268. \fBParameters\fP
  269. .RS 4
  270. \fIbackup_file\fP This is the full path and filename of the backup, e\&.g\&. 'home/Sully/myBackups/backupFromOpl\&.db'
  271. .RE
  272. .PP
  273. .SS "const QString ADatabase::sqliteVersion () const"
  274. .PP
  275. \fBADatabase::sqliteVersion\fP returns the database sqlite version\&. See also \fBdbRevision()\fP
  276. .PP
  277. \fBReturns\fP
  278. .RS 4
  279. sqlite version string
  280. .RE
  281. .PP
  282. .SH "Author"
  283. .PP
  284. Generated automatically by Doxygen for openPilotLog from the source code\&.