digiKam
album.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 : 2004-06-15
7  * Description : digiKam album types
8  *
9  * Copyright (C) 2004-2005 by Renchi Raju <renchi dot raju at gmail dot com>
10  * Copyright (C) 2006-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
11  * Copyright (C) 2014-2015 by Mohamed_Anwer <m_dot_anwer at gmx dot com>
12  *
13  * This program is free software; you can redistribute it
14  * and/or modify it under the terms of the GNU General
15  * Public License as published by the Free Software Foundation;
16  * either version 2, or (at your option)
17  * any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * ============================================================ */
25 
26 #ifndef DIGIKAM_ALBUM_H
27 #define DIGIKAM_ALBUM_H
28 
29 // Qt includes
30 
31 #include <QMetaType>
32 #include <QList>
33 #include <QString>
34 #include <QMap>
35 #include <QUrl>
36 #include <QVector>
37 #include <QObject>
38 
39 // Local includes
40 
41 #include "coredbalbuminfo.h"
42 #include "digikam_export.h"
43 
44 namespace Digikam
45 {
46 
50 class Album;
52 
53 class CoreDbUrl;
54 
66 class DIGIKAM_GUI_EXPORT Album
67 {
68 public:
69 
70  enum Type
71  {
72  PHYSICAL=0,
73  TAG,
74  DATE,
76  FACE
77  };
78 
82  Album* parent() const;
83 
87  Album* firstChild() const;
88 
92  Album* lastChild() const;
93 
99  Album* next() const;
100 
106  Album* prev() const;
107 
111  Album* childAtRow(int row) const;
112 
116  AlbumList childAlbums(bool recursive = false);
117 
121  QList<int> childAlbumIds(bool recursive = false);
122 
127  Type type() const;
128 
138  int id() const;
139 
157  int globalID() const;
158 
162  int childCount() const;
163 
167  int rowFromAlbum() const;
168 
172  QString title() const;
173 
177  virtual CoreDbUrl databaseUrl() const = 0;
178 
182  bool isRoot() const;
183 
190  bool isAncestorOf(Album* const album) const;
191 
196  bool isUsedByLabelsTree() const;
197 
202  bool isTrashAlbum() const;
203 
233  void setExtraData(const void* const key, void* const value);
234 
242  void removeExtraData(const void* const key);
243 
251  void* extraData(const void* const key) const;
252 
259  void setUsedByLabelsTree(bool isUsed);
260 
267  static int globalID(Type type, int id);
268 
269 protected:
270 
274  Album(Album::Type type, int id, bool root);
275 
281  virtual ~Album();
282 
286  void clear();
287 
295  void setTitle(const QString& title);
296 
304  void setParent(Album* const parent);
305 
313  void insertChild(Album* const child);
314 
322  void removeChild(Album* const child);
323 
324 private:
325 
326  // Disable
327  Album() = delete;
328  Album& operator==(const Album&) = delete;
329  Q_DISABLE_COPY(Album)
330 
331 private:
332 
333  bool m_root;
334  bool m_usedByLabelsTree;
335 
336  int m_id;
337 
338  QString m_name;
339  QString m_title;
340 
341  QMap<const void*, void*> m_extraMap;
342  QVector<Album*> m_childCache;
343 
344  Type m_type;
345 
346  Album* m_parent;
347 
348  friend class AlbumManager;
349 };
350 
356 class DIGIKAM_GUI_EXPORT PAlbum : public Album
357 {
358 public:
359 
361  explicit PAlbum(const QString& title);
362 
364  PAlbum(int albumRoot, const QString& label);
365 
367  PAlbum(int albumRoot, const QString& parentPath, const QString& title, int id);
368 
370  PAlbum(const QString& parentPath, int albumRoot);
371  ~PAlbum() override;
372 
373  void setCaption(const QString& caption);
374  void setCategory(const QString& category);
375  void setDate(const QDate& date);
376 
377  QString albumRootPath() const;
378  QString albumRootLabel() const;
379  int albumRootId() const;
380  QString caption() const;
381  QString category() const;
382  QDate date() const;
383  QString albumPath() const;
384  QString prettyUrl() const;
385  QString folderPath() const;
386  CoreDbUrl databaseUrl() const override;
387  QUrl fileUrl() const;
388  qlonglong iconId() const;
389  bool isAlbumRoot() const;
390 
391 private:
392 
397  static int m_uniqueTrashId;
398 
399  bool m_isAlbumRootAlbum;
400 
401  int m_albumRootId;
402 
403  QString m_path;
404  QString m_parentPath;
405  QString m_category;
406  QString m_caption;
407  qlonglong m_iconId;
408 
409  QDate m_date;
410 
411  friend class AlbumManager;
412 };
413 
419 class DIGIKAM_GUI_EXPORT TAlbum : public Album
420 {
421 public:
422 
423  TAlbum(const QString& title, int id, bool root=false);
424  ~TAlbum() override;
425 
431  QString tagPath(bool leadingSlash = true) const;
432  QString standardIconName() const;
433  CoreDbUrl databaseUrl() const override;
434  QString prettyUrl() const;
435  QString icon() const;
436  qlonglong iconId() const;
437  QList<int> tagIDs() const;
438 
439  bool isInternalTag() const;
440  bool hasProperty(const QString& key) const;
441  QString property(const QString& key) const;
442  QMap<QString, QString> properties() const;
443 
444 private:
445 
446  int m_pid;
447 
448  QString m_icon;
449  qlonglong m_iconId;
450 
451  friend class AlbumManager;
452 };
453 
459 class DIGIKAM_GUI_EXPORT DAlbum : public Album
460 {
461 public:
462 
463  enum Range
464  {
465  Month = 0,
466  Year
467  };
468 
469 public:
470 
471  explicit DAlbum(const QDate& date, bool root=false, Range range=Month);
472  ~DAlbum() override;
473 
474  QDate date() const;
475  Range range() const;
476  CoreDbUrl databaseUrl() const override;
477 
478 private:
479 
480  static int m_uniqueID;
481  QDate m_date;
482  Range m_range;
483 
484  friend class AlbumManager;
485 };
486 
492 class DIGIKAM_GUI_EXPORT SAlbum : public Album
493 {
494 public:
495 
496  SAlbum(const QString& title, int id, bool root=false);
497  ~SAlbum() override;
498 
499  CoreDbUrl databaseUrl() const override;
500  QString query() const;
501  DatabaseSearch::Type searchType() const;
502  bool isNormalSearch() const;
503  bool isAdvancedSearch() const;
504  bool isKeywordSearch() const;
505  bool isTimelineSearch() const;
506  bool isHaarSearch() const;
507  bool isMapSearch() const;
508  bool isDuplicatesSearch() const;
509 
515  bool isTemporarySearch() const;
516 
517  QString displayTitle() const;
518 
529  static QString getTemporaryTitle(DatabaseSearch::Type type,
531 
539  static QString getTemporaryHaarTitle(DatabaseSearch::HaarSearchType haarType);
540 
541 private:
542 
543  void setSearch(DatabaseSearch::Type type, const QString& query);
544 
545 private:
546 
547  QString m_query;
548  DatabaseSearch::Type m_searchType;
549 
550  friend class AlbumManager;
551 };
552 
571 class DIGIKAM_GUI_EXPORT AlbumIterator
572 {
573 public:
574 
575  explicit AlbumIterator(Album* const album);
576  ~AlbumIterator();
577 
578  AlbumIterator& operator++();
579  Album* operator*();
580  Album* current() const;
581 
582 private:
583 
584  // Disable
585  AlbumIterator() = delete;
586  Q_DISABLE_COPY(AlbumIterator)
587 
588 private:
589 
590  Album* m_current;
591  Album* m_root;
592 };
593 
594 } // namespace Digikam
595 
596 Q_DECLARE_METATYPE(Digikam::Album*)
597 Q_DECLARE_METATYPE(QList<Digikam::TAlbum*>)
598 
599 #endif // DIGIKAM_ALBUM_H
Definition: album.h:572
Definition: albummanager.h:73
Abstract base class for all album types.
Definition: album.h:67
Type
Definition: album.h:71
@ DATE
A date album type.
Definition: album.h:74
@ SEARCH
A search album type.
Definition: album.h:75
@ TAG
A tag album type.
Definition: album.h:73
virtual CoreDbUrl databaseUrl() const =0
Definition: coredburl.h:43
Definition: album.h:460
Range
Definition: album.h:464
Definition: album.h:357
Definition: album.h:493
Definition: album.h:420
qulonglong value
Definition: itemviewutilities.cpp:592
@ Album
Definition: coredbfields.h:58
HaarSearchType
Definition: coredbconstants.h:72
@ HaarImageSearch
Definition: coredbconstants.h:73
Type
Definition: coredbconstants.h:60
Definition: datefolderview.cpp:43
QList< Album * > AlbumList
Definition: album.h:50
PointTransformAffine operator*(const PointTransformAffine &lhs, const PointTransformAffine &rhs)
Definition: pointtransformaffine.cpp:86
bool operator==(const SearchTextSettings &a, const SearchTextSettings &b)
Definition: searchtextbar.cpp:49
Type
Definition: gpsitemcontainer.h:45