File indexing completed on 2025-01-05 03:53:48

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2000-12-05
0007  * Description : helper class used to modify physical albums in views
0008  *
0009  * SPDX-FileCopyrightText: 2009-2011 by Johannes Wienke <languitar at semipol dot de>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-or-later
0012  *
0013  * ============================================================ */
0014 
0015 #ifndef DIGIKAM_ALBUM_MODIFICATION_HELPER_H
0016 #define DIGIKAM_ALBUM_MODIFICATION_HELPER_H
0017 
0018 // Qt includes
0019 
0020 #include <QObject>
0021 #include <QWidget>
0022 
0023 // Local includes
0024 
0025 #include "album.h"
0026 
0027 namespace Digikam
0028 {
0029 
0030 /**
0031  * Utility class providing methods to modify physical albums (PAlbum) in a way
0032  * useful to implement views.
0033  *
0034  * @author jwienke
0035  */
0036 class AlbumModificationHelper : public QObject
0037 {
0038     Q_OBJECT
0039 
0040 public:
0041 
0042     /**
0043      * Constructor.
0044      *
0045      * @param parent the parent for qt parent child mechanism
0046      * @param dialogParent parent widget for dialogs displayed by this object
0047      */
0048     explicit AlbumModificationHelper(QObject* const parent, QWidget* const dialogParent);
0049 
0050     /**
0051      * Destructor.
0052      */
0053     ~AlbumModificationHelper() override;
0054 
0055     /**
0056      * Sets the album that the given action operates on.
0057      * You must call bindTag and then connect the action's triggered
0058      * to the desired slot, slotTagNew(), slotTagEdit() or slotTagDelete().
0059      * Note: Changes the Action's user data.
0060      */
0061     void bindAlbum(QAction* const action, PAlbum* const parent) const;
0062 
0063     /**
0064      * Returns the album bound with bindAlbum. The given QObject shall be
0065      * a QAction, but for convenience the given object
0066      * will be checked with qobject_cast first, so you can pass QObject::sender().
0067      */
0068     PAlbum* boundAlbum(QObject* const action) const;
0069 
0070 public Q_SLOTS:
0071 
0072     /**
0073      * Creates a new album under the given parent. The user will be prompted for
0074      * the settings of the new album.
0075      *
0076      * @param parentAlbum parent album for the new one
0077      * @return the new album or 0 if no album was created
0078      */
0079     PAlbum* slotAlbumNew(PAlbum* parentAlbum);
0080     PAlbum* slotAlbumNew();
0081 
0082     /**
0083      * Deletes the given album after waiting for a graphical confirmation of the
0084      * user.
0085      *
0086      * @param album the album to delete
0087      */
0088     void slotAlbumDelete(PAlbum* album);
0089     void slotAlbumDelete();
0090 
0091     /**
0092      * Renames the given album. The user will be prompted for a new name.
0093      *
0094      * @param album the album to rename
0095      */
0096     void slotAlbumRename(PAlbum* album);
0097     void slotAlbumRename();
0098 
0099     /**
0100      * Graphically edits the properties of the given album.
0101      *
0102      * @param album the album to edit
0103      */
0104     void slotAlbumEdit(PAlbum* album);
0105     void slotAlbumEdit();
0106 
0107     void slotAlbumResetIcon(PAlbum* album);
0108     void slotAlbumResetIcon();
0109 
0110 private:
0111 
0112     void addAlbumChildrenToList(QList<QUrl>& list, Album* const album);
0113 
0114 private:
0115 
0116     class Private;
0117     Private* const d;
0118 };
0119 
0120 } // namespace Digikam
0121 
0122 #endif // DIGIKAM_ALBUM_MODIFICATION_HELPER_H