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 
18 class KCompTreeNode;
19 class KCompletionPrivate;
20 class KCompletionMatchesWrapper;
21 class KCompletionMatches;
22 
115 class KCOMPLETION_EXPORT KCompletion : public QObject
116 {
117  Q_PROPERTY(CompOrder order READ order WRITE setOrder)
118  Q_PROPERTY(bool ignoreCase READ ignoreCase WRITE setIgnoreCase)
119  Q_PROPERTY(QStringList items READ items WRITE setItems)
120  Q_OBJECT
121  Q_DECLARE_PRIVATE(KCompletion)
122 
123 public:
133  CompletionNone = 1,
154  CompletionPopupAuto
155  };
156 
161  enum CompOrder { Sorted,
163  Weighted
164  };
166 
167 
170  KCompletion();
171 
175  virtual ~KCompletion();
176 
185  QStringList substringCompletion(const QString &string) const;
186 
193  virtual const QString &lastMatch() const;
194 
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 
456  virtual void setItems(const QStringList &itemList);
457 
464  void addItem(const QString &item);
465 
477  void addItem(const QString &item, uint weight);
478 
485  void removeItem(const QString &item);
486 
490  virtual void clear();
491 
492 Q_SIGNALS:
504  void match(const QString &item);
505 
512  void matches(const QStringList &matchlist);
513 
519  void multipleMatches();
520 
521 protected:
535  virtual void postProcessMatch(QString *match) const;
536 
547  virtual void postProcessMatches(QStringList *matchList) const;
548 
559  virtual void postProcessMatches(KCompletionMatches *matches) const;
560 
561 private:
564 };
565 
566 #endif // KCOMPLETION_H
Q_ENUM(...)
Lists all possible matches in a popup list box to choose from.
Definition: kcompletion.h:149
Use alphabetically sorted order.
Definition: kcompletion.h:161
Text is automatically filled in whenever possible.
Definition: kcompletion.h:137
CompOrder
Constants that represent the order in which KCompletion performs completion lookups.
Definition: kcompletion.h:161
Use order of insertion.
Definition: kcompletion.h:162
CompletionMode
This enum describes the completion mode used for by the KCompletion class.
Definition: kcompletion.h:129
A generic class for completing QStrings.
Definition: kcompletion.h:115
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:145
Q_DISABLE_COPY(Class)
Same as automatic, but shortest match is used for completion.
Definition: kcompletion.h:141
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Aug 6 2020 22:51:18 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.