digiKam
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  * Copyright (C) 2009-2010 by Andi Clemens <andi dot clemens at gmail dot com>
10  * Copyright (C) 2010-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option)
16  * any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #ifndef DIGIKAM_CONTEXT_MENU_HELPER_H
26 #define DIGIKAM_CONTEXT_MENU_HELPER_H
27 
28 // Qt includes
29 
30 #include <QObject>
31 #include <QList>
32 #include <QUrl>
33 
34 // Local includes
35 
36 #include "digikam_export.h"
37 #include "digikam_config.h"
38 #include "coredbalbuminfo.h"
39 
40 class QAction;
41 class QMenu;
42 class QPoint;
43 class QString;
44 
45 namespace Digikam
46 {
47 
48 class AbstractCheckableAlbumModel;
49 class Album;
50 class AlbumIconItem;
51 class AlbumModificationHelper;
52 class ItemInfo;
53 class ItemFilterModel;
54 class PAlbum;
55 class TagModificationHelper;
56 class TAlbum;
57 
79 class DIGIKAM_GUI_EXPORT ContextMenuHelper : public QObject // clazy:exclude=ctor-missing-parent-argument
80 {
81  Q_OBJECT
82 
83 public:
84 
85  typedef const QList<qlonglong> imageIds;
86 
87 public:
88 
94  explicit ContextMenuHelper(QMenu* const parent); // clazy:exclude=ctor-missing-parent-argument
95  ~ContextMenuHelper() override;
96 
106  void addAction(const QString& name, bool addDisabled = false);
107 
117  void addAction(QAction* const action, bool addDisabled = false);
118 
130  void addAction(QAction* const action, QObject* const recv, const char* const slot, bool addDisabled = false);
131 
138  void addStandardActionCut(QObject* const recv, const char* const slot);
139 
146  void addStandardActionCopy(QObject* const recv, const char* const slot);
147 
154  void addStandardActionPaste(QObject* const recv, const char* const slot);
155 
164  void addStandardActionItemDelete(QObject* const recv, const char* const slot, int quantity = 1);
165 
172  void addIQSAction(QObject* const recv, const char* const slot);
173 
181  void addStandardActionLightTable();
182 
193  void addStandardActionThumbnail(const imageIds& ids, Album* const album);
194 
204  void addOpenAndNavigateActions(const imageIds& ids, bool lightTable = false);
205 
215  void addServicesMenu(const QList<QUrl>& selectedItems);
216 
232  void addGotoMenu(const imageIds& ids);
233 
237  void addQueueManagerMenu();
238 
244  void addActionNewTag(TagModificationHelper* const helper, TAlbum* const parentTag = nullptr);
245  void addActionDeleteTag(TagModificationHelper* const helper, TAlbum* const tag);
246  void addActionDeleteTags(TagModificationHelper* const helper, const QList<TAlbum*>& tags);
247  void addActionEditTag(TagModificationHelper* const helper, TAlbum* const tag);
248 
252  void addActionDeleteFaceTag(TagModificationHelper* const helper, TAlbum* const tag);
253  void addActionDeleteFaceTags(TagModificationHelper* const helper, const QList<TAlbum*>& tags);
254 
258  void addActionTagToFaceTag(TagModificationHelper* const helper, TAlbum* const tag);
259  void addActionTagsToFaceTags(TagModificationHelper* const helper, const QList<TAlbum*>& tags);
260 
266  void addActionNewAlbum(AlbumModificationHelper* const helper, PAlbum* const parentAlbum = nullptr);
267  void addActionDeleteAlbum(AlbumModificationHelper* const helper, PAlbum* const album);
268  void addActionEditAlbum(AlbumModificationHelper* const helper, PAlbum* const album);
269  void addActionRenameAlbum(AlbumModificationHelper* const helper, PAlbum* const album);
270  void addActionResetAlbumIcon(AlbumModificationHelper* const helper, PAlbum* const album);
271 
286  void addAssignTagsMenu(const imageIds& ids);
287 
302  void addRemoveTagsMenu(const imageIds& ids);
303 
307  void addCreateTagFromAddressbookMenu();
308 
323  void addLabelsAction();
324 
332  void addGroupMenu(const imageIds& ids, const QList<QAction*>& extraMenuItems = QList<QAction*>());
333  void addGroupActions(const imageIds& ids);
334 
339  void setItemFilterModel(ItemFilterModel* const model);
340 
345  void addAlbumCheckUncheckActions(Album* const album);
346 
351  void setAlbumModel(AbstractCheckableAlbumModel* const model);
352 
356  void addImportMenu();
357 
361  void addExportMenu();
362 
368  void addSubMenu(QMenu* subMenu);
369 
373  void addSeparator();
374 
385  QAction* exec(const QPoint& pos, QAction* const at = nullptr);
386 
387 Q_SIGNALS:
388 
390  void signalGotoAlbum(const ItemInfo&);
391  void signalGotoDate(const ItemInfo&);
392  void signalGotoTag(int);
393  void signalAssignTag(int);
394  void signalRemoveTag(int);
399  void signalAddNewTagFromABCMenu(const QString&);
407 
408 private Q_SLOTS:
409 
410  void slotOpenWith();
411  void slotOpenWith(QAction* action);
412  void slotOpenInFileManager();
413  void slotOpenImageFile();
414  void slotDeselectAllAlbumItems();
415  void slotOpenGroups();
416  void slotCloseGroups();
417  void slotOpenAllGroups();
418  void slotCloseAllGroups();
419  void slotSelectChildren();
420  void slotDeselectChildren();
421  void slotSelectParents();
422  void slotDeselectParents();
423 
424 private:
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 
433 private:
434 
435  class Private;
436  Private* const d;
437 };
438 
439 } // namespace Digikam
440 
441 #endif // DIGIKAM_CONTEXT_MENU_HELPER_H
Definition: abstractalbummodel.h:358
Definition: albummodificationhelper.h:46
Abstract base class for all album types.
Definition: album.h:67
Definition: contextmenuhelper_p.h:115
A helper class to add actions and special menus to the context menu.
Definition: contextmenuhelper.h:80
void signalAddNewTagFromABCMenu(const QString &)
void signalGotoDate(const ItemInfo &)
const QList< qlonglong > imageIds
Definition: contextmenuhelper.h:85
void signalGotoAlbum(const ItemInfo &)
void signalSetThumbnail(const ItemInfo &)
Definition: itemfiltermodel.h:125
Definition: iteminfo.h:78
Definition: album.h:357
Definition: album.h:420
Definition: tagmodificationhelper.h:53
@ Album
Definition: coredbfields.h:58
Category
Definition: coredbconstants.h:95
Definition: datefolderview.cpp:43