digiKam
contextmenuhelper_p.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 - Private container.
8  *
9  * Copyright (C) 2009-2011 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_P_H
26 #define DIGIKAM_CONTEXT_MENU_HELPER_P_H
27 
28 #include "contextmenuhelper.h"
29 
30 // Qt includes
31 
32 #include <QAction>
33 #include <QApplication>
34 #include <QClipboard>
35 #include <QDir>
36 #include <QIcon>
37 #include <QMap>
38 #include <QMenu>
39 #include <QMimeData>
40 #include <QPointer>
41 #include <QString>
42 #include <QTimer>
43 
44 // KDE includes
45 
46 // Pragma directives to reduce warnings from KDE header files.
47 #if defined(Q_CC_GNU)
48 # pragma GCC diagnostic push
49 # pragma GCC diagnostic ignored "-Wdeprecated-declarations"
50 #endif
51 
52 #if defined(Q_CC_CLANG)
53 # pragma clang diagnostic push
54 # pragma clang diagnostic ignored "-Wmismatched-tags"
55 # pragma clang diagnostic ignored "-Wdeprecated-declarations"
56 #endif
57 
58 #include <kactioncollection.h>
59 #include <klocalizedstring.h>
60 
61 #ifdef HAVE_KIO
62 # include <kopenwithdialog.h>
63 #endif
64 
65 // Restore warnings
66 #if defined(Q_CC_GNU)
67 # pragma GCC diagnostic pop
68 #endif
69 
70 #if defined(Q_CC_CLANG)
71 # pragma clang diagnostic pop
72 #endif
73 
74 // Local includes
75 
76 #include "digikam_debug.h"
77 #include "album.h"
78 #include "coredb.h"
79 #include "albummanager.h"
80 #include "albumpointer.h"
82 #include "abstractalbummodel.h"
83 #include "coredbaccess.h"
84 #include "digikamapp.h"
85 #include "dservicemenu.h"
86 #include "dfileoperations.h"
87 #include "iteminfo.h"
88 #include "itemfiltermodel.h"
89 #include "itemviewutilities.h"
90 #include "lighttablewindow.h"
91 #include "queuemgrwindow.h"
92 #include "picklabelwidget.h"
93 #include "colorlabelwidget.h"
94 #include "ratingwidget.h"
95 #include "tagmodificationhelper.h"
96 #include "tagspopupmenu.h"
97 #include "fileactionmngr.h"
98 #include "tagscache.h"
99 #include "dimg.h"
100 #include "dxmlguiwindow.h"
101 
102 #ifdef HAVE_AKONADICONTACT
103 # include "akonadiiface.h"
104 #endif
105 
106 #ifdef Q_OS_WIN
107 # include <windows.h>
108 # include <shellapi.h>
109 #endif
110 
111 namespace Digikam
112 {
113 
114 class Q_DECL_HIDDEN ContextMenuHelper::Private
115 {
116 public:
117 
118  explicit Private(ContextMenuHelper* const q)
119  : gotoAlbumAction (nullptr),
120  gotoDateAction (nullptr),
121  setThumbnailAction (nullptr),
122  imageFilterModel (nullptr),
123  albumModel (nullptr),
124  parent (nullptr),
125  stdActionCollection (nullptr),
126  q (q)
127  {
128  }
129 
130  QAction* gotoAlbumAction;
131  QAction* gotoDateAction;
133 
136 
137  QMap<int, QAction*> queueActions;
138  QMap<QString, KService::Ptr> servicesMap;
139 
142 
143  QMenu* parent;
144 
145  KActionCollection* stdActionCollection;
146 
148 
149 public:
150 
151  QModelIndex indexForAlbumFromAction(QObject* const sender) const
152  {
153  QAction* action = nullptr;
154 
155  if ((action = qobject_cast<QAction*>(sender)))
156  {
157  Album* const album = action->data().value<AlbumPointer<> >();
158 
159  return albumModel->indexForAlbum(album);
160  }
161 
162  return QModelIndex();
163  }
164 
165  QAction* copyFromMainCollection(const QString& name) const
166  {
167  QAction* const mainAction = stdActionCollection->action(name);
168 
169  if (!mainAction)
170  {
171  return nullptr;
172  }
173 
174  QAction* const action = new QAction(mainAction->icon(), mainAction->text(), q);
175  action->setShortcut(mainAction->shortcut());
176  action->setToolTip(mainAction->toolTip());
177 
178  return action;
179  }
180 };
181 
182 } // namespace Digikam
183 
184 #endif // DIGIKAM_CONTEXT_MENU_HELPER_P_H
QModelIndex indexForAlbum(Album *album) const
Definition: abstractalbummodel.cpp:361
Definition: abstractalbummodel.h:358
Definition: albumpointer.h:48
Abstract base class for all album types.
Definition: album.h:67
Definition: contextmenuhelper_p.h:115
QList< qlonglong > selectedIds
Definition: contextmenuhelper_p.h:134
KActionCollection * stdActionCollection
Definition: contextmenuhelper_p.h:145
QAction * gotoAlbumAction
Definition: contextmenuhelper_p.h:130
QMenu * parent
Definition: contextmenuhelper_p.h:143
ContextMenuHelper * q
Definition: contextmenuhelper_p.h:147
QList< QUrl > selectedItems
Definition: contextmenuhelper_p.h:135
ItemFilterModel * imageFilterModel
Definition: contextmenuhelper_p.h:140
QMap< int, QAction * > queueActions
Definition: contextmenuhelper_p.h:137
QModelIndex indexForAlbumFromAction(QObject *const sender) const
Definition: contextmenuhelper_p.h:151
QAction * gotoDateAction
Definition: contextmenuhelper_p.h:131
AbstractCheckableAlbumModel * albumModel
Definition: contextmenuhelper_p.h:141
QAction * setThumbnailAction
Definition: contextmenuhelper_p.h:132
Private(ContextMenuHelper *const q)
Definition: contextmenuhelper_p.h:118
QAction * copyFromMainCollection(const QString &name) const
Definition: contextmenuhelper_p.h:165
QMap< QString, KService::Ptr > servicesMap
Definition: contextmenuhelper_p.h:138
A helper class to add actions and special menus to the context menu.
Definition: contextmenuhelper.h:80
Definition: itemfiltermodel.h:125
Definition: datefolderview.cpp:43