| 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 |
| 33 | * \inheaderfile KIO/RenameDialog |
| 34 | * \inmodule KIOWidgets |
| 35 | * |
| 36 | * The dialog shown when a CopyJob realizes that a destination file already exists, |
| 37 | * and wants to offer the user with the choice to either Rename, Overwrite, Skip; |
| 38 | * this dialog is also used when a .part file exists and the user can choose to |
| 39 | * Resume a previous download. |
| 40 | */ |
| 41 | class KIOWIDGETS_EXPORT RenameDialog : public QDialog |
| 42 | { |
| 43 | Q_OBJECT |
| 44 | public: |
| 45 | /*! |
| 46 | * Construct a "rename" dialog to let the user know that \a src is about to overwrite \a dest. |
| 47 | * |
| 48 | * \a parent parent widget (often 0) |
| 49 | * |
| 50 | * \a title the title for the dialog box |
| 51 | * |
| 52 | * \a src the url to the file/dir we're trying to copy, as it's part of the text message |
| 53 | * |
| 54 | * \a dest the path to destination file/dir, i.e. the one that already exists |
| 55 | * |
| 56 | * \a options parameters for the dialog (which buttons to show...), |
| 57 | * |
| 58 | * \a sizeSrc size of source file |
| 59 | * |
| 60 | * \a sizeDest size of destination file |
| 61 | * |
| 62 | * \a ctimeSrc creation time of source file |
| 63 | * |
| 64 | * \a ctimeDest creation time of destination file |
| 65 | * |
| 66 | * \a mtimeSrc modification time of source file |
| 67 | * |
| 68 | * \a mtimeDest modification time of destination file |
| 69 | */ |
| 70 | RenameDialog(QWidget *parent, |
| 71 | const QString &title, |
| 72 | const QUrl &src, |
| 73 | const QUrl &dest, |
| 74 | RenameDialog_Options options, |
| 75 | KIO::filesize_t sizeSrc = KIO::filesize_t(-1), |
| 76 | KIO::filesize_t sizeDest = KIO::filesize_t(-1), |
| 77 | const QDateTime &ctimeSrc = QDateTime(), |
| 78 | const QDateTime &ctimeDest = QDateTime(), |
| 79 | const QDateTime &mtimeSrc = QDateTime(), |
| 80 | const QDateTime &mtimeDest = QDateTime()); |
| 81 | ~RenameDialog() override; |
| 82 | |
| 83 | /*! |
| 84 | * Returns the new destination |
| 85 | * valid only if RENAME was chosen |
| 86 | */ |
| 87 | QUrl newDestUrl(); |
| 88 | |
| 89 | /*! |
| 90 | * Returns an automatically renamed destination |
| 91 | * valid always |
| 92 | */ |
| 93 | QUrl autoDestUrl() const; |
| 94 | |
| 95 | public Q_SLOTS: |
| 96 | /*! |
| 97 | * |
| 98 | */ |
| 99 | void cancelPressed(); |
| 100 | |
| 101 | /*! |
| 102 | * |
| 103 | */ |
| 104 | void renamePressed(); |
| 105 | |
| 106 | /*! |
| 107 | * |
| 108 | */ |
| 109 | void skipPressed(); |
| 110 | |
| 111 | /*! |
| 112 | * |
| 113 | */ |
| 114 | void overwritePressed(); |
| 115 | |
| 116 | /*! |
| 117 | * |
| 118 | */ |
| 119 | void overwriteAllPressed(); |
| 120 | |
| 121 | /*! |
| 122 | * |
| 123 | */ |
| 124 | void overwriteWhenOlderPressed(); |
| 125 | |
| 126 | /*! |
| 127 | * |
| 128 | */ |
| 129 | void resumePressed(); |
| 130 | |
| 131 | /*! |
| 132 | * |
| 133 | */ |
| 134 | void resumeAllPressed(); |
| 135 | |
| 136 | /*! |
| 137 | * |
| 138 | */ |
| 139 | void suggestNewNamePressed(); |
| 140 | |
| 141 | protected Q_SLOTS: |
| 142 | void enableRenameButton(const QString &); |
| 143 | private Q_SLOTS: |
| 144 | KIOWIDGETS_NO_EXPORT void applyAllPressed(); |
| 145 | KIOWIDGETS_NO_EXPORT void showSrcIcon(const KFileItem &); |
| 146 | KIOWIDGETS_NO_EXPORT void showDestIcon(const KFileItem &); |
| 147 | KIOWIDGETS_NO_EXPORT void showSrcPreview(const KFileItem &, const QPixmap &); |
| 148 | KIOWIDGETS_NO_EXPORT void showDestPreview(const KFileItem &, const QPixmap &); |
| 149 | KIOWIDGETS_NO_EXPORT void resizePanels(); |
| 150 | |
| 151 | private: |
| 152 | KIOWIDGETS_NO_EXPORT QWidget *createContainerWidget(QLabel *preview, QLabel *SizeLabel, QLabel *DateLabel); |
| 153 | |
| 154 | class RenameDialogPrivate; |
| 155 | std::unique_ptr<RenameDialogPrivate> const d; |
| 156 | }; |
| 157 | |
| 158 | } |
| 159 | |
| 160 | #endif |
| 161 | |