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>
|
2008-08-10 13:39:34 +02:00
|
|
|
#include "widgets/checkbox.h"
|
|
|
|
#include "widgets/combobox.h"
|
|
|
|
#include "widgets/flash.h"
|
|
|
|
#include "widgets/frame.h"
|
|
|
|
#include "widgets/groupbox.h"
|
|
|
|
#include "widgets/icon.h"
|
|
|
|
#include "widgets/label.h"
|
|
|
|
#include "widgets/lineedit.h"
|
|
|
|
#include "widgets/pushbutton.h"
|
|
|
|
#include "widgets/radiobutton.h"
|
|
|
|
#include "widgets/slider.h"
|
|
|
|
#include "widgets/tabbar.h"
|
|
|
|
#include "widgets/textedit.h"
|
2007-09-05 23:58:10 +02:00
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
2008-07-01 20:56:43 +02:00
|
|
|
class UiLoaderPrivate
|
2007-09-05 23:58:10 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
QStringList widgets;
|
|
|
|
QStringList layouts;
|
|
|
|
};
|
|
|
|
|
2008-10-11 18:19:04 +02:00
|
|
|
UiLoader::UiLoader(QObject *parent)
|
|
|
|
: QObject(parent),
|
|
|
|
d(new UiLoaderPrivate())
|
2007-09-05 23:58:10 +02:00
|
|
|
{
|
|
|
|
d->widgets
|
2007-11-20 01:47:20 +01:00
|
|
|
<< "CheckBox"
|
2008-08-10 13:39:34 +02:00
|
|
|
<< "ComboBox"
|
2007-11-20 01:47:20 +01:00
|
|
|
<< "Flash"
|
2008-08-10 13:39:34 +02:00
|
|
|
<< "Frame"
|
|
|
|
<< "GroupBox"
|
|
|
|
<< "Icon"
|
2007-11-20 01:47:20 +01:00
|
|
|
<< "Label"
|
2008-08-10 13:39:34 +02:00
|
|
|
<< "LineEdit"
|
|
|
|
<< "PushButton"
|
|
|
|
<< "RadioButton"
|
|
|
|
<< "Slider"
|
|
|
|
<< "TabBar"
|
|
|
|
<< "TextEdit";
|
2007-09-05 23:58:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
UiLoader::~UiLoader()
|
|
|
|
{
|
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList UiLoader::availableWidgets() const
|
|
|
|
{
|
|
|
|
return d->widgets;
|
|
|
|
}
|
|
|
|
|
2008-10-11 18:19:04 +02:00
|
|
|
QGraphicsWidget *UiLoader::createWidget(const QString &className, QGraphicsWidget *parent)
|
2007-09-05 23:58:10 +02:00
|
|
|
{
|
2007-11-20 01:47:20 +01:00
|
|
|
if (className == QString("CheckBox")) {
|
2008-10-11 18:19:04 +02:00
|
|
|
return new CheckBox(parent);
|
2007-09-05 23:58:10 +02:00
|
|
|
}
|
2008-08-10 13:39:34 +02:00
|
|
|
else if (className == QString("ComboBox")) {
|
2008-10-11 18:19:04 +02:00
|
|
|
return new ComboBox(parent);
|
2008-08-10 13:39:34 +02:00
|
|
|
}
|
2007-11-20 01:47:20 +01:00
|
|
|
else if (className == QString("Flash")) {
|
2008-10-11 18:19:04 +02:00
|
|
|
return new Flash(parent);
|
2007-09-05 23:58:10 +02:00
|
|
|
}
|
2008-08-10 13:39:34 +02:00
|
|
|
else if (className == QString("Frame")) {
|
2008-10-11 18:19:04 +02:00
|
|
|
return new Frame(parent);
|
2008-08-10 13:39:34 +02:00
|
|
|
}
|
|
|
|
else if (className == QString("GroupBox")) {
|
2008-10-11 18:19:04 +02:00
|
|
|
return new GroupBox(parent);
|
2008-08-10 13:39:34 +02:00
|
|
|
}
|
2007-11-20 01:47:20 +01:00
|
|
|
else if (className == QString("Icon")) {
|
2008-10-11 18:19:04 +02:00
|
|
|
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")) {
|
2008-10-11 18:19:04 +02:00
|
|
|
return new Label(parent);
|
2008-08-10 13:39:34 +02:00
|
|
|
}
|
|
|
|
else if (className == QString("LineEdit")) {
|
2008-10-11 18:19:04 +02:00
|
|
|
return new LineEdit(parent);
|
2007-09-05 23:58:10 +02:00
|
|
|
}
|
2007-11-20 01:47:20 +01:00
|
|
|
else if (className == QString("PushButton")) {
|
2008-10-11 18:19:04 +02:00
|
|
|
return new PushButton(parent);
|
2007-09-05 23:58:10 +02:00
|
|
|
}
|
2007-11-20 01:47:20 +01:00
|
|
|
else if (className == QString("RadioButton")) {
|
2008-10-11 18:19:04 +02:00
|
|
|
return new RadioButton(parent);
|
2007-09-05 23:58:10 +02:00
|
|
|
}
|
2008-08-10 13:39:34 +02:00
|
|
|
else if (className == QString("Slider")) {
|
2008-10-11 18:19:04 +02:00
|
|
|
return new Slider(parent);
|
2007-09-25 17:50:32 +02:00
|
|
|
}
|
2008-08-10 13:39:34 +02:00
|
|
|
else if (className == QString("TabBar")) {
|
2008-10-11 18:19:04 +02:00
|
|
|
return new TabBar(parent);
|
2008-08-10 13:39:34 +02:00
|
|
|
}
|
|
|
|
else if (className == QString("TextEdit")) {
|
2008-10-11 18:19:04 +02:00
|
|
|
return new TextEdit(parent);
|
2008-08-10 13:39:34 +02:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|