Debian Codegraph @

core/libs/album/manager/albummanager.h

raw
1 /* ============================================================
2 *
3 * This file is a part of digiKam project
4 * https://www.digikam.org
5 *
6 * Date : 2004-06-15
7 * Description : Albums manager interface.
8 *
9 * SPDX-FileCopyrightText: 2004 by Renchi Raju <renchi dot raju at gmail dot com>
10 * SPDX-FileCopyrightText: 2006-2026 by Gilles Caulier <caulier dot gilles at gmail dot com>
11 * SPDX-FileCopyrightText: 2006-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
12 *
13 * SPDX-License-Identifier: GPL-2.0-or-later
14 *
15 * ============================================================ */
16
17 #pragma once
18
19 // Qt includes
20
21 #include <QList>
22 #include <QObject>
23 #include <QString>
24 #include <QMap>
25 #include <QUrl>
26 #include <QDate>
27 #include <QFileInfo>
28
29 // Local includes
30
31 #include "album.h"
32 #include "coredbalbuminfo.h"
33 #include "dbengineparameters.h"
34 #include "digikam_export.h"
35 #include "itemlisterrecord.h"
36
37 namespace Digikam
38 {
39
40 class FAlbum;
41 class CollectionLocation;
42 class AlbumChangeset;
43 class TagChangeset;
44 class SearchChangeset;
45 class CollectionImageChangeset;
46 class ImageTagChangeset;
47
48 /**
49 * @class AlbumManager
50 *
51 * AlbumManager manages albums: does listing of albums and controls the lifetime of it.
52 * For PAlbums and TAlbums, the listing is done by reading the db directly and
53 * building the hierarchy of the albums. For DAlbums, since the listing takes
54 * time, the work is delegated to a dbjob. Interested frontend entities can
55 * connect to the albummanager to receive notifications of new Albums, when
56 * Albums are deleted and when the current album is changed.
57 *
58 * Additional operations are provided for: creating/deleting/rename Albums,
59 * updating icons and moving Albums.
60 *
61 */
62 class DIGIKAM_GUI_EXPORT AlbumManager : public QObject
63 {
64 Q_OBJECT
65
66 public:
67
68 AlbumManager();
69 ~AlbumManager() override;
70
71 /**
72 * A convenience function to get the instance of the AlbumManager
73 */
74 static AlbumManager* instance();
75
76 /**
77 * starts scanning the libraryPath and listing the albums. If the
78 * libraryPath has not changed since the last scan, then nothing happens
79 * @see setLibraryPath
80 * @see refresh
81 */
82 void startScan();
83
84 /**
85 * Stop ongoing operations, prepare for application shutdown
86 */
87 void cleanUp();
88
89 /**
90 * This is similar to startScan, except that it assumes you have run
91 * startScan at least once. It checks the database to see if any new albums
92 * have been added and updates them accordingly. Use this when a change in the
93 * filesystem is detected (but the album library path hasn't changed)
94 * @see startScan
95 */
96 void refresh();
97
98 /**
99 * Ensures that valid item counts for physical and tag albums are available
100 */
101 void prepareItemCounts();
102
103 bool isShowingOnlyAvailableAlbums() const;
104 void setShowOnlyAvailableAlbums(bool onlyAvailable);
105
106 private Q_SLOTS:
107
108 void slotImagesDeleted(const QList<qlonglong>& imageIds);
109
110 // -----------------------------------------------------------------------------
111
112 /**
113 * @name Operations with database
114 */
115
116 //@{
117
118 public:
119
120 /**
121 * Initialize. Informs the user about failures.
122 * Returns true on success, false on failure.
123 * A return value of false during startup indicates termination of the program
124 * (user is informed)
125 *
126 * ignoreDisappearedLocations is intended to be used in tests, because the path of the collection is hardcoded
127 * but when executing the test on different computers the collection might not be available at that path
128 */
129 bool setDatabase(const DbEngineParameters& params, bool priority,
130 const QString& suggestedAlbumRoot = QString(), bool ignoreDisappearedLocations = false);
131
132 /**
133 * Sets new database when chosen by the user in setup.
134 * Handles user notification about problems.
135 * Call this instead of setDatabase when digiKam is up and running.
136 */
137 void changeDatabase(const DbEngineParameters& params);
138
139 /**
140 * Checks if the given database path is equal to the current one
141 */
142 bool databaseEqual(const DbEngineParameters& parameters) const;
143
144 /**
145 * Some checks for settings done in first run wizard in case of QSlite Database.
146 */
147 static void checkDatabaseDirsAfterFirstRun(const QString& dbPath, const QString& albumPath);
148
149 private:
150
151 static bool moveToBackup(const QFileInfo& info);
152 static bool copyToNewLocation(const QFileInfo& oldFile,
153 const QFileInfo& newFile,
154 const QString& otherMessage = QString());
155
156 //@}
157
158 // -----------------------------------------------------------------------------
159
160 /**
161 * @name Operations with collections
162 */
163
164 //@{
165
166 private:
167
168 /**
169 * Returns true if it added or removed an album.
170 */
171 bool handleCollectionStatusChange(const CollectionLocation& location, int oldStatus);
172
173 void addAlbumRoot(const CollectionLocation& location);
174 void removeAlbumRoot(const CollectionLocation& location);
175
176 private Q_SLOTS:
177
178 void slotCollectionLocationStatusChanged(const CollectionLocation&, int);
179 void slotCollectionLocationPropertiesChanged(const CollectionLocation& location);
180 void slotCollectionImageChange(const CollectionImageChangeset& changeset);
181
182 //@}
183
184 // -----------------------------------------------------------------------------
185
186 /**
187 * @name Operations on generic Album
188 */
189
190 //@{
191
192 public:
193
194 /**
195 * set current album to @p albums.
196 */
197 void setCurrentAlbums(const QList<Album*>& albums);
198
199 /**
200 * @returns current albums, previously set up by setCurrentAlbums
201 */
202 AlbumList currentAlbums() const;
203
204 /**
205 * clear current albums.
206 */
207 void clearCurrentAlbums();
208
209 /**
210 * @return a Album with the given globalID
211 * @param gid the global id for the album
212 */
213 Album* findAlbum(int gid) const;
214
215 /**
216 * @return a Album with the given type and id
217 * @param type the type of album
218 * @param id the id for the album (not the global id)
219 */
220 Album* findAlbum(Album::Type type, int id) const;
221
222 /**
223 * @return A hash with the titles for all album IDs.
224 */
225 QHash<int, QString> albumTitles() const;
226
227 /**
228 * Returns if the given album is currently being moved, that is,
229 * if this album is in between signalAlbumAboutToBeMoved and
230 * signalAlbumMoved. In this case, you can preserve state of such an album
231 * because the object is guaranteed not to be deleted, even if
232 * signalAlbumAboutToBeDeleted is emitted.
233 */
234 bool isMovingAlbum(Album* album) const;
235
236 /**
237 * Returns the id of the item with the given filename in
238 * the given Album.
239 * @param album The album in which we search the item.
240 * @param fileName The name of the item file.
241 * @return The item id or -1 if not existent.
242 */
243 qlonglong getItemFromAlbum(Album* const album, const QString& fileName);
244
245 private:
246
247 bool hasDirectChildAlbumWithTitle(Album* parent, const QString& title);
248 void notifyAlbumDeletion(Album* album);
249 void updateAlbumPathHash();
250 void addGuardedPointer(Album* a, Album** pointer);
251 void removeGuardedPointer(Album* a, Album** pointer);
252 void changeGuardedPointer(Album* oldAlbum, Album* a, Album** pointer);
253 void invalidateGuardedPointers(Album* album);
254
255 private Q_SLOTS:
256
257 void slotAlbumsJobResult();
258 void slotAlbumsJobData(const QHash<int, int>& albumsStatHash);
259 void slotAlbumChange(const AlbumChangeset& changeset);
260 void getAlbumItemsCount();
261
262 Q_SIGNALS:
263
264 /**
265 * Emitted when an album is about to be added to the given parent (0 if album is root)
266 * after the item given by prev (prev is 0 if parent has no children yet).
267 */
268 void signalAlbumAboutToBeAdded(Album* album, Album* parent, Album* prev);
269
270 /**
271 * Emitted when the album has been added.
272 */
273 void signalAlbumAdded(Album* album);
274
275 /**
276 * Emitted when the album is about to be deleted, but is still fully valid.
277 */
278 void signalAlbumAboutToBeDeleted(Album* album);
279
280 /**
281 * Emitted when the album is deleted, but the object can still be accessed.
282 */
283 void signalAlbumDeleted(Album* album);
284
285 /**
286 * Emitted when the album is deleted, the object can no longer be accessed.
287 * For identification purposes, the former album pointer is passed.
288 */
289 void signalAlbumHasBeenDeleted(Album* album);
290
291 void signalAlbumsCleared();
292 void signalAlbumCurrentChanged(const QList<Album*>& albums);
293 void signalAllAlbumsLoaded();
294
295 void signalAlbumIconChanged(Album* album);
296 void signalAlbumRenamed(Album* album);
297 void signalAlbumNewPath(Album* album);
298
299 /**
300 * Emittedd when an album is about to be moved. Signals for deleting and adding will be
301 * sent afterwards, but the album object is guaranteed not to be deleted until after signalAlbumMoved.
302 */
303 void signalAlbumAboutToBeMoved(Album* album);
304
305 /**
306 * Emitted when the album is moved to its new parent. After signalAlbumAboutToBeMoved,
307 * all four signals for first deleting and then adding will have been sent.
308 */
309 void signalAlbumMoved(Album* album);
310 void signalAlbumsUpdated(int type);
311
312 /**
313 * Emitted when a change is done on available Albums.
314 * Please note that affected albums may appear or disappear after this signal has been emitted.
315 */
316 void signalShowOnlyAvailableAlbumsChanged(bool showsOnlyAvailableAlbums);
317
318 //@}
319
320 // -----------------------------------------------------------------------------
321
322 /**
323 * @name Operations on Date Album
324 */
325
326 //@{
327
328 public:
329
330 /**
331 * @return a list of all DAlbums
332 */
333 AlbumList allDAlbums() const;
334
335 /**
336 * @return a DAlbum with given ID
337 * @param id the id for the DAlbum
338 */
339 DAlbum* findDAlbum(int id) const;
340
341 /**
342 * Returns the latest count for DAlbums as also emitted via
343 * signalDAlbumsDirty.
344 *
345 * @return count map for DAlbums
346 */
347 QMap<YearMonth, int> getDAlbumsCount() const;
348
349 private Q_SLOTS:
350
351 void slotDatesJobResult();
352 void slotDatesJobData(const QHash<QDateTime, int>& datesStatHash);
353
354 /**
355 * Scan dates from the database and updates the DAlbums.
356 */
357 void scanDAlbumsScheduled();
358 void scanDAlbums();
359
360 Q_SIGNALS:
361
362 void signalDAlbumsDirty(const QMap<YearMonth, int>&);
363 void signalDatesHashDirty(const QHash<QDateTime, int>&);
364 void signalAllDAlbumsLoaded();
365
366 //@}
367
368 // -----------------------------------------------------------------------------
369
370 /**
371 * @name Operations on Physical Album
372 */
373
374 //@{
375
376 public:
377
378 /**
379 * @return a list of all PAlbums
380 */
381 AlbumList allPAlbums() const;
382
383 /**
384 * @returns the current PAlbum or null if no one is selected
385 */
386 PAlbum* currentPAlbum() const;
387
388 /**
389 * Given a complete file url (kde url with file protocol), it will try to find
390 * a PAlbum corresponding to it.
391 * \warning This should not be used, unless really necessary
392 * @return PAlbum corresponding to supplied @p url
393 * @param url the url we need to check
394 */
395 PAlbum* findPAlbum(const QUrl& url) const;
396
397 /**
398 * @return a PAlbum with given ID
399 * @param id the id for the PAlbum
400 */
401 PAlbum* findPAlbum(int id) const;
402
403 /**
404 * Returns the latest count for PAlbums as also emitted via
405 * signalPAlbumsDirty.
406 *
407 * @return count map for PAlbums
408 */
409 QHash<int, int> getPAlbumsCount() const;
410
411 void removeWatchedPAlbums(const PAlbum* const album);
412
413 /**
414 * Create a new PAlbum with supplied properties as a child of the parent
415 * This is equivalent to creating a new folder on the disk with supplied
416 * name in the parent's folder path. Also the supplied attributes are written
417 * out to the database
418 * @note the signalAlbumAdded will be fired before this function returns. Its
419 * recommended to connect to that signal to get notification of new album added
420 * @return the newly created PAlbum or 0 if it fails
421 * @param parent the parent album under which to create the new Album.
422 * Parent must not be root. Otherwise, use the other variants of this method.
423 * If parent is root, the albumRootPath must be supplied.
424 * @param name the name of the new album
425 * @param caption the caption for the new album
426 * @param date the date for the new album
427 * @param category the category for the new album
428 * @param errMsg this will contain the error message describing why the operation failed
429 */
430 PAlbum* createPAlbum(PAlbum* parent,
431 const QString& name,
432 const QString& caption,
433 const QDate& date,
434 const QString& category,
435 QString& errMsg);
436
437 /**
438 * Overloaded method. Here you can supply an albumRootPath which must
439 * correspond to an available collection location.
440 */
441 PAlbum* createPAlbum(const QString& albumRootPath,
442 const QString& name,
443 const QString& caption,
444 const QDate& date,
445 const QString& category,
446 QString& errMsg);
447
448 /**
449 * Overloaded method. Here you can supply a collection location (which
450 * must be available).
451 *
452 * @param location the collection for the new album
453 * @param name the name of the new album
454 * @param caption the caption for the new album
455 * @param date the date for the new album
456 * @param category the category for the new album
457 * @param errMsg this will contain the error message describing why the operation failed
458 */
459 PAlbum* createPAlbum(const CollectionLocation& location,
460 const QString& name,
461 const QString& caption,
462 const QDate& date,
463 const QString& category,
464 QString& errMsg);
465
466 /**
467 * Renames a PAlbum. This is equivalent to actually renaming the corresponding
468 * folder on the disk.
469 *
470 * @return true if the operation succeeds, false otherwise
471 * @param album the Album which should be renamed
472 * @param newName the new name for the album
473 * @param errMsg this will contain the error message describing why the operation failed
474 */
475 bool renamePAlbum(PAlbum* album,
476 const QString& newName,
477 QString& errMsg);
478
479 /**
480 * Update the icon for an album. The @p icon is the name (and not full path)
481 * of the file in the album
482 *
483 * @return true if the operation succeeds, false otherwise
484 * @param album the album for which icon should be changed
485 * @param iconID the filename of the new icon
486 * @param errMsg if the operation fails, this will contain the error message describing why the operation failed
487 */
488 bool updatePAlbumIcon(PAlbum* album,
489 qlonglong iconID,
490 QString& errMsg);
491
492 private:
493
494 bool showDatabaseSetupPage(const QString& error, bool priority, const QString& suggestedAlbumRoot);
495 void insertPAlbum(PAlbum* album, PAlbum* parent);
496 void removePAlbum(PAlbum* album);
497
498 private Q_SLOTS:
499
500 /**
501 * Scan albums directly from database and creates new PAlbums
502 * It only creates those PAlbums which haven't already been
503 * created.
504 */
505 void scanPAlbums();
506 void updateChangedPAlbums();
507
508 Q_SIGNALS:
509
510 void signalPAlbumsDirty(const QHash<int, int>&);
511 void signalEmptyTrash();
512
513 //@}
514
515 // -----------------------------------------------------------------------------
516
517 /**
518 * @name Operations on Tag Album
519 */
520
521 //@{
522
523 public:
524
525 /**
526 * @return a list of all TAlbums
527 */
528 AlbumList allTAlbums() const;
529
530 /**
531 * @returns the current TAlbum or null if no one is selected
532 */
533 QList<TAlbum*> currentTAlbums() const;
534
535 /**
536 * @return a TAlbum with given ID
537 * @param id the id for the TAlbum
538 */
539 TAlbum* findTAlbum(int id) const;
540
541 /**
542 * @return a TAlbum with given tag path, or 0 if not found
543 * @param tagPath the tag path ("People/Friend/John")
544 */
545 TAlbum* findTAlbum(const QString& tagPath) const;
546
547 /**
548 * Returns the latest count for TAlbums as also emitted via
549 * signalTAlbumsDirty.
550 *
551 * @return count map for TAlbums
552 */
553 QHash<int, int> getTAlbumsCount() const;
554
555 /**
556 * Create a new TAlbum with supplied properties as a child of the parent
557 * The tag is added to the database
558 * @note the signalAlbumAdded will be fired before this function returns. Its
559 * recommended to connect to that signal to get notification of new album added
560 *
561 * @return the newly created TAlbum or 0 if it fails
562 * @param parent the parent album under which to create the new Album
563 * @param name the name of the new album
564 * @param iconkde the iconkde for the new album (this is a filename which kde iconloader can load up
565 * @param errMsg this will contain the error message describing why the operation failed
566 */
567 TAlbum* createTAlbum(TAlbum* parent,
568 const QString& name,
569 const QString& iconkde,
570 QString& errMsg);
571
572 /**
573 * A list of tag paths is supplied.
574 * If no corresponding TAlbum exists, a new one will be created.
575 *
576 * @param _tagPaths A list of tag paths
577 * @returns A list of all TAlbums for the list (already existing or newly created)
578 */
579 AlbumList findOrCreateTAlbums(const QStringList& _tagPaths);
580
581 /**
582 * Delete a TAlbum.
583 * The tag is removed from the database
584 * @note the signalAlbumDeleted will be fired before this function returns. Its
585 * recommended to connect to that signal to get notification of album deletes
586 *
587 * @return true if the operation succeeds or false otherwise
588 * @param album the TAlbum to delete
589 * @param errMsg this will contain the error message describing why the
590 * @param imageIds list of image ID from the database where tag is removed
591 */
592 bool deleteTAlbum(TAlbum* album, QString& errMsg, QList<qlonglong>* imageIds = nullptr);
593
594 /**
595 * Renames a TAlbum.
596 * This updates the tag name in the database
597 *
598 * @return true if the operation succeeds, false otherwise
599 * @param album the Album which should be renamed
600 * @param name the new name for the album
601 * @param errMsg this will contain the error message describing why the operation failed
602 */
603 bool renameTAlbum(TAlbum* album, const QString& name, QString& errMsg);
604
605 /**
606 * Move a TAlbum to a new parent.
607 * This updates the tag parent ID in the database
608 *
609 * @return true if the operation succeeds, false otherwise
610 * @param album the Album which should be moved
611 * @param newParent the Parent Album to which album should be moved
612 * @param errMsg this will contain the error message describing why the operation failed
613 */
614 bool moveTAlbum(TAlbum* album, TAlbum* newParent, QString& errMsg);
615
616 /**
617 * Merge a TAlbum to a TAlbum.
618 * This updates the image tags in the database
619 *
620 * @return true if the operation succeeds, false otherwise
621 * @param album the Album which should be merged
622 * @param destAlbum the Album to which album should be merged
623 * @param dialog show dialog to ask the user if he wants to merge
624 * @param errMsg this will contain the error message describing why the operation failed
625 */
626
627 bool mergeTAlbum(TAlbum* album, TAlbum* destAlbum, bool dialog, QString& errMsg);
628
629 /**
630 * Update the icon for a TAlbum.
631 *
632 * @return true if the operation succeeds, false otherwise
633 * @param album the album for which icon should be changed
634 * @param iconKDE a simple filename which can be loaded by KIconLoader
635 * @param iconID id of the icon image file
636 * @param errMsg this will contain the error message describing why the operation failed
637 *
638 * @note if iconKDE is not empty then iconID is used. So if you want to set
639 * the icon to a file which can be loaded by QIcon, pass it in as
640 * iconKDE. otherwise pass a null QString to iconKDE and set iconID
641 */
642 bool updateTAlbumIcon(TAlbum* album,
643 const QString& iconKDE,
644 qlonglong iconID,
645 QString& errMsg);
646
647 /**
648 * Get a list of recently assigned tags (only last 6 tags are listed)
649 *
650 * @return the list of recently assigned TAlbums
651 * @param includeInternal include internal tags in the returned list, or skip them
652 */
653 AlbumList getRecentlyAssignedTags(bool includeInternal = false) const;
654
655 /**
656 * Return A list with the tag paths for a list of tag IDs.
657 *
658 * @param tagIDs list of tag album IDs
659 * @param leadingSlash if <code>true</code> return tags with a leading slash
660 * @param includeInternal include internal tags in the returned list, or skip them
661 */
662 QStringList tagPaths(const QList<int>& tagIDs,
663 bool leadingSlash = true,
664 bool includeInternal = false) const;
665
666 /**
667 * @return A list with the tag names for a list of tag IDs.
668 *
669 * @param tagIDs list of tag album IDs
670 * @param includeInternal include internal tags in the returned list, or skip them
671 */
672 QStringList tagNames(const QList<int>& tagIDs, bool includeInternal = false) const;
673
674 /**
675 * @return A hash with the tag paths for all tag IDs.
676 * @param leadingSlash if <code>true</code> return tags with a leading slash
677 * @param includeInternal include internal tags in the returned list, or skip them
678 */
679 QHash<int, QString> tagPaths(bool leadingSlash = true, bool includeInternal = false) const;
680
681 /**
682 * @return A hash with the tag names for all tag IDs.
683 * @param includeInternal include internal tags in the returned list, or skip them
684 */
685 QHash<int, QString> tagNames(bool includeInternal = false) const;
686
687 /**
688 * Returns a list of TAlbums which have the given property,
689 * or the given property/value combination.
690 */
691 AlbumList findTagsWithProperty(const QString& property);
692 AlbumList findTagsWithProperty(const QString& property, const QString& value);
693
694 /**
695 * TODO
696 */
697 QList<int> subTags(int tagId, bool recursive = false) const;
698 int findTopId(int tagId) const;
699
700 void askUserForWriteChangedTAlbumToFiles(TAlbum* const album);
701 void askUserForWriteChangedTAlbumToFiles(const QList<qlonglong>& imageIds);
702
703 private:
704
705 /**
706 * Checks whether an Album has a direct child with the given name.
707 *
708 * @param parent album to check children for
709 * @param title the title to search for
710 * @return <code>true</code> if there is a child with name, else <code>false</code>
711 */
712 void insertTAlbum(TAlbum* album, TAlbum* parent);
713 void removeTAlbum(TAlbum* album);
714
715 private Q_SLOTS:
716
717 /**
718 * Scan tags directly from database and creates new TAlbums
719 * It only creates those TAlbums which haven't already been
720 * created.
721 */
722 void scanTAlbums();
723
724 void slotTagsJobResult();
725 void slotTagsJobData(const QHash<int, int>& tagsStatHash);
726 void slotTagChange(const TagChangeset& changeset);
727 void slotImageTagChange(const ImageTagChangeset& changeset);
728
729 void getTagItemsCount();
730 void tagItemsCount();
731
732 Q_SIGNALS:
733
734 void signalTAlbumsDirty(const QHash<int, int>&);
735 void signalTagPropertiesChanged(TAlbum* album);
736
737 //@}
738
739 // -----------------------------------------------------------------------------
740
741 /**
742 * @name Operations on Search Album
743 */
744
745 //@{
746
747 public:
748
749 /**
750 * @return a list of all SAlbums
751 */
752 AlbumList allSAlbums() const;
753
754 /**
755 * @return a SAlbum with given ID
756 * @param id the id for the SAlbum
757 */
758 SAlbum* findSAlbum(int id) const;
759
760 /**
761 * @return a SAlbum with given name, or 0 if not found
762 * @param name the name of the search
763 */
764 SAlbum* findSAlbum(const QString& name) const;
765
766 /**
767 * @return SAlbums with given type, empty list if not found
768 * @param searchType the type of the search
769 */
770 QList<SAlbum*> findSAlbumsBySearchType(int searchType) const;
771
772 /**
773 * Create a new SAlbum with supplied url. If an existing SAlbum with same name
774 * exists this function will return a pointer to that album, instead of creating
775 * a new one. A newly created search album is added to the database. For an
776 * existing SAlbum, the url is updated and written out to the database
777 * @note the signalAlbumAdded will be fired before this function returns. Its
778 * recommended to connect to that signal to get notification of new album added
779 *
780 * @return the newly created SAlbum or an existing SAlbum with same name
781 * @param name name for the new search
782 * @param type the type of the search
783 * @param query search query to use
784 */
785 SAlbum* createSAlbum(const QString& name,
786 DatabaseSearch::Type type,
787 const QString& query);
788
789 /**
790 * Update the url for a SAlbum
791 *
792 * @return true if the operation succeeds, false otherwise
793 * @param album the album to update
794 * @param changedQuery the new query data of the album
795 * @param changedName a new name, or null to keep the current name
796 * @param type a new type, or UndefinedType to keep the current type
797 */
798 bool updateSAlbum(SAlbum* album,
799 const QString& changedQuery,
800 const QString& changedName = QString(),
801 DatabaseSearch::Type type = DatabaseSearch::UndefinedType);
802
803 /**
804 * Delete a SAlbum from the database
805 * @note the signalAlbumDeleted will be fired before this function returns. Its
806 * recommended to connect to that signal to get notification of album deletes
807 *
808 * @return true if the operation succeeds, false otherwise
809 * @param album the album to delete
810 */
811 bool deleteSAlbum(SAlbum* album);
812
813 private Q_SLOTS:
814
815 /**
816 * Scan searches directly from database and creates new SAlbums
817 * It only creates those SAlbums which haven't already been
818 * created.
819 */
820 void scanSAlbums();
821
822 void slotSearchChange(const SearchChangeset& changeset);
823
824 Q_SIGNALS:
825
826 void signalUpdateDuplicatesAlbums(const QList<SAlbum*>& modifiedAlbums,
827 const QList<qlonglong>& deletedImages);
828 void signalSearchUpdated(SAlbum* album);
829
830 //@}
831
832 // -----------------------------------------------------------------------------
833
834 /**
835 * @name Operations on Face Album
836 */
837
838 //@{
839
840 public:
841
842 /**
843 * Returns the latest count for faces as also emitted via
844 * signalFaceCountsDirty.
845 *
846 * @return count map for faces (confirmed and unconfirmed combined)
847 */
848 QHash<int, int> getFaceCount() const;
849
850 /**
851 * Returns the latest count for unconfirmed faces only
852 * as also emitted via signalFaceCountsDirty.
853 *
854 * @return count map for unconfirmed faces only
855 */
856 QHash<int, int> getUnconfirmedFaceCount() const;
857
858 private Q_SLOTS:
859
860 void slotPeopleJobResult();
861 void slotPeopleJobData(const QMap<QString,
862 QHash<int, int> >& facesStatHash);
863 void personItemsCount();
864
865 Q_SIGNALS:
866
867 void signalFaceCountsDirty(const QHash<int, int>& faceCount,
868 const QHash<int, int>& uFaceCount,
869 const QList<int>& toUpdatedFaces);
870
871 //@}
872
873 private:
874
875 /// @note disabled
876 explicit AlbumManager(QObject*) = delete;
877
878 public:
879
880 // Declared public because it used in ChangingDB class.
881 class Private;
882
883 private:
884
885 Private* const d = nullptr;
886
887 template <class T> friend class AlbumPointer;
888 friend class Album;
889 };
890
891 } // namespace Digikam