KCompletion

kcompletion.h
1 /*
2  This file is part of the KDE libraries
3  SPDX-FileCopyrightText: 1999, 2000 Carsten Pfeiffer <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #ifndef KCOMPLETION_H
9 #define KCOMPLETION_H
10 
11 #include <kcompletion_export.h>
12 
13 #include <QObject>
14 #include <QStringList>
15 #include <QPointer>
16 #include <QKeySequence>
17 #include <memory>
18 
19 class KCompTreeNode;
20 class KCompletionPrivate;
21 class KCompletionMatchesWrapper;
22 class KCompletionMatches;
23 
116 class KCOMPLETION_EXPORT KCompletion : public QObject
117 {
118  Q_PROPERTY(CompOrder order READ order WRITE setOrder)
119  Q_PROPERTY(bool ignoreCase READ ignoreCase WRITE setIgnoreCase)
120  Q_PROPERTY(QStringList items READ items WRITE setItems)
121  Q_OBJECT
122  Q_DECLARE_PRIVATE(KCompletion)
123 
124 public:
134  CompletionNone = 1,
155  CompletionPopupAuto
156  };
157 
162  enum CompOrder { Sorted,
164  Weighted
165  };
167 
168 
171  KCompletion();
172 
176  virtual ~KCompletion();
177 
186  QStringList substringCompletion(const QString &string) const;
187 
194  virtual const QString &lastMatch() const;
195 
212  QStringList items() const;
213 
217  bool isEmpty() const;
218 
224  virtual void setCompletionMode(CompletionMode mode);
225 
233  CompletionMode completionMode() const;
234 
255  virtual void setOrder(CompOrder order);
256 
262  CompOrder order() const;
263 
271  virtual void setIgnoreCase(bool ignoreCase);
272 
279  bool ignoreCase() const;
280 
287  QStringList allMatches();
288 
294  QStringList allMatches(const QString &string);
295 
308  KCompletionMatches allWeightedMatches();
309 
315  KCompletionMatches allWeightedMatches(const QString &string);
316 
330  virtual void setSoundsEnabled(bool enable);
331 
338  bool soundsEnabled() const;
339 
345  bool hasMultipleMatches() const;
346 
347 public Q_SLOTS:
369  virtual QString makeCompletion(const QString &string);
370 
379  QString previousMatch();
380 
389  QString nextMatch();
390 
391 #if KCOMPLETION_ENABLE_DEPRECATED_SINCE(5, 0)
392 
399  KCOMPLETION_DEPRECATED_VERSION(5, 0, "Use KCompletion::makeCompletion(const QString &)")
400  void slotMakeCompletion(const QString &string) //inline (redirect)
401  {
402  (void) makeCompletion(string);
403  }
404 #endif
405 
406 #if KCOMPLETION_ENABLE_DEPRECATED_SINCE(5, 0)
407 
413  KCOMPLETION_DEPRECATED_VERSION(5, 0, "Use KCompletion::previousMatch()")
414  void slotPreviousMatch() //inline (redirect)
415  {
416  (void) previousMatch();
417  }
418 #endif
419 
420 #if KCOMPLETION_ENABLE_DEPRECATED_SINCE(5, 0)
421 
427  KCOMPLETION_DEPRECATED_VERSION(5, 0, "Use KCompletion::nextMatch()")
428  void slotNextMatch() //inline (redirect)
429  {
430  (void) nextMatch();
431  }
432 #endif
433 
439  void insertItems(const QStringList &items);
440 
455  virtual void setItems(const QStringList &itemList);
456 
463  void addItem(const QString &item);
464 
476  void addItem(const QString &item, uint weight);
477 
484  void removeItem(const QString &item);
485 
489  virtual void clear();
490 
491 Q_SIGNALS:
503  void match(const QString &item);
504 
511  void matches(const QStringList &matchlist);
512 
518  void multipleMatches();
519 
520 protected:
534  virtual void postProcessMatch(QString *match) const;
535 
546  virtual void postProcessMatches(QStringList *matchList) const;
547 
558  virtual void postProcessMatches(KCompletionMatches *matches) const;
559 
560 private:
562  std::unique_ptr<KCompletionPrivate> const d_ptr;
563 };
564 
565 #endif // KCOMPLETION_H
Q_ENUM(...)
Lists all possible matches in a popup list box to choose from.
Definition: kcompletion.h:150
Use alphabetically sorted order.
Definition: kcompletion.h:162
Text is automatically filled in whenever possible.
Definition: kcompletion.h:138
CompOrder
Constants that represent the order in which KCompletion performs completion lookups.
Definition: kcompletion.h:162
Use order of insertion.
Definition: kcompletion.h:163
CompletionMode
This enum describes the completion mode used for by the KCompletion class.
Definition: kcompletion.h:130
A generic class for completing QStrings.
Definition: kcompletion.h:116
This structure is returned by KCompletion::allWeightedMatches().
Q_PROPERTY(...)
Completes text much in the same way as a typical *nix shell would.
Definition: kcompletion.h:146
Q_DISABLE_COPY(Class)
Same as automatic, but shortest match is used for completion.
Definition: kcompletion.h:142
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Jan 16 2021 22:54:03 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.