KIO

batchrenamejob.h
1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 2017 Chinmoy Ranjan Pradhan <chinmoyrp65@gmail.com>
4
5 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6*/
7
8#ifndef BATCHRENAMEJOB_H
9#define BATCHRENAMEJOB_H
10
11#include "job_base.h"
12#include "kiocore_export.h"
13
14namespace KIO
15{
16class BatchRenameJobPrivate;
17
18/**
19 * @class KIO::BatchRenameJob batchrenamejob.h <KIO/BatchRenameJob>
20 *
21 * A KIO job that renames multiple files in one go.
22 *
23 * @since 5.42
24 */
25class KIOCORE_EXPORT BatchRenameJob : public Job
26{
27 Q_OBJECT
28
29public:
30 ~BatchRenameJob() override;
31
32Q_SIGNALS:
33 /**
34 * Signals that a file was renamed.
35 */
36 void fileRenamed(const QUrl &oldUrl, const QUrl &newUrl);
37
38protected Q_SLOTS:
39 void slotResult(KJob *job) override;
40
41protected:
42 /// @internal
43 KIOCORE_NO_EXPORT explicit BatchRenameJob(BatchRenameJobPrivate &dd);
44
45private:
46 Q_DECLARE_PRIVATE(BatchRenameJob)
47};
48
49/**
50 * Renames multiple files at once.
51 *
52 * The new filename is obtained by replacing the characters represented by
53 * @p placeHolder by the index @p index.
54 * E.g. Calling batchRename({"file:///Test.jpg"}, "Test #" 12, '#') renames
55 * the file to "Test 12.jpg". A connected sequence of placeholders results in
56 * leading zeros. batchRename({"file:///Test.jpg"}, "Test ####" 12, '#') renames
57 * the file to "Test 0012.jpg". And if no placeholder is there then @p index is
58 * appended to @p newName. Calling batchRename({"file:///Test.jpg"}, "NewTest" 12, '#')
59 * renames the file to "NewTest12.jpg".
60 *
61 * @param src The list of items to rename.
62 * @param newName The base name to use in all new filenames.
63 * @param index The integer(incremented after renaming a file) to add to the base name.
64 * @param placeHolder The character(s) which @p index will replace.
65 *
66 * @return A pointer to the job handling the operation.
67 * @since 5.42
68 */
69KIOCORE_EXPORT BatchRenameJob *batchRename(const QList<QUrl> &src, const QString &newName, int index, QChar placeHolder, JobFlags flags = DefaultFlags);
70
71}
72
73#endif
A KIO job that renames multiple files in one go.
void fileRenamed(const QUrl &oldUrl, const QUrl &newUrl)
Signals that a file was renamed.
The base class for all jobs.
A namespace for KIO globals.
KIOCORE_EXPORT BatchRenameJob * batchRename(const QList< QUrl > &src, const QString &newName, int index, QChar placeHolder, JobFlags flags=DefaultFlags)
Renames multiple files at once.
@ DefaultFlags
Show the progress info GUI, no Resume and no Overwrite.
Definition job_base.h:246
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:16:27 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.