1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 2000 David Smith <dsmith@algonet.se>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#ifndef KSHELLCOMPLETION_H
9#define KSHELLCOMPLETION_H
10
11#include <QString>
12#include <QStringList>
13
14#include "kurlcompletion.h"
15
16#include <memory>
17
18class KShellCompletionPrivate;
19
20/*!
21 * \class KShellCompletion
22 * \inmodule KIOWidgets
23 *
24 * \brief This class does shell-like completion of file names.
25 *
26 * A string passed to makeCompletion() will be interpreted as a shell
27 * command line. Completion will be done on the last argument on the line.
28 * Returned matches consist of the first arguments (uncompleted) plus the
29 * completed last argument.
30 */
31class KIOWIDGETS_EXPORT KShellCompletion : public KUrlCompletion
32{
33 Q_OBJECT
34
35public:
36 /*!
37 * Constructs a KShellCompletion object.
38 */
39 KShellCompletion();
40 ~KShellCompletion() override;
41
42 /*!
43 * Finds completions to the given text.
44 * The first match is returned and emitted in the signal match().
45 *
46 * \a text the text to complete
47 *
48 * Returns the first match, or QString() if not found
49 */
50 QString makeCompletion(const QString &text) override;
51
52protected:
53 // Called by KCompletion
54 void postProcessMatch(QString *match) const override;
55 void postProcessMatches(QStringList *matches) const override;
56 void postProcessMatches(KCompletionMatches *matches) const override;
57
58private:
59 std::unique_ptr<KShellCompletionPrivate> const d;
60};
61
62#endif // KSHELLCOMPLETION_H
63

source code of kio/src/widgets/kshellcompletion.h