File indexing completed on 2025-01-05 03:59:47

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2012-01-04
0007  * Description : a message box to manage camera items
0008  *
0009  * SPDX-FileCopyrightText: 2012-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-or-later
0012  *
0013  * ============================================================ */
0014 
0015 #ifndef DIGIKAM_CAMERA_MESSAGE_BOX_H
0016 #define DIGIKAM_CAMERA_MESSAGE_BOX_H
0017 
0018 // Qt includes
0019 
0020 #include <QWidget>
0021 #include <QTreeWidget>
0022 
0023 // Local includes
0024 
0025 #include "camerathumbsctrl.h"
0026 #include "digikam_export.h"
0027 
0028 class QDialog;
0029 class QDialogButtonBox;
0030 
0031 namespace Digikam
0032 {
0033 
0034 class DIGIKAM_GUI_EXPORT CameraItem : public QTreeWidgetItem
0035 {
0036 
0037 public:
0038 
0039     CameraItem(QTreeWidget* const parent, const CamItemInfo& info);
0040     ~CameraItem()                  override;
0041 
0042     bool hasValidThumbnail() const;
0043     CamItemInfo info()       const;
0044 
0045     void setThumb(const QPixmap& pix, bool hasThumb = true);
0046 
0047 private:
0048 
0049     class Private;
0050     Private* const d;
0051 
0052 private:
0053 
0054     Q_DISABLE_COPY(CameraItem)
0055 };
0056 
0057 // -----------------------------------------------------------
0058 
0059 class DIGIKAM_GUI_EXPORT CameraItemList : public QTreeWidget
0060 {
0061     Q_OBJECT
0062 
0063 public:
0064 
0065     explicit CameraItemList(QWidget* const parent = nullptr);
0066     ~CameraItemList()                             override;
0067 
0068     void setThumbCtrl(CameraThumbsCtrl* const ctrl);
0069     void setItems(const CamItemInfoList& items);
0070 
0071 private:
0072 
0073     void drawRow(QPainter* p,
0074                  const QStyleOptionViewItem& opt,
0075                  const QModelIndex& index)  const override;
0076 
0077 private Q_SLOTS:
0078 
0079     void slotThumbnailLoaded(const CamItemInfo&);
0080 
0081 private:
0082 
0083     class Private;
0084     Private* const d;
0085 };
0086 
0087 // -----------------------------------------------------------
0088 
0089 class DIGIKAM_GUI_EXPORT CameraMessageBox
0090 {
0091 
0092 public:
0093 
0094     /**
0095      * Show List of camera items into an informative message box.
0096      */
0097     static void informationList(CameraThumbsCtrl* const ctrl,
0098                                 QWidget* const parent,
0099                                 const QString& caption,
0100                                 const QString& text,
0101                                 const CamItemInfoList& items,
0102                                 const QString& dontShowAgainName = QString());
0103 
0104     /**
0105      * Show List of camera items to process into a message box and wait user feedback.
0106      * Return QMessageBox::Yes or QMessageBox::Cancel
0107      */
0108     static int warningContinueCancelList(CameraThumbsCtrl* const ctrl,
0109                                          QWidget* const parent,
0110                                          const QString& caption,
0111                                          const QString& text,
0112                                          const CamItemInfoList& items,
0113                                          const QString& dontAskAgainName = QString());
0114 };
0115 
0116 } // namespace Digikam
0117 
0118 #endif // DIGIKAM_CAMERA_MESSAGE_BOX_H