digiKam
deletedialog.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 : 2005-05-07
7  * Description : a dialog to delete item.
8  *
9  * Copyright (C) 2004 by Michael Pyne <michael dot pyne at kdemail dot net>
10  * Copyright (C) 2006 by Ian Monroe <ian at monroe dot nu>
11  * Copyright (C) 2009 by Andi Clemens <andi dot clemens at gmail dot com>
12  * Copyright (C) 2006-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
13  * Copyright (C) 2008-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
14  *
15  * This program is free software; you can redistribute it
16  * and/or modify it under the terms of the GNU General
17  * Public License as published by the Free Software Foundation;
18  * either version 2, or (at your option)
19  * any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * GNU General Public License for more details.
25  *
26  * ============================================================ */
27 
28 #ifndef DIGIKAM_DELETE_DIALOG_H
29 #define DIGIKAM_DELETE_DIALOG_H
30 
31 // Qt includes
32 
33 #include <QWidget>
34 #include <QTreeWidget>
35 #include <QUrl>
36 #include <QDialog>
37 
38 // Local includes
39 
40 #include "digikam_export.h"
41 #include "thumbnailloadthread.h"
42 
43 namespace Digikam
44 {
45 
46 namespace DeleteDialogMode
47 {
48 
50 {
53  Subalbums
54 };
55 
57 {
63 };
64 
65 } // namespace DeleteDialogMode
66 
67 // -----------------------------------------------------------
68 
69 class DeleteItem : public QTreeWidgetItem
70 {
71 
72 public:
73 
74  explicit DeleteItem(QTreeWidget* const parent, const QUrl& url);
75  ~DeleteItem() override;
76 
77  bool hasValidThumbnail() const;
78  QUrl url() const;
79  QString fileUrl() const;
80 
81  void setThumb(const QPixmap& pix, bool hasThumb = true);
82 
83 private:
84 
85  Q_DISABLE_COPY(DeleteItem)
86 
87 private:
88 
89  class Private;
90  Private* const d;
91 };
92 
93 // -----------------------------------------------------------
94 
95 class DeleteItemList : public QTreeWidget
96 {
97  Q_OBJECT
98 
99 public:
100 
101  explicit DeleteItemList(QWidget* const parent = nullptr);
102  ~DeleteItemList() override;
103 
104 private :
105 
106  void drawRow(QPainter* p,
107  const QStyleOptionViewItem& opt,
108  const QModelIndex& index) const override;
109 
110 private Q_SLOTS:
111 
112  void slotThumbnailLoaded(const LoadingDescription&, const QPixmap&);
113 
114 private:
115 
116  class Private;
117  Private* const d;
118 };
119 
120 // -----------------------------------------------------------
121 
122 class DeleteWidget : public QWidget
123 {
124  Q_OBJECT
125 
126 public:
127 
128  explicit DeleteWidget(QWidget* const parent = nullptr);
129  ~DeleteWidget() override;
130 
131  void setUrls(const QList<QUrl>& urls);
134 
135 private Q_SLOTS:
136 
137  void slotShouldDelete(bool);
138 
139 private:
140 
141  void updateText();
142 
143 private:
144 
145  class Private;
146  Private* const d;
147 
148  friend class DeleteDialog;
149 };
150 
151 // -----------------------------------------------------------
152 
153 class DeleteDialog : public QDialog
154 {
155  Q_OBJECT
156 
157 public:
158 
159  enum Mode
160  {
164  };
165 
166 public:
167 
168  explicit DeleteDialog(QWidget* const parent);
169  ~DeleteDialog() override;
170 
171  bool confirmDeleteList(const QList<QUrl>& condemnedURLs,
173  DeleteDialogMode::DeleteMode deleteMode);
174  bool shouldDelete() const;
175 
176  void setUrls(const QList<QUrl>& urls);
179 
180 protected Q_SLOTS:
181 
182  void slotUser1Clicked();
183  void slotShouldDelete(bool);
184 
185 private:
186 
187  void keyPressEvent(QKeyEvent*) override;
188 
189 private:
190 
191  class Private;
192  Private* const d;
193 };
194 
195 } // namespace Digikam
196 
197 #endif // DIGIKAM_DELETE_DIALOG_H
Definition: deletedialog.h:154
void presetDeleteMode(DeleteDialogMode::DeleteMode mode)
Definition: deletedialog.cpp:608
~DeleteDialog() override
Definition: deletedialog.cpp:526
Mode
Definition: deletedialog.h:160
@ ModeSubalbums
Definition: deletedialog.h:163
@ ModeAlbums
Definition: deletedialog.h:162
@ ModeFiles
Definition: deletedialog.h:161
bool shouldDelete() const
Definition: deletedialog.cpp:590
void slotShouldDelete(bool)
Definition: deletedialog.cpp:595
DeleteDialog(QWidget *const parent)
Definition: deletedialog.cpp:494
void setListMode(DeleteDialogMode::ListMode mode)
Definition: deletedialog.cpp:655
bool confirmDeleteList(const QList< QUrl > &condemnedURLs, DeleteDialogMode::ListMode listMode, DeleteDialogMode::DeleteMode deleteMode)
Definition: deletedialog.cpp:531
void setUrls(const QList< QUrl > &urls)
Definition: deletedialog.cpp:557
void slotUser1Clicked()
Definition: deletedialog.cpp:562
Definition: deletedialog.h:96
~DeleteItemList() override
Definition: deletedialog.cpp:194
DeleteItemList(QWidget *const parent=nullptr)
Definition: deletedialog.cpp:172
Definition: deletedialog.h:70
QUrl url() const
Definition: deletedialog.cpp:111
~DeleteItem() override
Definition: deletedialog.cpp:101
DeleteItem(QTreeWidget *const parent, const QUrl &url)
Definition: deletedialog.cpp:76
bool hasValidThumbnail() const
Definition: deletedialog.cpp:106
void setThumb(const QPixmap &pix, bool hasThumb=true)
Definition: deletedialog.cpp:130
QString fileUrl() const
Definition: deletedialog.cpp:116
Definition: deletedialog.h:123
void setListMode(DeleteDialogMode::ListMode mode)
Definition: deletedialog.cpp:372
~DeleteWidget() override
Definition: deletedialog.cpp:344
DeleteWidget(QWidget *const parent=nullptr)
Definition: deletedialog.cpp:267
void setUrls(const QList< QUrl > &urls)
Definition: deletedialog.cpp:349
void setDeleteMode(DeleteDialogMode::DeleteMode deleteMode)
Definition: deletedialog.cpp:366
Definition: loadingdescription.h:45
DeleteMode
Definition: deletedialog.h:57
@ UseTrash
same checkbox as above, preset to trash
Definition: deletedialog.h:61
@ NoChoiceDeletePermanently
same as above
Definition: deletedialog.h:59
@ DeletePermanently
same checkbox as above, preset to permanent
Definition: deletedialog.h:62
@ NoChoiceTrash
"Do not show again" checkbox, does not show if config entry is set
Definition: deletedialog.h:58
@ UserPreference
Checkbox to toggle trash/permanent, preset to user's last preference.
Definition: deletedialog.h:60
ListMode
Definition: deletedialog.h:50
@ Subalbums
Definition: deletedialog.h:53
@ Albums
Definition: deletedialog.h:52
@ Files
Definition: deletedialog.h:51
Definition: datefolderview.cpp:43