ADatabase.3 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. .TH "ADatabase" 3 "Fri Apr 30 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 \fBdbVersion\fP () const"
  34. .br
  35. .ti -1c
  36. .RI "TableNames_T \fBgetTableNames\fP () const"
  37. .br
  38. .RI "Return the names of all tables in the database\&. "
  39. .ti -1c
  40. .RI "ColumnNames_T \fBgetTableColumns\fP (TableName_T table_name) const"
  41. .br
  42. .RI "Return the names of a given table in the database\&. "
  43. .ti -1c
  44. .RI "void \fBupdateLayout\fP ()"
  45. .br
  46. .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\&. "
  47. .ti -1c
  48. .RI "const QString \fBsqliteVersion\fP () const"
  49. .br
  50. .RI "\fBADatabase::sqliteVersion\fP returns database sqlite version\&. "
  51. .ti -1c
  52. .RI "bool \fBconnect\fP ()"
  53. .br
  54. .RI "Connect to the database and populate database information\&. "
  55. .ti -1c
  56. .RI "void \fBdisconnect\fP ()"
  57. .br
  58. .RI "closes the database connection\&. "
  59. .ti -1c
  60. .RI "QVector< QVariant > \fBcustomQuery\fP (QString statement, int return_values)"
  61. .br
  62. .RI "Can be used to send a complex query to the database\&. "
  63. .ti -1c
  64. .RI "bool \fBexists\fP (\fBAEntry\fP entry)"
  65. .br
  66. .RI "Checks if an entry exists in the database, based on position data\&. "
  67. .ti -1c
  68. .RI "bool \fBexists\fP (\fBDataPosition\fP data_position)"
  69. .br
  70. .ti -1c
  71. .RI "bool \fBcommit\fP (\fBAEntry\fP entry)"
  72. .br
  73. .RI "commits an entry to the database, calls either insert or update, based on position data "
  74. .ti -1c
  75. .RI "bool \fBinsert\fP (\fBAEntry\fP new_entry)"
  76. .br
  77. .RI "Create new entry in the databse based on UserInput\&. "
  78. .ti -1c
  79. .RI "bool \fBupdate\fP (\fBAEntry\fP updated_entry)"
  80. .br
  81. .RI "Updates entry in database from existing entry tweaked by the user\&. "
  82. .ti -1c
  83. .RI "bool \fBremove\fP (\fBAEntry\fP entry)"
  84. .br
  85. .RI "deletes an entry from the database\&. "
  86. .ti -1c
  87. .RI "bool \fBremoveMany\fP (QList< \fBDataPosition\fP >)"
  88. .br
  89. .RI "deletes a list of entries from the database\&. Optimised for speed when deleting many entries\&. "
  90. .ti -1c
  91. .RI "RowData_T \fBgetEntryData\fP (\fBDataPosition\fP data_position)"
  92. .br
  93. .RI "retreive entry data from the database to create an entry object "
  94. .ti -1c
  95. .RI "\fBAEntry\fP \fBgetEntry\fP (\fBDataPosition\fP data_position)"
  96. .br
  97. .RI "retreive an Entry from the database\&. "
  98. .ti -1c
  99. .RI "\fBAPilotEntry\fP \fBgetPilotEntry\fP (RowId_T row_id)"
  100. .br
  101. .RI "retreives a PilotEntry from the database\&. "
  102. .ti -1c
  103. .RI "\fBATailEntry\fP \fBgetTailEntry\fP (RowId_T row_id)"
  104. .br
  105. .RI "retreives a TailEntry from the database\&. "
  106. .ti -1c
  107. .RI "\fBAAircraftEntry\fP \fBgetAircraftEntry\fP (RowId_T row_id)"
  108. .br
  109. .RI "retreives a TailEntry from the database\&. "
  110. .ti -1c
  111. .RI "\fBAFlightEntry\fP \fBgetFlightEntry\fP (RowId_T row_id)"
  112. .br
  113. .RI "retreives a flight entry from the database\&. "
  114. .ti -1c
  115. .RI "\fBACurrencyEntry\fP \fBgetCurrencyEntry\fP (ACurrencyEntry::CurrencyName currency_name)"
  116. .br
  117. .RI "Retreives a currency entry from the database\&. "
  118. .ti -1c
  119. .RI "const QStringList \fBgetCompletionList\fP (ADatabaseTarget target)"
  120. .br
  121. .RI "getCompletionList returns a QStringList of values for a QCompleter based on database values "
  122. .ti -1c
  123. .RI "const QMap< QString, RowId_T > \fBgetIdMap\fP (ADatabaseTarget target)"
  124. .br
  125. .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\&. "
  126. .ti -1c
  127. .RI "int \fBgetLastEntry\fP (ADatabaseTarget target)"
  128. .br
  129. .RI "returns the ROWID for the newest entry in the respective database\&. "
  130. .ti -1c
  131. .RI "QList< RowId_T > \fBgetForeignKeyConstraints\fP (RowId_T foreign_row_id, ADatabaseTarget target)"
  132. .br
  133. .RI "returns a list of ROWID's in the flights table for which foreign key constraints exist\&. "
  134. .ti -1c
  135. .RI "\fBAPilotEntry\fP \fBresolveForeignPilot\fP (RowId_T foreign_key)"
  136. .br
  137. .RI "Resolves the foreign key in a flight entry\&. "
  138. .ti -1c
  139. .RI "\fBATailEntry\fP \fBresolveForeignTail\fP (RowId_T foreign_key)"
  140. .br
  141. .RI "Resolves the foreign key in a flight entry\&. "
  142. .ti -1c
  143. .RI "QMap< ADatabaseSummaryKey, QString > \fBdatabaseSummary\fP (const QString &db_path)"
  144. .br
  145. .RI "Return the summary of the DB_PATH as a stringlist\&. "
  146. .ti -1c
  147. .RI "bool \fBrestoreBackup\fP (const QString &backup_file)"
  148. .br
  149. .RI "\fBADatabase::restoreBackup\fP restores the database from a given backup file and replaces the currently active database\&. "
  150. .ti -1c
  151. .RI "bool \fBcreateBackup\fP (const QString &dest_file)"
  152. .br
  153. .RI "\fBADatabase::createBackup\fP copies the currently used database to an external backup location provided by the user\&. "
  154. .in -1c
  155. .SS "Static Public Member Functions"
  156. .in +1c
  157. .ti -1c
  158. .RI "static \fBADatabase\fP * \fBinstance\fP ()"
  159. .br
  160. .ti -1c
  161. .RI "static QSqlDatabase \fBdatabase\fP ()"
  162. .br
  163. .RI "Can be used to access the database connection\&. "
  164. .in -1c
  165. .SS "Public Attributes"
  166. .in +1c
  167. .ti -1c
  168. .RI "\fBADatabaseError\fP \fBlastError\fP"
  169. .br
  170. .ti -1c
  171. .RI "const QFileInfo \fBdatabaseFile\fP"
  172. .br
  173. .in -1c
  174. .SH "Detailed Description"
  175. .PP
  176. The DB class encapsulates the SQL database by providing fast access to hot database data\&.
  177. .SH "Member Function Documentation"
  178. .PP
  179. .SS "bool ADatabase::createBackup (const QString & dest_file)"
  180. .PP
  181. \fBADatabase::createBackup\fP copies the currently used database to an external backup location provided by the user\&.
  182. .PP
  183. \fBParameters\fP
  184. .RS 4
  185. \fIdest_file\fP This is the full path and filename of where the backup will be created, e\&.g\&. 'home/Sully/myBackups/backupFromOpl\&.db'
  186. .RE
  187. .PP
  188. .SS "QVector< QVariant > ADatabase::customQuery (QString statement, int return_values)"
  189. .PP
  190. Can be used to send a complex query to the database\&.
  191. .PP
  192. \fBParameters\fP
  193. .RS 4
  194. \fIquery\fP - the full sql query statement
  195. .br
  196. \fIreturnValues\fP - the number of return values
  197. .RE
  198. .PP
  199. .SS "QSqlDatabase ADatabase::database ()\fC [static]\fP"
  200. .PP
  201. Can be used to access the database connection\&.
  202. .PP
  203. \fBReturns\fP
  204. .RS 4
  205. The QSqlDatabase object pertaining to the connection\&.
  206. .RE
  207. .PP
  208. .SS "QMap< ADatabaseSummaryKey, QString > ADatabase::databaseSummary (const QString & db_path)"
  209. .PP
  210. Return the summary of the DB_PATH as a stringlist\&.
  211. .PP
  212. \fBTodo\fP
  213. .RS 4
  214. Contemplate whether it should be a more generic function that may be used for different elements to summarize\&. and ADD DOCUMENTATION, theres some specific sql stuff going on\&.
  215. .RE
  216. .PP
  217. \fBReturns\fP
  218. .RS 4
  219. .RE
  220. .PP
  221. .SS "\fBAAircraftEntry\fP ADatabase::getAircraftEntry (RowId_T row_id)"
  222. .PP
  223. 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\&.
  224. .SS "\fBAFlightEntry\fP ADatabase::getFlightEntry (RowId_T row_id)"
  225. .PP
  226. 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\&.
  227. .SS "const QMap< QString, RowId_T > ADatabase::getIdMap (ADatabaseTarget target)"
  228. .PP
  229. 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\&.
  230. .PP
  231. \fBTodo\fP
  232. .RS 4
  233. What is this QString semantically? As i understand its a 'QueryResult' QVariant cast to QString
  234. .RE
  235. .PP
  236. .SS "\fBAPilotEntry\fP ADatabase::getPilotEntry (RowId_T row_id)"
  237. .PP
  238. 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\&.
  239. .SS "\fBATailEntry\fP ADatabase::getTailEntry (RowId_T row_id)"
  240. .PP
  241. 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\&.
  242. .SS "\fBAPilotEntry\fP ADatabase::resolveForeignPilot (RowId_T foreign_key)"
  243. .PP
  244. Resolves the foreign key in a flight entry\&.
  245. .PP
  246. \fBReturns\fP
  247. .RS 4
  248. The Pilot Entry referencted by the foreign key\&.
  249. .RE
  250. .PP
  251. .SS "\fBATailEntry\fP ADatabase::resolveForeignTail (RowId_T foreign_key)"
  252. .PP
  253. Resolves the foreign key in a flight entry\&.
  254. .PP
  255. \fBReturns\fP
  256. .RS 4
  257. The Tail Entry referencted by the foreign key\&.
  258. .RE
  259. .PP
  260. .SS "bool ADatabase::restoreBackup (const QString & backup_file)"
  261. .PP
  262. \fBADatabase::restoreBackup\fP restores the database from a given backup file and replaces the currently active database\&.
  263. .PP
  264. \fBParameters\fP
  265. .RS 4
  266. \fIbackup_file\fP This is the full path and filename of the backup, e\&.g\&. 'home/Sully/myBackups/backupFromOpl\&.db'
  267. .RE
  268. .PP
  269. \fBReturns\fP
  270. .RS 4
  271. .RE
  272. .PP
  273. .SS "const QString ADatabase::sqliteVersion () const"
  274. .PP
  275. \fBADatabase::sqliteVersion\fP returns database sqlite version\&.
  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\&.