Scribus
Open source desktop publishing at your fingertips
aspellpluginimpl.h
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 // Local include files
19 #include "ui_aspellpluginbase.h" // For GUI from QT4 designer
20 // #include "donedlgimpl.h" // For spell-checking done dialog
21 #include "suggest.h" // For aspell interface class
22 
23 class ScribusDoc;
24 class PrefsContext;
25 class PageItem;
26 
32 class AspellPluginImpl : public QDialog, private Ui::AspellPluginBase
33 {
34  Q_OBJECT
35 private:
37  static const char* kDEF_CONTEXT;
39  static const QString kDEF_ASPELL_ENTRY;
41  Speller::Aspell::Suggest* fsuggest;
43  PrefsContext* fprefs;
45  QString flang;
47  QString fjargon;
49  QString fencoding;
51  QString fentry;
53  ScribusDoc* fdoc;
55  bool m_docIsChanged;
56 #if 0
57  // HACK: this is not used anywhere - PV
59  struct Changes
60  {
62  uint fnwords;
64  uint fntot;
66  uint fnframes;
75  Changes(uint nwords=0, uint ntot=0, uint nframes=0) :
76  fnwords(nwords), fntot(ntot), fnframes(nframes) {}
77  } fnchanges;
78 #endif
79 
80  QString fcontent;
82  uint fpos;
83  QHash<QString, QString> rememberedWords;
85  int fidx;
87  QStringList fwordlist;
89  PageItem* fFrame;
91  QString m_errorMessage;
92 
93 protected:
100  void checkText();
107  void nextWord();
116  void setPreferences(const QString& lang,
117  const QString& jargon,
118  const QString& encoding=Speller::Aspell::Suggest::kDEF_ENCODING,
119  const QString& entry=kDEF_ASPELL_ENTRY);
126  void getPreferences();
133  void activateSpellGUI(bool active);
140  void parseItem();
147  void parseSelection();
154  void spellCheckDone();
155 
161  bool handleSpellConfig(const QString & dictFullName);
162 
163 public:
171  AspellPluginImpl(ScribusDoc* doc, QWidget* parent=NULL);
179 
183  QString errorMessage() { return m_errorMessage; } ;
184 
185 public slots:
192  void on_fcloseBtn_clicked();
199  void on_fchangeBtn_clicked();
213  void on_fskipBtn_clicked();
220  void on_fskipAllBtn_clicked();
227  void on_faddWordBtn_clicked();
242 
243 protected slots:
244  void languageChange();
245 
246 };
247 #endif // #ifndef ASPELLPLUGINIMPL_H
248 //@@@@@@@@@@@@@@@@@@@@@@@@@ END OF FILE @@@@@@@@@@@@@@@@@@@@@@@@@
void on_fcloseBtn_clicked()
Slot: Called when the "Close" button is clicked. Makes any pending replacements, and closes spell-che...
Definition: aspellpluginimpl.cpp:285
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.
Definition: aspellpluginimpl.h:32
AspellPluginImpl(ScribusDoc *doc, QWidget *parent=NULL)
Constructor for spell-checking plugin implementation.
Definition: aspellpluginimpl.cpp:31
void getPreferences()
Retrieve saved user preferences: language, jargon, encoding.
Definition: aspellpluginimpl.cpp:474
static const char * kDEF_ENCODING
Default character encoding for words.
Definition: suggest.h:117
void on_flistReplacements_itemActivated()
Slot: Called when an item in the list of aspell suggestions is highlighted. Changes the current word ...
Definition: aspellpluginimpl.cpp:420
void parseSelection()
Spell-check selected frames in the page.
Definition: aspellpluginimpl.cpp:516
void setPreferences(const QString &lang, const QString &jargon, const QString &encoding=Speller::Aspell::Suggest::kDEF_ENCODING, const QString &entry=kDEF_ASPELL_ENTRY)
Save user preferences.
Definition: aspellpluginimpl.cpp:487
the Document Class
Definition: scribusdoc.h:90
void spellCheckDone()
Called when spell-checking is completed. Pops up an information dialog.
Definition: aspellpluginimpl.cpp:263
void activateSpellGUI(bool active)
Activates spell-checking GUI elements in spell-checking tab, i.e., everything except combo box at top...
Definition: aspellpluginimpl.cpp:146
void nextWord()
Skips to the beginning of the next word in 'fcontent', the text being spell-checked.
Definition: aspellpluginimpl.cpp:164
Class for interfacing with aspell. Should work with any aspell version from 0.60 onwards.
Definition: suggest.h:31
bool handleSpellConfig(const QString &dictFullName)
Sets the dict configuration based on given dictFullName or in the constructor. See on_flistDicts_acti...
Definition: aspellpluginimpl.cpp:428
void on_fchangeAllBtn_clicked()
Slot: Called when the "Change All" button is clicked. Replaces all occurrences of the word being chec...
Definition: aspellpluginimpl.cpp:328
void on_fskipBtn_clicked()
Slot: Called when the "Skip" button is clicked. Skips the word currently being spell-checked.
Definition: aspellpluginimpl.cpp:365
QString errorMessage()
Returns a error message for caller. It should disable the plugin then.
Definition: aspellpluginimpl.h:183
void on_fskipAllBtn_clicked()
Slot: Called when the "Skip All" button is clicked. Skips all occurences of the word currently being ...
Definition: aspellpluginimpl.cpp:374
void parseItem()
Base method to spell-check text in current frame.
Definition: aspellpluginimpl.cpp:505
Definition: prefscontext.h:40
void on_fchangeBtn_clicked()
Slot: Called when the "Change" button is clicked. Replaces the word being checked with the currently ...
Definition: aspellpluginimpl.cpp:293
~AspellPluginImpl()
Destructor for spell-checking plugin implementation.
Definition: aspellpluginimpl.cpp:127
void on_faddWordBtn_clicked()
Slot: Called when the "Add word" button is clicked. Adds current suggestion to user's personal direct...
Definition: aspellpluginimpl.cpp:401
Definition: pageitem.h:92
void checkText()
Initializes the position in the current text, sets the current word, and starts spell-checking.
Definition: aspellpluginimpl.cpp:199
void on_flistDicts_activated()
Slot: Called when an item in the list of available aspell dictionaries is selected. Resets aspell dictionary to selected one.
Definition: aspellpluginimpl.cpp:448