KIO

renamedialog.h
1 /*
2  This file is part of the KDE libraries
3  SPDX-FileCopyrightText: 2000 Stephan Kulow <[email protected]>
4  SPDX-FileCopyrightText: 1999-2008 David Faure <[email protected]>
5  SPDX-FileCopyrightText: 2001 Holger Freyther <[email protected]>
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  * @since 4.5
80  * valid always
81  */
82  QUrl autoDestUrl() const;
83 
84 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 0)
85  /**
86  * Given a directory path and a filename (which usually exists already),
87  * this function returns a suggested name for a file that doesn't exist
88  * in that directory. The existence is only checked for local urls though.
89  * The suggested file name is of the form "foo 1", "foo 2" etc.
90  * @deprecated Since 5.0. Use KIO::suggestName, since 5.61, use KFileUtils::suggestName from KCoreAddons
91  */
92  KIOWIDGETS_DEPRECATED_VERSION(
93  5,
94  0,
95  "Use KFileUtils::suggestName(const QUrl &, const QString &) from KCoreAddons >= 5.61, or KIO::suggestName(const QUrl &, const QString &)")
96  static QString suggestName(const QUrl &baseURL, const QString &oldName);
97 #endif
98 
99 public Q_SLOTS:
100  void cancelPressed();
101  void renamePressed();
102  void skipPressed();
103  void autoSkipPressed();
104  void overwritePressed();
105  void overwriteAllPressed();
106  void overwriteWhenOlderPressed();
107  void resumePressed();
108  void resumeAllPressed();
109  void suggestNewNamePressed();
110 
111 protected Q_SLOTS:
112  void enableRenameButton(const QString &);
113 private Q_SLOTS:
114  void applyAllPressed();
115  void showSrcIcon(const KFileItem &);
116  void showDestIcon(const KFileItem &);
117  void showSrcPreview(const KFileItem &, const QPixmap &);
118  void showDestPreview(const KFileItem &, const QPixmap &);
119  void resizePanels();
120 
121 private:
122  QScrollArea *createContainerLayout(QWidget *parent, const KFileItem &item, QLabel *preview);
123  class RenameDialogPrivate;
124  std::unique_ptr<RenameDialogPrivate> const d;
125 };
126 
127 }
128 
129 #endif
qulonglong filesize_t
64-bit file size
Definition: global.h:39
A namespace for KIO globals.
KIOCORE_EXPORT QString suggestName(const QUrl &baseURL, const QString &oldName)
Given a directory path and a filename (which usually exists already), this function returns a suggest...
Definition: global.cpp:280
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Oct 1 2022 03:57:12 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.