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 <kxmlguiwindow.h>
31 #include <klineedit.h>
32 #include <kkeysequencewidget.h>
34 #include "phrasebook.h"
35 #include "ui_buttonboxui.h"
42 class KToolBarPopupAction
;
50 typedef QList
<StandardBook
> StandardBookList
;
52 /**The class PhraseTreeItem is an ListViewItem for either a phrase or a phrase book.
53 *@author Gunnar Schmi Dt
56 class CheckBookItem
: public Q3CheckListItem
{
58 CheckBookItem (Q3ListViewItem
*parent
, Q3ListViewItem
*last
,
59 const QString
&text
, const QString
&name
, const QString
&filename
);
60 CheckBookItem (Q3ListView
*parent
, Q3ListViewItem
*last
,
61 const QString
&text
, const QString
&name
, const QString
&filename
);
65 virtual void activate ();
66 virtual void stateChange (bool);
67 virtual void propagateStateChange ();
68 virtual void childChange (int numberDiff
, int selDiff
);
76 * This class represents a widget for configuring the initial phrasebook.
77 * @author Gunnar Schmi Dt
80 class InitialPhraseBookWidget
: public QWidget
{
83 InitialPhraseBookWidget(QWidget
*parent
, const char *name
);
84 ~InitialPhraseBookWidget();
89 /** initializes the list of standard phrase books */
90 void initStandardPhraseBooks ();
96 * The class StandardPhraseBookInsertAction implements an Action for
97 * inserting a standard phrase book.
98 * @author Gunnar Schmi Dt
100 class StandardPhraseBookInsertAction
: public KAction
{
103 StandardPhraseBookInsertAction (const KUrl
&url
, const QString
& name
, const QObject
* receiver
, const char* slot
, KActionCollection
* parent
)
104 : KAction (KIcon("phrasebook"), name
, parent
) {
106 connect (this, SIGNAL(slotActivated (const KUrl
&)), receiver
, slot
);
107 parent
->addAction(name
, this);
109 ~StandardPhraseBookInsertAction () {
113 void slotActivated () {
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 QWidget
, public Ui::ButtonBoxUI
{
132 ButtonBoxWidget (QWidget
*parent
= 0, const char *name
= 0);
135 KKeySequenceWidget
*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 KXmlGuiWindow
{
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 QAction
* fileNewPhrase
;
226 QAction
* fileNewBook
;
229 KToolBarPopupAction
* toolbarImport
;
230 KActionMenu
* fileImportStandardBook
;