Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / workspace / libs / plasma / uiloader.cpp
blobe64a9090eb9c284a8376697414c26306a9477f74
1 /*
2 * Copyright 2007 Richard J. Moore <rich@kde.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Library General Public License as
6 * published by the Free Software Foundation; either version 2, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details
14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #include "uiloader.h"
22 #include <QStringList>
24 #include <QGraphicsLinearLayout>
26 #include "plasma/widgets/checkbox.h"
27 #include "plasma/widgets/flash.h"
28 #include "plasma/widgets/icon.h"
29 #include "plasma/widgets/label.h"
30 #include "plasma/widgets/pushbutton.h"
31 #include "plasma/widgets/radiobutton.h"
32 #include "plasma/widgets/meter.h"
34 #include "plasma/layouts/flowlayout.h"
36 namespace Plasma
39 class UiLoader::Private
41 public:
42 QStringList widgets;
43 QStringList layouts;
46 UiLoader::UiLoader( QObject *parent )
47 : d( new Private() )
49 d->widgets
50 << "CheckBox"
51 << "Flash"
52 << "Icon"
53 << "Label"
54 << "PushButton"
55 << "RadioButton"
56 << "Meter";
58 d->layouts
59 << "VBoxLayout"
60 << "HBoxLayout"
61 << "FlowLayout";
64 UiLoader::~UiLoader()
66 delete d;
69 QStringList UiLoader::availableWidgets() const
71 return d->widgets;
74 Widget *UiLoader::createWidget( const QString &className, Widget *parent )
76 if (className == QString("CheckBox")) {
77 return new CheckBox( parent );
79 else if (className == QString("Flash")) {
80 return new Flash( parent );
82 else if (className == QString("Icon")) {
83 return new Icon( parent );
85 else if (className == QString("Label")) {
86 return new Label( parent ); // Constructor here requires a Widget
88 else if (className == QString("PushButton")) {
89 return new PushButton( parent ); // Constructor here requires a Widget
91 else if (className == QString("RadioButton")) {
92 return new RadioButton( parent );
94 else if (className == QString("Meter")) {
95 return new Meter( parent );
98 return 0;
101 QStringList UiLoader::availableLayouts() const
103 return d->layouts;
106 QGraphicsLayout *UiLoader::createLayout( const QString &className, QGraphicsLayoutItem *parent )
108 if (className == QString("HBoxLayout")) {
109 return new QGraphicsLinearLayout( Qt::Horizontal, parent );
111 else if (className == QString("VBoxLayout")) {
112 return new QGraphicsLinearLayout( Qt::Vertical, parent );
114 else if (className == QString("FlowLayout")) {
115 return new FlowLayout( parent );
118 return 0;