1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date        : 2009-05-07
7  * Description : Context menu for GPS list view.
8  *
9  * Copyright (C) 2010-2021 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  * Copyright (C) 2009-2014 by Michael G. Hansen <mike at mghansen dot de>
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_GPS_ITEM_LIST_CONTEXT_MENU_H
26 #define DIGIKAM_GPS_ITEM_LIST_CONTEXT_MENU_H
27 
28 // Qt includes:
29 
30 #include <QObject>
31 
32 // Local includes
33 
34 #include "digikam_config.h"
35 #include "lookupaltitude.h"
36 #include "gpsdatacontainer.h"
37 #include "gpsitemlist.h"
38 #include "digikam_export.h"
39 
40 class QUrl;
41 
42 namespace Digikam
43 {
44 
45 class GPSUndoCommand;
46 class GPSBookmarkOwner;
47 
48 class DIGIKAM_EXPORT GPSItemListContextMenu : public QObject
49 {
50     Q_OBJECT
51 
52 public:
53 
54     explicit GPSItemListContextMenu(GPSItemList* const imagesList,
55                                     GPSBookmarkOwner* const bookmarkOwner = nullptr);
56     ~GPSItemListContextMenu()                           override;
57 
58     void setEnabled(const bool state);
59 
60 protected:
61 
62     void setGPSDataForSelectedItems(const GPSDataContainer& gpsData, const QString& undoDescription);
63     bool getCurrentItemPositionAndUrl(GPSDataContainer* const gpsInfo, QUrl* const itemUrl);
64     void removeInformationFromSelectedImages(const GPSDataContainer::HasFlags flagsToClear, const QString& undoDescription);
65 
66     bool eventFilter(QObject* watched, QEvent* event)   override;
67 
68     static bool getCurrentPosition(GPSDataContainer* position, void* mydata);
69 
70 private Q_SLOTS:
71 
72     void copyActionTriggered();
73     void pasteSwapActionTriggered();
74     void pasteActionTriggered(bool swap = false);
75     void slotBookmarkSelected(const GPSDataContainer& position);
76     void slotRemoveCoordinates();
77     void slotRemoveAltitude();
78     void slotRemoveUncertainty();
79     void slotRemoveSpeed();
80     void slotLookupMissingAltitudes();
81     void slotAltitudeLookupReady(const QList<int>& readyRequests);
82     void slotAltitudeLookupDone();
83     void slotAltitudeLookupCancel();
84 
85 Q_SIGNALS:
86 
87     void signalSetUIEnabled(const bool enabledState);
88     void signalSetUIEnabled(const bool enabledState, QObject* const cancelObject, const QString& cancelSlot);
89     void signalProgressSetup(const int maxProgress, const QString& progressText);
90     void signalProgressChanged(const int currentProgress);
91     void signalUndoCommand(GPSUndoCommand* undoCommand);
92 
93 private:
94 
95     class Private;
96     Private* const d;
97 };
98 
99 } // namespace Digikam
100 
101 #endif // DIGIKAM_GPS_ITEM_LIST_CONTEXT_MENU_H
102