File indexing completed on 2024-12-01 03:41:20
0001 /* 0002 This file is part of the KDE libraries 0003 SPDX-FileCopyrightText: 2000 Stephan Kulow <coolo@kde.org> 0004 SPDX-FileCopyrightText: 1999-2008 David Faure <faure@kde.org> 0005 SPDX-FileCopyrightText: 2001 Holger Freyther <freyther@kde.org> 0006 0007 SPDX-License-Identifier: LGPL-2.0-or-later 0008 */ 0009 0010 #ifndef KIO_RENAMEDIALOG_H 0011 #define KIO_RENAMEDIALOG_H 0012 0013 #include <QDateTime> 0014 #include <QDialog> 0015 #include <QString> 0016 #include <kio/jobuidelegateextension.h> 0017 0018 #include "kiowidgets_export.h" 0019 #include <kio/global.h> 0020 0021 #include <memory> 0022 0023 class QScrollArea; 0024 class QLabel; 0025 class QPixmap; 0026 class KFileItem; 0027 class KSqueezedTextLabel; 0028 0029 namespace KIO 0030 { 0031 /** 0032 * @class KIO::RenameDialog renamedialog.h <KIO/RenameDialog> 0033 * 0034 * The dialog shown when a CopyJob realizes that a destination file already exists, 0035 * and wants to offer the user with the choice to either Rename, Overwrite, Skip; 0036 * this dialog is also used when a .part file exists and the user can choose to 0037 * Resume a previous download. 0038 */ 0039 class KIOWIDGETS_EXPORT RenameDialog : public QDialog 0040 { 0041 Q_OBJECT 0042 public: 0043 /** 0044 * Construct a "rename" dialog to let the user know that @p src is about to overwrite @p dest. 0045 * 0046 * @param parent parent widget (often 0) 0047 * @param title the title for the dialog box 0048 * @param src the url to the file/dir we're trying to copy, as it's part of the text message 0049 * @param dest the path to destination file/dir, i.e. the one that already exists 0050 * @param options parameters for the dialog (which buttons to show...), 0051 * @param sizeSrc size of source file 0052 * @param sizeDest size of destination file 0053 * @param ctimeSrc creation time of source file 0054 * @param ctimeDest creation time of destination file 0055 * @param mtimeSrc modification time of source file 0056 * @param mtimeDest modification time of destination file 0057 */ 0058 RenameDialog(QWidget *parent, 0059 const QString &title, 0060 const QUrl &src, 0061 const QUrl &dest, 0062 RenameDialog_Options options, 0063 KIO::filesize_t sizeSrc = KIO::filesize_t(-1), 0064 KIO::filesize_t sizeDest = KIO::filesize_t(-1), 0065 const QDateTime &ctimeSrc = QDateTime(), 0066 const QDateTime &ctimeDest = QDateTime(), 0067 const QDateTime &mtimeSrc = QDateTime(), 0068 const QDateTime &mtimeDest = QDateTime()); 0069 ~RenameDialog() override; 0070 0071 /** 0072 * @return the new destination 0073 * valid only if RENAME was chosen 0074 */ 0075 QUrl newDestUrl(); 0076 0077 /** 0078 * @return an automatically renamed destination 0079 * valid always 0080 */ 0081 QUrl autoDestUrl() const; 0082 0083 public Q_SLOTS: 0084 void cancelPressed(); 0085 void renamePressed(); 0086 void skipPressed(); 0087 void overwritePressed(); 0088 void overwriteAllPressed(); 0089 void overwriteWhenOlderPressed(); 0090 void resumePressed(); 0091 void resumeAllPressed(); 0092 void suggestNewNamePressed(); 0093 0094 protected Q_SLOTS: 0095 void enableRenameButton(const QString &); 0096 private Q_SLOTS: 0097 KIOWIDGETS_NO_EXPORT void applyAllPressed(); 0098 KIOWIDGETS_NO_EXPORT void showSrcIcon(const KFileItem &); 0099 KIOWIDGETS_NO_EXPORT void showDestIcon(const KFileItem &); 0100 KIOWIDGETS_NO_EXPORT void showSrcPreview(const KFileItem &, const QPixmap &); 0101 KIOWIDGETS_NO_EXPORT void showDestPreview(const KFileItem &, const QPixmap &); 0102 KIOWIDGETS_NO_EXPORT void resizePanels(); 0103 0104 private: 0105 KIOWIDGETS_NO_EXPORT QWidget *createContainerWidget(QLabel *preview, QLabel *SizeLabel, QLabel *DateLabel); 0106 0107 class RenameDialogPrivate; 0108 std::unique_ptr<RenameDialogPrivate> const d; 0109 }; 0110 0111 } 0112 0113 #endif