digiKam
iteminfo.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2005-04-21
7  * Description : Handling access to one item and associated data
8  *
9  * Copyright (C) 2005 by Renchi Raju <renchi dot raju at gmail dot com>
10  * Copyright (C) 2007-2013 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
11  * Copyright (C) 2009-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
12  * Copyright (C) 2013 by Michael G. Hansen <mike at mghansen dot de>
13  *
14  * This program is free software; you can redistribute it
15  * and/or modify it under the terms of the GNU General
16  * Public License as published by the Free Software Foundation;
17  * either version 2, or (at your option)
18  * any later version.
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  * GNU General Public License for more details.
24  *
25  * ============================================================ */
26 
27 #ifndef DIGIKAM_ITEM_INFO_H
28 #define DIGIKAM_ITEM_INFO_H
29 
30 // Qt includes
31 
32 #include <QUrl>
33 #include <QList>
34 #include <QSize>
35 #include <QString>
36 #include <QDateTime>
37 #include <QExplicitlySharedDataPointer>
38 
39 // Local includes
40 
41 #include "digikam_export.h"
42 #include "coredbalbuminfo.h"
43 #include "coredburl.h"
44 #include "coredbfields.h"
45 #include "iteminfolist.h"
46 
47 namespace Digikam
48 {
49 
50 class DImageHistory;
51 class HistoryImageId;
52 class ItemComments;
53 class ImageCommonContainer;
54 class ItemCopyright;
55 class ItemExtendedProperties;
56 class ItemInfoData;
57 class ItemListerRecord;
58 class ImageMetadataContainer;
59 class VideoMetadataContainer;
60 class ItemPosition;
61 class ItemTagPair;
62 class PhotoInfoContainer;
63 class VideoInfoContainer;
64 class Template;
65 class ThumbnailIdentifier;
66 class ThumbnailInfo;
67 
77 class DIGIKAM_DATABASE_EXPORT ItemInfo
78 {
79 public:
80 
82 
83 public:
84 
89  ItemInfo();
90 
95  explicit ItemInfo(qlonglong ID);
96 
101  explicit ItemInfo(const ItemListerRecord& record);
102 
106  ItemInfo(const ItemInfo& info);
107 
111  ~ItemInfo();
112 
116  static ItemInfo fromLocalFile(const QString& path);
117  static ItemInfo fromUrl(const QUrl& url);
118 
123  static ItemInfo fromLocationAlbumAndName(int locationId, const QString& album, const QString& name);
124 
125  ItemInfo& operator=(const ItemInfo& info);
126 
127  bool operator==(const ItemInfo& info) const;
128  bool operator!=(const ItemInfo& info) const;
129  bool operator<(const ItemInfo& info) const;
130 
137  ItemInfo copyItem(int dstAlbumID, const QString& dstFileName);
138 
144  bool isLocationAvailable() const;
145 
146 public:
147 
148  // -----------------------------------------------------------------------------
149 
154 
158  bool isNull() const;
159 
163  QString name() const;
164 
168  QDateTime dateTime() const;
169 
173  QDateTime modDateTime() const;
174 
178  qlonglong fileSize() const;
179 
184  QSize dimensions() const;
185 
190  QUrl fileUrl() const;
191 
195  QString filePath() const;
196 
200  qlonglong id() const;
201 
205  int albumId() const;
206 
210  int albumRootId() const;
211 
215  double aspectRatio() const;
216 
220  qlonglong manualOrder() const;
221 
225  DatabaseItem::Category category() const;
226 
231  QString format() const;
232 
236  bool isVisible() const;
237 
241  bool isRemoved() const;
242 
247  int orientation() const;
248 
252  QString title() const;
253 
257  QString comment() const;
258 
262  int faceCount() const;
263 
267  int unconfirmedFaceCount() const;
268 
274  QMap<QString, QString> getSuggestedNames() const;
275 
280  void setName(const QString& newName);
281 
286  void setDateTime(const QDateTime& dateTime);
287 
292  void setModDateTime(const QDateTime& dateTime);
293 
297  void setManualOrder(qlonglong value);
298 
302  void setOrientation(int value);
303 
307  void setVisible(bool isVisible);
308 
312  DatabaseFieldsHashRaw getDatabaseFieldsRaw(const DatabaseFields::Set& requestedSet) const;
313  QVariant getDatabaseFieldRaw(const DatabaseFields::Set& requestedField) const;
314 
316 
317 public:
318 
319  // -----------------------------------------------------------------------------
320 
325 
329  ItemPosition imagePosition() const;
330 
335  double longitudeNumber() const;
336  double latitudeNumber() const;
337  double altitudeNumber() const;
338  bool hasCoordinates() const;
339  bool hasAltitude() const;
340 
342 
343 public:
344 
345  // -----------------------------------------------------------------------------
346 
351 
358  DImageHistory imageHistory() const;
359  void setItemHistory(const DImageHistory& history);
360  bool hasImageHistory() const;
361 
365  QString uuid() const;
366  void setUuid(const QString& uuid);
367 
371  HistoryImageId historyImageId() const;
372 
378  bool hasDerivedImages() const;
379  bool hasAncestorImages() const;
380 
381  QList<ItemInfo> derivedImages() const;
382  QList<ItemInfo> ancestorImages() const;
383 
388  QList<QPair<qlonglong, qlonglong> > relationCloud() const;
389 
394  void markDerivedFrom(const ItemInfo& ancestorImage);
395 
397 
398 public:
399 
400  // -----------------------------------------------------------------------------
401 
406 
410  bool isGrouped() const;
415  bool hasGroupedImages() const;
416  int numberOfGroupedImages() const;
417 
422  ItemInfo groupImage() const;
423  qlonglong groupImageId() const;
424 
429  QList<ItemInfo> groupedImages() const;
430 
434  void addToGroup(const ItemInfo& info);
435 
440  void removeFromGroup();
441 
446  void clearGroup();
447 
449 
450 public:
451 
452  // -----------------------------------------------------------------------------
453 
458 
464  ImageCommonContainer imageCommonContainer() const;
465  ImageMetadataContainer imageMetadataContainer() const;
466  VideoMetadataContainer videoMetadataContainer() const;
467  PhotoInfoContainer photoInfoContainer() const;
468  VideoInfoContainer videoInfoContainer() const;
469 
473  Template metadataTemplate() const;
474 
479  void setMetadataTemplate(const Template& t);
480 
484  void removeMetadataTemplate();
485 
493  ItemComments imageComments(CoreDbAccess& access) const;
494 
500  ItemCopyright imageCopyright() const;
501 
507  ItemExtendedProperties imageExtendedProperties() const;
508 
510 
511 public:
512 
513  // -----------------------------------------------------------------------------
514 
519 
524  void setTag(int tagID);
525 
530  void addTagPaths(const QStringList& tagPaths);
531 
536  void removeTag(int tagID);
537 
541  void removeAllTags();
542 
548  ItemTagPair imageTagPair(int tagId) const;
549  QList<ItemTagPair> availableItemTagPairs() const;
550 
557  QList<int> tagIds() const;
558 
559 private:
560 
561  void loadTagIds() const;
562 
564 
565 public:
566 
567  // -----------------------------------------------------------------------------
568 
574 
578  int pickLabel() const;
579 
583  int colorLabel() const;
584 
588  int rating() const;
589 
593  void setPickLabel(int value);
594 
598  void setColorLabel(int value);
599 
603  void setRating(int value);
604 
606 
607 public:
608 
609  // -----------------------------------------------------------------------------
610 
616 
620  ThumbnailIdentifier thumbnailIdentifier() const;
621  ThumbnailInfo thumbnailInfo() const;
622  static ThumbnailIdentifier thumbnailIdentifier(qlonglong id);
623 
625 
626 public:
627 
628  // -----------------------------------------------------------------------------
629 
635 
636  double similarityTo(const qlonglong imageId) const;
637  double currentSimilarity() const;
638 
642  qlonglong currentReferenceImage() const;
643 
647  uint hash() const;
648 
652  QList<ItemInfo> fromUniqueHash(const QString& uniqueHash, qlonglong fileSize);
653 
657  QString uniqueHash() const;
658 
660 
661 private:
662 
663  friend class ItemInfoCache;
664  friend class ItemInfoList;
665 
666  QExplicitlySharedDataPointer<ItemInfoData> m_data;
667 };
668 
669 inline uint qHash(const ItemInfo& info)
670 {
671  return info.hash();
672 }
673 
675 DIGIKAM_DATABASE_EXPORT QDebug operator<<(QDebug stream, const ItemInfo& info);
676 
677 } // namespace Digikam
678 
680 Q_DECLARE_METATYPE(Digikam::ItemInfo)
681 
682 #endif // DIGIKAM_ITEM_INFO_H
Definition: coredbaccess.h:56
Definition: dimagehistory.h:49
Definition: coredbfields.h:389
Definition: historyimageid.h:42
Definition: coredbinfocontainers.h:36
Definition: coredbinfocontainers.h:66
Definition: itemcomments.h:48
Definition: itemcopyright.h:48
Definition: itemextendedproperties.h:44
Definition: iteminfocache.h:47
Definition: iteminfolist.h:47
Definition: iteminfo.h:78
uint hash() const
Definition: iteminfo_similarity.cpp:70
DatabaseFields::Hash< QVariant > DatabaseFieldsHashRaw
Definition: iteminfo.h:81
Definition: itemlisterrecord.h:48
Definition: itemposition.h:47
Definition: itemtagpair.h:46
Definition: photoinfocontainer.h:41
Definition: template.h:46
Definition: thumbnailinfo.h:40
Definition: thumbnailinfo.h:58
Definition: videoinfocontainer.h:41
Definition: coredbinfocontainers.h:97
Q_DECLARE_TYPEINFO(Digikam::ItemInfo, Q_MOVABLE_TYPE)
qulonglong value
Definition: itemviewutilities.cpp:592
Category
Definition: coredbconstants.h:95
Definition: datefolderview.cpp:43
QDebug operator<<(QDebug dbg, const DbEngineParameters &p)
Definition: dbengineparameters.cpp:863
bool operator==(const SearchTextSettings &a, const SearchTextSettings &b)
Definition: searchtextbar.cpp:49
uint qHash(const PAlbumPath &id)
Definition: albummanager_p.h:141
bool operator<(const WSAlbum &first, const WSAlbum &second)
Definition: wstalker.cpp:47