Rev 11088 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
11087 | fschmid | 1 | /* |
2 | For general Scribus (>=1.3.2) copyright and licensing information please refer |
||
3 | to the COPYING file provided with the program. Following this notice may exist |
||
4 | a copyright and/or license notice that predates the release of Scribus 1.3.2 |
||
5 | for which a new license (GPL+exception) is in place. |
||
6 | */ |
||
7 | #ifndef ASPELLPLUGINIMPL_H |
||
8 | #define ASPELLPLUGINIMPL_H |
||
9 | |||
10 | // ISO C++ include files |
||
11 | #include <string> // For replacement word from aspell |
||
12 | #include <vector> // For array of replacements from aspell |
||
13 | // QT include files |
||
14 | #include <QRegExp> |
||
15 | #include <QString> |
||
16 | #include <QStringList> |
||
17 | #include <QHash> |
||
18 | // Scribus include files |
||
19 | #include "scribusdoc.h" // For ScribusDoc |
||
20 | #include "scribus.h" // For ScribusMainWindow |
||
21 | #include "selection.h" // Item selected |
||
22 | #include "prefsfile.h" // Stored plugin preferences |
||
23 | #include "prefsmanager.h" // Preferences manager |
||
24 | // Local include files |
||
25 | #include "ui_aspellpluginbase.h" // For GUI from QT4 designer |
||
26 | // #include "donedlgimpl.h" // For spell-checking done dialog |
||
27 | #include "suggest.h" // For aspell interface class |
||
28 | |||
29 | /*! |
||
30 | \class AspellPluginImpl |
||
31 | \author Gora Mohanty <gora@srijan.in> |
||
32 | \brief Implementation of plugin. GUI part is derived from AspellPluginBase class, as aspellpluginbase.{cpp,h} get overwritten by uic. Interface to aspell uses Speller::Aspell::Suggest |
||
33 | */ |
||
34 | class AspellPluginImpl : public QDialog, private Ui::AspellPluginBase |
||
35 | { |
||
36 | Q_OBJECT |
||
37 | private: |
||
38 | /*! \brief Context name for storing preferences */ |
||
39 | static const char* kDEF_CONTEXT; |
||
40 | /*! Formatted string for aspell dictionary entry: Form of <name>--<lang>--<jargon>--<size> */ |
||
41 | static const QString kDEF_ASPELL_ENTRY; |
||
42 | /*! \brief Aspell interface object. */ |
||
43 | Speller::Aspell::Suggest* fsuggest; |
||
44 | /*! \brief Scribus preferences object. */ |
||
45 | PrefsContext* fprefs; |
||
46 | /*! \brief Language for aspell dictionary. */ |
||
47 | QString flang; |
||
48 | /*! \brief Jargon for aspell dictionary. */ |
||
49 | QString fjargon; |
||
50 | /*! \brief Character encoding for words. */ |
||
51 | QString fencoding; |
||
52 | /*! \brief Formatted string for aspell dictionary entry: Form of <name>--<lang>--<jargon>--<size> */ |
||
53 | QString fentry; |
||
54 | /*! \brief Pointer to current document. */ |
||
55 | ScribusDoc* fdoc; |
||
56 | /*! \brief Structure to keep track of number of changes made. */ |
||
57 | struct Changes |
||
58 | { |
||
59 | /*! brief Number of words changed in this frame. */ |
||
60 | uint fnwords; |
||
61 | /*! brief Number of words changed in all. */ |
||
62 | uint fntot; |
||
63 | /*! brief Number of frames changed. */ |
||
64 | uint fnframes; |
||
65 | /*! |
||
66 | \author Gora Mohanty <gora@srijan.in> |
||
67 | \brief Constructor for counts of items changes |
||
68 | \param nwords: No. of words changed in this frame. |
||
69 | \param ntot: Total no. of words changed. |
||
70 | \param nframes: No. of frames changed. |
||
71 | \retval None |
||
72 | */ |
||
73 | Changes(uint nwords=0, uint ntot=0, uint nframes=0) : |
||
74 | fnwords(nwords), fntot(ntot), fnframes(nframes) {} |
||
75 | } fnchanges; |
||
76 | /*! \brief Extracted string of text from one frame. */ |
||
77 | QString fcontent; |
||
78 | /*! \brief Position in 'fcontent' of word being spell-checked. */ |
||
79 | uint fpos; |
||
80 | QHash<QString, QString> rememberedWords; |
||
81 | /*! \brief Index in 'fcontent' of word being spell-checked. */ |
||
82 | int fidx; |
||
83 | /*! \brief Word currently being spell-checked. */ |
||
84 | QStringList fwordlist; |
||
85 | /*! \brief Pointer to current frame. */ |
||
86 | PageItem* fFrame; |
||
87 | /*! \brief Model for list of dictionaries. */ |
||
88 | |||
89 | protected: |
||
90 | /*! |
||
91 | \author Gora Mohanty <gora@srijan.in> |
||
92 | \brief Initializes the position in the current text, sets the current word, and starts spell-checking. |
||
93 | \param None |
||
94 | \retval None |
||
95 | */ |
||
96 | void checkText(); |
||
97 | /*! |
||
98 | \author Gora Mohanty <gora@srijan.in> |
||
99 | \brief Skips to the beginning of the next word in 'fcontent', the text being spell-checked. |
||
100 | \param None |
||
101 | \retval None |
||
102 | */ |
||
103 | void nextWord(); |
||
104 | /*! |
||
105 | \author Gora Mohanty <gora@srijan.in> |
||
106 | \brief Save user preferences |
||
107 | \param language: Language for aspell dictionary |
||
108 | \param jargon: Jargon for aspell dictionary |
||
109 | \param encoding: Encoding for aspell dictionary |
||
110 | \retval None |
||
111 | */ |
||
112 | void setPreferences(const QString& lang, |
||
113 | const QString& jargon, |
||
114 | const QString& encoding=Speller::Aspell::Suggest::kDEF_ENCODING, |
||
115 | const QString& entry=kDEF_ASPELL_ENTRY); |
||
116 | /*! |
||
117 | \author Gora Mohanty <gora@srijan.in> |
||
118 | \brief Retrieve saved user preferences: language, jargon, encoding. |
||
119 | \param None |
||
120 | \retval None |
||
121 | */ |
||
122 | void getPreferences(); |
||
123 | /*! |
||
124 | \author Gora Mohanty <gora@srijan.in> |
||
125 | \brief Activates spell-checking GUI elements in spell-checking tab, i.e., everything except combo box at top |
||
126 | \param None |
||
127 | \retval None |
||
128 | */ |
||
129 | void activateSpellGUI(); |
||
130 | /*! |
||
131 | \author Gora Mohanty <gora@srijan.in> |
||
132 | \brief Deactivates spell-checking GUI elements in spell-checking tab, i.e., everything except combo box at top |
||
133 | \param None |
||
134 | \retval None |
||
135 | */ |
||
136 | void deactivateSpellGUI(); |
||
137 | /*! |
||
138 | \author Gora Mohanty <gora@srijan.in> |
||
139 | \brief Base method to spell-check text in current frame. |
||
140 | \param None |
||
141 | \retval None |
||
142 | */ |
||
143 | void parseItem(); |
||
144 | /*! |
||
145 | \author Gora Mohanty <gora@srijan.in> |
||
146 | \brief Spell-check selected frames in the page |
||
147 | \param None |
||
148 | \retval None |
||
149 | */ |
||
150 | void parseSelection(); |
||
151 | /*! |
||
152 | \author Gora Mohanty <gora@srijan.in> |
||
153 | \brief Called when spell-checking is completed. Pops up an information dialog. |
||
154 | \param None |
||
155 | \retval None |
||
156 | */ |
||
157 | void spellCheckDone(); |
||
158 | |||
159 | public: |
||
160 | /*! |
||
161 | \author Gora Mohanty <gora@srijan.in> |
||
162 | \brief Constructor for spell-checking plugin implementation. |
||
163 | \param doc: Scribus doc |
||
164 | \param parent: Parent window that this is a child of. |
||
165 | \retval None |
||
166 | */ |
||
167 | AspellPluginImpl(ScribusDoc* doc, QWidget* parent=NULL); |
||
168 | /*! |
||
169 | \author Gora Mohanty <gora@srijan.in> |
||
170 | \brief Destructor for spell-checking plugin implementation. |
||
171 | \param None |
||
172 | \retval None |
||
173 | */ |
||
174 | ~AspellPluginImpl(); |
||
175 | |||
176 | public slots: |
||
177 | /*! |
||
178 | \author Gora Mohanty <gora@srijan.in> |
||
179 | \brief Slot: Called when the "Close" button is clicked. Makes any pending replacements, and closes spell-check window. |
||
180 | \param None |
||
181 | \retval None |
||
182 | */ |
||
183 | void on_fcloseBtn_clicked(); |
||
184 | /*! |
||
185 | \author Gora Mohanty <gora@srijan.in> |
||
186 | \brief Slot: Called when the "Change" button is clicked. Replaces the word being checked with the currently selected replacement. |
||
187 | \param None |
||
188 | \retval None |
||
189 | */ |
||
190 | void on_fchangeBtn_clicked(); |
||
191 | /*! |
||
192 | \author Gora Mohanty <gora@srijan.in> |
||
193 | \brief Slot: Called when the "Change All" button is clicked. Replaces all occurrences of the word being checked with the currently selected replacement. |
||
194 | \param None |
||
195 | \retval None |
||
196 | */ |
||
197 | void on_fchangeAllBtn_clicked(); |
||
198 | /*! |
||
199 | \author Gora Mohanty <gora@srijan.in> |
||
200 | \brief Slot: Called when the "Skip" button is clicked. Skips the word currently being spell-checked. |
||
201 | \param None |
||
202 | \retval None |
||
203 | */ |
||
204 | void on_fskipBtn_clicked(); |
||
205 | /*! |
||
206 | \author Gora Mohanty <gora@srijan.in> |
||
207 | \brief Slot: Called when the "Skip All" button is clicked. Skips all occurences of the word currently being spell-checked. |
||
208 | \param None |
||
209 | \retval None |
||
210 | */ |
||
211 | void on_fskipAllBtn_clicked(); |
||
212 | /*! |
||
213 | \author Gora Mohanty <gora@srijan.in> |
||
214 | \brief Slot: Called when the "Add word" button is clicked. Adds current suggestion to user's personal directory. |
||
215 | \param None |
||
216 | \retval None |
||
217 | */ |
||
218 | void on_faddWordBtn_clicked(); |
||
219 | /*! |
||
220 | \author Gora Mohanty <gora@srijan.in> |
||
221 | \brief Slot: Called when an item in the list of aspell suggestions is highlighted. Changes the current word (in the text edit box). |
||
222 | \param None |
||
223 | \retval None |
||
224 | */ |
||
225 | void on_flistReplacements_itemActivated(); |
||
226 | /*! |
||
227 | \author Gora Mohanty <gora@srijan.in> |
||
228 | \brief Slot: Called when an item in the list of available aspell dictionaries is selected. Resets aspell dictionary to selected one. |
||
229 | \param None |
||
230 | \retval None |
||
231 | */ |
||
11088 | fschmid | 232 | void on_flistDicts_activated(); |
11087 | fschmid | 233 | |
234 | protected slots: |
||
235 | void languageChange(); |
||
236 | |||
237 | }; |
||
238 | #endif // #ifndef ASPELLPLUGINIMPL_H |
||
239 | //@@@@@@@@@@@@@@@@@@@@@@@@@ END OF FILE @@@@@@@@@@@@@@@@@@@@@@@@@ |