1 /***************************************************************************
2 phrasebookdialog.h - description
4 begin : Don Sep 19 2002
5 copyright : (C) 2002 by Gunnar Schmi Dt
6 email : kmouth@schmi-dt.de
7 ***************************************************************************/
9 /***************************************************************************
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. *
16 ***************************************************************************/
18 #ifndef PHRASEBOOKDIALOG_H
19 #define PHRASEBOOKDIALOG_H
22 #include <QRadioButton>
23 #include <q3buttongroup.h>
25 #include <q3listview.h>
28 #include <QGridLayout>
30 #include <kmainwindow.h>
31 #include <klineedit.h>
32 #include <kkeybutton.h>
34 #include "phrasebook.h"
35 #include "buttonboxui.h"
43 class KToolBarPopupAction
;
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
{
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
);
66 virtual void activate ();
67 virtual void stateChange (bool);
68 virtual void propagateStateChange ();
69 virtual void childChange (int numberDiff
, int selDiff
);
77 * This class represents a widget for configuring the initial phrasebook.
78 * @author Gunnar Schmi Dt
81 class InitialPhraseBookWidget
: public QWidget
{
84 InitialPhraseBookWidget(QWidget
*parent
, const char *name
);
85 ~InitialPhraseBookWidget();
90 /** initializes the list of standard phrase books */
91 void initStandardPhraseBooks ();
97 * The class StandardPhraseBookInsertAction implements an Action for
98 * inserting a standard phrase book.
99 * @author Gunnar Schmi Dt
101 class StandardPhraseBookInsertAction
: public KAction
{
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) {
107 connect (this, SIGNAL(slotActivated (const KUrl
&)), receiver
, slot
);
109 ~StandardPhraseBookInsertAction () {
113 void slotActivated () {
114 KAction::slotTriggered();
115 emit
slotActivated (url
);
119 void slotActivated (const KUrl
&url
);
126 * This class represents a widget holding the buttons of the phrase book
128 * @author Gunnar Schmi Dt
130 class ButtonBoxWidget
: public ButtonBoxUI
{
132 ButtonBoxWidget (QWidget
*parent
= 0, const char *name
= 0);
135 KKeyButton
*keyButton
;
136 Q3ButtonGroup
*group
;
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
;
151 /** Constructor. It is private because this class implements the singleton
152 * pattern. For creating the instance of the dialog, use the get() method.
156 static QString
displayPath (QString path
);
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();
171 void slotTextChanged (const QString
&s
);
173 void slotCustomKey();
174 void capturedShortcut (const KShortcut
& cut
);
176 void selectionChanged ();
177 void contextMenuRequested(Q3ListViewItem
*, const QPoint
&pos
, int);
184 void slotAddPhrasebook ();
185 void slotAddPhrase ();
188 void slotImportPhrasebook ();
189 void slotImportPhrasebook (const KUrl
&url
);
190 void slotExportPhrasebook ();
193 void slotDropped (QDropEvent
*e
, Q3ListViewItem
*parent
, Q3ListViewItem
*after
);
194 void slotMoved (Q3ListViewItem
*item
, Q3ListViewItem
*, Q3ListViewItem
*);
197 void phrasebookConfirmed (PhraseBook
&book
);
200 static StandardBookList
standardPhraseBooks ();
203 /** initializes the KActions of the window */
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
);
220 bool phrasebookChanged
;
222 PhraseTree
*treeView
;
223 ButtonBoxWidget
*buttonBox
;
225 KAction
* fileNewPhrase
;
226 KAction
* fileNewBook
;
229 KToolBarPopupAction
* toolbarImport
;
230 KActionMenu
* fileImportStandardBook
;