digiKam
Loading...
Searching...
No Matches
contextmenuhelper.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 : 2009-02-15
7 * Description : contextmenu helper class
8 *
9 * SPDX-FileCopyrightText: 2009-2010 by Andi Clemens <andi dot clemens at gmail dot com>
10 * SPDX-FileCopyrightText: 2010-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
11 *
12 * SPDX-License-Identifier: GPL-2.0-or-later
13 *
14 * ============================================================ */
15
16#pragma once
17
18// Qt includes
19
20#include <QObject>
21#include <QList>
22#include <QUrl>
23
24// Local includes
25
26#include "digikam_export.h"
27#include "digikam_config.h"
28#include "coredbalbuminfo.h"
29
30class QAction;
31class QMenu;
32class QPoint;
33class QString;
34
35namespace Digikam
36{
37
38class AbstractCheckableAlbumModel;
39class Album;
40class AlbumIconItem;
41class AlbumModificationHelper;
42class ItemInfo;
43class ItemFilterModel;
44class PAlbum;
45class TagModificationHelper;
46class TAlbum;
47
69class DIGIKAM_GUI_EXPORT ContextMenuHelper : public QObject // clazy:exclude=ctor-missing-parent-argument
70{
71 Q_OBJECT
72
73public:
74
75 typedef const QList<qlonglong> imageIds;
76
77public:
78
84 explicit ContextMenuHelper(QMenu* const parent); // clazy:exclude=ctor-missing-parent-argument
85 ~ContextMenuHelper() override;
86
96 void addAction(const QString& name, bool addDisabled = false);
97
107 void addAction(QAction* const action, bool addDisabled = false);
108
120 void addAction(QAction* const action, QObject* const recv, const char* const slot, bool addDisabled = false);
121
128 void addStandardActionCut(QObject* const recv, const char* const slot);
129
136 void addStandardActionCopy(QObject* const recv, const char* const slot);
137
144 void addStandardActionPaste(QObject* const recv, const char* const slot);
145
154 void addStandardActionItemDelete(QObject* const recv, const char* const slot, int quantity = 1);
155
162 void addIQSAction(QObject* const recv, const char* const slot);
163
171 void addStandardActionLightTable();
172
183 void addStandardActionThumbnail(const imageIds& ids, Album* const album);
184
194 void addOpenAndNavigateActions(const imageIds& ids, bool lightTable = false);
195
205 void addServicesMenu(const QList<QUrl>& selectedItems);
206
222 void addGotoMenu(const imageIds& ids);
223
227 void addQueueManagerMenu();
228
234 void addActionNewTag(TagModificationHelper* const helper, TAlbum* const parentTag = nullptr);
235 void addActionDeleteTag(TagModificationHelper* const helper, TAlbum* const tag);
236 void addActionDeleteTags(TagModificationHelper* const helper, const QList<TAlbum*>& tags);
237 void addActionEditTag(TagModificationHelper* const helper, TAlbum* const tag);
238
242 void addActionDeleteFaceTag(TagModificationHelper* const helper, TAlbum* const tag);
243 void addActionDeleteFaceTags(TagModificationHelper* const helper, const QList<TAlbum*>& tags);
244
248 void addActionTagToFaceTag(TagModificationHelper* const helper, TAlbum* const tag);
249 void addActionTagsToFaceTags(TagModificationHelper* const helper, const QList<TAlbum*>& tags);
250
256 void addActionNewAlbum(AlbumModificationHelper* const helper, PAlbum* const parentAlbum = nullptr);
257 void addActionDeleteAlbum(AlbumModificationHelper* const helper, PAlbum* const album);
258 void addActionEditAlbum(AlbumModificationHelper* const helper, PAlbum* const album);
259 void addActionRenameAlbum(AlbumModificationHelper* const helper, PAlbum* const album);
260 void addActionResetAlbumIcon(AlbumModificationHelper* const helper, PAlbum* const album);
261
276 void addAssignTagsMenu(const imageIds& ids);
277
292 void addRemoveTagsMenu(const imageIds& ids);
293
301 void addRemoveAllTags(const imageIds& ids);
302
306 void addCreateTagFromAddressbookMenu();
307
322 void addLabelsAction();
323
331 void addGroupMenu(const imageIds& ids, const QList<QAction*>& extraMenuItems = QList<QAction*>());
332 void addGroupActions(const imageIds& ids);
333
338 void setItemFilterModel(ItemFilterModel* const model);
339
344 void addAlbumCheckUncheckActions(Album* const album);
345
350 void setAlbumModel(AbstractCheckableAlbumModel* const model);
351
355 void addImportMenu();
356
360 void addExportMenu();
361
367 void addSubMenu(QMenu* subMenu);
368
372 void addSeparator();
373
384 QAction* exec(const QPoint& pos, QAction* const at = nullptr);
385
386Q_SIGNALS:
387
391 void signalGotoTag(int);
398 void signalAddNewTagFromABCMenu(const QString&);
406
407private Q_SLOTS:
408
409 void slotOpenWith();
410 void slotOpenWith(QAction* action);
411 void slotOpenInFileManager();
412 void slotOpenImageFile();
413 void slotDeselectAllAlbumItems();
414 void slotOpenGroups();
415 void slotCloseGroups();
416 void slotOpenAllGroups();
417 void slotCloseAllGroups();
418 void slotSelectChildren();
419 void slotDeselectChildren();
420 void slotSelectParents();
421 void slotDeselectParents();
422 void slotRemoveAllTags();
423
424private:
425
426 void setGroupsOpen(bool open);
427 void setSelectedIds(const imageIds& ids);
428 void setSelectedItems(const QList<QUrl>& urls);
429
430 bool imageIdsHaveSameCategory(const imageIds& ids, DatabaseItem::Category category);
431 QList<QAction*> groupMenuActions(const imageIds& ids);
432
433private:
434
435 class Private;
436 Private* const d = nullptr;
437};
438
439} // namespace Digikam
Definition abstractalbummodel.h:357
Definition albummodificationhelper.h:36
Abstract base class for all album types.
Definition album.h:57
Definition contextmenuhelper_p.h:106
A helper class to add actions and special menus to the context menu.
Definition contextmenuhelper.h:70
void signalAddNewTagFromABCMenu(const QString &)
void signalGotoDate(const ItemInfo &)
const QList< qlonglong > imageIds
Definition contextmenuhelper.h:75
void signalGotoAlbum(const ItemInfo &)
void signalSetThumbnail(const ItemInfo &)
Definition itemfiltermodel.h:115
Definition iteminfo.h:68
Definition album.h:357
Definition album.h:421
Definition tagmodificationhelper.h:43
@ Album
Definition coredbfields.h:48
Category
Definition coredbconstants.h:69
Definition datefolderview.cpp:34