plasma-framework/uiloader.cpp
Alexis Ménard 4467261c95 Merge woc branch to trunk, say good bye to old plasma, there is a lot of stuff to port
applets, 
please update to another revision to use the version that works

green flag from aaron


svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=796368
2008-04-13 13:23:39 +00:00

122 lines
3.0 KiB
C++

/*
* Copyright 2007 Richard J. Moore <rich@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "uiloader.h"
#include <QStringList>
#include "plasma/widgets/checkbox.h"
#include "plasma/widgets/flash.h"
#include "plasma/widgets/icon.h"
#include "plasma/widgets/label.h"
#include "plasma/widgets/pushbutton.h"
#include "plasma/widgets/radiobutton.h"
#include "plasma/widgets/meter.h"
#include "plasma/layouts/hboxlayout.h"
#include "plasma/layouts/vboxlayout.h"
#include "plasma/layouts/flowlayout.h"
namespace Plasma
{
class UiLoader::Private
{
public:
QStringList widgets;
QStringList layouts;
};
UiLoader::UiLoader( QObject *parent )
: d( new Private() )
{
d->widgets
<< "CheckBox"
<< "Flash"
<< "Icon"
<< "Label"
<< "PushButton"
<< "RadioButton"
<< "Meter";
d->layouts
<< "VBoxLayout"
<< "HBoxLayout"
<< "FlowLayout";
}
UiLoader::~UiLoader()
{
delete d;
}
QStringList UiLoader::availableWidgets() const
{
return d->widgets;
}
Widget *UiLoader::createWidget( const QString &className, Widget *parent )
{
if (className == QString("CheckBox")) {
return new CheckBox( parent );
}
else if (className == QString("Flash")) {
return new Flash( parent );
}
else if (className == QString("Icon")) {
return new Icon( parent );
}
else if (className == QString("Label")) {
return new Label( parent ); // Constructor here requires a Widget
}
else if (className == QString("PushButton")) {
return new PushButton( parent ); // Constructor here requires a Widget
}
else if (className == QString("RadioButton")) {
return new RadioButton( parent );
}
else if (className == QString("Meter")) {
return new Meter( parent );
}
return 0;
}
QStringList UiLoader::availableLayouts() const
{
return d->layouts;
}
Layout *UiLoader::createLayout( const QString &className, LayoutItem *parent )
{
if (className == QString("HBoxLayout")) {
return new HBoxLayout( parent );
}
else if (className == QString("VBoxLayout")) {
return new VBoxLayout( parent );
}
else if (className == QString("FlowLayout")) {
return new FlowLayout( parent );
}
return 0;
}
}