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 class KShellCompletionPrivate;
17 
18 /**
19  * @class KShellCompletion kshellcompletion.h <KShellCompletion>
20  *
21  * This class does shell-like completion of file names.
22  * A string passed to makeCompletion() will be interpreted as a shell
23  * command line. Completion will be done on the last argument on the line.
24  * Returned matches consist of the first arguments (uncompleted) plus the
25  * completed last argument.
26  *
27  * @short Shell-like completion of file names
28  * @author David Smith <dsmith@algonet.se>
29  */
30 class KIOWIDGETS_EXPORT KShellCompletion : public KUrlCompletion
31 {
32     Q_OBJECT
33 
34 public:
35     /**
36      * Constructs a KShellCompletion object.
37      */
38     KShellCompletion();
39     ~KShellCompletion() override;
40 
41     /**
42      * Finds completions to the given text.
43      * The first match is returned and emitted in the signal match().
44      * @param text the text to complete
45      * @return the first match, or QString() if not found
46      */
47     QString makeCompletion(const QString &text) override;
48 
49 protected:
50     // Called by KCompletion
51     void postProcessMatch(QString *match) const override;
52     void postProcessMatches(QStringList *matches) const override;
53     void postProcessMatches(KCompletionMatches *matches) const override;
54 
55 private:
56     KShellCompletionPrivate *const d;
57 };
58 
59 #endif // KSHELLCOMPLETION_H
60