@@ -92,35 +92,47 @@ struct ZipData {
9292 QString release;
9393};
9494
95+
9596/* *
96- * @struct ListItemPicture
97- * @brief Represents a Tomb Raider Level Entry Card Picture .
97+ * @struct ListItemData
98+ * @brief Represents a Tomb Raider Level Entry Card Info .
9899 *
99- * This struct is designed to store a single TRLE (Tomb Raider Level Editor) level picture record.
100- * Each record is a cover image displayed as a card in the application.
100+ * This struct is designed to store a single TRLE (Tomb Raider Level Editor) level record.
101+ * Each record contains metadata and a cover image displayed as a card in the application.
102+ * The struct includes properties to facilitate searching, filtering, and sorting.
101103 */
102- struct ListItemPicture {
104+ struct ListItemData {
103105 /* *
104- * @brief Default constructor for `ListItemPicture `.
106+ * @brief Default constructor for `ListItemData `.
105107 *
106- * Initializes an empty instance of `ListItemPicture `.
108+ * Initializes an empty instance of `ListItemData `.
107109 */
108- ListItemPicture () {}
110+ ListItemData () {}
109111
110112 /* *
111- * @brief Parameterized constructor for `ListItemPicture `.
113+ * @brief Parameterized constructor for `ListItemData `.
112114 *
113- * This constructor initializes a `ListItemPicture` object with a cover image.
114- * The image is converted from raw `QByteArray` to a `QIcon` after scaling it to
115- * fit within 640x480 dimensions. The scaling maintains the aspect ratio and
116- * smooths out pixels using `Qt::SmoothTransformation`. The image is centered
117- * within a transparent background if its aspect ratio does not perfectly match the target.
115+ * This constructor initializes a `ListItemData` object with metadata.
118116 *
119117 * @param id The TRLE numeric level ID.
120- * @param imageData The cover image as a `QByteArray`. Supported formats include JPEG, PNG, and WEBP.
118+ * @param title The TRLE title. Expected to contain a single name.
119+ * @param author The TRLE author(s). Can be a single name or multiple names.
120+ * @param type The TRLE type, represented by a numeric ID.
121+ * @param classInput The TRLE class, represented by a numeric ID.
122+ * @param releaseDate The release date in the format "YYYY-MM-DD" (e.g., "2000-01-01").
123+ * @param difficulty The TRLE difficulty, represented by a numeric ID.
124+ * @param duration The TRLE duration, represented by a numeric ID.
125+ * @param m_cover The cover image as a `m_cover`.
121126 */
122- ListItemPicture (
123- qint64 id, QByteArray imageData) : m_trle_id(id) {
127+ ListItemData (
128+ qint64 id, const QString& title, const QStringList& authors,
129+ qint64 type, qint64 classInput, const QString& releaseDate,
130+ qint64 difficulty, qint64 duration) :
131+ m_trle_id (id), m_title(title), m_authors(authors), m_type(type),
132+ m_class (classInput), m_releaseDate(releaseDate),
133+ m_difficulty (difficulty), m_duration(duration) {}
134+
135+ void addPicture (const QByteArray& imageData) {
124136 // Load the image from the byte array
125137 QPixmap pixmap;
126138 pixmap.loadFromData (imageData, " WEBP" );
@@ -151,57 +163,9 @@ struct ListItemPicture {
151163 painter.drawPixmap (xOffset, yOffset, scaledPixmap);
152164 painter.end ();
153165
154- // Store the resulting pixmap in a QIcon
155- m_picture. addPixmap ( centeredPixmap) ;
166+ // Store the resulting pixmap in m_picture
167+ m_cover = centeredPixmap;
156168 }
157-
158- // Data members
159- qint64 m_trle_id; // /< The TRLE level id.
160- QIcon m_picture; // /< The cover image.
161- };
162-
163- /* *
164- * @struct ListItemData
165- * @brief Represents a Tomb Raider Level Entry Card Info.
166- *
167- * This struct is designed to store a single TRLE (Tomb Raider Level Editor) level record.
168- * Each record contains metadata and a cover image displayed as a card in the application.
169- * The struct includes properties to facilitate searching, filtering, and sorting without
170- * the cover image, just a pointer.
171- */
172- struct ListItemData {
173- /* *
174- * @brief Default constructor for `ListItemData`.
175- *
176- * Initializes an empty instance of `ListItemData`.
177- */
178- ListItemData () {}
179-
180- /* *
181- * @brief Parameterized constructor for `ListItemData`.
182- *
183- * This constructor initializes a `ListItemData` object with metadata.
184- *
185- * @param id The TRLE numeric level ID.
186- * @param title The TRLE title. Expected to contain a single name.
187- * @param author The TRLE author(s). Can be a single name or multiple names.
188- * @param type The TRLE type, represented by a numeric ID.
189- * @param classInput The TRLE class, represented by a numeric ID.
190- * @param releaseDate The release date in the format "YYYY-MM-DD" (e.g., "2000-01-01").
191- * @param difficulty The TRLE difficulty, represented by a numeric ID.
192- * @param duration The TRLE duration, represented by a numeric ID.
193- * @param m_cover The cover image as a `ListItemPicture*`.
194- */
195- ListItemData (
196- qint64 id, const QString& title, const QStringList& authors,
197- qint64 type, qint64 classInput, const QString& releaseDate,
198- qint64 difficulty, qint64 duration) :
199- m_trle_id (id), m_title(title), m_authors(authors), m_type(type),
200- m_class (classInput), m_releaseDate(releaseDate),
201- m_difficulty (difficulty), m_duration(duration) {
202- m_cover = nullptr ;
203- }
204-
205169 // Data members
206170 qint64 m_trle_id; // /< The TRLE level id.
207171 QString m_title; // /< The TRLE level title.
@@ -211,7 +175,7 @@ struct ListItemData {
211175 QString m_releaseDate; // /< The release date in "YYYY-MM-DD" format.
212176 qint64 m_difficulty; // /< ID of the difficulty of the level.
213177 qint64 m_duration; // /< ID of the estimated duration of the level.
214- ListItemPicture* m_cover; // /< The TRLE cover image pointer.
178+ QPixmap m_cover; // /< The TRLE cover image pointer.
215179};
216180
217181/* *
@@ -243,19 +207,18 @@ struct InfoData {
243207 : m_body(body) {
244208 for (const QByteArray& image : imageList) {
245209 QPixmap pixmap;
246- QIcon finalIcon;
247210
248211 // Load image data into a QPixmap and convert it to a QIcon
249- if (pixmap.loadFromData (image, " WEBP" ) == true ) {
250- finalIcon. addPixmap (pixmap) ;
212+ if (! pixmap.loadFromData (image, " WEBP" )) {
213+ qDebug () << " Could not load webp data to QPixmap. " ;
251214 }
252215
253- m_imageList.push_back (finalIcon );
216+ m_imageList.push_back (pixmap );
254217 }
255218 }
256219
257220 QString m_body; // /< The textual content associated with this object.
258- QVector<QIcon > m_imageList; // /< A list of icons generated from image data.
221+ QVector<QPixmap > m_imageList; // /< A list of level large screen image data.
259222};
260223
261224class Data : public QObject {
@@ -298,7 +261,7 @@ class Data : public QObject {
298261
299262 qint64 getListRowCount ();
300263 QVector<ListItemData> getListItems ();
301- QVector<ListItemPicture> getPictures (QList<qint64> trle_ids );
264+ void getCoverPictures (QVector<ListItemData*>* items );
302265 InfoData getInfo (int id);
303266 QString getWalkthrough (int id);
304267 int getType (int id);
0 commit comments