70
70
QString albumRootPath = CollectionManager::instance()->albumRootPath(shortInfo.albumRootID);
71
m_fileInfo = QFileInfo(DatabaseUrl::fromAlbumAndName(shortInfo.itemName,
72
shortInfo.album, albumRootPath, shortInfo.albumRootID).fileUrl().toLocalFile());
71
m_fileInfo = QFileInfo(DatabaseUrl::fromAlbumAndName(shortInfo.itemName,
72
shortInfo.album, albumRootPath, shortInfo.albumRootID).fileUrl().toLocalFile());
75
75
void ImageScanner::setCategory(DatabaseItem::Category category)
121
121
void ImageScanner::addImage(int albumId)
123
123
// there is a limit here for file size <2TB
124
m_scanInfo.albumID = albumId;
125
m_scanInfo.itemName = m_fileInfo.fileName();
126
m_scanInfo.status = DatabaseItem::Visible;
124
m_scanInfo.albumID = albumId;
125
m_scanInfo.itemName = m_fileInfo.fileName();
126
m_scanInfo.status = DatabaseItem::Visible;
127
128
// category is set by setCategory
128
129
m_scanInfo.modificationDate = m_fileInfo.lastModified();
129
int fileSize = (int)m_fileInfo.size();
130
int fileSize = (int)m_fileInfo.size();
130
132
// the QByteArray is an ASCII hex string
131
m_scanInfo.uniqueHash = uniqueHash();
133
m_scanInfo.uniqueHash = uniqueHash();
133
kDebug(digiKamAreaCode) << "Adding new item" << m_fileInfo.filePath();
134
m_scanInfo.id = DatabaseAccess().db()->addItem(m_scanInfo.albumID, m_scanInfo.itemName,
135
m_scanInfo.status, m_scanInfo.category,
136
m_scanInfo.modificationDate, fileSize,
137
m_scanInfo.uniqueHash);
135
kDebug() << "Adding new item" << m_fileInfo.filePath();
136
m_scanInfo.id = DatabaseAccess().db()->addItem(m_scanInfo.albumID, m_scanInfo.itemName,
137
m_scanInfo.status, m_scanInfo.category,
138
m_scanInfo.modificationDate, fileSize,
139
m_scanInfo.uniqueHash);
140
142
void ImageScanner::updateImage()
142
144
// part from addImage()
143
145
m_scanInfo.modificationDate = m_fileInfo.lastModified();
144
int fileSize = (int)m_fileInfo.size();
145
m_scanInfo.uniqueHash = uniqueHash();
146
int fileSize = (int)m_fileInfo.size();
147
m_scanInfo.uniqueHash = uniqueHash();
147
149
DatabaseAccess().db()->updateItem(m_scanInfo.id, m_scanInfo.category,
148
150
m_scanInfo.modificationDate, fileSize, m_scanInfo.uniqueHash);
207
209
// Sort by priority, as implemented by custom lessThan()
208
210
qStableSort(candidates.begin(), candidates.end(), lessThanForIdentity);
210
kDebug(digiKamAreaCode) << "Recognized" << m_fileInfo.filePath() << "as identical to item" << candidates.first().id;
212
kDebug() << "Recognized" << m_fileInfo.filePath() << "as identical to item" << candidates.first().id;
212
214
// Copy attributes.
213
215
// Todo for the future is to worry about syncing identical files.
224
226
// some basic validity checking
225
227
if (srcId == m_scanInfo.id)
227
230
ItemScanInfo info = access.db()->getItemScanInfo(srcId);
231
kDebug(digiKamAreaCode) << "Recognized" << m_fileInfo.filePath() << "as copied from" << srcId;
234
kDebug() << "Recognized" << m_fileInfo.filePath() << "as copied from" << srcId;
232
235
access.db()->copyImageAttributes(srcId, m_scanInfo.id);
291
294
DatabaseAccess access;
292
295
access.db()->changeImageInformation(m_scanInfo.id, infos,
293
DatabaseFields::Width
294
| DatabaseFields::Height
295
| DatabaseFields::Format
296
| DatabaseFields::ColorDepth
297
| DatabaseFields::ColorModel);
296
DatabaseFields::Width |
297
DatabaseFields::Height |
298
DatabaseFields::Format |
299
DatabaseFields::ColorDepth |
300
DatabaseFields::ColorModel);
300
303
static MetadataFields allImageMetadataFields()
502
505
foreach (const QString& key, keys)
504
507
KFileMetaInfoItem item = metaInfo.item(key);
505
kDebug(digiKamAreaCode) << item.name() << item.value();
508
kDebug() << item.name() << item.value();
535
538
if (m_hasMetadata)
537
540
m_img.setComments(m_metadata.getComments());
542
#if KEXIV2_VERSION >= 0x010000
543
m_img.setExif(m_metadata.getExifEncoded());
538
545
m_img.setExif(m_metadata.getExif());
539
548
m_img.setIptc(m_metadata.getIptc());
540
549
m_img.setXmp(m_metadata.getXmp());
806
817
DatabaseAccess access;
807
818
imagesFields = access.db()->getImagesFields(imageid,
808
DatabaseFields::Name |
819
DatabaseFields::Name |
809
820
DatabaseFields::ModificationDate |
810
821
DatabaseFields::FileSize);
812
823
imageInformationFields = access.db()->getImageInformation(imageid,
813
DatabaseFields::Rating |
814
DatabaseFields::CreationDate |
824
DatabaseFields::Rating |
825
DatabaseFields::CreationDate |
815
826
DatabaseFields::DigitizationDate |
816
DatabaseFields::Orientation |
817
DatabaseFields::Width |
818
DatabaseFields::Height |
819
DatabaseFields::Format |
820
DatabaseFields::ColorDepth |
827
DatabaseFields::Orientation |
828
DatabaseFields::Width |
829
DatabaseFields::Height |
830
DatabaseFields::Format |
831
DatabaseFields::ColorDepth |
821
832
DatabaseFields::ColorModel);