1 /* This file is part of the KDE project
2    Copyright (C) 2003 Lucijan Busch <lucijan@gmx.at>
3    Copyright (C) 2004-2009 Jarosław Staniek <staniek@kde.org>
4 
5    This library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Library General Public
7    License as published by the Free Software Foundation; either
8    version 2 of the License, or (at your option) any later version.
9 
10    This library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Library General Public License for more details.
14 
15    You should have received a copy of the GNU Library General Public License
16    along with this library; see the file COPYING.LIB.  If not, write to
17    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19 */
20 
21 #include "widgetfactory.h"
22 
23 #include "WidgetInfo.h"
24 #include "libactionwidget.h"
25 
26 #include <KexiIcon.h>
27 
28 using namespace KFormDesigner;
29 
30 class Q_DECL_HIDDEN LibActionWidget::Private
31 {
32 public:
33     explicit Private(WidgetInfo *w);
34     ~Private();
35 
36     QByteArray className;
37 };
38 
Private(WidgetInfo * w)39 LibActionWidget::Private::Private(WidgetInfo *w) : className(w->className())
40 {
41 }
42 
~Private()43 LibActionWidget::Private::~Private()
44 {
45 }
46 
LibActionWidget(ActionGroup * group,WidgetInfo * w)47 LibActionWidget::LibActionWidget(ActionGroup *group, WidgetInfo *w)
48     : KToggleAction(QIcon::fromTheme(w->iconName()), w->name(), group), d(new Private(w))
49 {
50     setObjectName(QLatin1String("library_widget_") + w->className());
51     group->addAction(this);
52     setToolTip(w->name());
53     setWhatsThis(w->description());
54 }
55 
~LibActionWidget()56 LibActionWidget::~LibActionWidget()
57 {
58     delete d;
59 }
60 
61 void
slotToggled(bool checked)62 LibActionWidget::slotToggled(bool checked)
63 {
64     KToggleAction::slotToggled(checked);
65     if (checked)
66         emit toggled(d->className);
67 }
68 
69