File indexing completed on 2025-01-19 03:59:23

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2004-09-16
0007  * Description : Camera interface
0008  *
0009  * SPDX-FileCopyrightText: 2004-2005 by Renchi Raju <renchi dot raju at gmail dot com>
0010  * SPDX-FileCopyrightText: 2006-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0011  * SPDX-FileCopyrightText: 2006-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
0012  * SPDX-FileCopyrightText: 2012      by Islam Wazery <wazery at ubuntu dot com>
0013  *
0014  * SPDX-License-Identifier: GPL-2.0-or-later
0015  *
0016  * ============================================================ */
0017 
0018 #ifndef DIGIKAM_IMPORTUI_H
0019 #define DIGIKAM_IMPORTUI_H
0020 
0021 // Qt includes
0022 
0023 #include <QDateTime>
0024 #include <QString>
0025 #include <QImage>
0026 #include <QKeyEvent>
0027 #include <QCloseEvent>
0028 #include <QMultiMap>
0029 #include <QUrl>
0030 
0031 // Local includes
0032 
0033 #include "camiteminfo.h"
0034 #include "dhistoryview.h"
0035 #include "dmetadata.h"
0036 //#include "camerahistoryupdater.h"
0037 #include "downloadsettings.h"
0038 #include "importiconview.h"
0039 #include "dxmlguiwindow.h"
0040 #include "digikam_export.h"
0041 
0042 namespace Digikam
0043 {
0044 
0045 class Album;
0046 class PAlbum;
0047 class CollectionLocation;
0048 class CameraHistoryUpdater;
0049 class ImportIconView;
0050 class CameraThumbsCtrl;
0051 
0052 class DIGIKAM_GUI_EXPORT ImportUI : public DXmlGuiWindow
0053 {
0054     Q_OBJECT
0055 
0056 public:
0057 
0058     explicit ImportUI(const QString& cameraTitle,
0059                       const QString& model,
0060                       const QString& port,
0061                       const QString& path,
0062                       int startIndex);
0063     ~ImportUI() override;
0064 
0065     static ImportUI* instance();
0066 
0067     bool isBusy()   const;
0068     bool isClosed() const;
0069 
0070     bool    cameraDeleteSupport()   const;
0071     bool    cameraUploadSupport()   const;
0072     bool    cameraMkDirSupport()    const;
0073     bool    cameraDelDirSupport()   const;
0074     bool    cameraUseUMSDriver()    const;
0075     bool    cameraUseGPhotoDriver() const;
0076     QString cameraTitle()           const;
0077 
0078     void enableZoomPlusAction(bool val);
0079     void enableZoomMinusAction(bool val);
0080 
0081     DownloadSettings downloadSettings()     const;
0082 
0083     CameraThumbsCtrl* getCameraThumbsCtrl() const;
0084 
0085 public:
0086 
0087     DInfoInterface* infoIface(DPluginAction* const) override
0088     {
0089         return nullptr;
0090     };
0091 
0092 Q_SIGNALS:
0093 
0094     void signalLastDestination(const QUrl&);
0095     void signalWindowHasMoved();
0096     void signalEscapePressed();
0097     void signalPreviewRequested(const CamItemInfo&, bool);
0098     void signalNewSelection(bool);
0099 
0100 public Q_SLOTS:
0101 
0102     void slotDownload(bool onlySelected, bool deleteAfter, Album* pAlbum = nullptr);
0103     void slotUploadItems(const QList<QUrl>&); // public to be used in drag'n'drop
0104 
0105 protected:
0106 
0107     void closeEvent(QCloseEvent* e) override;
0108     void moveEvent(QMoveEvent* e)   override;
0109 
0110 private:
0111 
0112     void setupActions();
0113     void updateActions();
0114     void setupConnections();
0115     void setupUserArea();
0116     void setupStatusBar();
0117     void setupAccelerators();
0118     void setupCameraController(const QString& model, const QString& port, const QString& path);
0119 
0120     void readSettings();
0121     void saveSettings();
0122     bool createAutoAlbum(const QUrl& parentURL, const QString& sub,
0123                          const QDate& date, QString& errMsg) const;
0124 
0125     bool dialogClosed();
0126     void finishDialog();
0127     void refreshFreeSpace();
0128     void refreshCollectionFreeSpace();
0129     void deleteItems(bool onlySelected, bool onlyDownloaded);
0130     void toggleLock(CamItemInfo& info);
0131     void setDownloaded(CamItemInfo& itemInfo, int status);
0132     void itemsSelectionSizeInfo(qint64& fSizeBytes, qint64& dSizeBytes);
0133     QMap<QString, int> countItemsByFolders() const;
0134     void checkItem4Deletion(const CamItemInfo& info, QStringList& folders, QStringList& files,
0135                             CamItemInfoList& deleteList, CamItemInfoList& lockedList);
0136 
0137     QString identifyCategoryforMime(const QString& mime);
0138 
0139     bool checkDiskSpace(PAlbum* pAlbum);
0140     bool downloadCameraItems(PAlbum* pAlbum, bool onlySelected, bool deleteAfter);
0141     bool createSubAlbums(QUrl& downloadUrl, const QString& suffix, const QDateTime& dateTime);
0142     bool createSubAlbum(QUrl& downloadUrl, const QString& subalbum, const QDate& date);
0143     bool createDateBasedSubAlbum(QUrl& downloadUrl, const QDateTime& dateTime);
0144     bool createExtBasedSubAlbum(QUrl& downloadUrl, const QString& suffix, const QDate& date);
0145     void postProcessAfterDownload();
0146 
0147 
0148     void showThumbBar(bool visible)         override;
0149     void showSideBars(bool visible)         override;
0150     bool thumbbarVisibility() const         override;
0151     void customizedFullScreenMode(bool set) override;
0152     void toogleShowBar();
0153     void setInitialSorting();
0154     void sidebarTabTitleStyleChanged();
0155     void updateRightSideBar(const CamItemInfo& info);
0156 
0157 private Q_SLOTS:
0158 
0159     void slotClose();
0160     void slotCancelButton();
0161 
0162     void slotShowLog();
0163     void slotConnected(bool val);
0164     void slotBusy(bool val);
0165     void slotLogMsg(const QString& msg, DHistoryView::EntryType type,
0166                     const QString& folder = QString(), const QString& file = QString());
0167     void slotInformation();
0168     void slotCapture();
0169     void slotCameraInformation(const QString&, const QString&, const QString&);
0170     void slotCameraFreeSpaceInfo(qint64 bytesSize, qint64 bytesAvail);
0171     void slotCollectionLocationStatusChanged(const CollectionLocation& location, int oldStatus);
0172     void slotHistoryEntryClicked(const QVariant&);
0173 
0174     void slotFolderList(const QStringList& folderList);
0175 
0176     void slotZoomSliderChanged(int size);
0177     void slotZoomChanged(double zoom);
0178     void slotThumbSizeChanged(int size);
0179 
0180     void slotUpload();
0181 
0182     void slotDownloadNew();
0183     void slotDownloadSelected();
0184     void slotDownloadAll();
0185 
0186     void slotDownloadAndDeleteNew();
0187     void slotDownloadAndDeleteSelected();
0188     void slotDownloadAndDeleteAll();
0189 
0190     void slotDeleteAfterDownload();
0191     void slotDeleteSelected();
0192     void slotDeleteNew();
0193     void slotDeleteAll();
0194 
0195     void slotToggleLock();
0196     void slotMarkAsDownloaded();
0197 
0198     void slotUploaded(const CamItemInfo&);
0199     void slotDownloaded(const QString&, const QString&, const QString&, int);
0200     void slotDeleted(const QString&, const QString&, bool);
0201     void slotLocked(const QString&, const QString&, bool);
0202 
0203     void slotUpdateRenamePreview();
0204     void slotSelectNew();
0205     void slotSelectLocked();
0206     void slotProgressTimerDone();
0207 
0208     void slotNewSelection(bool);
0209     void slotImageSelected(const CamItemInfoList& selection, const CamItemInfoList& listAll);
0210 
0211     void slotSwitchedToPreview();
0212     void slotSwitchedToIconView();
0213     void slotSwitchedToMapView();
0214 
0215     void slotMetadata(const QString& folder, const QString& file, const MetaEngineData& meta);
0216 
0217     void setFilter(Filter*);
0218 
0219     void slotToggleShowBar();
0220     void slotColorManagementOptionsChanged();
0221     void slotToggleColorManagedView();
0222     void slotSetup()                   override;
0223     void slotComponentsInfo()          override;
0224     void slotDBStat()                  override;
0225     void slotOnlineVersionCheck()      override;
0226     void slotToggleRightSideBar()      override;
0227     void slotPreviousRightSideBarTab() override;
0228     void slotNextRightSideBarTab()     override;
0229 
0230     void slotSetupChanged();
0231 
0232 private:
0233 
0234     // Disable
0235     ImportUI(QWidget*) = delete;
0236 
0237 private:
0238 
0239     class Private;
0240     Private* const   d;
0241 
0242     static ImportUI* m_instance;
0243 };
0244 
0245 } // namespace Digikam
0246 
0247 #endif // DIGIKAM_IMPORTUI_H