summaryrefslogtreecommitdiffstats
path: root/kmouth/wordcompletion/wordcompletion.h
blob: f0cb812e9e815fa323796fce6940ea1cee110302 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#ifndef WORDCOMPLETION_H
#define WORDCOMPLETION_H

#include <kcompletion.h>

/**
 * This class does completion based on a dictionary of words.
 */
class WordCompletion : public KCompletion {
   friend class WordListWidget;
   Q_OBJECT
public:
   WordCompletion();
   virtual ~WordCompletion();

   /**
    * Returns the names for the available word lists
    */
   QStringList wordLists();

   /**
    * Returns the names for those word lists that contain
    * words of a given language.
    */
   QStringList wordLists(const QString &language);
   
   /**
    * Returns the language of a given word list.
    */
   QString languageOfWordList(const QString &wordlist);

   /**
    * Returns the name of the currently active word list.
    */
   QString currentWordList();

   /**
    * Finds completions to the given text.
    */
   virtual QString makeCompletion(const QString&);

   static bool isConfigured();
   
   /**
    * Adds the words from the given sentence to the list of words.
    */
   void addSentence (const QString &sentence);
   
public slots:
   /**
    * Re-reads the configuration.
    */
   void configure();
   
   /**
    * Specify which word list gets used for the actual word completion.
    * If there is no word list with the given name the first configured
    * list gets used.
    * The method returns true if the specified word list was found.
    */
   bool setWordList(const QString &wordlist);

   /**
    * Saves the added words to disk.
    */
   void save ();

signals:
   void wordListsChanged (const QStringList &wordLists);
   void currentListChanged (const QString &wordList);

private:
   class WordCompletionPrivate;
   WordCompletionPrivate *d;
};

#endif // KURLCOMPLETION_H