1 | /* |
2 | This file is part of the KDE libraries |
3 | SPDX-FileCopyrightText: 2000 Stephan Kulow <coolo@kde.org> |
4 | SPDX-FileCopyrightText: 1999-2008 David Faure <faure@kde.org> |
5 | SPDX-FileCopyrightText: 2001 Holger Freyther <freyther@kde.org> |
6 | |
7 | SPDX-License-Identifier: LGPL-2.0-or-later |
8 | */ |
9 | |
10 | #ifndef KIO_RENAMEDIALOG_H |
11 | #define KIO_RENAMEDIALOG_H |
12 | |
13 | #include <QDateTime> |
14 | #include <QDialog> |
15 | #include <QString> |
16 | #include <kio/jobuidelegateextension.h> |
17 | |
18 | #include "kiowidgets_export.h" |
19 | #include <kio/global.h> |
20 | |
21 | #include <memory> |
22 | |
23 | class QScrollArea; |
24 | class QLabel; |
25 | class QPixmap; |
26 | class KFileItem; |
27 | class KSqueezedTextLabel; |
28 | |
29 | namespace KIO |
30 | { |
31 | /** |
32 | * @class KIO::RenameDialog renamedialog.h <KIO/RenameDialog> |
33 | * |
34 | * The dialog shown when a CopyJob realizes that a destination file already exists, |
35 | * and wants to offer the user with the choice to either Rename, Overwrite, Skip; |
36 | * this dialog is also used when a .part file exists and the user can choose to |
37 | * Resume a previous download. |
38 | */ |
39 | class KIOWIDGETS_EXPORT RenameDialog : public QDialog |
40 | { |
41 | Q_OBJECT |
42 | public: |
43 | /** |
44 | * Construct a "rename" dialog to let the user know that @p src is about to overwrite @p dest. |
45 | * |
46 | * @param parent parent widget (often 0) |
47 | * @param title the title for the dialog box |
48 | * @param src the url to the file/dir we're trying to copy, as it's part of the text message |
49 | * @param dest the path to destination file/dir, i.e. the one that already exists |
50 | * @param options parameters for the dialog (which buttons to show...), |
51 | * @param sizeSrc size of source file |
52 | * @param sizeDest size of destination file |
53 | * @param ctimeSrc creation time of source file |
54 | * @param ctimeDest creation time of destination file |
55 | * @param mtimeSrc modification time of source file |
56 | * @param mtimeDest modification time of destination file |
57 | */ |
58 | RenameDialog(QWidget *parent, |
59 | const QString &title, |
60 | const QUrl &src, |
61 | const QUrl &dest, |
62 | RenameDialog_Options options, |
63 | KIO::filesize_t sizeSrc = KIO::filesize_t(-1), |
64 | KIO::filesize_t sizeDest = KIO::filesize_t(-1), |
65 | const QDateTime &ctimeSrc = QDateTime(), |
66 | const QDateTime &ctimeDest = QDateTime(), |
67 | const QDateTime &mtimeSrc = QDateTime(), |
68 | const QDateTime &mtimeDest = QDateTime()); |
69 | ~RenameDialog() override; |
70 | |
71 | /** |
72 | * @return the new destination |
73 | * valid only if RENAME was chosen |
74 | */ |
75 | QUrl newDestUrl(); |
76 | |
77 | /** |
78 | * @return an automatically renamed destination |
79 | * valid always |
80 | */ |
81 | QUrl autoDestUrl() const; |
82 | |
83 | public Q_SLOTS: |
84 | void cancelPressed(); |
85 | void renamePressed(); |
86 | void skipPressed(); |
87 | void overwritePressed(); |
88 | void overwriteAllPressed(); |
89 | void overwriteWhenOlderPressed(); |
90 | void resumePressed(); |
91 | void resumeAllPressed(); |
92 | void suggestNewNamePressed(); |
93 | |
94 | protected Q_SLOTS: |
95 | void enableRenameButton(const QString &); |
96 | private Q_SLOTS: |
97 | KIOWIDGETS_NO_EXPORT void applyAllPressed(); |
98 | KIOWIDGETS_NO_EXPORT void showSrcIcon(const KFileItem &); |
99 | KIOWIDGETS_NO_EXPORT void showDestIcon(const KFileItem &); |
100 | KIOWIDGETS_NO_EXPORT void showSrcPreview(const KFileItem &, const QPixmap &); |
101 | KIOWIDGETS_NO_EXPORT void showDestPreview(const KFileItem &, const QPixmap &); |
102 | KIOWIDGETS_NO_EXPORT void resizePanels(); |
103 | |
104 | private: |
105 | KIOWIDGETS_NO_EXPORT QWidget *createContainerWidget(QLabel *preview, QLabel *SizeLabel, QLabel *DateLabel); |
106 | |
107 | class RenameDialogPrivate; |
108 | std::unique_ptr<RenameDialogPrivate> const d; |
109 | }; |
110 | |
111 | } |
112 | |
113 | #endif |
114 | |