File indexing completed on 2024-07-21 12:11:53

0001 /*
0002     This file is part of the KDE libraries
0003     SPDX-FileCopyrightText: 2000 David Smith <dsmith@algonet.se>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef KSHELLCOMPLETION_H
0009 #define KSHELLCOMPLETION_H
0010 
0011 #include <QString>
0012 #include <QStringList>
0013 
0014 #include "kurlcompletion.h"
0015 
0016 #include <memory>
0017 
0018 class KShellCompletionPrivate;
0019 
0020 /**
0021  * @class KShellCompletion kshellcompletion.h <KShellCompletion>
0022  *
0023  * This class does shell-like completion of file names.
0024  * A string passed to makeCompletion() will be interpreted as a shell
0025  * command line. Completion will be done on the last argument on the line.
0026  * Returned matches consist of the first arguments (uncompleted) plus the
0027  * completed last argument.
0028  *
0029  * @short Shell-like completion of file names
0030  * @author David Smith <dsmith@algonet.se>
0031  */
0032 class KIOWIDGETS_EXPORT KShellCompletion : public KUrlCompletion
0033 {
0034     Q_OBJECT
0035 
0036 public:
0037     /**
0038      * Constructs a KShellCompletion object.
0039      */
0040     KShellCompletion();
0041     ~KShellCompletion() override;
0042 
0043     /**
0044      * Finds completions to the given text.
0045      * The first match is returned and emitted in the signal match().
0046      * @param text the text to complete
0047      * @return the first match, or QString() if not found
0048      */
0049     QString makeCompletion(const QString &text) override;
0050 
0051 protected:
0052     // Called by KCompletion
0053     void postProcessMatch(QString *match) const override;
0054     void postProcessMatches(QStringList *matches) const override;
0055     void postProcessMatches(KCompletionMatches *matches) const override;
0056 
0057 private:
0058     std::unique_ptr<KShellCompletionPrivate> const d;
0059 };
0060 
0061 #endif // KSHELLCOMPLETION_H