2525#include < QSqlError>
2626#include < QSqlQuery>
2727
28+
29+ /* *
30+ * @struct FileList
31+ * @brief Files object to keep track of files.
32+ *
33+ */
2834struct FileList {
2935 QString path;
3036 QString md5sum;
3137};
3238
3339/* *
3440 * @struct FolderNames
35- * @brief Folder names game used on Windows
41+ * @brief Folder names game used on Windows.
42+ *
3643 * These names are used by steam and installed in the common folder on Linux.
3744 * Except for `TombEngine (TEN)` I made that one up.
3845 */
@@ -48,6 +55,13 @@ struct FolderNames {
4855 };
4956};
5057
58+ /* *
59+ * @struct ExecutableNames
60+ * @brief Executable game file names used on Windows used to start the games.
61+ *
62+ * These are searched for together with rootless tree patterns. Also used as a default
63+ * starter by using a symbolic link to the executable that links to ddraw, directx11 or opengl.
64+ */
5165struct ExecutableNames {
5266 QMap<int , QString> data = {
5367 {0 , " null" },
@@ -60,14 +74,33 @@ struct ExecutableNames {
6074 };
6175};
6276
77+ /* *
78+ * @struct ZipData
79+ * @brief Holds download information for a Tomb Raider Level.
80+ *
81+ * This struct is designed to store a TRLE download file record for trle.net or trcustoms.org.
82+ * Each file record contains data for downloading and file name etc for the application.
83+ */
6384struct ZipData {
6485 /* *
65- * @struct ZipData
66- * @brief
67- * @param
68- * @details
86+ * @brief Default constructor for `ZipData`.
87+ *
88+ * Initializes an empty instance of `ZipData`.
6989 */
7090 ZipData () {}
91+ /* *
92+ * @brief Parameterized constructor for `ZipData`.
93+ *
94+ * This constructor initializes a `ZipData` object with metadata.
95+ *
96+ * @param zipName TRLE level zip file name.
97+ * @param zipSize Size of the file form TRLE in MiB.
98+ * @param md5sum checksum of the archive.
99+ * @param url String of download address.
100+ * @param version File version from trcustoms.org
101+ * @param type Level type.
102+ * @param release date of file release.
103+ */
71104 ZipData (
72105 const QString& zipName,
73106 float zipSize,
@@ -77,21 +110,21 @@ struct ZipData {
77110 int type,
78111 const QString& release) :
79112 name (zipName),
80- megabyteSize (zipSize),
113+ mebibyteSize (zipSize),
81114 md5sum (md5sum),
82115 url (url),
83116 version (version),
84117 type (type),
85118 release (release) {}
86- QString name;
87- float megabyteSize;
88- QString md5sum;
89- QString url;
90- int version;
91- int type;
92- QString release;
93- };
94119
120+ QString name; // /< The archive file name.
121+ float mebibyteSize; // /< The archive file size in MiB.
122+ QString md5sum; // /< The archive md5sum.
123+ QString url; // /< The URL of the TRLE level download.
124+ int version; // /< The Version of trcustoms archive file.
125+ int type; // /< The TRLE type used to identify a executable.
126+ QString release; // /< The The date of file release from trcustoms.
127+ };
95128
96129/* *
97130 * @struct ListItemData
@@ -180,11 +213,11 @@ struct ListItemData {
180213
181214/* *
182215 * @struct InfoData
183- * @brief Store HTML data and a list of icons generated from image WEBP data.
216+ * @brief Store HTML data and a list of level pictures generated from image WEBP data.
184217 *
185218 * This struct is designed to store a body of HTML and convert a list of image data
186- * (provided as `QByteArray`) into `QIcon ` objects. The `QIcon ` objects can then
187- * be used in Qt-based applications with QtWebEngine and QIcons in a split view manner.
219+ * (provided as `QByteArray`) into `QPixmap ` objects. The `QPixmap ` objects can then
220+ * be used in Qt-based applications with QtWebEngine and QPixmap in a split view manner.
188221 */
189222struct InfoData {
190223 /* *
@@ -197,18 +230,18 @@ struct InfoData {
197230 /* *
198231 * @brief Constructs an `InfoData` object with the given body and image list.
199232 *
200- * Converts each image in the provided `QVector<QByteArray>` to a `QIcon ` object
233+ * Converts each image in the provided `QVector<QByteArray>` to a `QPixmap ` object
201234 * using the "WEBP" format and stores them in the icon list.
202235 *
203- * @param body A string representing the main textual content.
236+ * @param body A string representing the main textual content in HTML .
204237 * @param imageList A vector of image data in `QByteArray` format.
205238 */
206239 InfoData (const QString& body, const QVector<QByteArray>& imageList)
207240 : m_body(body) {
208241 for (const QByteArray& image : imageList) {
209242 QPixmap pixmap;
210243
211- // Load image data into a QPixmap and convert it to a QIcon
244+ // Load image data into a QPixmap
212245 if (!pixmap.loadFromData (image, " WEBP" )) {
213246 qDebug () << " Could not load webp data to QPixmap." ;
214247 }
@@ -221,16 +254,36 @@ struct InfoData {
221254 QVector<QPixmap> m_imageList; // /< A list of level large screen image data.
222255};
223256
257+ /* *
258+ * @class Data
259+ * @brief Data component connected to the Model in the MVC pattern.
260+ *
261+ * It handles database connection(s) and reads and write scraped data.
262+ * Its a singlton in global space that packs data into struct's and passes them
263+ * to and from the Model.
264+ *
265+ */
224266class Data : public QObject {
225267 Q_OBJECT
226268
227269 public:
270+ /* *
271+ * Mayers thread safe singleton pattern.
272+ */
228273 static Data& getInstance () {
229274 // cppcheck-suppress threadsafety-threadsafety
230275 static Data instance;
231276 return instance;
232277 }
233278
279+ /* *
280+ * @brief Connect to the main database.
281+ *
282+ * Once we setup camp in home, we can use the path to camp.
283+ * That is usually in ~/.local/share/AppName
284+ *
285+ * @param path Full path to the datbase without the file name.
286+ */
234287 bool initializeDatabase (const QString& path) {
235288 bool status = false ;
236289 const QString filePath = QString (" %1/%2" ).arg (path, " tombll.db" );
@@ -244,7 +297,6 @@ class Data : public QObject {
244297 } else {
245298 db = QSqlDatabase::addDatabase (" QSQLITE" );
246299 db.setDatabaseName (QString (" %1/tombll.db" ).arg (path));
247- // db.setConnectOptions("QSQLITE_OPEN_READONLY");
248300 if (db.open () == true ) { // flawfinder: ignore
249301 status = true ;
250302 } else {
@@ -255,19 +307,67 @@ class Data : public QObject {
255307 return status;
256308 }
257309
310+ /* *
311+ * @brief Close the connection to the main database.
312+ *
313+ * Dont need to be called before the application exit.
314+ */
258315 void releaseDatabase () {
259316 db.close ();
260317 }
261318
319+ /* *
320+ * @brief Count all the Level records in the database
321+ * @return The number of Level records
322+ */
262323 qint64 getListRowCount ();
324+ /* *
325+ * @brief Get the main list of levels, without the picture
326+ * @return The QVector ListItemData is all the level metadata
327+ */
263328 QVector<ListItemData> getListItems ();
329+ /* *
330+ * @brief Add Cover Pictures to ListItemData pointers
331+ * @param Cache like used QVector for holding ListItemData pointers
332+ */
264333 void getCoverPictures (QVector<ListItemData*>* items);
334+ /* *
335+ * @brief Get the info page, this is HTML and picture data you see on trel.net
336+ * @param
337+ * @return The InfoData is a struct of QString and QVector<QPixmap>
338+ */
265339 InfoData getInfo (int id);
340+ /* *
341+ * @brief Get the walkthrough HTML page
342+ * @param
343+ * @return
344+ */
266345 QString getWalkthrough (int id);
346+ /* *
347+ * @brief
348+ * @param
349+ * @return
350+ */
267351 int getType (int id);
268352
353+ /* *
354+ * @brief
355+ * @param
356+ * @return
357+ */
269358 QVector<FileList> getFileList (const int id);
359+ /* *
360+ * @brief
361+ * @param
362+ * @return
363+ */
270364 ZipData getDownload (const int id);
365+ /* *
366+ * @brief
367+ * @param
368+ * @param
369+ * @return
370+ */
271371 void setDownloadMd5 (const int id, const QString& newMd5sum);
272372
273373 private:
0 commit comments