fix tricky regression noticed by Vyacheslav Tokarev on Google Reader.
[kdelibs.git] / kio / kio / renamedialog.h
blob139bcedd4c7c007caad2852312247f3b6d85ef98
1 /* This file is part of the KDE libraries
2 Copyright (C) 2000 Stephan Kulow <coolo@kde.org>
3 1999 - 2008 David Faure <faure@kde.org>
4 2001 Holger Freyther <freyther@kde.org>
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
22 #ifndef KIO_RENAMEDIALOG_H
23 #define KIO_RENAMEDIALOG_H
25 #include <kurl.h>
26 #include <QtGui/QDialog>
27 #include <QtCore/QString>
28 #include <sys/types.h>
30 #include <kio/global.h>
32 namespace KIO {
34 // KDE5: get rid of M_OVERWRITE_ITSELF, trigger it internally if src==dest
35 // KDE5: get rid of M_SINGLE. If not multi, then single ;)
36 // KDE5: use QFlags to get rid of all the casting!
37 /**
38 * M_OVERWRITE: We have an existing dest, show details about it and offer to overwrite it.
39 * M_OVERWRITE_ITSELF: Warn that the current operation would overwrite a file with itself,
40 * which is not allowed.
41 * M_SKIP: Offer a "Skip" button, to skip other files too. Requires M_MULTI.
42 * M_SINGLE: Deprecated and unused, please ignore.
43 * M_MULTI: Set if the current operation concerns multiple files, so it makes sense
44 * to offer buttons that apply the user's choice to all files/folders.
45 * M_RESUME: Offer a "Resume" button (plus "Resume All" if M_MULTI)
46 * M_NORENAME: Don't offer a "Rename" button
47 * M_ISDIR: The dest is a directory, so label the "overwrite" button something like "merge" instead.
49 enum RenameDialog_Mode { M_OVERWRITE = 1, M_OVERWRITE_ITSELF = 2, M_SKIP = 4, M_SINGLE = 8, M_MULTI = 16, M_RESUME = 32, M_NORENAME = 64, M_ISDIR = 128 };
51 /**
52 * The result of open_RenameDialog().
54 enum RenameDialog_Result { R_RESUME = 6, R_RESUME_ALL = 7, R_OVERWRITE = 4, R_OVERWRITE_ALL = 5, R_SKIP = 2, R_AUTO_SKIP = 3, R_RENAME = 1, R_CANCEL = 0 };
57 /**
58 * A dialog for the options to rename two files.
59 * @short A dialog for renaming files.
61 class KIO_EXPORT RenameDialog : public QDialog
63 Q_OBJECT
64 public:
65 /**
66 * Construct a "rename" dialog.
67 * @param parent parent widget (often 0)
68 * @param caption the caption for the dialog box
69 * @param src the url to the file/dir we're trying to copy, as it's part of the text message
70 * @param dest the path to destination file/dir, i.e. the one that already exists
71 * @param mode parameters for the dialog (which buttons to show...),
72 * @param sizeSrc size of source file
73 * @param sizeDest size of destination file
74 * @param ctimeSrc creation time of source file
75 * @param ctimeDest creation time of destination file
76 * @param mtimeSrc modification time of source file
77 * @param mtimeDest modification time of destination file
78 * @see RenameDialog_Mode
80 RenameDialog( QWidget *parent, const QString & caption,
81 const KUrl & src, const KUrl & dest,
82 RenameDialog_Mode mode,
83 KIO::filesize_t sizeSrc = (KIO::filesize_t) -1,
84 KIO::filesize_t sizeDest = (KIO::filesize_t) -1,
85 time_t ctimeSrc = (time_t) -1,
86 time_t ctimeDest = (time_t) -1,
87 time_t mtimeSrc = (time_t) -1,
88 time_t mtimeDest = (time_t) -1 );
89 ~RenameDialog();
91 /**
92 * @return the new destination
93 * valid only if RENAME was chosen
95 KUrl newDestUrl();
97 /**
98 * Given a directory path and a filename (which usually exists already),
99 * this function returns a suggested name for a file that doesn't exist
100 * in that directory. The existence is only checked for local urls though.
101 * The suggested file name is of the form foo_1 foo_2 etc.
103 static QString suggestName(const KUrl& baseURL, const QString& oldName);
105 public Q_SLOTS:
106 void cancelPressed();
107 void renamePressed();
108 void skipPressed();
109 void autoSkipPressed();
110 void overwritePressed();
111 void overwriteAllPressed();
112 void resumePressed();
113 void resumeAllPressed();
114 void suggestNewNamePressed();
116 protected Q_SLOTS:
117 void enableRenameButton(const QString &);
118 private:
119 class RenameDialogPrivate;
120 RenameDialogPrivate* const d;
121 void pluginHandling( );
126 #endif