Port++
[kdeaccessibility.git] / kmouth / phrasebook / phrasebookdialog.h
blob976a5f91d2ab289486ee45ebbd80e15d5fff4041
1 /***************************************************************************
2 phrasebookdialog.h - description
3 -------------------
4 begin : Don Sep 19 2002
5 copyright : (C) 2002 by Gunnar Schmi Dt
6 email : kmouth@schmi-dt.de
7 ***************************************************************************/
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
18 #ifndef PHRASEBOOKDIALOG_H
19 #define PHRASEBOOKDIALOG_H
21 #include <q3button.h>
22 #include <QRadioButton>
23 #include <q3buttongroup.h>
24 #include <QLabel>
25 #include <q3listview.h>
26 //Added by qt3to4:
27 #include <QList>
28 #include <QGridLayout>
29 #include <QDropEvent>
30 #include <kmainwindow.h>
31 #include <klineedit.h>
32 #include <kkeybutton.h>
33 #include <kurl.h>
34 #include "phrasebook.h"
35 #include "buttonboxui.h"
37 class Q3ListViewItem;
38 class PhraseTreeItem;
39 class PhraseTree;
40 class QStringList;
41 class QString;
42 class K3ListView;
43 class KToolBarPopupAction;
44 class KActionMenu;
46 struct StandardBook {
47 QString name;
48 QString path;
49 QString filename;
51 typedef QList<StandardBook> StandardBookList;
53 /**The class PhraseTreeItem is an ListViewItem for either a phrase or a phrase book.
54 *@author Gunnar Schmi Dt
57 class CheckBookItem : public Q3CheckListItem {
58 public:
59 CheckBookItem (Q3ListViewItem *parent, Q3ListViewItem *last,
60 const QString &text, const QString &name, const QString &filename);
61 CheckBookItem (Q3ListView *parent, Q3ListViewItem *last,
62 const QString &text, const QString &name, const QString &filename);
63 ~CheckBookItem();
65 protected:
66 virtual void activate ();
67 virtual void stateChange (bool);
68 virtual void propagateStateChange ();
69 virtual void childChange (int numberDiff, int selDiff);
71 private:
72 int numberOfBooks;
73 int selectedBooks;
76 /**
77 * This class represents a widget for configuring the initial phrasebook.
78 * @author Gunnar Schmi Dt
81 class InitialPhraseBookWidget : public QWidget {
82 Q_OBJECT
83 public:
84 InitialPhraseBookWidget(QWidget *parent, const char *name);
85 ~InitialPhraseBookWidget();
87 void createBook();
89 private:
90 /** initializes the list of standard phrase books */
91 void initStandardPhraseBooks ();
93 K3ListView *books;
96 /**
97 * The class StandardPhraseBookInsertAction implements an Action for
98 * inserting a standard phrase book.
99 * @author Gunnar Schmi Dt
101 class StandardPhraseBookInsertAction : public KAction {
102 Q_OBJECT
103 public:
104 StandardPhraseBookInsertAction (const KUrl &url, const QString& name, const QObject* receiver, const char* slot, KActionCollection* parent)
105 : KAction (name, "phrasebook", 0, 0, 0, parent, 0) {
106 this->url = url;
107 connect (this, SIGNAL(slotActivated (const KUrl &)), receiver, slot);
109 ~StandardPhraseBookInsertAction () {
112 public slots:
113 void slotActivated () {
114 KAction::slotTriggered();
115 emit slotActivated (url);
118 signals:
119 void slotActivated (const KUrl &url);
121 private:
122 KUrl url;
126 * This class represents a widget holding the buttons of the phrase book
127 * edit window.
128 * @author Gunnar Schmi Dt
130 class ButtonBoxWidget : public ButtonBoxUI {
131 public:
132 ButtonBoxWidget (QWidget *parent = 0, const char *name = 0);
133 ~ButtonBoxWidget ();
135 KKeyButton *keyButton;
136 Q3ButtonGroup *group;
138 protected:
139 QGridLayout *keyButtonPlaceLayout;
143 * The class PhraseBookDialog implements a dialog for editing phrase books.
144 * @author Gunnar Schmi Dt
147 class PhraseBookDialog : public KMainWindow {
148 friend class InitialPhraseBookWidget;
149 Q_OBJECT
150 private:
151 /** Constructor. It is private because this class implements the singleton
152 * pattern. For creating the instance of the dialog, use the get() method.
154 PhraseBookDialog ();
156 static QString displayPath (QString path);
158 public:
159 /** Returns a pointer to the instance of this dialog. As a part off the
160 * singleton pattern it will make sure that there is at most one instance
161 * of the dialog at a given time.
163 static PhraseBookDialog *get();
165 /** Destructor. */
166 ~PhraseBookDialog();
168 bool queryClose ();
170 public slots:
171 void slotTextChanged (const QString &s);
172 void slotNoKey();
173 void slotCustomKey();
174 void capturedShortcut (const KShortcut& cut);
176 void selectionChanged ();
177 void contextMenuRequested(Q3ListViewItem *, const QPoint &pos, int);
179 void slotRemove ();
180 void slotCut ();
181 void slotCopy ();
182 void slotPaste ();
184 void slotAddPhrasebook ();
185 void slotAddPhrase ();
187 void slotSave ();
188 void slotImportPhrasebook ();
189 void slotImportPhrasebook (const KUrl &url);
190 void slotExportPhrasebook ();
191 void slotPrint ();
193 void slotDropped (QDropEvent *e, Q3ListViewItem *parent, Q3ListViewItem *after);
194 void slotMoved (Q3ListViewItem *item, Q3ListViewItem *, Q3ListViewItem *);
196 signals:
197 void phrasebookConfirmed (PhraseBook &book);
199 private:
200 static StandardBookList standardPhraseBooks ();
202 void initGUI();
203 /** initializes the KActions of the window */
204 void initActions();
205 /** initializes the list of standard phrase books */
206 void initStandardPhraseBooks ();
208 Q3ListViewItem *addBook (Q3ListViewItem *parent, Q3ListViewItem *after, PhraseBook *book);
209 Q3ListViewItem *addBook (Q3ListViewItem *item, PhraseBook *book);
211 void setShortcut (const KShortcut &cut);
213 void _warning (const QKeySequence &cut, const QString &sAction, const QString &sTitle);
215 bool isGlobalKeyPresent (const KShortcut& cut, bool warnUser);
216 bool isPhraseKeyPresent (const KShortcut& cut, bool warnUser);
217 bool isKeyPresent (const KShortcut& cut, bool warnUser);
219 PhraseBook book;
220 bool phrasebookChanged;
222 PhraseTree *treeView;
223 ButtonBoxWidget *buttonBox;
225 KAction* fileNewPhrase;
226 KAction* fileNewBook;
227 KAction* fileSave;
228 KAction* fileImport;
229 KToolBarPopupAction* toolbarImport;
230 KActionMenu* fileImportStandardBook;
231 KAction* fileExport;
232 KAction* filePrint;
233 KAction* fileClose;
234 KAction* editCut;
235 KAction* editCopy;
236 KAction* editPaste;
237 KAction* editDelete;
240 #endif