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
1=== modified file 'src/database/media-table.cpp'
2--- src/database/media-table.cpp 2013-07-01 14:44:34 +0000
3+++ src/database/media-table.cpp 2015-01-20 13:15:55 +0000
4@@ -65,18 +65,20 @@
5 */
6 qint64 MediaTable::createIdForMedia(const QString& filename,
7 const QDateTime& timestamp, const QDateTime& exposureTime,
8- Orientation originalOrientation, qint64 filesize)
9+ Orientation originalOrientation, qint64 filesize, QSize size)
10 {
11 // Add the row.
12 QSqlQuery query(*m_db->getDB());
13 query.prepare("INSERT INTO MediaTable (filename, timestamp, exposure_time, "
14- "original_orientation, filesize) VALUES (:filename, :timestamp, "
15- ":exposure_time, :original_orientation, :filesize)");
16+ "original_orientation, filesize, width, height) VALUES (:filename, :timestamp, "
17+ ":exposure_time, :original_orientation, :filesize, :width, :height)");
18 query.bindValue(":filename", filename);
19 query.bindValue(":timestamp", timestamp.toMSecsSinceEpoch());
20 query.bindValue(":exposure_time", exposureTime.toMSecsSinceEpoch());
21 query.bindValue(":original_orientation", originalOrientation);
22 query.bindValue(":filesize", filesize);
23+ query.bindValue(":width", size.width());
24+ query.bindValue(":height", size.height());
25 if (!query.exec())
26 m_db->logSqlError(query);
27
28
29=== modified file 'src/database/media-table.h'
30--- src/database/media-table.h 2013-07-01 14:44:34 +0000
31+++ src/database/media-table.h 2015-01-20 13:15:55 +0000
32@@ -41,7 +41,7 @@
33
34 qint64 createIdForMedia(const QString& filename, const QDateTime& timestamp,
35 const QDateTime& exposureTime, Orientation originalOrientation,
36- qint64 filesize);
37+ qint64 filesize, QSize size);
38
39 void updateMedia(qint64 mediaId, const QString& filename,
40 const QDateTime& timestamp, const QDateTime& exposureTime,
41
42=== modified file 'src/media-object-factory.cpp'
43--- src/media-object-factory.cpp 2014-05-31 02:01:13 +0000
44+++ src/media-object-factory.cpp 2015-01-20 13:15:55 +0000
45@@ -150,9 +150,12 @@
46 return 0;
47 }
48
49+ // This will cause the real size to be read from the file
50+ if (photo) m_size = photo->size();
51+
52 // Add to DB.
53 id = m_mediaTable->createIdForMedia(file.absoluteFilePath(), m_timeStamp,
54- m_exposureTime, m_orientation, m_fileSize);
55+ m_exposureTime, m_orientation, m_fileSize, m_size);
56 } else {
57 // Load metadata from DB.
58 m_mediaTable->getRow(id, m_size, m_orientation, m_timeStamp, m_exposureTime);
59
60=== modified file 'src/photo/photo.cpp'
61--- src/photo/photo.cpp 2014-12-17 00:34:42 +0000
62+++ src/photo/photo.cpp 2015-01-20 13:15:55 +0000
63@@ -232,8 +232,9 @@
64 .toTransform());
65
66 // Cache this here since the image is already loaded.
67- if (!isSizeSet())
68+ if (!isSizeSet()) {
69 setSize(image.size());
70+ }
71 }
72
73 return image;
74
75=== modified file 'tests/unittests/stubs/media-table_stub.cpp'
76--- tests/unittests/stubs/media-table_stub.cpp 2013-07-01 14:44:34 +0000
77+++ tests/unittests/stubs/media-table_stub.cpp 2015-01-20 13:15:55 +0000
78@@ -33,6 +33,8 @@
79 QDateTime exposureTime;
80 Orientation originalOrientation;
81 qint64 filesize;
82+ int width;
83+ int height;
84 };
85
86 static qint64 mediaLastId = 0;
87@@ -62,7 +64,7 @@
88
89 qint64 MediaTable::createIdForMedia(const QString& filename,
90 const QDateTime& timestamp, const QDateTime& exposureTime,
91- Orientation originalOrientation, qint64 filesize)
92+ Orientation originalOrientation, qint64 filesize, QSize size)
93 {
94 MediaDataRow row;
95 row.id = mediaLastId;
96@@ -72,6 +74,8 @@
97 row.exposureTime = exposureTime;
98 row.originalOrientation = originalOrientation;
99 row.filesize = filesize;
100+ row.height = size.height();
101+ row.width = size.width();
102 mediaFakeTable.append(row);
103 return row.id;
104 }

Subscribers

People subscribed via source and target branches

to all changes: