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>
|
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
|
|
|
class UiLoader::Private
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
QStringList widgets;
|
|
|
|
QStringList layouts;
|
|
|
|
};
|
|
|
|
|
|
|
|
UiLoader::UiLoader( QObject *parent )
|
2008-04-13 15:23:39 +02:00
|
|
|
: d( new Private() )
|
2007-09-05 23:58:10 +02:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2008-04-13 23:20:07 +02:00
|
|
|
Applet *UiLoader::createWidget( const QString &className, Applet *parent )
|
2007-09-05 23:58:10 +02:00
|
|
|
{
|
2008-04-13 23:20:07 +02:00
|
|
|
#ifdef RICHARD_WORK
|
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 );
|
|
|
|
}
|
2008-04-13 23:20:07 +02:00
|
|
|
#endif
|
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
|
|
|
{
|
2008-04-13 23:20:07 +02:00
|
|
|
#ifdef RICHARD_WORK
|
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
|
|
|
}
|
2008-04-13 23:20:07 +02:00
|
|
|
#endif
|
2007-09-05 23:58:10 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-09-10 00:34:10 +02:00
|
|
|
}
|