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;
|
|
|
|
};
|
|
|
|
|
|
|
|
UiLoader::UiLoader( QObject *parent )
|
2008-08-10 13:39:34 +02:00
|
|
|
: 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-08-10 13:39:34 +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")) {
|
|
|
|
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")) {
|
|
|
|
return new ComboBox( parent );
|
|
|
|
}
|
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
|
|
|
}
|
2008-08-10 13:39:34 +02:00
|
|
|
else if (className == QString("Frame")) {
|
|
|
|
return new Frame( parent );
|
|
|
|
}
|
|
|
|
else if (className == QString("GroupBox")) {
|
|
|
|
return new GroupBox( parent );
|
|
|
|
}
|
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")) {
|
2008-08-10 13:39:34 +02:00
|
|
|
return new Label( parent );
|
|
|
|
}
|
|
|
|
else if (className == QString("LineEdit")) {
|
|
|
|
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-08-10 13:39:34 +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")) {
|
|
|
|
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")) {
|
|
|
|
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")) {
|
|
|
|
return new TabBar( parent );
|
|
|
|
}
|
|
|
|
else if (className == QString("TextEdit")) {
|
|
|
|
return new TextEdit( 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
|
|
|
{
|
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
|
|
|
}
|