From a6ab7f1c6dcf3076aa5488a790d81f42cbc93b48 Mon Sep 17 00:00:00 2001 From: Alexander Golubev Date: Mon, 4 Aug 2025 03:29:51 +0300 Subject: Use TQImage rather than TQPixmap in the backend-oriented code TQImage is more suitable for i/o operations and long-term storage rather than TQPixmap (which is better for immediate display on the screen). The UI rarely does displays all those photos and does it one-by-one (i.e. there is no big gallery), so there is no significant performance penalty for the use of TQImage. On the contrary this way we should save some memory on allocations associated X11 stuff for pixmaps and loading time when the database contains a lot of photos. Note that there is yet another use of TQPixmap in `htmlexporter` which cannot be replaced because it uses TQPainter, which didn't supported QImage until Qt5. Signed-off-by: Alexander Golubev --- src/backends/qsqlrecipedb.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/backends/qsqlrecipedb.cpp') diff --git a/src/backends/qsqlrecipedb.cpp b/src/backends/qsqlrecipedb.cpp index ccd4cb8..4074338 100644 --- a/src/backends/qsqlrecipedb.cpp +++ b/src/backends/qsqlrecipedb.cpp @@ -518,14 +518,14 @@ void TQSqlRecipeDB::storePhoto( int recipeID, const TQByteArray &data ) query.exec(); } -void TQSqlRecipeDB::loadPhoto( int recipeID, TQPixmap &photo ) +void TQSqlRecipeDB::loadPhoto( int recipeID, TQImage &photo ) { TQString command = TQString( "SELECT photo FROM recipes WHERE id=%1;" ).arg( recipeID ); TQSqlQuery query( command, database ); if ( query.isActive() && query.first() ) { TQCString decodedPic; - TQPixmap pix; + TQImage img; KCodecs::base64Decode( query.value( 0 ).toCString(), decodedPic ); int len = decodedPic.size(); @@ -533,9 +533,9 @@ void TQSqlRecipeDB::loadPhoto( int recipeID, TQPixmap &photo ) TQByteArray picData( len ); memcpy( picData.data(), decodedPic.data(), len ); - bool ok = pix.loadFromData( picData, "JPEG" ); + bool ok = img.loadFromData( picData, "JPEG" ); if ( ok ) - photo = pix; + photo = img; } } } @@ -624,7 +624,7 @@ void TQSqlRecipeDB::saveRecipe( Recipe *recipe ) TQBuffer buffer( ba ); buffer.open( IO_WriteOnly ); TQImageIO iio( &buffer, "JPEG" ); - iio.setImage( recipe->photo.convertToImage() ); + iio.setImage( recipe->photo ); iio.write(); storePhoto( recipeID, ba ); -- cgit v1.2.3