2007-09-05 23:58:10 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2007 Richard J. Moore <rich@kde.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2007-09-14 22:17:11 +02:00
|
|
|
* 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.
|
2007-09-05 23:58:10 +02:00
|
|
|
*
|
|
|
|
* 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>
|
|
|
|
|
2007-11-20 00:45:56 +01:00
|
|
|
#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"
|
2007-09-05 23:58:10 +02:00
|
|
|
|
2008-02-29 18:50:57 +01:00
|
|
|
#include "plasma/layouts/hboxlayout.h"
|
|
|
|
#include "plasma/layouts/vboxlayout.h"
|
2007-11-20 00:45:56 +01:00
|
|
|
#include "plasma/layouts/flowlayout.h"
|
2007-09-05 23:58:10 +02:00
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
|
|
|
class UiLoader::Private
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
QStringList widgets;
|
|
|
|
QStringList layouts;
|
|
|
|
};
|
|
|
|
|
|
|
|
UiLoader::UiLoader( QObject *parent )
|
|
|
|
: d( new Private() )
|
|
|
|
{
|
|
|
|
d->widgets
|
2007-11-20 01:47:20 +01:00
|
|
|
<< "CheckBox"
|
|
|
|
<< "Flash"
|
|
|
|
<< "Icon"
|
|
|
|
<< "Label"
|
|
|
|
<< "PushButton"
|
|
|
|
<< "RadioButton"
|
2007-09-25 17:50:32 +02:00
|
|
|
<< "Meter";
|
2007-09-05 23:58:10 +02:00
|
|
|
|
|
|
|
d->layouts
|
2007-11-20 01:47:20 +01:00
|
|
|
<< "VBoxLayout"
|
|
|
|
<< "HBoxLayout"
|
|
|
|
<< "FlowLayout";
|
2007-09-05 23:58:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
UiLoader::~UiLoader()
|
|
|
|
{
|
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList UiLoader::availableWidgets() const
|
|
|
|
{
|
|
|
|
return d->widgets;
|
|
|
|
}
|
|
|
|
|
2007-09-06 00:35:54 +02:00
|
|
|
Widget *UiLoader::createWidget( const QString &className, Widget *parent )
|
2007-09-05 23:58:10 +02:00
|
|
|
{
|
2007-11-20 01:47:20 +01:00
|
|
|
if (className == QString("CheckBox")) {
|
|
|
|
return new CheckBox( parent );
|
2007-09-05 23:58:10 +02:00
|
|
|
}
|
2007-11-20 01:47:20 +01:00
|
|
|
else if (className == QString("Flash")) {
|
|
|
|
return new Flash( parent );
|
2007-09-05 23:58:10 +02:00
|
|
|
}
|
2007-11-20 01:47:20 +01:00
|
|
|
else if (className == QString("Icon")) {
|
|
|
|
return new Icon( parent );
|
2007-09-05 23:58:10 +02:00
|
|
|
}
|
2007-11-20 01:47:20 +01:00
|
|
|
else if (className == QString("Label")) {
|
|
|
|
return new Label( parent ); // Constructor here requires a Widget
|
2007-09-05 23:58:10 +02:00
|
|
|
}
|
2007-11-20 01:47:20 +01:00
|
|
|
else if (className == QString("PushButton")) {
|
|
|
|
return new PushButton( parent ); // Constructor here requires a Widget
|
2007-09-05 23:58:10 +02:00
|
|
|
}
|
2007-11-20 01:47:20 +01:00
|
|
|
else if (className == QString("RadioButton")) {
|
|
|
|
return new RadioButton( parent );
|
2007-09-05 23:58:10 +02:00
|
|
|
}
|
2007-11-20 01:47:20 +01:00
|
|
|
else if (className == QString("Meter")) {
|
2007-09-25 17:50:32 +02:00
|
|
|
return new Meter( parent );
|
|
|
|
}
|
2007-09-05 23:58:10 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList UiLoader::availableLayouts() const
|
|
|
|
{
|
|
|
|
return d->layouts;
|
|
|
|
}
|
|
|
|
|
2008-02-29 18:50:57 +01:00
|
|
|
Layout *UiLoader::createLayout( const QString &className, LayoutItem *parent )
|
2007-09-05 23:58:10 +02:00
|
|
|
{
|
2007-11-20 01:47:20 +01:00
|
|
|
if (className == QString("HBoxLayout")) {
|
2008-02-29 18:50:57 +01:00
|
|
|
return new HBoxLayout( parent );
|
2007-09-05 23:58:10 +02:00
|
|
|
}
|
2007-11-20 01:47:20 +01:00
|
|
|
else if (className == QString("VBoxLayout")) {
|
2008-02-29 18:50:57 +01:00
|
|
|
return new VBoxLayout( parent );
|
2007-09-05 23:58:10 +02:00
|
|
|
}
|
2007-11-20 01:47:20 +01:00
|
|
|
else if (className == QString("FlowLayout")) {
|
|
|
|
return new FlowLayout( parent );
|
2007-09-05 23:58:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-09-10 00:34:10 +02:00
|
|
|
}
|