Merge lp:~phablet-team/gallery-app/fix-crop-on-new-photos into lp:gallery-app

Proposed by Ugo Riboni
Status: Merged
Approved by: Arthur Mello
Approved revision: 1129
Merged at revision: 1131
Proposed branch: lp:~phablet-team/gallery-app/fix-crop-on-new-photos
Merge into: lp:gallery-app
Diff against target: 104 lines (+17/-7)
5 files modified
src/database/media-table.cpp (+5/-3)
src/database/media-table.h (+1/-1)
src/media-object-factory.cpp (+4/-1)
src/photo/photo.cpp (+2/-1)
tests/unittests/stubs/media-table_stub.cpp (+5/-1)
To merge this branch: bzr merge lp:~phablet-team/gallery-app/fix-crop-on-new-photos
Reviewer Review Type Date Requested Status
Arthur Mello (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+246441@code.launchpad.net

Commit message

Make sure the first time a photo is added to the database we read the actual size save it to the database

Description of the change

Make sure the first time a photo is added to the database we read the actual size save it to the database

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1129. By Ugo Riboni

Remove debug messages

Revision history for this message
Arthur Mello (artmello) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/database/media-table.cpp'
--- src/database/media-table.cpp 2013-07-01 14:44:34 +0000
+++ src/database/media-table.cpp 2015-01-20 13:15:55 +0000
@@ -65,18 +65,20 @@
65 */65 */
66qint64 MediaTable::createIdForMedia(const QString& filename,66qint64 MediaTable::createIdForMedia(const QString& filename,
67 const QDateTime& timestamp, const QDateTime& exposureTime,67 const QDateTime& timestamp, const QDateTime& exposureTime,
68 Orientation originalOrientation, qint64 filesize)68 Orientation originalOrientation, qint64 filesize, QSize size)
69{69{
70 // Add the row.70 // Add the row.
71 QSqlQuery query(*m_db->getDB());71 QSqlQuery query(*m_db->getDB());
72 query.prepare("INSERT INTO MediaTable (filename, timestamp, exposure_time, "72 query.prepare("INSERT INTO MediaTable (filename, timestamp, exposure_time, "
73 "original_orientation, filesize) VALUES (:filename, :timestamp, "73 "original_orientation, filesize, width, height) VALUES (:filename, :timestamp, "
74 ":exposure_time, :original_orientation, :filesize)");74 ":exposure_time, :original_orientation, :filesize, :width, :height)");
75 query.bindValue(":filename", filename);75 query.bindValue(":filename", filename);
76 query.bindValue(":timestamp", timestamp.toMSecsSinceEpoch());76 query.bindValue(":timestamp", timestamp.toMSecsSinceEpoch());
77 query.bindValue(":exposure_time", exposureTime.toMSecsSinceEpoch());77 query.bindValue(":exposure_time", exposureTime.toMSecsSinceEpoch());
78 query.bindValue(":original_orientation", originalOrientation);78 query.bindValue(":original_orientation", originalOrientation);
79 query.bindValue(":filesize", filesize);79 query.bindValue(":filesize", filesize);
80 query.bindValue(":width", size.width());
81 query.bindValue(":height", size.height());
80 if (!query.exec())82 if (!query.exec())
81 m_db->logSqlError(query);83 m_db->logSqlError(query);
8284
8385
=== modified file 'src/database/media-table.h'
--- src/database/media-table.h 2013-07-01 14:44:34 +0000
+++ src/database/media-table.h 2015-01-20 13:15:55 +0000
@@ -41,7 +41,7 @@
4141
42 qint64 createIdForMedia(const QString& filename, const QDateTime& timestamp,42 qint64 createIdForMedia(const QString& filename, const QDateTime& timestamp,
43 const QDateTime& exposureTime, Orientation originalOrientation,43 const QDateTime& exposureTime, Orientation originalOrientation,
44 qint64 filesize);44 qint64 filesize, QSize size);
4545
46 void updateMedia(qint64 mediaId, const QString& filename,46 void updateMedia(qint64 mediaId, const QString& filename,
47 const QDateTime& timestamp, const QDateTime& exposureTime,47 const QDateTime& timestamp, const QDateTime& exposureTime,
4848
=== modified file 'src/media-object-factory.cpp'
--- src/media-object-factory.cpp 2014-05-31 02:01:13 +0000
+++ src/media-object-factory.cpp 2015-01-20 13:15:55 +0000
@@ -150,9 +150,12 @@
150 return 0;150 return 0;
151 }151 }
152152
153 // This will cause the real size to be read from the file
154 if (photo) m_size = photo->size();
155
153 // Add to DB.156 // Add to DB.
154 id = m_mediaTable->createIdForMedia(file.absoluteFilePath(), m_timeStamp,157 id = m_mediaTable->createIdForMedia(file.absoluteFilePath(), m_timeStamp,
155 m_exposureTime, m_orientation, m_fileSize);158 m_exposureTime, m_orientation, m_fileSize, m_size);
156 } else {159 } else {
157 // Load metadata from DB.160 // Load metadata from DB.
158 m_mediaTable->getRow(id, m_size, m_orientation, m_timeStamp, m_exposureTime);161 m_mediaTable->getRow(id, m_size, m_orientation, m_timeStamp, m_exposureTime);
159162
=== modified file 'src/photo/photo.cpp'
--- src/photo/photo.cpp 2014-12-17 00:34:42 +0000
+++ src/photo/photo.cpp 2015-01-20 13:15:55 +0000
@@ -232,8 +232,9 @@
232 .toTransform());232 .toTransform());
233233
234 // Cache this here since the image is already loaded.234 // Cache this here since the image is already loaded.
235 if (!isSizeSet())235 if (!isSizeSet()) {
236 setSize(image.size());236 setSize(image.size());
237 }
237 }238 }
238239
239 return image;240 return image;
240241
=== modified file 'tests/unittests/stubs/media-table_stub.cpp'
--- tests/unittests/stubs/media-table_stub.cpp 2013-07-01 14:44:34 +0000
+++ tests/unittests/stubs/media-table_stub.cpp 2015-01-20 13:15:55 +0000
@@ -33,6 +33,8 @@
33 QDateTime exposureTime;33 QDateTime exposureTime;
34 Orientation originalOrientation;34 Orientation originalOrientation;
35 qint64 filesize;35 qint64 filesize;
36 int width;
37 int height;
36};38};
3739
38static qint64 mediaLastId = 0;40static qint64 mediaLastId = 0;
@@ -62,7 +64,7 @@
6264
63qint64 MediaTable::createIdForMedia(const QString& filename,65qint64 MediaTable::createIdForMedia(const QString& filename,
64 const QDateTime& timestamp, const QDateTime& exposureTime,66 const QDateTime& timestamp, const QDateTime& exposureTime,
65 Orientation originalOrientation, qint64 filesize)67 Orientation originalOrientation, qint64 filesize, QSize size)
66{68{
67 MediaDataRow row;69 MediaDataRow row;
68 row.id = mediaLastId;70 row.id = mediaLastId;
@@ -72,6 +74,8 @@
72 row.exposureTime = exposureTime;74 row.exposureTime = exposureTime;
73 row.originalOrientation = originalOrientation;75 row.originalOrientation = originalOrientation;
74 row.filesize = filesize;76 row.filesize = filesize;
77 row.height = size.height();
78 row.width = size.width();
75 mediaFakeTable.append(row);79 mediaFakeTable.append(row);
76 return row.id;80 return row.id;
77}81}

Subscribers

People subscribed via source and target branches

to all changes: