File indexing completed on 2025-01-19 03:50:38
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2009-02-15 0007 * Description : contextmenu helper class - Private container. 0008 * 0009 * SPDX-FileCopyrightText: 2009-2011 by Andi Clemens <andi dot clemens at gmail dot com> 0010 * SPDX-FileCopyrightText: 2010-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0011 * 0012 * SPDX-License-Identifier: GPL-2.0-or-later 0013 * 0014 * ============================================================ */ 0015 0016 #ifndef DIGIKAM_CONTEXT_MENU_HELPER_P_H 0017 #define DIGIKAM_CONTEXT_MENU_HELPER_P_H 0018 0019 #include "contextmenuhelper.h" 0020 0021 // Qt includes 0022 0023 #include <QAction> 0024 #include <QApplication> 0025 #include <QClipboard> 0026 #include <QDir> 0027 #include <QIcon> 0028 #include <QMap> 0029 #include <QMenu> 0030 #include <QMimeData> 0031 #include <QPointer> 0032 #include <QString> 0033 #include <QTimer> 0034 0035 // KDE includes 0036 0037 // Pragma directives to reduce warnings from KDE header files. 0038 #if defined(Q_CC_GNU) 0039 # pragma GCC diagnostic push 0040 # pragma GCC diagnostic ignored "-Wdeprecated-declarations" 0041 #endif 0042 0043 #if defined(Q_CC_CLANG) 0044 # pragma clang diagnostic push 0045 # pragma clang diagnostic ignored "-Wmismatched-tags" 0046 # pragma clang diagnostic ignored "-Wdeprecated-declarations" 0047 #endif 0048 0049 #include <kactioncollection.h> 0050 #include <klocalizedstring.h> 0051 0052 #ifdef HAVE_KIO 0053 # include <kopenwithdialog.h> 0054 #endif 0055 0056 // Restore warnings 0057 #if defined(Q_CC_GNU) 0058 # pragma GCC diagnostic pop 0059 #endif 0060 0061 #if defined(Q_CC_CLANG) 0062 # pragma clang diagnostic pop 0063 #endif 0064 0065 // Local includes 0066 0067 #include "digikam_debug.h" 0068 #include "album.h" 0069 #include "coredb.h" 0070 #include "albummanager.h" 0071 #include "albumpointer.h" 0072 #include "albummodificationhelper.h" 0073 #include "abstractalbummodel.h" 0074 #include "coredbaccess.h" 0075 #include "digikamapp.h" 0076 #include "dservicemenu.h" 0077 #include "dfileoperations.h" 0078 #include "iteminfo.h" 0079 #include "itemfiltermodel.h" 0080 #include "itemviewutilities.h" 0081 #include "lighttablewindow.h" 0082 #include "queuemgrwindow.h" 0083 #include "metadataremover.h" 0084 #include "picklabelwidget.h" 0085 #include "colorlabelwidget.h" 0086 #include "ratingwidget.h" 0087 #include "tagmodificationhelper.h" 0088 #include "tagspopupmenu.h" 0089 #include "fileactionmngr.h" 0090 #include "tagscache.h" 0091 #include "dimg.h" 0092 #include "dxmlguiwindow.h" 0093 0094 #ifdef HAVE_AKONADICONTACT 0095 # include "akonadiiface.h" 0096 #endif 0097 0098 #ifdef Q_OS_WIN 0099 # include <windows.h> 0100 # include <shellapi.h> 0101 #endif 0102 0103 namespace Digikam 0104 { 0105 0106 class Q_DECL_HIDDEN ContextMenuHelper::Private 0107 { 0108 public: 0109 0110 explicit Private(ContextMenuHelper* const q) 0111 : gotoAlbumAction (nullptr), 0112 gotoDateAction (nullptr), 0113 setThumbnailAction (nullptr), 0114 imageFilterModel (nullptr), 0115 albumModel (nullptr), 0116 parent (nullptr), 0117 stdActionCollection (nullptr), 0118 q (q) 0119 { 0120 } 0121 0122 QAction* gotoAlbumAction; 0123 QAction* gotoDateAction; 0124 QAction* setThumbnailAction; 0125 0126 QList<qlonglong> selectedIds; 0127 QList<QUrl> selectedItems; 0128 0129 QMap<int, QAction*> queueActions; 0130 QMap<QString, KService::Ptr> servicesMap; 0131 0132 ItemFilterModel* imageFilterModel; 0133 AbstractCheckableAlbumModel* albumModel; 0134 0135 QMenu* parent; 0136 0137 KActionCollection* stdActionCollection; 0138 0139 ContextMenuHelper* q; 0140 0141 public: 0142 0143 QModelIndex indexForAlbumFromAction(QObject* const sender) const 0144 { 0145 QAction* action = nullptr; 0146 0147 if ((action = qobject_cast<QAction*>(sender))) 0148 { 0149 Album* const album = action->data().value<AlbumPointer<> >(); 0150 0151 return albumModel->indexForAlbum(album); 0152 } 0153 0154 return QModelIndex(); 0155 } 0156 0157 QAction* copyFromMainCollection(const QString& name) const 0158 { 0159 QAction* const mainAction = stdActionCollection->action(name); 0160 0161 if (!mainAction) 0162 { 0163 return nullptr; 0164 } 0165 0166 QAction* const action = new QAction(mainAction->icon(), mainAction->text(), q); 0167 action->setShortcut(mainAction->shortcut()); 0168 action->setToolTip(mainAction->toolTip()); 0169 0170 return action; 0171 } 0172 0173 QList<DPluginAction*> exportPluginActions() const 0174 { 0175 KXMLGUIClient* const client = const_cast<KXMLGUIClient*>(stdActionCollection->parentGUIClient()); 0176 QList<DPluginAction*> actions = DPluginLoader::instance()->pluginsActions(DPluginAction::GenericExport, 0177 dynamic_cast<KXmlGuiWindow*>(client)); 0178 0179 return actions; 0180 } 0181 0182 }; 0183 0184 } // namespace Digikam 0185 0186 #endif // DIGIKAM_CONTEXT_MENU_HELPER_P_H