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"
|
2008-10-29 18:46:33 +01:00
|
|
|
#include "widgets/flashinglabel.h"
|
2008-08-10 13:39:34 +02:00
|
|
|
#include "widgets/frame.h"
|
|
|
|
#include "widgets/groupbox.h"
|
2008-10-29 18:46:33 +01:00
|
|
|
#include "widgets/iconwidget.h"
|
2008-08-10 13:39:34 +02:00
|
|
|
#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-10-12 00:48:38 +02:00
|
|
|
<< "ComboBox"
|
2008-10-29 18:46:33 +01:00
|
|
|
<< "FlashingLabel"
|
2008-10-12 00:48:38 +02:00
|
|
|
<< "Frame"
|
2008-08-10 13:39:34 +02:00
|
|
|
<< "GroupBox"
|
2008-10-29 18:46:33 +01:00
|
|
|
<< "IconWidget"
|
2007-11-20 01:47:20 +01:00
|
|
|
<< "Label"
|
2008-08-10 13:39:34 +02:00
|
|
|
<< "LineEdit"
|
2008-10-12 00:48:38 +02:00
|
|
|
<< "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);
|
2008-10-12 00:48:38 +02:00
|
|
|
} else if (className == QString("ComboBox")) {
|
2008-10-11 18:19:04 +02:00
|
|
|
return new ComboBox(parent);
|
2008-10-29 18:46:33 +01:00
|
|
|
} else if (className == QString("FlashingLabel")) {
|
|
|
|
return new FlashingLabel(parent);
|
2008-10-12 00:48:38 +02:00
|
|
|
} else if (className == QString("Frame")) {
|
2008-10-11 18:19:04 +02:00
|
|
|
return new Frame(parent);
|
2008-10-12 00:48:38 +02:00
|
|
|
} else if (className == QString("GroupBox")) {
|
2008-10-11 18:19:04 +02:00
|
|
|
return new GroupBox(parent);
|
2008-10-29 18:46:33 +01:00
|
|
|
} else if (className == QString("IconWidget")) {
|
|
|
|
return new IconWidget(parent);
|
2008-10-12 00:48:38 +02:00
|
|
|
} else if (className == QString("Label")) {
|
2008-10-11 18:19:04 +02:00
|
|
|
return new Label(parent);
|
2008-10-12 00:48:38 +02:00
|
|
|
} else if (className == QString("LineEdit")) {
|
2008-10-11 18:19:04 +02:00
|
|
|
return new LineEdit(parent);
|
2008-10-12 00:48:38 +02:00
|
|
|
} else if (className == QString("PushButton")) {
|
2008-10-11 18:19:04 +02:00
|
|
|
return new PushButton(parent);
|
2008-10-12 00:48:38 +02:00
|
|
|
} else if (className == QString("RadioButton")) {
|
2008-10-11 18:19:04 +02:00
|
|
|
return new RadioButton(parent);
|
2008-10-12 00:48:38 +02:00
|
|
|
} else if (className == QString("Slider")) {
|
2008-10-11 18:19:04 +02:00
|
|
|
return new Slider(parent);
|
2008-10-12 00:48:38 +02:00
|
|
|
} else if (className == QString("TabBar")) {
|
2008-10-11 18:19:04 +02:00
|
|
|
return new TabBar(parent);
|
2008-10-12 00:48:38 +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-10-12 00:48:38 +02: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-10-12 00:48:38 +02:00
|
|
|
return new HBoxLayout(parent);
|
|
|
|
} else if (className == QString("VBoxLayout")) {
|
|
|
|
return new VBoxLayout(parent);
|
|
|
|
} 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
|
|
|
}
|