summaryrefslogtreecommitdiffstats
path: root/lib/widgets/propeditor
diff options
context:
space:
mode:
Diffstat (limited to 'lib/widgets/propeditor')
-rw-r--r--lib/widgets/propeditor/Mainpage.dox116
-rw-r--r--lib/widgets/propeditor/Makefile.am18
-rw-r--r--lib/widgets/propeditor/childproperty.cpp145
-rw-r--r--lib/widgets/propeditor/childproperty.h83
-rw-r--r--lib/widgets/propeditor/compat_tools.h6
-rw-r--r--lib/widgets/propeditor/multiproperty.cpp273
-rw-r--r--lib/widgets/propeditor/multiproperty.h126
-rw-r--r--lib/widgets/propeditor/pcheckbox.cpp76
-rw-r--r--lib/widgets/propeditor/pcheckbox.h54
-rw-r--r--lib/widgets/propeditor/pcolorbutton.cpp120
-rw-r--r--lib/widgets/propeditor/pcolorbutton.h62
-rw-r--r--lib/widgets/propeditor/pcolorcombo.cpp78
-rw-r--r--lib/widgets/propeditor/pcolorcombo.h54
-rw-r--r--lib/widgets/propeditor/pcombobox.cpp110
-rw-r--r--lib/widgets/propeditor/pcombobox.h72
-rw-r--r--lib/widgets/propeditor/pcursoredit.cpp41
-rw-r--r--lib/widgets/propeditor/pcursoredit.h42
-rw-r--r--lib/widgets/propeditor/pdateedit.cpp70
-rw-r--r--lib/widgets/propeditor/pdateedit.h51
-rw-r--r--lib/widgets/propeditor/pdatetimeedit.cpp69
-rw-r--r--lib/widgets/propeditor/pdatetimeedit.h52
-rw-r--r--lib/widgets/propeditor/pdoublenuminput.cpp94
-rw-r--r--lib/widgets/propeditor/pdoublenuminput.h64
-rw-r--r--lib/widgets/propeditor/pdummywidget.cpp54
-rw-r--r--lib/widgets/propeditor/pdummywidget.h60
-rw-r--r--lib/widgets/propeditor/pfontbutton.cpp86
-rw-r--r--lib/widgets/propeditor/pfontbutton.h52
-rw-r--r--lib/widgets/propeditor/pfontcombo.cpp86
-rw-r--r--lib/widgets/propeditor/pfontcombo.h56
-rw-r--r--lib/widgets/propeditor/plineedit.cpp61
-rw-r--r--lib/widgets/propeditor/plineedit.h52
-rw-r--r--lib/widgets/propeditor/plinestyleedit.cpp205
-rw-r--r--lib/widgets/propeditor/plinestyleedit.h50
-rw-r--r--lib/widgets/propeditor/ppixmapedit.cpp149
-rw-r--r--lib/widgets/propeditor/ppixmapedit.h57
-rw-r--r--lib/widgets/propeditor/ppointedit.cpp64
-rw-r--r--lib/widgets/propeditor/ppointedit.h50
-rw-r--r--lib/widgets/propeditor/prectedit.cpp64
-rw-r--r--lib/widgets/propeditor/prectedit.h50
-rw-r--r--lib/widgets/propeditor/property.cpp129
-rw-r--r--lib/widgets/propeditor/property.h181
-rw-r--r--lib/widgets/propeditor/propertyeditor.cpp480
-rw-r--r--lib/widgets/propeditor/propertyeditor.h129
-rw-r--r--lib/widgets/propeditor/propertyeditor.pro40
-rw-r--r--lib/widgets/propeditor/propertylist.cpp369
-rw-r--r--lib/widgets/propeditor/propertylist.h200
-rw-r--r--lib/widgets/propeditor/propertymachinefactory.cpp207
-rw-r--r--lib/widgets/propeditor/propertymachinefactory.h97
-rw-r--r--lib/widgets/propeditor/propertywidget.cpp64
-rw-r--r--lib/widgets/propeditor/propertywidget.h88
-rw-r--r--lib/widgets/propeditor/propertywidgetproxy.cpp106
-rw-r--r--lib/widgets/propeditor/propertywidgetproxy.h81
-rw-r--r--lib/widgets/propeditor/psizeedit.cpp65
-rw-r--r--lib/widgets/propeditor/psizeedit.h51
-rw-r--r--lib/widgets/propeditor/psizepolicyedit.cpp77
-rw-r--r--lib/widgets/propeditor/psizepolicyedit.h54
-rw-r--r--lib/widgets/propeditor/pspinbox.cpp73
-rw-r--r--lib/widgets/propeditor/pspinbox.h53
-rw-r--r--lib/widgets/propeditor/pstringlistedit.cpp121
-rw-r--r--lib/widgets/propeditor/pstringlistedit.h62
-rw-r--r--lib/widgets/propeditor/psymbolcombo.cpp131
-rw-r--r--lib/widgets/propeditor/psymbolcombo.h62
-rw-r--r--lib/widgets/propeditor/purledit.cpp97
-rw-r--r--lib/widgets/propeditor/purledit.h70
-rw-r--r--lib/widgets/propeditor/pyesnobutton.cpp76
-rw-r--r--lib/widgets/propeditor/pyesnobutton.h51
-rw-r--r--lib/widgets/propeditor/qeditlistbox.cpp401
-rw-r--r--lib/widgets/propeditor/qeditlistbox.h255
-rw-r--r--lib/widgets/propeditor/qfloatinput.cpp51
-rw-r--r--lib/widgets/propeditor/qfloatinput.h48
-rw-r--r--lib/widgets/propeditor/test.cpp86
-rwxr-xr-xlib/widgets/propeditor/test.pro40
-rw-r--r--lib/widgets/propeditor/undo.xpm44
73 files changed, 7211 insertions, 0 deletions
diff --git a/lib/widgets/propeditor/Mainpage.dox b/lib/widgets/propeditor/Mainpage.dox
new file mode 100644
index 00000000..6bc81be0
--- /dev/null
+++ b/lib/widgets/propeditor/Mainpage.dox
@@ -0,0 +1,116 @@
+/**
+@mainpage The KDevelop Property Editing Library
+
+<b>Link with</b>: -lkdevelop
+
+<b>Include path</b>: -I\$(kde_includes)/kdevelop/propeditor
+
+
+\section whatis What is Property Editor?
+
+%Property editor is a collection of facilities to store and edit the
+properties of an object. For example, look at %Qt Designer. Each widget
+has a list of properties that can be edited in a nice table form.
+Same ideology is used to edit properties in Kugar Report Designer
+(from KOffice distribution). In KDevelop project manager can also display
+the properties of currently selected build item in property editor.
+
+\section over Library Overview
+
+This PropertyEditor library is a redesign of Kugar property editing library
+with the goal to be more generic and extensible.
+
+Library provides a @ref PropertyLib::Property class which stores property name, value and some
+more important information like description or the list of possible values.
+Using @ref PropertyLib::Property class adds more overhead over Q_PROPERTY but provides more
+flexibility. You can subclass @ref PropertyLib::Property and create your custom properties.
+Custom properties can have either predefined type (see @ref PropertyLib::Property::PropertyType) or
+custom type. Custom type should be used if a custom property editor widget is
+necessary.
+
+Properties are organized into lists. @ref PropertyLib::PropertyList is designed
+to store such lists in most efficient manner. It also allows to group
+properties (for example think about "geometrical" properties like "x", "y", etc.).
+
+Property lists can be displayed in @ref PropertyLib::PropertyEditor widget which will
+display them in a table form. @ref PropertyLib::PropertyEditor takes a pointer to a @ref PropertyLib::PropertyList object so @ref PropertyLib::PropertyBuffer can be used too.
+
+@ref PropertyLib::PropertyBuffer is designed to provide a method to access an intersection
+of property lists. For example, let's consider object A with property list a_list
+abd object B with list b_list. Now let's imagine we want to display common properties
+from a_list and b_list in one @ref PropertyLib::PropertyEditor widget. Obviously, we need to
+"intersect" a_list with b_list and display the result of intersection.
+This is why @ref PropertyLib::PropertyBuffer is used for editing. If we change
+the value of a property in the editor, @ref PropertyLib::PropertyBuffer will update
+both properties from underlying a_list and b_list.
+
+@ref PropertyLib::PropertyEditor at the same time shows only one editor for selected
+property in the list. Each @ref PropertyLib::Property::PropertyType has corresponding @ref PropertyLib::PropertyWidget
+which displays property editor or draws a property in the list if it is not edited.
+More exactly, if @ref PropertyLib::PropertyEditor needs to display editor widget, it displays
+@ref PropertyLib::PropertyWidget, else it calls @ref PropertyLib::PropertyWidget::drawViewer function.
+Custom property widgets should be subclasses of @ref PropertyLib::PropertyWidget.
+
+To create property widgets at runtime, a factory is used. Factory class is
+called @ref PropertyLib::PropertyMachineFactory. Static function @ref PropertyLib::PropertyMachineFactory::getInstance
+can be used to obtain the reference to the factory instance. Factory creates and returns
+so-called @ref PropertyLib::Machine for each registered property type (either predefined or user defined).
+
+@ref PropertyLib::Machine contains @ref PropertyLib::PropertyWidget and a list of "detailed" machines.
+Usually only property widget is necessary for a property but there are
+complex properties like "Font" for example. We would like to see separate editors
+for font family, size, etc. and a button to choose all of these in the dialog.
+For that "Font" property, a PropertyWidget with a "choose font" button
+and also number of detailed widgets like "font family" combo, etc. can be created.
+
+\section Examples
+A simple example on how to create a property editor and use it with one property list:
+\code
+ using namespace PropertyLib;
+
+ PropertyEditor *m_editor = new PropertyEditor(this);
+
+ PropertyList *list = new PropertyList;
+ list->addProperty("My Group", new Property(Property::Integer, "First Property",
+ "This is my first property", -5));
+ list->addProperty("My Group", new Property(Property::String, "Second Property",
+ "This is my second property", "Hello"));
+ list->addProperty(new Property(Property::Color, "Third Property",
+ "This is my third property", QColor("green")));
+
+ m_editor->populateProperties(*list);
+\endcode
+\image html propeditor1.png "Simple property editor"
+
+More advanced example with property buffers and list intersection:
+\code
+ using namespace PropertyLib;
+
+ PropertyEditor *m_editor = new PropertyEditor(this);
+
+ PropertyList *list = new PropertyList;
+ list->addProperty("My Group", new Property(Property::Integer, "First Property",
+ "This is my first property", -5));
+ list->addProperty("My Group", new Property(Property::String, "Second Property",
+ "This is my second property", "Hello"));
+ list->addProperty(new Property(Property::Color, "Third Property",
+ "This is my third property", QColor("green")));
+
+ PropertyList *list2 = new PropertyList;
+ list2->addProperty("My Group", new Property(Property::Integer, "First Property",
+ "This is my first property", -7));
+ list2->addProperty("My Group", new Property(Property::String, "Second Property",
+ "This is my second property", "Hello"));
+ list2->addProperty(new Property(Property::String, "Third Property",
+ "This is my third property", "green"));
+
+ PropertyBuffer buf(list);
+ buf.intersect(list2);
+
+ m_editor->populateProperties(&buf);
+\endcode
+\image html propeditor2.png "Result of property list intersection"
+In this example only properties named "First Property" and "Second Property" will be shown in editor.
+"Third Property" has different types in list and list2 and will not be included in intersection.
+
+*/
diff --git a/lib/widgets/propeditor/Makefile.am b/lib/widgets/propeditor/Makefile.am
new file mode 100644
index 00000000..bd055733
--- /dev/null
+++ b/lib/widgets/propeditor/Makefile.am
@@ -0,0 +1,18 @@
+INCLUDES = -I$(top_srcdir)/lib/compat $(all_includes)
+METASOURCES = AUTO
+
+lib_LTLIBRARIES = libkdevpropertyeditor.la
+libkdevpropertyeditor_la_LIBADD = $(LIB_KIO)
+libkdevpropertyeditor_la_LDFLAGS = -no-undefined $(all_libraries)
+libkdevpropertyeditor_la_SOURCES = childproperty.cpp pcombobox.cpp pdummywidget.cpp ppointedit.cpp propertymachinefactory.cpp pstringlistedit.cpp\
+multiproperty.cpp pcursoredit.cpp pfontbutton.cpp prectedit.cpp propertywidget.cpp psymbolcombo.cpp\
+pcheckbox.cpp pdateedit.cpp pfontcombo.cpp property.cpp psizeedit.cpp purledit.cpp\
+pcolorbutton.cpp pdatetimeedit.cpp plineedit.cpp propertyeditor.cpp psizepolicyedit.cpp pyesnobutton.cpp\
+pcolorcombo.cpp pdoublenuminput.cpp ppixmapedit.cpp propertylist.cpp pspinbox.cpp propertywidgetproxy.cpp plinestyleedit.cpp qeditlistbox.cpp
+
+kdevpropeditorincludedir = $(includedir)/kdevelop/propeditor
+kdevpropeditorinclude_HEADERS = childproperty.h pcombobox.h pdummywidget.h ppointedit.h propertymachinefactory.h pcursoredit.h pfontbutton.h prectedit.h propertywidget.h pdateedit.h pfontcombo.h property.h psizeedit.h pdatetimeedit.h plineedit.h propertyeditor.h psizepolicyedit.h pdoublenuminput.h ppixmapedit.h propertylist.h pspinbox.h propertywidgetproxy.h multiproperty.h pyesnobutton.h purledit.h psymbolcombo.h pstringlistedit.h pcolorcombo.h pcolorbutton.h pcheckbox.h plinestyleedit.h
+
+DOXYGEN_REFERENCES = dcop interfaces kdecore kdefx kdeui khtml kmdi kio kjs kparts kutils
+DOXYGEN_PROJECTNAME = KDevelop Property Editing Library
+include ../../../Doxyfile.am
diff --git a/lib/widgets/propeditor/childproperty.cpp b/lib/widgets/propeditor/childproperty.cpp
new file mode 100644
index 00000000..72cfb053
--- /dev/null
+++ b/lib/widgets/propeditor/childproperty.cpp
@@ -0,0 +1,145 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "childproperty.h"
+
+#include <qsize.h>
+#include <qpoint.h>
+#include <qrect.h>
+#include <qsizepolicy.h>
+
+#include "multiproperty.h"
+
+namespace PropertyLib{
+
+ChildProperty::ChildProperty(MultiProperty *parent, int type, ChildPropertyType childType, const QString &name,
+ const QString &description, const QVariant &value, bool save, bool readOnly)
+ :Property(type, name, description, value, save, readOnly), m_parent(parent), m_childType(childType)
+{
+}
+
+ChildProperty::ChildProperty(MultiProperty *parent, const QString & name, ChildPropertyType childType,
+ const QMap<QString, QVariant> &v_valueList, const QString &description,
+ const QVariant &value, bool save, bool readOnly)
+ :Property(name, v_valueList, description, value, save, readOnly), m_parent(parent), m_childType(childType)
+{
+}
+
+void ChildProperty::setValue(const QVariant &value, bool // rememberOldValue
+ )
+{
+ qWarning("ChildProperty::setValue");
+ if (!m_parent->valid())
+ return;
+ switch (m_parent->type())
+ {
+ case Size:
+ {
+ qWarning("ChildProperty::setValue for QSize");
+ QSize v = m_parent->value().toSize();
+ if (m_childType == Size_Height)
+ v.setHeight(value.toInt());
+ else if (m_childType == Size_Width)
+ v.setWidth(value.toInt());
+ m_parent->setValue(v);
+ break;
+ }
+ case Point:
+ {
+ qWarning("ChildProperty::setValue for QPoint");
+ QPoint v = m_parent->value().toPoint();
+ if (m_childType == Point_X)
+ v.setX(value.toInt());
+ else if (m_childType == Point_Y)
+ v.setY(value.toInt());
+ m_parent->setValue(v);
+ break;
+ }
+ case Rect:
+ {
+ qWarning("ChildProperty::setValue for QRect");
+ QRect v = m_parent->value().toRect();
+ if (m_childType == Rect_X)
+ v.setX(value.toInt());
+ else if (m_childType == Rect_Y)
+ v.setY(value.toInt());
+ else if (m_childType == Rect_Width)
+ v.setWidth(value.toInt());
+ else if (m_childType == Rect_Height)
+ v.setHeight(value.toInt());
+ m_parent->setValue(v);
+ break;
+ }
+ case SizePolicy:
+ {
+ qWarning("ChildProperty::setValue for QSizePolicy");
+ QSizePolicy v = m_parent->value().toSizePolicy();
+ if (m_childType == SizePolicy_HorData)
+ v.setHorData(QSizePolicy::SizeType(value.toInt()));
+ else if (m_childType == SizePolicy_VerData)
+ v.setVerData(QSizePolicy::SizeType(value.toInt()));
+ else if (m_childType == SizePolicy_HorStretch)
+ v.setHorStretch(value.toInt());
+ else if (m_childType == SizePolicy_VerStretch)
+ v.setVerStretch(value.toInt());
+ m_parent->setValue(v);
+ break;
+ }
+ }
+}
+
+QVariant ChildProperty::value( ) const
+{
+ if (!m_parent->valid())
+ return QVariant();
+ switch (m_parent->type())
+ {
+ case Size:
+ if (m_childType == Size_Height)
+ return m_parent->value().toSize().height();
+ else if (m_childType == Size_Width)
+ return m_parent->value().toSize().width();
+ case Point:
+ if (m_childType == Point_X)
+ return m_parent->value().toPoint().x();
+ else if (m_childType == Point_Y)
+ return m_parent->value().toPoint().y();
+ case Rect:
+ if (m_childType == Rect_X)
+ return m_parent->value().toRect().x();
+ else if (m_childType == Rect_Y)
+ return m_parent->value().toRect().y();
+ else if (m_childType == Rect_Width)
+ return m_parent->value().toRect().width();
+ else if (m_childType == Rect_Height)
+ return m_parent->value().toRect().height();
+ case SizePolicy:
+ if (m_childType == SizePolicy_HorData)
+ return m_parent->value().toSizePolicy().horData();
+ else if (m_childType == SizePolicy_VerData)
+ return m_parent->value().toSizePolicy().verData();
+ else if (m_childType == SizePolicy_HorStretch)
+ return m_parent->value().toSizePolicy().horStretch();
+ else if (m_childType == SizePolicy_VerStretch)
+ return m_parent->value().toSizePolicy().verStretch();
+ }
+ return QVariant();
+}
+
+}
diff --git a/lib/widgets/propeditor/childproperty.h b/lib/widgets/propeditor/childproperty.h
new file mode 100644
index 00000000..13399a08
--- /dev/null
+++ b/lib/widgets/propeditor/childproperty.h
@@ -0,0 +1,83 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef CHILDPROPERTY_H
+#define CHILDPROPERTY_H
+
+#include "property.h"
+
+namespace PropertyLib{
+
+class MultiProperty;
+
+/**
+@short Child property
+
+Child property is a detailed property for complex parent properties.
+For example, to edit a property of Point type one can request two
+child properties for "x" and "y" components of a point.
+
+Child properties instances usually belong to MultiProperty class
+which is used to fetch and display them in the property editor.
+Child properties are created by a PropertyMachineFactory.
+Factory in such case does not only creates a machine for a property,
+but also fills corrresponding multiproperty with a list of child
+properties.
+*/
+class ChildProperty: public Property{
+public:
+ enum ChildPropertyType {
+ Size_Height,
+ Size_Width,
+ Point_X,
+ Point_Y,
+ Rect_X,
+ Rect_Y,
+ Rect_Width,
+ Rect_Height,
+ SizePolicy_HorData,
+ SizePolicy_VerData,
+ SizePolicy_HorStretch,
+ SizePolicy_VerStretch
+ };
+
+ /**Constructs empty property.*/
+ ChildProperty() {}
+ /**Constructs property.*/
+ ChildProperty(MultiProperty *parent, int type, ChildPropertyType childType, const QString &name,
+ const QString &description, const QVariant &value = QVariant(),
+ bool save = true, bool readOnly = false);
+ /**Constructs property with @ref ValueFromList type.*/
+ ChildProperty(MultiProperty *parent, const QString &name, ChildPropertyType childType,
+ const QMap<QString, QVariant> &v_valueList, const QString &description,
+ const QVariant &value = QVariant(), bool save = true, bool readOnly = false);
+
+ /**@return the value of the property.*/
+ virtual QVariant value() const;
+ /**Sets the value of the property.*/
+ virtual void setValue(const QVariant &value, bool rememberOldValue = true);
+
+private:
+ MultiProperty *m_parent;
+ ChildPropertyType m_childType;
+};
+
+}
+
+#endif
diff --git a/lib/widgets/propeditor/compat_tools.h b/lib/widgets/propeditor/compat_tools.h
new file mode 100644
index 00000000..1a1a8735
--- /dev/null
+++ b/lib/widgets/propeditor/compat_tools.h
@@ -0,0 +1,6 @@
+#ifndef COMPAT_TOOLS_H
+#define COMPAT_TOOLS_H
+
+#define i18n QObject::tr
+
+#endif
diff --git a/lib/widgets/propeditor/multiproperty.cpp b/lib/widgets/propeditor/multiproperty.cpp
new file mode 100644
index 00000000..7e32345a
--- /dev/null
+++ b/lib/widgets/propeditor/multiproperty.cpp
@@ -0,0 +1,273 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo <cloudtemple@mskat.net> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "multiproperty.h"
+
+#include "propertylist.h"
+
+namespace PropertyLib{
+
+MultiProperty::MultiProperty(Property *prop)
+ :m_propertyList(0)
+{
+ list.append(prop);
+}
+
+MultiProperty::MultiProperty(PropertyList *propertyList)
+ :m_propertyList(propertyList)
+{
+}
+
+MultiProperty::MultiProperty(PropertyList *propertyList, Property *prop)
+ :m_propertyList(propertyList)
+{
+ list.append(prop);
+}
+
+MultiProperty::~MultiProperty()
+{
+}
+
+QString MultiProperty::name() const
+{
+ if (list.count() >= 1)
+ return list.getFirst()->name();
+ return QString::null;
+}
+
+int MultiProperty::type() const
+{
+ if (list.count() >= 1)
+ return list.getFirst()->type();
+ return QVariant::Invalid;
+}
+
+QVariant MultiProperty::value() const
+{
+ QVariant value;
+ if (list.count() >= 1)
+ value = list.getFirst()->value();
+
+ QPtrListIterator<Property> it(list);
+ Property *property;
+ while ((property = it.current()) != 0)
+ {
+ if (property->value() != value)
+ return QVariant::Invalid;
+ ++it;
+ }
+
+ return value;
+}
+
+QString MultiProperty::description() const
+{
+ QString description;
+ if (list.count() >= 1)
+ description = list.getFirst()->description();
+
+ QPtrListIterator<Property> it(list);
+ Property *property;
+ while ((property = it.current()) != 0)
+ {
+ if (property->description() != description)
+ return QString::null;
+ ++it;
+ }
+
+ return description;
+}
+
+bool MultiProperty::readOnly() const
+{
+ bool v = true;
+ if (list.count() >= 1)
+ v = list.getFirst()->readOnly();
+
+ QPtrListIterator<Property> it(list);
+ Property *property;
+ while ((property = it.current()) != 0)
+ {
+ if (property->readOnly() != v)
+ return false;
+ ++it;
+ }
+
+ return v;
+}
+
+bool MultiProperty::visible() const
+{
+ bool v = true;
+ if (list.count() >= 1)
+ v = list.getFirst()->readOnly();
+
+ QPtrListIterator<Property> it(list);
+ Property *property;
+ while ((property = it.current()) != 0)
+ {
+ if (property->visible() != v)
+ return false;
+ ++it;
+ }
+
+ return v;
+}
+
+QMap<QString, QVariant> MultiProperty::valueList() const
+{
+ if (list.count() >= 1)
+ return list.getFirst()->valueList;
+ return QMap<QString, QVariant>();
+}
+
+void MultiProperty::setDescription(const QString &description)
+{
+ Property *property;
+ for (property = list.first(); property; property = list.next())
+ property->setDescription(description);
+}
+
+/*void MultiProperty::setName(const QString &name)
+{
+}
+
+void MultiProperty::setType(int type)
+{
+}
+*/
+void MultiProperty::setValue(const QVariant &value)
+{
+ Property *property;
+ for (property = list.first(); property; property = list.next())
+ {
+ property->setValue(value);
+ if (m_propertyList)
+ {
+// qWarning("emit change");
+ emit m_propertyList->propertyValueChanged(property);
+ }
+ }
+}
+
+void MultiProperty::setValue(const QVariant &value, bool emitChange)
+{
+ Property *property;
+ for (property = list.first(); property; property = list.next())
+ {
+ property->setValue(value);
+ if (emitChange && m_propertyList)
+ emit m_propertyList->propertyValueChanged(property);
+ }
+}
+
+void MultiProperty::setValueList(const QMap<QString, QVariant> &valueList)
+{
+ Property *property;
+ for (property = list.first(); property; property = list.next())
+ property->setValueList(valueList);
+}
+
+void MultiProperty::addProperty(Property *prop)
+{
+ list.append(prop);
+}
+
+void MultiProperty::removeProperty(Property *prop)
+{
+/* qWarning("op >> removing %s", prop->name().ascii());
+ qWarning("op >> list is %d", list.count());*/
+ /*bool b = */list.remove(prop);
+/* qWarning("op >> list is %d", list.count());
+ qWarning("op >> removal is %s", b?"true":"false"); */
+}
+
+bool MultiProperty::operator ==(const MultiProperty &prop) const
+{
+ if ( (type() == prop.type()) && (name() == prop.name()) )
+ return true;
+ return false;
+}
+
+bool MultiProperty::operator ==(const Property &prop) const
+{
+/* qWarning("MultiProperty::operator == for %s = %s", name().ascii(), prop.name().ascii());
+ qWarning("MultiProperty::operator == for %d = %d", type(), prop.type());*/
+ if ( (type() == prop.type()) && (name() == prop.name()) )
+ return true;
+ return false;
+}
+
+void MultiProperty::addProperty( MultiProperty *prop)
+{
+ Property *property;
+ for (property = prop->list.first(); property; property = prop->list.next())
+ addProperty(property);
+}
+
+void MultiProperty::removeProperty( MultiProperty *prop)
+{
+ Property *property;
+ for (property = prop->list.first(); property; property = prop->list.next())
+ removeProperty(property);
+}
+
+QVariant MultiProperty::findValueDescription() const
+{
+ QVariant val = value();
+ if (type() != Property::ValueFromList)
+ return val;
+ QMap<QString, QVariant> vl = valueList();
+ for (QMap<QString, QVariant>::const_iterator it = vl.begin(); it != vl.end(); ++ it)
+ {
+ if (it.data() == val)
+ return it.key();
+ }
+ return "";
+}
+
+QVariant MultiProperty::findValueDescription(QVariant val) const
+{
+ if (type() != Property::ValueFromList)
+ return val;
+ QMap<QString, QVariant> vl = valueList();
+ for (QMap<QString, QVariant>::const_iterator it = vl.begin(); it != vl.end(); ++ it)
+ {
+ if (it.data() == val)
+ return it.key();
+ }
+ return "";
+}
+
+bool MultiProperty::valid() const
+{
+ return list.count() != 0;
+}
+
+void MultiProperty::undo()
+{
+ Property *property;
+ for (property = list.first(); property; property = list.next())
+ {
+ property->setValue(property->oldValue(), false);
+ if (m_propertyList)
+ emit m_propertyList->propertyValueChanged(property);
+ }
+}
+
+}
diff --git a/lib/widgets/propeditor/multiproperty.h b/lib/widgets/propeditor/multiproperty.h
new file mode 100644
index 00000000..e6402027
--- /dev/null
+++ b/lib/widgets/propeditor/multiproperty.h
@@ -0,0 +1,126 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo <cloudtemple@mskat.net> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef MULTIPROPERTY_H
+#define MULTIPROPERTY_H
+
+#include <qptrlist.h>
+#include <qmap.h>
+#include <qvariant.h>
+
+#include "property.h"
+#include "childproperty.h"
+
+namespace PropertyLib{
+
+class PropertyList;
+
+/** @file multiproperty.h
+@short Contains @ref PropertyLib::MultiProperty class.
+*/
+
+/**
+@short Holds a list of properties with the same name and type.
+
+It is used by @ref PropertyLib::PropertyList to store properties. Generally, @ref PropertyLib::PropertyList
+stores a list of multiproperties instead of properties. This allows working
+with many properties of the same name and type at the same type.
+
+MultiProperty is also responsible for storing detailed %property editors (instances
+of @ref ChildProperty class. It's too much overhead to store child properties
+with their parent properties. MultiProperty provides a way to store child properties
+only once for all properties with the same name and same type.
+*/
+class MultiProperty
+{
+public:
+ /**Constructs multiproperty with one property which is not connected to a property list.*/
+ MultiProperty(Property *prop);
+ /**Constructs empty multiproperty.*/
+ MultiProperty(PropertyList *propertyList);
+ /**Constructs multiproperty with one Property in the list.*/
+ MultiProperty(PropertyList *propertyList, Property *prop);
+ ~MultiProperty();
+
+ /**Compares two multiproperties.*/
+ bool operator ==(const MultiProperty &prop) const;
+ /**Compares %multiproperty with %property.*/
+ bool operator ==(const Property &prop) const;
+
+ /**Adds %property to the list.*/
+ void addProperty(Property *prop);
+ /**Removes %property from the list.*/
+ void removeProperty(Property *prop);
+ /**Adds all properties from the %multiproperty prop.*/
+ void addProperty(MultiProperty *prop);
+ /**Removes all properties that exists in the %multiproperty prop.*/
+ void removeProperty(MultiProperty *prop);
+
+ /**Returns the name of a %property.*/
+ QString name() const;
+ /**Returns the type of a %property.*/
+ int type() const;
+ /**Returns the value of a %property.*/
+ QVariant value() const;
+ /**Returns the description of a %property.*/
+ QString description() const;
+ /**Returns the readonly attribute of a %property.*/
+ bool readOnly() const;
+ /**Returns the visibility attribute of a %property.*/
+ bool visible() const;
+ /**The string-to-value correspondence list of the %property.*/
+ QMap<QString, QVariant> valueList() const;
+
+ /**Sets the value of a %property.*/
+ void setValue(const QVariant& value);
+ /**Sets the value of a %property.
+ @param value new value of thus %multiproperty
+ @param emitChange if set to true then %property list which owns this %multiproperty
+ emits propertyValueChanged signal.*/
+ void setValue(const QVariant& value, bool emitChange);
+ /**Sets the description of a %property.*/
+ void setDescription(const QString &description);
+ /**Sets the list of possible values of a %property.*/
+ void setValueList(const QMap< QString, QVariant >& valueList);
+
+ /**Finds string description for a value.*/
+ QVariant findValueDescription() const;
+ /**Finds string description for a value.*/
+ QVariant findValueDescription(QVariant val) const;
+
+ /**Returns true if the %multiproperty has no properties in the list (i.e. it's invalid).*/
+ bool valid() const;
+
+ /**Reverts the property value to previous setting.*/
+ void undo();
+
+ /**The list of child properties.*/
+ QValueList<ChildProperty> details;
+
+private:
+ QPtrList<Property> list;
+
+ PropertyList *m_propertyList;
+
+friend class PropertyList;
+friend class PropertyBuffer;
+};
+
+}
+
+#endif
diff --git a/lib/widgets/propeditor/pcheckbox.cpp b/lib/widgets/propeditor/pcheckbox.cpp
new file mode 100644
index 00000000..7b0b187e
--- /dev/null
+++ b/lib/widgets/propeditor/pcheckbox.cpp
@@ -0,0 +1,76 @@
+/***************************************************************************
+ * Copyright (C) 2003-2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "pcheckbox.h"
+
+#include <qlayout.h>
+#include <qcheckbox.h>
+#include <qpainter.h>
+
+#ifndef PURE_QT
+#include <klocale.h>
+#else
+#include "compat_tools.h"
+#endif
+
+namespace PropertyLib{
+
+PCheckBox::PCheckBox(MultiProperty *property, QWidget *parent, const char *name)
+ :PropertyWidget(property, parent, name)
+{
+ QHBoxLayout *l = new QHBoxLayout(this, 0, 0);
+ m_edit = new QCheckBox(this);
+ m_edit->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+ l->addWidget(m_edit);
+
+ connect(m_edit, SIGNAL(toggled(bool)), this, SLOT(updateProperty(bool)));
+}
+
+QVariant PCheckBox::value() const
+{
+ return QVariant(m_edit->isChecked());
+}
+
+void PCheckBox::setValue(const QVariant &value, bool emitChange)
+{
+ disconnect(m_edit, SIGNAL(toggled(bool)), this, SLOT(updateProperty(bool)));
+ m_edit->setChecked(value.toBool());
+ connect(m_edit, SIGNAL(toggled(bool)), this, SLOT(updateProperty(bool)));
+ if (emitChange)
+ emit propertyChanged(m_property, value);
+}
+
+void PCheckBox::updateProperty(bool val)
+{
+ emit propertyChanged(m_property, QVariant(val));
+}
+
+void PCheckBox::drawViewer(QPainter *p, const QColorGroup &cg, const QRect &r, const QVariant &value)
+{
+ p->setBrush(cg.background());
+ p->setPen(Qt::NoPen);
+ p->drawRect(r);
+ p->drawText(r, Qt::AlignLeft | Qt::AlignVCenter | Qt::SingleLine, value.toBool() ? i18n("true") : i18n("false"));
+}
+
+}
+
+#ifndef PURE_QT
+#include "pcheckbox.moc"
+#endif
diff --git a/lib/widgets/propeditor/pcheckbox.h b/lib/widgets/propeditor/pcheckbox.h
new file mode 100644
index 00000000..374617f7
--- /dev/null
+++ b/lib/widgets/propeditor/pcheckbox.h
@@ -0,0 +1,54 @@
+/***************************************************************************
+ * Copyright (C) 2003-2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef PCHECKBOX_H
+#define PCHECKBOX_H
+
+#include "propertywidget.h"
+
+class QCheckBox;
+
+namespace PropertyLib{
+
+/**
+@short %Property editor with checkbox.
+*/
+class PCheckBox: public PropertyWidget{
+ Q_OBJECT
+public:
+ PCheckBox(MultiProperty *property, QWidget *parent = 0, const char *name = 0);
+
+ /**@return the value currently entered in the editor widget.*/
+ virtual QVariant value() const;
+ /**Sets the value shown in the editor widget. Set emitChange to false
+ if you don't want to emit propertyChanged signal.*/
+ virtual void setValue(const QVariant &value, bool emitChange=true);
+ /**Function to draw a property viewer when the editor isn't shown.*/
+ virtual void drawViewer(QPainter *p, const QColorGroup &cg, const QRect &r, const QVariant &value);
+
+private slots:
+ void updateProperty(bool val);
+
+private:
+ QCheckBox *m_edit;
+};
+
+}
+
+#endif
diff --git a/lib/widgets/propeditor/pcolorbutton.cpp b/lib/widgets/propeditor/pcolorbutton.cpp
new file mode 100644
index 00000000..7404e1de
--- /dev/null
+++ b/lib/widgets/propeditor/pcolorbutton.cpp
@@ -0,0 +1,120 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "pcolorbutton.h"
+
+#include <qlayout.h>
+#include <qpainter.h>
+
+#ifndef PURE_QT
+#include <kcolorbutton.h>
+#else
+#include <qpushbutton.h>
+#include <qpixmap.h>
+#include <qiconset.h>
+#endif
+#include <qcolordialog.h>
+
+namespace PropertyLib {
+
+PColorButton::PColorButton(MultiProperty* property, QWidget* parent, const char* name)
+ :PropertyWidget(property, parent, name)
+{
+ QHBoxLayout *l = new QHBoxLayout(this, 0, 0);
+#ifndef PURE_QT
+ m_edit = new KColorButton(this);
+ connect(m_edit, SIGNAL(changed(const QColor&)), this, SLOT(updateProperty(const QColor&)));
+#else
+ m_edit = new QPushButton(this);
+ connect(m_edit, SIGNAL(clicked()), this, SLOT(changeColor()));
+#endif
+
+ m_edit->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+ l->addWidget(m_edit);
+}
+
+QVariant PColorButton::value() const
+{
+#ifndef PURE_QT
+ return QVariant(m_edit->color());
+#else
+ return QVariant(m_color);
+#endif
+}
+
+void PColorButton::drawViewer(QPainter* p, const QColorGroup& cg, const QRect& r, const QVariant& value)
+{
+/* p->setBrush(value.toColor());
+ p->setPen(Qt::NoPen);
+ p->drawRect(r);*/
+ p->setPen(Qt::NoPen);
+ p->setBrush(cg.background());
+ p->drawRect(r);
+
+ p->setBrush(value.toColor());
+ p->setPen(Qt::SolidLine);
+ QRect r2(r);
+ r2.setTopLeft(r.topLeft() + QPoint(5,5));
+ r2.setBottomRight(r.bottomRight() - QPoint(5,5));
+ p->drawRect(r2);
+}
+
+void PColorButton::setValue(const QVariant& value, bool emitChange)
+{
+#ifndef PURE_QT
+ disconnect(m_edit, SIGNAL(changed(const QColor&)), this, SLOT(updateProperty(const QColor&)));
+ m_edit->setColor(value.toColor());
+ connect(m_edit, SIGNAL(changed(const QColor&)), this, SLOT(updateProperty(const QColor&)));
+#else
+ m_color = value.toColor();
+ m_edit->setText(m_color.name());
+ QPixmap px;
+ px.resize(14,14);
+ px.fill(m_color);
+ m_edit->setIconSet(px);
+#endif
+ if (emitChange)
+ emit propertyChanged(m_property, value);
+
+}
+
+void PColorButton::updateProperty(const QColor &// color
+ )
+{
+ emit propertyChanged(m_property, value());
+}
+
+void PColorButton::changeColor()
+{
+#ifdef PURE_QT
+ m_color = QColorDialog::getColor(m_color,this);
+ updateProperty(m_color);
+ m_edit->setText(m_color.name());
+ QPixmap px;
+ px.resize(14,14);
+ px.fill(m_color);
+ m_edit->setIconSet(px);
+
+#endif
+}
+
+}
+#ifndef PURE_QT
+#include "pcolorbutton.moc"
+#endif
diff --git a/lib/widgets/propeditor/pcolorbutton.h b/lib/widgets/propeditor/pcolorbutton.h
new file mode 100644
index 00000000..67e02ef9
--- /dev/null
+++ b/lib/widgets/propeditor/pcolorbutton.h
@@ -0,0 +1,62 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef PCOLORBUTTON_H
+#define PCOLORBUTTON_H
+
+#include "propertywidget.h"
+
+#ifndef PURE_QT
+class KColorButton;
+#else
+class QPushButton;
+#include <qcolor.h>
+#endif
+namespace PropertyLib{
+
+/**
+@short %Property editor with color chooser button.
+*/
+class PColorButton: public PropertyWidget
+{
+ Q_OBJECT
+public:
+ PColorButton(MultiProperty *property, QWidget *parent = 0, const char *name = 0);
+
+ virtual QVariant value() const;
+ virtual void drawViewer(QPainter* p, const QColorGroup& cg, const QRect& r, const QVariant& value);
+ virtual void setValue(const QVariant& value, bool emitChange);
+
+protected slots:
+ void updateProperty(const QColor& color);
+
+ void changeColor();
+
+private:
+#ifndef PURE_QT
+ KColorButton *m_edit;
+#else
+ QPushButton *m_edit;
+ QColor m_color;
+#endif
+};
+
+}
+
+#endif
diff --git a/lib/widgets/propeditor/pcolorcombo.cpp b/lib/widgets/propeditor/pcolorcombo.cpp
new file mode 100644
index 00000000..4d09a10f
--- /dev/null
+++ b/lib/widgets/propeditor/pcolorcombo.cpp
@@ -0,0 +1,78 @@
+/***************************************************************************
+ * Copyright (C) 2002-2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "pcolorcombo.h"
+
+#include <qlayout.h>
+#include <qpainter.h>
+
+#include <kcolorcombo.h>
+
+namespace PropertyLib{
+
+PColorCombo::PColorCombo(MultiProperty *property, QWidget *parent, const char *name)
+ :PropertyWidget(property, parent, name)
+{
+ QHBoxLayout *l = new QHBoxLayout(this, 0, 0);
+ m_edit = new KColorCombo(this);
+ m_edit->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+ l->addWidget(m_edit);
+
+ connect(m_edit, SIGNAL(activated(int)), this, SLOT(updateProperty(int)));
+}
+
+QVariant PColorCombo::value() const
+{
+ return QVariant(m_edit->color());
+}
+
+void PColorCombo::setValue(const QVariant &value, bool emitChange)
+{
+ disconnect(m_edit, SIGNAL(activated(int)), this, SLOT(updateProperty(int)));
+ m_edit->setColor(value.toColor());
+ connect(m_edit, SIGNAL(activated(int)), this, SLOT(updateProperty(int)));
+ if (emitChange)
+ emit propertyChanged(m_property, value);
+}
+
+void PColorCombo::updateProperty(int /*val*/)
+{
+ emit propertyChanged(m_property, value());
+}
+
+void PColorCombo::drawViewer(QPainter *p, const QColorGroup &cg, const QRect &r, const QVariant &value)
+{
+ p->setPen(Qt::NoPen);
+ p->setBrush(cg.background());
+ p->drawRect(r);
+
+ p->setBrush(value.toColor());
+ p->setPen(Qt::SolidLine);
+ QRect r2(r);
+ r2.setTopLeft(r.topLeft() + QPoint(5,5));
+ r2.setBottomRight(r.bottomRight() - QPoint(5,5));
+ p->drawRect(r2);
+}
+
+}
+
+#ifndef PURE_QT
+#include "pcolorcombo.moc"
+#endif
+
diff --git a/lib/widgets/propeditor/pcolorcombo.h b/lib/widgets/propeditor/pcolorcombo.h
new file mode 100644
index 00000000..512fa9ad
--- /dev/null
+++ b/lib/widgets/propeditor/pcolorcombo.h
@@ -0,0 +1,54 @@
+/***************************************************************************
+ * Copyright (C) 2002-2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef PCOLORCOMBO_H
+#define PCOLORCOMBO_H
+
+#include "propertywidget.h"
+
+class KColorCombo;
+
+namespace PropertyLib{
+
+/**
+@short %Property editor with color combobox.
+*/
+class PColorCombo: public PropertyWidget{
+ Q_OBJECT
+public:
+ PColorCombo(MultiProperty *property, QWidget *parent = 0, const char *name = 0);
+
+ /**@return the value currently entered in the editor widget.*/
+ virtual QVariant value() const;
+ /**Sets the value shown in the editor widget. Set emitChange to false
+ if you don't want to emit propertyChanged signal.*/
+ virtual void setValue(const QVariant &value, bool emitChange=true);
+ /**Function to draw a property viewer when the editor isn't shown.*/
+ virtual void drawViewer(QPainter *p, const QColorGroup &cg, const QRect &r, const QVariant &value);
+
+private slots:
+ void updateProperty(int val);
+
+private:
+ KColorCombo *m_edit;
+};
+
+}
+
+#endif
diff --git a/lib/widgets/propeditor/pcombobox.cpp b/lib/widgets/propeditor/pcombobox.cpp
new file mode 100644
index 00000000..9c1619cf
--- /dev/null
+++ b/lib/widgets/propeditor/pcombobox.cpp
@@ -0,0 +1,110 @@
+/***************************************************************************
+ * Copyright (C) 2002-2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "pcombobox.h"
+
+#include <qcombobox.h>
+#include <qlayout.h>
+
+namespace PropertyLib{
+
+PComboBox::PComboBox(MultiProperty *property, const QMap<QString, QVariant> &list, QWidget *parent, const char *name)
+ :PropertyWidget(property, parent, name), m_valueList(list)
+{
+ init(false);
+}
+
+PComboBox::PComboBox(MultiProperty *property, const QMap<QString, QVariant> &list, bool rw, QWidget *parent, const char *name)
+ :PropertyWidget(property, parent, name), m_valueList(list)
+{
+ init(rw);
+}
+
+void PComboBox::init(bool rw)
+{
+ QHBoxLayout *l = new QHBoxLayout(this, 0, 0);
+ m_edit = new QComboBox(rw, this);
+ m_edit->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+ l->addWidget(m_edit);
+
+ fillBox();
+
+ connect(m_edit, SIGNAL(activated(int)), this, SLOT(updateProperty(int)));
+}
+
+void PComboBox::fillBox()
+{
+ for (QMap<QString, QVariant>::const_iterator it = m_valueList.begin(); it != m_valueList.end(); it++)
+ {
+ m_edit->insertItem(it.key());
+ }
+}
+
+QVariant PComboBox::value() const
+{
+ QMap<QString, QVariant>::const_iterator it = m_valueList.find(m_edit->currentText());
+ if (it == m_valueList.end())
+ return QVariant("");
+ return QVariant(it.data());
+}
+
+void PComboBox::setValue(const QVariant &value, bool emitChange)
+{
+#if QT_VERSION >= 0x030100
+ if (!value.isNull())
+#else
+ if (value.canCast(QVariant::String))
+#endif
+ {
+ disconnect(m_edit, SIGNAL(activated(int)), this, SLOT(updateProperty(int)));
+ m_edit->setCurrentText(findDescription(value));
+ connect(m_edit, SIGNAL(activated(int)), this, SLOT(updateProperty(int)));
+ if (emitChange)
+ emit propertyChanged(m_property, value);
+ }
+}
+
+void PComboBox::updateProperty(int /*val*/)
+{
+ emit propertyChanged(m_property, value());
+}
+
+QString PComboBox::findDescription(const QVariant &value)
+{
+ for (QMap<QString, QVariant>::const_iterator it = m_valueList.begin(); it != m_valueList.end(); ++ it)
+ {
+ if (it.data() == value)
+ return it.key();
+ }
+ return "";
+}
+
+void PComboBox::setValueList(const QMap<QString, QVariant> &valueList)
+{
+ m_valueList = valueList;
+ m_edit->clear();
+ fillBox();
+}
+
+}
+
+#ifndef PURE_QT
+#include "pcombobox.moc"
+#endif
+
diff --git a/lib/widgets/propeditor/pcombobox.h b/lib/widgets/propeditor/pcombobox.h
new file mode 100644
index 00000000..c2f8dc2f
--- /dev/null
+++ b/lib/widgets/propeditor/pcombobox.h
@@ -0,0 +1,72 @@
+/***************************************************************************
+ * Copyright (C) 2002-2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef PCOMBOBOX_H
+#define PCOMBOBOX_H
+
+#include <qmap.h>
+
+#include <qcombobox.h>
+
+#include "propertywidget.h"
+
+class QComboBox;
+
+namespace PropertyLib{
+
+/**
+@short %Property editor with combobox.
+*/
+class PComboBox: public PropertyWidget{
+ Q_OBJECT
+public:
+ /**This constructor is used for read-only selection combo. It provides a value from valueList*/
+ PComboBox(MultiProperty *property, const QMap<QString, QVariant> &list, QWidget *parent = 0, const char *name = 0);
+ /**This constructor is used for read-write selection combo. It provides a value from valueList*/
+ PComboBox(MultiProperty *property, const QMap<QString, QVariant> &list, bool rw, QWidget *parent = 0, const char *name = 0);
+
+ /**@return the value currently entered in the editor widget.*/
+ virtual QVariant value() const;
+ /**Sets the value shown in the editor widget. Set emitChange to false
+ if you don't want to emit propertyChanged signal.*/
+ virtual void setValue(const QVariant &value, bool emitChange=true);
+ /**Sets the list of possible values shown in the editor widget. This method
+ does not emit propertyChanged signal. Reimplemented because combobox is used
+ to display possible values from valueList.*/
+ virtual void setValueList(const QMap<QString, QVariant> &valueList);
+
+protected:
+ QString findDescription(const QVariant &value);
+
+protected slots:
+ void updateProperty(int val);
+
+private:
+ virtual void fillBox();
+ void init(bool rw = false);
+
+ /** map<description, value>*/
+ QMap<QString, QVariant> m_valueList;
+
+ QComboBox *m_edit;
+};
+
+}
+
+#endif
diff --git a/lib/widgets/propeditor/pcursoredit.cpp b/lib/widgets/propeditor/pcursoredit.cpp
new file mode 100644
index 00000000..5667421d
--- /dev/null
+++ b/lib/widgets/propeditor/pcursoredit.cpp
@@ -0,0 +1,41 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "pcursoredit.h"
+
+#include <qpainter.h>
+
+namespace PropertyLib{
+
+PCursorEdit::PCursorEdit(MultiProperty* property, const QMap<QString, QVariant> &spValues,
+ QWidget* parent, const char* name)
+ :PComboBox(property, spValues, parent, name)
+{
+}
+
+void PCursorEdit::drawViewer(QPainter* p, const QColorGroup& cg, const QRect& r, const QVariant& value)
+{
+ PropertyWidget::drawViewer(p, cg, r, findDescription(value));
+}
+
+}
+
+#ifndef PURE_QT
+#include "pcursoredit.moc"
+#endif
diff --git a/lib/widgets/propeditor/pcursoredit.h b/lib/widgets/propeditor/pcursoredit.h
new file mode 100644
index 00000000..0a9ccb9a
--- /dev/null
+++ b/lib/widgets/propeditor/pcursoredit.h
@@ -0,0 +1,42 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef PCURSOREDIT_H
+#define PCURSOREDIT_H
+
+#include "pcombobox.h"
+
+namespace PropertyLib{
+
+/**
+@short %Property editor for QCursor values.
+*/
+class PCursorEdit: public PComboBox
+{
+ Q_OBJECT
+public:
+ PCursorEdit(MultiProperty* property, const QMap<QString, QVariant> &spValues,
+ QWidget* parent = 0, const char* name = 0);
+
+ virtual void drawViewer(QPainter* p, const QColorGroup& cg, const QRect& r, const QVariant& value);
+};
+
+}
+
+#endif
diff --git a/lib/widgets/propeditor/pdateedit.cpp b/lib/widgets/propeditor/pdateedit.cpp
new file mode 100644
index 00000000..48a020e8
--- /dev/null
+++ b/lib/widgets/propeditor/pdateedit.cpp
@@ -0,0 +1,70 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "pdateedit.h"
+
+#include <qdatetimeedit.h>
+#include <qpainter.h>
+#include <qlayout.h>
+
+namespace PropertyLib{
+
+PDateEdit::PDateEdit(MultiProperty* property, QWidget* parent, const char* name)
+ :PropertyWidget(property, parent, name)
+{
+ QHBoxLayout *l = new QHBoxLayout(this, 0, 0);
+ m_edit = new QDateEdit(this);
+ m_edit->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+ l->addWidget(m_edit);
+
+ connect(m_edit, SIGNAL(valueChanged(const QDate&)), this, SLOT(updateProperty(const QDate&)));
+}
+
+QVariant PDateEdit::value() const
+{
+ return QVariant(m_edit->date());
+}
+
+void PDateEdit::drawViewer(QPainter* p, const QColorGroup& cg, const QRect& r, const QVariant& value)
+{
+ p->setPen(Qt::NoPen);
+ p->setBrush(cg.background());
+ p->drawRect(r);
+ p->drawText(r, Qt::AlignLeft | Qt::AlignVCenter | Qt::SingleLine, value.toDate().toString(Qt::LocalDate));
+}
+
+void PDateEdit::setValue(const QVariant& value, bool emitChange)
+{
+ disconnect(m_edit, SIGNAL(valueChanged(const QDate&)), this, SLOT(updateProperty(const QDate&)));
+ m_edit->setDate(value.toDate());
+ connect(m_edit, SIGNAL(valueChanged(const QDate&)), this, SLOT(updateProperty(const QDate&)));
+ if (emitChange)
+ emit propertyChanged(m_property, value);
+}
+
+void PDateEdit::updateProperty(const QDate &val)
+{
+ emit propertyChanged(m_property, QVariant(val));
+}
+
+}
+
+#ifndef PURE_QT
+#include "pdateedit.moc"
+#endif
diff --git a/lib/widgets/propeditor/pdateedit.h b/lib/widgets/propeditor/pdateedit.h
new file mode 100644
index 00000000..166e1e3f
--- /dev/null
+++ b/lib/widgets/propeditor/pdateedit.h
@@ -0,0 +1,51 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef PDATEEDIT_H
+#define PDATEEDIT_H
+
+#include "propertywidget.h"
+
+class QDateEdit;
+
+namespace PropertyLib{
+
+/**
+@short %Property editor for QDate values.
+*/
+class PDateEdit : public PropertyWidget
+{
+Q_OBJECT
+public:
+ PDateEdit(MultiProperty* property, QWidget* parent=0, const char* name=0);
+
+ virtual QVariant value() const;
+ virtual void drawViewer(QPainter* p, const QColorGroup& cg, const QRect& r, const QVariant& value);
+ virtual void setValue(const QVariant& value, bool emitChange);
+
+private slots:
+ void updateProperty(const QDate &val);
+
+private:
+ QDateEdit *m_edit;
+};
+
+}
+
+#endif
diff --git a/lib/widgets/propeditor/pdatetimeedit.cpp b/lib/widgets/propeditor/pdatetimeedit.cpp
new file mode 100644
index 00000000..ec9025ec
--- /dev/null
+++ b/lib/widgets/propeditor/pdatetimeedit.cpp
@@ -0,0 +1,69 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "pdatetimeedit.h"
+
+#include <qdatetimeedit.h>
+#include <qpainter.h>
+#include <qlayout.h>
+
+namespace PropertyLib{
+
+PDateTimeEdit::PDateTimeEdit(MultiProperty* property, QWidget* parent, const char* name): PropertyWidget(property, parent, name)
+{
+ QHBoxLayout *l = new QHBoxLayout(this, 0, 0);
+ m_edit = new QDateTimeEdit(this);
+ m_edit->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+ l->addWidget(m_edit);
+
+ connect(m_edit, SIGNAL(valueChanged(const QDateTime&)), this, SLOT(updateProperty(const QDateTime&)));
+}
+
+QVariant PDateTimeEdit::value() const
+{
+ return QVariant(m_edit->dateTime());
+}
+
+void PDateTimeEdit::drawViewer(QPainter* p, const QColorGroup& cg, const QRect& r, const QVariant& value)
+{
+ p->setPen(Qt::NoPen);
+ p->setBrush(cg.background());
+ p->drawRect(r);
+ p->drawText(r, Qt::AlignLeft | Qt::AlignVCenter | Qt::SingleLine, value.toDateTime().toString(Qt::LocalDate));
+}
+
+void PDateTimeEdit::setValue(const QVariant& value, bool emitChange)
+{
+ disconnect(m_edit, SIGNAL(valueChanged(const QDateTime&)), this, SLOT(updateProperty(const QDateTime&)));
+ m_edit->setDateTime(value.toDateTime());
+ connect(m_edit, SIGNAL(valueChanged(const QDateTime&)), this, SLOT(updateProperty(const QDateTime&)));
+ if (emitChange)
+ emit propertyChanged(m_property, value);
+}
+
+void PDateTimeEdit::updateProperty(const QDateTime &val)
+{
+ emit propertyChanged(m_property, QVariant(val));
+}
+
+}
+
+#ifndef PURE_QT
+#include "pdatetimeedit.moc"
+#endif
diff --git a/lib/widgets/propeditor/pdatetimeedit.h b/lib/widgets/propeditor/pdatetimeedit.h
new file mode 100644
index 00000000..6421ef03
--- /dev/null
+++ b/lib/widgets/propeditor/pdatetimeedit.h
@@ -0,0 +1,52 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef PDATETIMEEDIT_H
+#define PDATETIMEEDIT_H
+
+#include "propertywidget.h"
+
+class QDateTimeEdit;
+
+namespace PropertyLib{
+
+/**
+@short %Property editor for QDateTime values.
+*/
+class PDateTimeEdit : public PropertyWidget
+{
+Q_OBJECT
+public:
+ PDateTimeEdit(MultiProperty* property, QWidget* parent=0, const char* name=0);
+
+ virtual QVariant value() const;
+ virtual void drawViewer(QPainter* p, const QColorGroup& cg, const QRect& r, const QVariant& value);
+ virtual void setValue(const QVariant& value, bool emitChange);
+
+private slots:
+ void updateProperty(const QDateTime &val);
+
+private:
+ QDateTimeEdit *m_edit;
+
+};
+
+}
+
+#endif
diff --git a/lib/widgets/propeditor/pdoublenuminput.cpp b/lib/widgets/propeditor/pdoublenuminput.cpp
new file mode 100644
index 00000000..5be997e4
--- /dev/null
+++ b/lib/widgets/propeditor/pdoublenuminput.cpp
@@ -0,0 +1,94 @@
+/***************************************************************************
+ * Copyright (C) 2003-2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "pdoublenuminput.h"
+
+#ifndef PURE_QT
+#include <knuminput.h>
+#else
+#include "qfloatinput.h"
+#endif
+
+#include <limits.h>
+#include <math.h>
+#include <qlayout.h>
+
+namespace PropertyLib{
+
+PDoubleNumInput::PDoubleNumInput(MultiProperty *property, QWidget *parent, const char *name)
+ :PropertyWidget(property, parent, name)
+{
+ QHBoxLayout *l = new QHBoxLayout(this, 0, 0);
+#ifndef PURE_QT
+ m_edit = new KDoubleNumInput(-999999.0, 999999.0, 0.0, 0.01, 2, this);
+ m_edit->setLabel(QString::null);
+ connect(m_edit, SIGNAL(valueChanged(double)), this, SLOT(updateProperty(double)));
+#else
+ m_edit = new QFloatInput(-999999, 999999, 0.01, 2, this );
+ connect(m_edit, SIGNAL(valueChanged(int)), this, SLOT(updateProperty(int)));
+#endif
+ m_edit->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+/* m_edit->setMinValue(-999999999);
+ m_edit->setMaxValue(+999999999);
+ m_edit->setPrecision(2);*/
+ l->addWidget(m_edit);
+
+}
+
+QVariant PDoubleNumInput::value() const
+{
+ return QVariant(m_edit->value());
+}
+
+void PDoubleNumInput::setValue(const QVariant &value, bool emitChange)
+{
+#ifndef PURE_QT
+ disconnect(m_edit, SIGNAL(valueChanged(double)), this, SLOT(updateProperty(double)));
+ m_edit->setValue(value.toDouble());
+ connect(m_edit, SIGNAL(valueChanged(double)), this, SLOT(updateProperty(double)));
+#else
+ disconnect(m_edit, SIGNAL(valueChanged(int)), this, SLOT(updateProperty(int)));
+ m_edit->setValue(int(value.toDouble()*pow(m_edit->digits(),10)));
+ connect(m_edit, SIGNAL(valueChanged(int)), this, SLOT(updateProperty(int)));
+#endif
+ if (emitChange)
+ emit propertyChanged(m_property, value);
+}
+
+void PDoubleNumInput::updateProperty(double val)
+{
+ emit propertyChanged(m_property, QVariant(val));
+}
+void PDoubleNumInput::updateProperty(int val)
+{
+#ifdef PURE_QT
+ QString format = QString("%.%1f").arg( m_edit->digits() );
+ QString strVal = QString().sprintf(format.latin1(),
+ (val/(float)pow(m_edit->digits(),10)) );
+ emit propertyChanged(m_property, QVariant(strVal));
+#else
+ Q_UNUSED(val);
+#endif
+}
+
+}
+
+#ifndef PURE_QT
+#include "pdoublenuminput.moc"
+#endif
diff --git a/lib/widgets/propeditor/pdoublenuminput.h b/lib/widgets/propeditor/pdoublenuminput.h
new file mode 100644
index 00000000..f38622ed
--- /dev/null
+++ b/lib/widgets/propeditor/pdoublenuminput.h
@@ -0,0 +1,64 @@
+/***************************************************************************
+ * Copyright (C) 2003-2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef PDOUBLENUMINPUT_H
+#define PDOUBLENUMINPUT_H
+
+#include "propertywidget.h"
+
+#ifndef PURE_QT
+class KDoubleNumInput;
+#else
+class QFloatInput;
+#endif
+
+namespace PropertyLib{
+
+/**
+@short %Property editor with double num input box.
+*/
+class PDoubleNumInput: public PropertyWidget
+{
+Q_OBJECT
+public:
+ PDoubleNumInput(MultiProperty *property, QWidget *parent = 0, const char *name = 0);
+
+ /**@return the value currently entered in the editor widget.*/
+ virtual QVariant value() const;
+ /**Sets the value shown in the editor widget. Set emitChange to false
+ if you don't want to emit propertyChanged signal.*/
+ virtual void setValue(const QVariant &value, bool emitChange=true);
+
+private slots:
+ //because of a bug in moc which doesn't detect conditional slots
+ //we need them both
+ void updateProperty(double val);
+ void updateProperty(int val);
+
+private:
+#ifndef PURE_QT
+ KDoubleNumInput *m_edit;
+#else
+ QFloatInput *m_edit;
+#endif
+};
+
+}
+
+#endif
diff --git a/lib/widgets/propeditor/pdummywidget.cpp b/lib/widgets/propeditor/pdummywidget.cpp
new file mode 100644
index 00000000..ddf09d12
--- /dev/null
+++ b/lib/widgets/propeditor/pdummywidget.cpp
@@ -0,0 +1,54 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "pdummywidget.h"
+
+#include <qpainter.h>
+
+namespace PropertyLib{
+
+PDummyWidget::PDummyWidget(MultiProperty *property, QWidget *parent, const char *name)
+ :PropertyWidget(property, parent, name)
+{
+}
+
+QVariant PDummyWidget::value() const
+{
+ return m_value;
+}
+
+void PDummyWidget::setValue(const QVariant &value, bool emitChange)
+{
+ m_value = value;
+ if (emitChange)
+ emit propertyChanged(m_property, value);
+}
+
+void PDummyWidget::drawViewer(QPainter *p, const QColorGroup &cg, const QRect &r, const QVariant &/*value*/)
+{
+ p->setBrush(cg.background());
+ p->setPen(Qt::NoPen);
+ p->drawRect(r);
+}
+
+}
+
+#ifndef PURE_QT
+#include "pdummywidget.moc"
+#endif
diff --git a/lib/widgets/propeditor/pdummywidget.h b/lib/widgets/propeditor/pdummywidget.h
new file mode 100644
index 00000000..24a30837
--- /dev/null
+++ b/lib/widgets/propeditor/pdummywidget.h
@@ -0,0 +1,60 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef PDUMMYWIDGET_H
+#define PDUMMYWIDGET_H
+
+#include "propertywidget.h"
+#include "multiproperty.h"
+
+class QWidget;
+class QVariant;
+class QPainter;
+class QColorGroup;
+class QRect;
+
+namespace PropertyLib{
+
+/**
+@short %Property editor with empty widget.
+
+This is usefull for properties which can't be edited in a generic way
+like QValueList's or QMap's stored in a variant.
+*/
+class PDummyWidget: public PropertyWidget
+{
+ Q_OBJECT
+public:
+ PDummyWidget(MultiProperty *property, QWidget *parent = 0, const char *name = 0);
+
+ /**@return the value currently entered in the editor widget.*/
+ virtual QVariant value() const;
+ /**Sets the value shown in the editor widget. Set emitChange to false
+ if you don't want to emit propertyChanged signal.*/
+ virtual void setValue(const QVariant& value, bool emitChange);
+ /**Function to draw a property viewer when the editor isn't shown.*/
+ virtual void drawViewer(QPainter *p, const QColorGroup &cg, const QRect &r, const QVariant &value);
+
+private:
+ QVariant m_value;
+};
+
+}
+
+#endif
diff --git a/lib/widgets/propeditor/pfontbutton.cpp b/lib/widgets/propeditor/pfontbutton.cpp
new file mode 100644
index 00000000..3b999dd3
--- /dev/null
+++ b/lib/widgets/propeditor/pfontbutton.cpp
@@ -0,0 +1,86 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "pfontbutton.h"
+
+#include <qlayout.h>
+#include <qpainter.h>
+#include <qpushbutton.h>
+
+#include <kfontrequester.h>
+
+#ifndef PURE_QT
+#include <klocale.h>
+#else
+#include "compat_tools.h"
+#endif
+
+namespace PropertyLib{
+
+PFontButton::PFontButton(MultiProperty* property, QWidget* parent, const char* name)
+ :PropertyWidget(property, parent, name)
+{
+ QHBoxLayout *l = new QHBoxLayout(this, 0, 0);
+ m_edit = new KFontRequester(this);
+ m_edit->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+#ifndef PURE_QT
+ m_edit->button()->setText(i18n("..."));
+#endif
+ l->addWidget(m_edit);
+
+ connect(m_edit, SIGNAL(fontSelected(const QFont& )), this, SLOT(updateProperty(const QFont& )));
+}
+
+QVariant PFontButton::value() const
+{
+ return QVariant(m_edit->font());
+}
+
+void PFontButton::drawViewer(QPainter* p, const QColorGroup& cg, const QRect& r, const QVariant& value)
+{
+ p->setPen(Qt::NoPen);
+ p->setBrush(cg.background());
+ p->drawRect(r);
+ QFontInfo fi(value.toFont());
+ p->drawText(r, Qt::AlignLeft | Qt::AlignVCenter | Qt::SingleLine,
+ fi.family() + (fi.bold() ? i18n(" Bold") : QString("")) +
+ (fi.italic() ? i18n(" Italic") : QString("")) +
+ " " + QString("%1").arg(fi.pointSize()) );
+}
+
+void PFontButton::setValue(const QVariant& value, bool emitChange)
+{
+ disconnect(m_edit, SIGNAL(fontSelected(const QFont&)), this, SLOT(updateProperty(const QFont&)));
+ m_edit->setFont(value.toFont());
+ connect(m_edit, SIGNAL(fontSelected(const QFont& )), this, SLOT(updateProperty(const QFont& )));
+ if (emitChange)
+ emit propertyChanged(m_property, value);
+}
+
+void PFontButton::updateProperty(const QFont &// font
+ )
+{
+ emit propertyChanged(m_property, value());
+}
+
+}
+
+#ifndef PURE_QT
+#include "pfontbutton.moc"
+#endif
diff --git a/lib/widgets/propeditor/pfontbutton.h b/lib/widgets/propeditor/pfontbutton.h
new file mode 100644
index 00000000..20dcd566
--- /dev/null
+++ b/lib/widgets/propeditor/pfontbutton.h
@@ -0,0 +1,52 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef PFONTBUTTON_H
+#define PFONTBUTTON_H
+
+#include "propertywidget.h"
+
+class KFontRequester;
+
+namespace PropertyLib{
+
+/**
+@short %Property editor with font chooser button.
+*/
+class PFontButton : public PropertyWidget
+{
+Q_OBJECT
+public:
+ PFontButton(MultiProperty* property, QWidget* parent = 0, const char* name = 0);
+
+ virtual QVariant value() const;
+ virtual void drawViewer(QPainter* p, const QColorGroup& cg, const QRect& r, const QVariant& value);
+ virtual void setValue(const QVariant& value, bool emitChange);
+
+protected slots:
+ void updateProperty(const QFont& font);
+
+private:
+ KFontRequester *m_edit;
+
+};
+
+}
+
+#endif
diff --git a/lib/widgets/propeditor/pfontcombo.cpp b/lib/widgets/propeditor/pfontcombo.cpp
new file mode 100644
index 00000000..7c648a30
--- /dev/null
+++ b/lib/widgets/propeditor/pfontcombo.cpp
@@ -0,0 +1,86 @@
+/***************************************************************************
+ * Copyright (C) 2002-2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "pfontcombo.h"
+
+#ifndef PURE_QT
+#include <kfontcombo.h>
+#else
+#include <qcombobox.h>
+#endif
+
+#include <qlayout.h>
+
+#ifdef PURE_QT
+#include <qfontdatabase.h>
+#endif
+
+namespace PropertyLib{
+
+PFontCombo::PFontCombo(MultiProperty *property, QWidget *parent, const char *name)
+ :PropertyWidget(property, parent, name)
+{
+ QHBoxLayout *l = new QHBoxLayout(this, 0, 0);
+ m_edit = new KFontCombo(this);
+ m_edit->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+ l->addWidget(m_edit);
+
+ /*adymo: KFontCombo seems to have a bug: when it is not editable, the signals
+ activated(int) and textChanged(const QString &) are not emitted*/
+#ifdef PURE_QT
+ QFontDatabase fonts;
+ m_edit->insertStringList(fonts.families());
+ connect(m_edit, SIGNAL(activated(const QString &)), this, SLOT(updateProperty(const QString&)));
+#else
+ connect(m_edit, SIGNAL(textChanged(const QString&)), this, SLOT(updateProperty(const QString&)));
+#endif
+}
+
+QVariant PFontCombo::value() const
+{
+#ifndef PURE_QT
+ return QVariant(m_edit->currentFont());
+#else
+ return QVariant(m_edit->currentText());
+#endif
+}
+
+void PFontCombo::setValue(const QVariant &value, bool emitChange)
+{
+ disconnect(m_edit, SIGNAL(textChanged(const QString&)), this, SLOT(updateProperty(const QString&)));
+#ifndef PURE_QT
+ m_edit->setCurrentFont(value.toString());
+#else
+ m_edit->setCurrentText(value.toString());
+#endif
+ connect(m_edit, SIGNAL(textChanged(const QString&)), this, SLOT(updateProperty(const QString&)));
+ if (emitChange)
+ emit propertyChanged(m_property, value);
+}
+
+void PFontCombo::updateProperty(const QString &val)
+{
+ emit propertyChanged(m_property, QVariant(val));
+}
+
+}
+
+#ifndef PURE_QT
+#include "pfontcombo.moc"
+#endif
diff --git a/lib/widgets/propeditor/pfontcombo.h b/lib/widgets/propeditor/pfontcombo.h
new file mode 100644
index 00000000..be2671db
--- /dev/null
+++ b/lib/widgets/propeditor/pfontcombo.h
@@ -0,0 +1,56 @@
+/***************************************************************************
+ * Copyright (C) 2002-2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef PFONTCOMBO_H
+#define PFONTCOMBO_H
+
+#include "propertywidget.h"
+
+#ifdef PURE_QT
+#define KFontCombo QComboBox
+#endif
+
+class KFontCombo;
+
+namespace PropertyLib{
+
+/**
+@short %Property editor with font combo box.
+*/
+class PFontCombo: public PropertyWidget{
+ Q_OBJECT
+public:
+ PFontCombo(MultiProperty *property, QWidget *parent = 0, const char *name = 0);
+
+ /**@return the value currently entered in the editor widget.*/
+ virtual QVariant value() const;
+ /**Sets the value shown in the editor widget. Set emitChange to false
+ if you don't want to emit propertyChanged signal.*/
+ virtual void setValue(const QVariant &value, bool emitChange=true);
+
+private slots:
+ void updateProperty(const QString &val);
+
+private:
+ KFontCombo *m_edit;
+};
+
+}
+
+#endif
diff --git a/lib/widgets/propeditor/plineedit.cpp b/lib/widgets/propeditor/plineedit.cpp
new file mode 100644
index 00000000..ac5d7c2a
--- /dev/null
+++ b/lib/widgets/propeditor/plineedit.cpp
@@ -0,0 +1,61 @@
+/***************************************************************************
+ * Copyright (C) 2002-2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "plineedit.h"
+
+#include <klineedit.h>
+#include <qlayout.h>
+
+namespace PropertyLib{
+
+PLineEdit::PLineEdit(MultiProperty *property, QWidget *parent, const char *name)
+ :PropertyWidget(property, parent, name)
+{
+ QHBoxLayout *l = new QHBoxLayout(this, 0, 0);
+ m_edit = new KLineEdit(this);
+ m_edit->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+ l->addWidget(m_edit);
+
+ connect(m_edit, SIGNAL(textChanged(const QString&)), this, SLOT(updateProperty(const QString&)));
+}
+
+QVariant PLineEdit::value() const
+{
+ return QVariant(m_edit->text());
+}
+
+void PLineEdit::setValue(const QVariant &value, bool emitChange)
+{
+ disconnect(m_edit, SIGNAL(textChanged(const QString&)), this, SLOT(updateProperty(const QString&)));
+ m_edit->setText(value.toString());
+ connect(m_edit, SIGNAL(textChanged(const QString&)), this, SLOT(updateProperty(const QString&)));
+ if (emitChange)
+ emit propertyChanged(m_property, value);
+}
+
+void PLineEdit::updateProperty(const QString& val)
+{
+ emit propertyChanged(m_property, QVariant(val));
+}
+
+}
+
+#ifndef PURE_QT
+#include "plineedit.moc"
+#endif
diff --git a/lib/widgets/propeditor/plineedit.h b/lib/widgets/propeditor/plineedit.h
new file mode 100644
index 00000000..ea6f0bd9
--- /dev/null
+++ b/lib/widgets/propeditor/plineedit.h
@@ -0,0 +1,52 @@
+/***************************************************************************
+ * Copyright (C) 2002-2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef PLINEEDIT_H
+#define PLINEEDIT_H
+
+#include "propertywidget.h"
+
+class KLineEdit;
+
+namespace PropertyLib{
+
+/**
+@short %Property editor with line edit.
+*/
+class PLineEdit: public PropertyWidget{
+ Q_OBJECT
+public:
+ PLineEdit(MultiProperty *property, QWidget *parent = 0, const char *name = 0);
+
+ /**@return the value currently entered in the editor widget.*/
+ virtual QVariant value() const;
+ /**Sets the value shown in the editor widget. Set emitChange to false
+ if you don't want to emit propertyChanged signal.*/
+ virtual void setValue(const QVariant &value, bool emitChange=true);
+
+private slots:
+ void updateProperty(const QString &val);
+
+private:
+ KLineEdit *m_edit;
+};
+
+}
+
+#endif
diff --git a/lib/widgets/propeditor/plinestyleedit.cpp b/lib/widgets/propeditor/plinestyleedit.cpp
new file mode 100644
index 00000000..d596ad93
--- /dev/null
+++ b/lib/widgets/propeditor/plinestyleedit.cpp
@@ -0,0 +1,205 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "plinestyleedit.h"
+
+#include <qpainter.h>
+#include <qpixmap.h>
+#include <qcombobox.h>
+#include <qlayout.h>
+
+namespace PropertyLib {
+
+ const char *nopen[]={
+ "48 16 1 1",
+ ". c None",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................"};
+ const char *solid[]={
+ "48 16 2 1",
+ ". c None",
+ "# c #000000",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ ".###########################################....",
+ ".###########################################....",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................"};
+ const char *dash[]={
+ "48 16 2 1",
+ ". c None",
+ "# c #000000",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ ".#########..#########..#########..##########....",
+ ".#########..#########..#########..##########....",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................"};
+ const char *dashdot[]={
+ "48 16 2 1",
+ ". c None",
+ "# c #000000",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ ".#########..##..#########..##..#########..##....",
+ ".#########..##..#########..##..#########..##....",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................"};
+ const char *dashdotdot[]={
+ "48 16 2 1",
+ ". c None",
+ "# c #000000",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ ".#########..##..##..#########..##..##..#####....",
+ ".#########..##..##..#########..##..##..#####....",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................",
+ "................................................"};
+
+
+PLineStyleEdit::PLineStyleEdit(MultiProperty* property, QWidget* parent, const char* name): PropertyWidget(property, parent, name)
+{
+ QHBoxLayout *l = new QHBoxLayout(this, 0, 0);
+ m_edit = new QComboBox(this);
+ m_edit->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+ l->addWidget(m_edit);
+
+ m_edit->insertItem(QPixmap(nopen));
+ m_edit->insertItem(QPixmap(solid));
+ m_edit->insertItem(QPixmap(dash));
+ m_edit->insertItem(QPixmap(dashdot));
+ m_edit->insertItem(QPixmap(dashdotdot));
+
+ connect(m_edit, SIGNAL(activated(int)), this, SLOT(updateProperty(int)));
+}
+
+QVariant PLineStyleEdit::value() const
+{
+ return m_edit->currentItem();
+}
+
+void PLineStyleEdit::drawViewer(QPainter* p, const QColorGroup& cg, const QRect& r, const QVariant& value)
+{
+ p->setPen(Qt::NoPen);
+ p->setBrush(cg.background());
+ p->drawRect(r);
+
+ if (!value.canCast(QVariant::Int))
+ if ((value.toInt() > 5) || (value.toInt() < 0))
+ return;
+
+ switch (value.toInt()) {
+ case 0:
+ p->drawPixmap(r, QPixmap(nopen));
+ break;
+ case 1:
+ p->drawPixmap(r, QPixmap(solid));
+ break;
+ case 2:
+ p->drawPixmap(r, QPixmap(dash));
+ break;
+ case 3:
+ p->drawPixmap(r, QPixmap(dashdot));
+ break;
+ case 4:
+ p->drawPixmap(r, QPixmap(dashdot));
+ break;
+ case 5:
+ p->drawPixmap(r, QPixmap(dashdotdot));
+ break;
+ }
+}
+
+void PLineStyleEdit::setValue(const QVariant& value, bool emitChange)
+{
+ if (!value.canCast(QVariant::Int))
+ return;
+ if ((value.toInt() > 5) || (value.toInt() < 0))
+ return;
+ disconnect(m_edit, SIGNAL(activated(int)), this, SLOT(updateProperty(int)));
+ m_edit->setCurrentItem(value.toInt());
+ connect(m_edit, SIGNAL(activated(int)), this, SLOT(updateProperty(int)));
+ if (emitChange)
+ emit propertyChanged(m_property, value);
+}
+
+void PLineStyleEdit::updateProperty(int val)
+{
+ emit propertyChanged(m_property, QVariant(val));
+}
+
+}
+
+#ifndef PURE_QT
+#include "plinestyleedit.moc"
+#endif
diff --git a/lib/widgets/propeditor/plinestyleedit.h b/lib/widgets/propeditor/plinestyleedit.h
new file mode 100644
index 00000000..1992efba
--- /dev/null
+++ b/lib/widgets/propeditor/plinestyleedit.h
@@ -0,0 +1,50 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef PROPERTYLIBPLINESTYLEEDIT_H
+#define PROPERTYLIBPLINESTYLEEDIT_H
+
+#include "propertywidget.h"
+
+class QComboBox;
+
+namespace PropertyLib {
+
+/**
+@short Line style editor
+*/
+class PLineStyleEdit : public PropertyWidget {
+ Q_OBJECT
+public:
+ PLineStyleEdit(MultiProperty* property, QWidget* parent = 0, const char* name = 0);
+
+ virtual QVariant value() const;
+ virtual void drawViewer(QPainter* p, const QColorGroup& cg, const QRect& r, const QVariant& value);
+ virtual void setValue(const QVariant& value, bool emitChange);
+
+private slots:
+ void updateProperty(int val);
+
+private:
+ QComboBox *m_edit;
+};
+
+}
+
+#endif
diff --git a/lib/widgets/propeditor/ppixmapedit.cpp b/lib/widgets/propeditor/ppixmapedit.cpp
new file mode 100644
index 00000000..b20cc7b3
--- /dev/null
+++ b/lib/widgets/propeditor/ppixmapedit.cpp
@@ -0,0 +1,149 @@
+/***************************************************************************
+ * Copyright (C) 2003 Cedric Pasteur *
+ * <cedric.pasteur@free.fr> *
+ * Copyright (C) 2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "ppixmapedit.h"
+
+#include <qlayout.h>
+#include <qpainter.h>
+#include <qlabel.h>
+#include <qcursor.h>
+
+#ifndef PURE_QT
+#include <klocale.h>
+#else
+#include "compat_tools.h"
+#endif
+
+#ifndef PURE_QT
+#include <kfiledialog.h>
+#else
+#include <qfiledialog.h>
+#endif
+#include <qpushbutton.h>
+
+namespace PropertyLib{
+
+PPixmapEdit::PPixmapEdit(MultiProperty* property, QWidget* parent, const char* name)
+ :PropertyWidget(property, parent, name)
+{
+ QHBoxLayout *l = new QHBoxLayout(this, 0, 0);
+ m_edit = new QLabel(this);
+ m_edit->setAlignment(Qt::AlignTop);
+ m_edit->resize(width(), height()-1);
+ m_edit->setBackgroundMode(Qt::PaletteBase);
+ m_edit->installEventFilter(this);
+
+ m_button = new QPushButton(i18n("..."), this);
+ m_button->resize(height(), height()-8);
+ m_button->move(width() - m_button->width() -1, 0);
+ m_button->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
+ l->addWidget(m_edit);
+ l->addWidget(m_button);
+ m_popup = new QLabel(0, 0, Qt::WStyle_NoBorder|Qt::WX11BypassWM|WStyle_StaysOnTop);
+ m_popup->hide();
+
+
+ connect(m_button, SIGNAL(clicked()), this, SLOT(updateProperty()));
+}
+
+QVariant PPixmapEdit::value() const
+{
+ return QVariant(*(m_edit->pixmap()));
+}
+
+void PPixmapEdit::drawViewer(QPainter* p, const QColorGroup& cg, const QRect& r, const QVariant& value)
+{
+ p->setPen(Qt::NoPen);
+ p->setBrush(cg.background());
+ p->drawRect(r);
+ p->drawPixmap(r.topLeft().x(), r.topLeft().y(), value.toPixmap());
+}
+
+void PPixmapEdit::setValue(const QVariant& value, bool emitChange)
+{
+ m_edit->setPixmap(value.toPixmap());
+ if (emitChange)
+ emit propertyChanged(m_property, value);
+}
+
+void PPixmapEdit::updateProperty()
+{
+#ifndef PURE_QT
+ KURL url = KFileDialog::getImageOpenURL(QString::null, this);
+ if (!url.isEmpty())
+ {
+ m_edit->setPixmap(QPixmap(url.path()));
+ emit propertyChanged(m_property, value());
+ }
+#else
+ QString url = QFileDialog::getOpenFileName();
+ if (!url.isEmpty())
+ {
+ m_edit->setPixmap(QPixmap(url));
+ emit propertyChanged(m_property, value());
+ }
+#endif
+}
+
+void PPixmapEdit::resizeEvent(QResizeEvent *ev)
+{
+ m_edit->resize(ev->size().width(), ev->size().height()-1);
+ m_button->move(ev->size().width() - m_button->width(), 0);
+ m_edit->setMaximumHeight(m_button->height());
+}
+
+bool PPixmapEdit::eventFilter(QObject *o, QEvent *ev)
+{
+ if(o == m_edit)
+ {
+ if(ev->type() == QEvent::MouseButtonPress)
+ {
+ if(m_edit->pixmap()->size().height() < height()-2
+ && m_edit->pixmap()->size().width() < width()-20)
+ return false;
+ m_popup->setPixmap(*(m_edit->pixmap()));
+ m_popup->resize(m_edit->pixmap()->size());
+ m_popup->move(QCursor::pos());
+ m_popup->show();
+ }
+ if(ev->type() == QEvent::MouseButtonRelease)
+ {
+ if(m_popup->isVisible())
+ m_popup->hide();
+ }
+ if(ev->type() == QEvent::KeyPress)
+ {
+ QKeyEvent* e = static_cast<QKeyEvent*>(ev);
+ if((e->key() == Key_Enter) || (e->key()== Key_Space) || (e->key() == Key_Return))
+ {
+ m_button->animateClick();
+ return true;
+ }
+ }
+ }
+ return PropertyWidget::eventFilter(o, ev);
+}
+
+}
+
+#ifndef PURE_QT
+#include "ppixmapedit.moc"
+#endif
diff --git a/lib/widgets/propeditor/ppixmapedit.h b/lib/widgets/propeditor/ppixmapedit.h
new file mode 100644
index 00000000..e61dc73c
--- /dev/null
+++ b/lib/widgets/propeditor/ppixmapedit.h
@@ -0,0 +1,57 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef PPIXMAPEDIT_H
+#define PPIXMAPEDIT_H
+
+#include "propertywidget.h"
+
+class QLabel;
+class QPushButton;
+
+namespace PropertyLib{
+
+/**
+@short %Property editor which shows a pixmap and allows to load it from file.
+*/
+class PPixmapEdit : public PropertyWidget
+{
+ Q_OBJECT
+public:
+ PPixmapEdit(MultiProperty* property, QWidget* parent = 0, const char* name = 0);
+
+ virtual QVariant value() const;
+ virtual void drawViewer(QPainter* p, const QColorGroup& cg, const QRect& r, const QVariant& value);
+ virtual void setValue(const QVariant& value, bool emitChange);
+
+ virtual void resizeEvent(QResizeEvent *ev);
+ virtual bool eventFilter(QObject *o, QEvent *ev);
+
+protected slots:
+ void updateProperty();
+
+private:
+ QLabel *m_edit;
+ QLabel *m_popup;
+ QPushButton *m_button;
+};
+
+}
+
+#endif
diff --git a/lib/widgets/propeditor/ppointedit.cpp b/lib/widgets/propeditor/ppointedit.cpp
new file mode 100644
index 00000000..f9f37bf0
--- /dev/null
+++ b/lib/widgets/propeditor/ppointedit.cpp
@@ -0,0 +1,64 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "ppointedit.h"
+
+#include <klineedit.h>
+#include <qlayout.h>
+#include <qpainter.h>
+
+namespace PropertyLib{
+
+PPointEdit::PPointEdit(MultiProperty* property, QWidget* parent, const char* name): PropertyWidget(property, parent, name)
+{
+ QHBoxLayout *l = new QHBoxLayout(this, 0, 0);
+ m_edit = new KLineEdit(this);
+ m_edit->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+ l->addWidget(m_edit);
+
+ m_edit->setReadOnly(true);
+}
+
+QVariant PPointEdit::value() const
+{
+ return m_value;
+}
+
+void PPointEdit::drawViewer(QPainter* p, const QColorGroup& cg, const QRect& r, const QVariant& value)
+{
+ p->setPen(Qt::NoPen);
+ p->setBrush(cg.background());
+ p->drawRect(r);
+ p->drawText(r, Qt::AlignLeft | Qt::AlignVCenter | Qt::SingleLine, QString("[ %1, %2 ]").arg(value.toPoint().x()).arg(value.toPoint().y()));
+}
+
+void PPointEdit::setValue(const QVariant& value, bool emitChange)
+{
+ m_value = value;
+ m_edit->setText(QString("[ %1, %2 ]").arg(value.toPoint().x()).arg(value.toPoint().y()));
+
+ if (emitChange)
+ emit propertyChanged(m_property, value);
+}
+
+}
+
+#ifndef PURE_QT
+#include "ppointedit.moc"
+#endif
diff --git a/lib/widgets/propeditor/ppointedit.h b/lib/widgets/propeditor/ppointedit.h
new file mode 100644
index 00000000..9b571ced
--- /dev/null
+++ b/lib/widgets/propeditor/ppointedit.h
@@ -0,0 +1,50 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef PPOINTEDIT_H
+#define PPOINTEDIT_H
+
+#include "propertywidget.h"
+
+class KLineEdit;
+
+namespace PropertyLib{
+
+/**
+@short %Property editor for QPoint values.
+*/
+class PPointEdit : public PropertyWidget
+{
+Q_OBJECT
+public:
+ PPointEdit(MultiProperty* property, QWidget* parent=0, const char* name=0);
+
+ virtual QVariant value() const;
+ virtual void drawViewer(QPainter* p, const QColorGroup& cg, const QRect& r, const QVariant& value);
+ virtual void setValue(const QVariant& value, bool emitChange);
+
+private:
+ KLineEdit *m_edit;
+ QVariant m_value;
+
+};
+
+}
+
+#endif
diff --git a/lib/widgets/propeditor/prectedit.cpp b/lib/widgets/propeditor/prectedit.cpp
new file mode 100644
index 00000000..c049b5d6
--- /dev/null
+++ b/lib/widgets/propeditor/prectedit.cpp
@@ -0,0 +1,64 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "prectedit.h"
+
+#include <klineedit.h>
+#include <qlayout.h>
+#include <qpainter.h>
+
+namespace PropertyLib{
+
+PRectEdit::PRectEdit(MultiProperty* property, QWidget* parent, const char* name): PropertyWidget(property, parent, name)
+{
+ QHBoxLayout *l = new QHBoxLayout(this, 0, 0);
+ m_edit = new KLineEdit(this);
+ m_edit->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+ l->addWidget(m_edit);
+
+ m_edit->setReadOnly(true);
+}
+
+QVariant PRectEdit::value() const
+{
+ return m_value;
+}
+
+void PRectEdit::drawViewer(QPainter* p, const QColorGroup& cg, const QRect& r, const QVariant& value)
+{
+ p->setPen(Qt::NoPen);
+ p->setBrush(cg.background());
+ p->drawRect(r);
+ p->drawText(r, Qt::AlignLeft | Qt::AlignVCenter | Qt::SingleLine, QString("[ %1, %2, %3, %4 ]").arg(value.toRect().x()).arg(value.toRect().y()).arg(value.toRect().width()).arg(value.toRect().height()));
+}
+
+void PRectEdit::setValue(const QVariant& value, bool emitChange)
+{
+ m_value = value;
+ m_edit->setText(QString("[ %1, %2, %3, %4 ]").arg(value.toRect().x()).arg(value.toRect().y()).arg(value.toRect().width()).arg(value.toRect().height()));
+
+ if (emitChange)
+ emit propertyChanged(m_property, value);
+}
+
+}
+
+#ifndef PURE_QT
+#include "prectedit.moc"
+#endif
diff --git a/lib/widgets/propeditor/prectedit.h b/lib/widgets/propeditor/prectedit.h
new file mode 100644
index 00000000..44bcfed4
--- /dev/null
+++ b/lib/widgets/propeditor/prectedit.h
@@ -0,0 +1,50 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef PRECTEDIT_H
+#define PRECTEDIT_H
+
+#include "propertywidget.h"
+
+class KLineEdit;
+
+namespace PropertyLib{
+
+/**
+@short %Property editor for QRect values.
+*/
+class PRectEdit : public PropertyWidget
+{
+ Q_OBJECT
+public:
+ PRectEdit(MultiProperty* property, QWidget* parent=0, const char* name=0);
+
+ virtual QVariant value() const;
+ virtual void drawViewer(QPainter* p, const QColorGroup& cg, const QRect& r, const QVariant& value);
+ virtual void setValue(const QVariant& value, bool emitChange);
+
+private:
+ KLineEdit *m_edit;
+ QVariant m_value;
+
+};
+
+}
+
+#endif
diff --git a/lib/widgets/propeditor/property.cpp b/lib/widgets/propeditor/property.cpp
new file mode 100644
index 00000000..d53af8cf
--- /dev/null
+++ b/lib/widgets/propeditor/property.cpp
@@ -0,0 +1,129 @@
+/***************************************************************************
+ * Copyright (C) 2002-2004 by Alexander Dymo <cloudtemple@mskat.net> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "property.h"
+
+#include <qstring.h>
+
+namespace PropertyLib{
+
+Property::Property(int type, const QString &name, const QString &description,
+ const QVariant &value, bool save, bool readOnly):
+ m_type(type), m_name(name), m_description(description), m_value(value), m_save(save),
+ m_readOnly(readOnly), m_visible(true)
+{
+}
+
+Property::Property(const QString &name, const QMap<QString, QVariant> &v_valueList,
+ const QString &description, const QVariant &value, bool save, bool readOnly):
+ valueList(v_valueList), m_type(ValueFromList), m_name(name),
+ m_description(description), m_value(value), m_save(save), m_readOnly(readOnly),
+ m_visible(true)
+{
+}
+
+Property::~Property()
+{
+}
+
+bool Property::allowSaving() const
+{
+ return m_save;
+}
+
+bool Property::operator<(const Property &prop) const
+{
+ if ((type() < prop.type()) && (name() < prop.name()))
+ return true;
+ else
+ return false;
+}
+
+QString Property::name() const
+{
+ return m_name;
+}
+
+void Property::setName(const QString &name)
+{
+ m_name = name;
+}
+
+int Property::type() const
+{
+ return m_type;
+}
+
+void Property::setType(int type)
+{
+ m_type = type;
+}
+
+QVariant Property::value() const
+{
+ return m_value;
+}
+
+void Property::setValue(const QVariant &value, bool rememberOldValue)
+{
+ if (rememberOldValue)
+ m_oldValue = m_value;
+ else
+ m_oldValue = value;
+ m_value = value;
+}
+
+QString Property::description() const
+{
+ return m_description;
+}
+
+void Property::setDescription(const QString &description)
+{
+ m_description = description;
+}
+
+void Property::setValueList(const QMap<QString, QVariant> &v_valueList)
+{
+ valueList = v_valueList;
+}
+
+bool Property::readOnly() const
+{
+ return m_readOnly;
+}
+
+bool Property::visible() const
+{
+ return m_visible;
+}
+
+void Property::setVisible( const bool visible )
+{
+ m_visible = visible;
+}
+
+QVariant Property::oldValue() const
+{
+ if (m_oldValue.isNull())
+ return m_value;
+ else
+ return m_oldValue;
+}
+
+}
diff --git a/lib/widgets/propeditor/property.h b/lib/widgets/propeditor/property.h
new file mode 100644
index 00000000..13a1ad8b
--- /dev/null
+++ b/lib/widgets/propeditor/property.h
@@ -0,0 +1,181 @@
+/***************************************************************************
+ * Copyright (C) 2002-2004 by Alexander Dymo <cloudtemple@mskat.net> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef PROPERTY_H
+#define PROPERTY_H
+
+#include <qvariant.h>
+
+#include <qmap.h>
+
+class QWidget;
+class QString;
+
+/**Namespace which contain property editing classes.*/
+namespace PropertyLib{
+
+/** @file property.h
+@short Contains @ref PropertyLib::Property class and @ref PropertyLib::Property::PropertyType enum.
+*/
+
+/**
+@short Property.
+
+It includes support for QStringList properties, an i18n'ed label and stores an old value to allow undo.
+
+Contains name, type and value.
+
+Type can be one of predefined types (including standard @ref QVariant types) by @ref PropertyLib::Property::PropertyType
+enum or custom user type. User defined types should have values more than 3000.
+
+Value is a @ref QVariant.
+
+Property can optionally have a list of possible values.
+In that case use @ref ValueFromList type and valueList member.
+Use @ref description for i18n'ed label.
+
+Examples:
+creating property:
+\code
+Property *property = new Property(String, name, description, value)
+\endcode
+using convenience constructor to create property of ValueFromList type:
+\code
+Property *property = new Property(name, possibleValuesList, description, value);
+\endcode
+*/
+class Property {
+public:
+ /** PropertyType.
+ Integers that represent the type of the property. */
+ enum PropertyType {
+ //standard supported QVariant types
+ Invalid = QVariant::Invalid /**<invalid property type*/,
+ Map = QVariant::Map /**<QMap<QString, QVariant>*/,
+ List = QVariant::List /**<QValueList<QVariant>*/,
+ String = QVariant::String /**<string*/,
+ StringList = QVariant::StringList /**<string list*/,
+ Font = QVariant::Font /**<font*/,
+ Pixmap = QVariant::Pixmap /**<pixmap*/,
+ //@todo implement QVariant::Brush
+ Rect = QVariant::Rect /**<rectangle (x,y, width, height)*/,
+ Size = QVariant::Size /**<size (width, height)*/,
+ Color = QVariant::Color /**<color*/,
+ //@todo implement QVariant::Palette
+ //@todo implement QVariant::ColorGroup
+ //@todo implement QVariant::IconSet
+ Point = QVariant::Point /**<point (x,y)*/,
+ //@todo implement QVariant::Image
+ Integer = QVariant::Int /**<integer*/,
+ //@todo implement QVariant::UInt
+ Boolean = QVariant::Bool /**<boolean*/,
+ Double = QVariant::Double /**<double*/,
+ //@todo implement QVariant::CString
+ //@todo implement QVariant::PointArray
+ //@todo implement QVariant::Region
+ //@todo implement QVariant::Bitmap
+ Cursor = QVariant::Cursor /**<cursor*/,
+ SizePolicy = QVariant::SizePolicy /**<size policy (horizontal, vertical)*/,
+ Date = QVariant::Date /**<date*/,
+ //@todo implement QVariant::Time
+ DateTime = QVariant::DateTime /**<date and time*/,
+ //@todo implement QVariant::ByteArray
+ //@todo implement QVariant::BitArray
+ //@todo implement QVariant::KeySequence
+ //@todo implement QVariant::Pen
+ //@todo implement QVariant::Long
+ //@todo implement QVariant::LongLong
+ //@todo implement QVariant::ULongLong
+
+
+ //predefined custom types
+ ValueFromList = 2000 /**<string value from a list*/,
+ Symbol = 2001 /**<unicode symbol code*/,
+ FontName = 2002 /**<font name, e.g. "times new roman"*/,
+ FileURL = 2003 /**<url of a file*/,
+ DirectoryURL = 2004 /**<url of a directory*/,
+ LineStyle = 2005 /**<line style*/,
+
+ UserDefined = 3000 /**<plugin defined properties should start here*/
+ };
+
+ /**Constructs empty property.*/
+ Property() {}
+ /**Constructs property.*/
+ Property(int type, const QString &name, const QString &description,
+ const QVariant &value = QVariant(), bool save = true, bool readOnly = false);
+ /**Constructs property with @ref ValueFromList type.*/
+ Property(const QString &name, const QMap<QString, QVariant> &v_valueList,
+ const QString &description, const QVariant &value = QVariant(), bool save = true, bool readOnly = false);
+ virtual ~Property();
+
+ virtual bool operator<(const Property &prop) const;
+
+ /**@return the name of the property.*/
+ virtual QString name() const;
+ /**Sets the name of the property.*/
+ virtual void setName(const QString &name);
+ /**@return the type of the property.*/
+ virtual int type() const;
+ /**Sets the type of the property.*/
+ virtual void setType(int type);
+ /**@return the value of the property.*/
+ virtual QVariant value() const;
+ /**Sets the value of the property.*/
+ virtual void setValue(const QVariant &value, bool rememberOldValue = true);
+ /**@return the description of the property.*/
+ virtual QString description() const;
+ /**Sets the description of the property.*/
+ virtual void setDescription(const QString &description);
+ /**Sets the string-to-value correspondence list of the property.
+ This is used to create comboboxes-like property editors.*/
+ virtual void setValueList(const QMap<QString, QVariant> &list);
+ /**The string-to-value correspondence list of the property.*/
+ QMap<QString, QVariant> valueList;
+
+ /**Tells if the property can be saved to a stream, xml, etc.
+ There is a possibility to use "GUI" properties that aren't
+ stored but used only in a GUI.*/
+ virtual bool allowSaving() const;
+ /**Tells if the property is read only.*/
+ virtual bool readOnly() const;
+ /**Tells if the property is visible.*/
+ virtual bool visible() const;
+ /**Set the visibility.*/
+ virtual void setVisible(const bool visible);
+
+ /**Gets the previous property value.*/
+ virtual QVariant oldValue() const;
+
+private:
+// Property(Property &property) {};
+// void operator=(Property &property) {};
+
+ int m_type;
+ QString m_name;
+ QString m_description;
+ QVariant m_value;
+ QVariant m_oldValue;
+ bool m_save;
+ bool m_readOnly;
+ bool m_visible;
+};
+
+}
+
+#endif
diff --git a/lib/widgets/propeditor/propertyeditor.cpp b/lib/widgets/propeditor/propertyeditor.cpp
new file mode 100644
index 00000000..58c2b936
--- /dev/null
+++ b/lib/widgets/propeditor/propertyeditor.cpp
@@ -0,0 +1,480 @@
+/***************************************************************************
+ * Copyright (C) 2002-2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "propertyeditor.h"
+
+#ifndef PURE_QT
+#include <klocale.h>
+#include <kdebug.h>
+#include <kiconloader.h>
+#else
+#include "compat_tools.h"
+#endif
+
+#include <qtable.h>
+#include <qlayout.h>
+#include <qpainter.h>
+#include <qptrlist.h>
+#include <qvaluelist.h>
+#include <qpushbutton.h>
+
+#include "property.h"
+#include "multiproperty.h"
+#include "propertymachinefactory.h"
+
+namespace PropertyLib{
+
+class PropertyItem: public KListViewItem{
+public:
+ PropertyItem(PropertyEditor *parent, MultiProperty *property)
+ :KListViewItem(parent, property->description()), m_editor(parent), m_property(property),
+ m_changed(false)
+ {
+ }
+
+ PropertyItem(PropertyEditor *editor, KListViewItem *parent, MultiProperty *property)
+ :KListViewItem(parent, property->description()), m_editor(editor),
+ m_property(property), m_changed(false)
+ {
+ }
+
+/* int type() const
+ {
+ return m_property->type();
+ }
+
+ QString name() const
+ {
+ return m_property->name();
+ }
+ */
+ MultiProperty *property() const
+ {
+ return m_property;
+ }
+
+ virtual void paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int align)
+ {
+ if ((column == 0) && m_changed)
+ {
+ QFont font;
+ font.setBold(true);
+ p->setFont(font);
+ p->setBrush(cg.highlight());
+ p->setPen(cg.highlightedText());
+ }
+ if (column == 1)
+ {
+ QRect r(0, 0, m_editor->header()->sectionSize(1), height());
+ //FIXME: this is ugly, but how else can we deal with ValueFromList properties?
+ QVariant valueToDraw;
+ if (m_property->type() == Property::ValueFromList)
+ valueToDraw = m_property->findValueDescription();
+ else
+ valueToDraw = m_property->value();
+ QColorGroup icg(cg);
+#ifndef PURE_QT
+ icg.setColor(QColorGroup::Background, backgroundColor());
+#else
+ icg.setColor(QColorGroup::Background, white);
+#endif
+ m_editor->machine(m_property)->propertyEditor->drawViewer(p, icg, r, valueToDraw);
+ return;
+ }
+ KListViewItem::paintCell(p, cg, column, width, align);
+ }
+
+ virtual void setup()
+ {
+ KListViewItem::setup();
+ setHeight(static_cast<int>(height()*1.5));
+ }
+
+ void setChanged(bool changed)
+ {
+ m_changed = changed;
+ }
+
+private:
+ PropertyEditor *m_editor;
+ MultiProperty *m_property;
+ bool m_changed;
+};
+
+
+class PropertyGroupItem: public KListViewItem{
+public:
+ PropertyGroupItem(KListView *parent, const QString &name)
+ :KListViewItem(parent, name)
+ {
+ init();
+ }
+ PropertyGroupItem(KListViewItem *parent, const QString &name)
+ :KListViewItem(parent, name)
+ {
+ init();
+ }
+
+ virtual void paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int align)
+ {
+ if (column == 0)
+ {
+ QFont font;
+ font.setBold(true);
+ p->setFont(font);
+ p->setBrush(cg.highlight());
+ p->setPen(cg.highlightedText());
+ }
+ KListViewItem::paintCell(p, cg, column, width, align);
+ }
+ virtual void setup()
+ {
+ KListViewItem::setup();
+ setHeight(static_cast<int>(height()*1.4));
+ }
+
+private:
+ void init()
+ {
+ setOpen(true);
+ }
+};
+
+class SeparatorItem: public KListViewItem{
+public:
+ SeparatorItem(KListView *parent)
+ :KListViewItem(parent)
+ {
+ setSelectable(false);
+ }
+};
+PropertyEditor::PropertyEditor(QWidget *parent, const char *name)
+ :KListView(parent, name)
+{
+ setSorting(-1);
+
+ addColumn(i18n("Name"));
+ addColumn(i18n("Value"));
+ setAllColumnsShowFocus(true);
+ setColumnWidthMode(0, QListView::Maximum);
+ setResizeMode(QListView::LastColumn);
+
+ header()->setClickEnabled(false);
+
+ connect(header(), SIGNAL(sizeChange(int, int, int)),
+ this, SLOT(updateEditorSize()));
+ connect(this, SIGNAL(currentChanged(QListViewItem*)),
+ this, SLOT(slotClicked(QListViewItem*)));
+
+ m_currentEditItem = 0;
+ m_doubleClickForEdit = true;
+ m_lastClickedItem = 0;
+ m_currentEditWidget = 0;
+ m_list = 0;
+
+ m_currentEditArea = new QWidget(viewport());
+ m_currentEditArea->hide();
+ m_undoButton = new QPushButton(m_currentEditArea);
+#ifndef PURE_QT
+ m_undoButton->setPixmap(SmallIcon("undo"));
+#else
+ m_undoButton->setPixmap( QPixmap("undo.xpm") );
+#endif
+ m_undoButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::MinimumExpanding);
+ m_undoButton->resize(m_undoButton->height(), m_undoButton->height());
+ m_undoButton->hide();
+ connect(m_undoButton, SIGNAL(clicked()), this, SLOT(undo()));
+ m_currentEditLayout = new QGridLayout(m_currentEditArea, 1, 2, 0, 0);
+// m_currentEditLayout->addWidget(m_undoButton, 0, 1);
+}
+
+PropertyEditor::~PropertyEditor()
+{
+ clearMachineCache();
+}
+
+void PropertyEditor::populateProperties(PropertyList *list)
+{
+ if (list == 0)
+ return;
+ m_list = list;
+ connect(m_list, SIGNAL(propertyValueChanged(Property*)), this, SLOT(propertyValueChanged(Property*)));
+ const QValueList<QPair<QString, QValueList<QString> > >& groups = m_list->propertiesOfGroup();
+ for (QValueList<QPair<QString, QValueList<QString> > >::const_iterator it = groups.begin();
+ it != groups.end(); ++it)
+ {
+// qWarning("PropertyEditor::populateProperties: adding group %s", (*it).first.ascii());
+ PropertyGroupItem *group = 0;
+ if ( (!(*it).first.isEmpty()) && ((*it).second.count() > 0) )
+ group = new PropertyGroupItem(this, (*it).first);
+ const QValueList<QString> &properties = (*it).second;
+ for (QValueList<QString>::const_iterator it2 = properties.begin(); it2 != properties.end(); ++it2)
+ {
+// qWarning("PropertyEditor::populateProperties: adding property %s", (*it2).ascii());
+ if (group)
+ addProperty(group, *it2);
+ else
+ addProperty(*it2);
+ }
+ }
+ if (firstChild())
+ {
+ setCurrentItem(firstChild());
+ setSelected(firstChild(), true);
+ slotClicked(firstChild());
+ }
+}
+
+void PropertyEditor::addProperty(PropertyGroupItem *group, const QString &name)
+{
+ if ((*m_list)[name] == 0)
+ return;
+// qWarning("%s = name : object null ", name.ascii());
+ PropertyItem *pitem = new PropertyItem(this, group, (*m_list)[name]);
+ addChildProperties(pitem);
+}
+
+void PropertyEditor::addProperty(const QString &name)
+{
+ if ((*m_list)[name] == 0)
+ return;
+// qWarning("%s = name : object null ", name.ascii());
+ PropertyItem *pitem = new PropertyItem(this, (*m_list)[name]);
+ addChildProperties(pitem);
+}
+
+void PropertyEditor::addChildProperties(PropertyItem *parent)
+{
+ MultiProperty *prop = parent->property();
+ //force machine creation to get detailed properties appended to current multiproperty
+ if ( !m_registeredForType.contains(prop->name())
+ && (PropertyMachineFactory::getInstance()->hasDetailedEditors(prop->type())) )
+ {
+ //FIXME: find better solution
+ machine(prop);
+ }
+
+// qWarning("seeking children: count: %d", prop->details.count());
+
+ parent->setOpen(true);
+ for (QValueList<ChildProperty>::iterator it = prop->details.begin(); it != prop->details.end(); ++it)
+ {
+// qWarning("found child %s", (*it).name().ascii());
+ new PropertyItem(this, parent, new MultiProperty(&m_detailedList, &(*it)));
+ }
+}
+
+void PropertyEditor::clearProperties()
+{
+ m_detailedList.clear();
+ if (!m_list)
+ return;
+
+ hideEditor();
+
+ disconnect(m_list, SIGNAL(propertyValueChanged(Property*)), this, SLOT(propertyValueChanged(Property*)));
+ clear();
+ delete m_list;
+ m_list = 0;
+}
+
+void PropertyEditor::propertyValueChanged(Property *property)
+{
+// qWarning("PropertyEditor::propertyValueChanged");
+ if (m_currentEditWidget->propertyName() == property->name())
+ m_currentEditWidget->setValue(property->value(), false);
+ else
+ {
+// repaint all items
+ QListViewItemIterator it(this);
+ while (it.current())
+ {
+ repaintItem(it.current());
+ ++it;
+ }
+ }
+}
+
+void PropertyEditor::propertyChanged(MultiProperty *property, const QVariant &value)
+{
+ if (!property)
+ return;
+
+ qWarning("editor: assign %s to %s", property->name().latin1(), value.toString().latin1());
+ property->setValue(value, false);
+
+ //highlight changed properties
+ if (m_currentEditItem && (m_currentEditItem->property() == property))
+ {
+ m_currentEditItem->setChanged(true);
+ repaintItem(m_currentEditItem);
+ }
+
+ emit changed();
+
+/* if (m_list->contains(name))
+ {
+ (*m_list)[name]->setValue(value, false);
+// else if (m_detailedList->contains(*/
+}
+
+void PropertyEditor::hideEditor()
+{
+ m_lastClickedItem = 0;
+ m_currentEditItem = 0;
+ if (m_currentEditWidget)
+ {
+ m_currentEditLayout->remove(m_currentEditWidget);
+ m_currentEditWidget->hide();
+ }
+ m_currentEditLayout->remove(m_undoButton);
+ m_undoButton->hide();
+ m_currentEditArea->hide();
+ m_currentEditWidget = 0;
+}
+
+void PropertyEditor::showEditor(PropertyItem *item)
+{
+ m_currentEditItem = item;
+ placeEditor(item);
+ m_currentEditWidget->show();
+ m_undoButton->show();
+ m_currentEditArea->show();
+}
+
+void PropertyEditor::placeEditor(PropertyItem *item)
+{
+ QRect r = itemRect(item);
+ if (!r.size().isValid())
+ {
+ ensureItemVisible(item);
+ r = itemRect(item);
+ }
+
+ r.setX(header()->sectionPos(1));
+ r.setWidth(header()->sectionSize(1));
+
+ // check if the column is fully visible
+ if (visibleWidth() < r.right())
+ r.setRight(visibleWidth());
+
+ r = QRect(viewportToContents(r.topLeft()), r.size());
+
+ if (item->pixmap(1))
+ {
+ r.setX(r.x() + item->pixmap(1)->width());
+ }
+
+ if (PropertyWidget* editor = prepareEditor(item))
+ {
+ m_currentEditLayout->addWidget(editor, 0, 0);
+ m_currentEditLayout->addWidget(m_undoButton, 0, 1);
+ m_currentEditArea->resize(r.size());
+// m_currentEditLayout->invalidate();
+ moveChild(m_currentEditArea, r.x(), r.y());
+ m_currentEditWidget = editor;
+ }
+}
+
+PropertyWidget* PropertyEditor::prepareEditor(PropertyItem *item)
+{
+ PropertyWidget *editorWidget = 0;
+/* if (item->depth() >= 2)
+ {
+ editorWidget = machine(item->name())->propertyEditor;
+ editorWidget->setValue(m_accessor->value(item->name()), false);
+ }
+ else
+ {*/
+ editorWidget = machine(item->property())->propertyEditor;
+ editorWidget->setProperty(item->property());
+ if (item->property()->type() == Property::ValueFromList)
+ editorWidget->setValueList(item->property()->valueList());
+ editorWidget->setValue(item->property()->value(), false);
+ //}
+ return editorWidget;
+}
+
+void PropertyEditor::updateEditorSize()
+{
+ if (m_currentEditItem)
+ placeEditor(m_currentEditItem);
+}
+
+void PropertyEditor::slotClicked(QListViewItem *item)
+{
+ if (item == 0)
+ {
+ hideEditor();
+ return;
+ }
+ if (item != m_lastClickedItem)
+ {
+ hideEditor();
+ PropertyItem *it = dynamic_cast<PropertyItem*>(item);
+ if (it)
+ {
+ showEditor(it);
+ }
+ }
+
+ m_lastClickedItem = item;
+}
+
+Machine *PropertyEditor::machine(MultiProperty *property)
+{
+// int type = property->type();
+ QString name = property->name();
+ QMap<QString, QVariant> values = property->valueList();
+ if (m_registeredForType[name] == 0)
+ {
+ m_registeredForType[name] = PropertyMachineFactory::getInstance()->machineForProperty(property);
+ connect(m_registeredForType[name]->propertyEditor, SIGNAL(propertyChanged(MultiProperty*, const QVariant&)),
+ this, SLOT(propertyChanged(MultiProperty*, const QVariant&)));
+ m_registeredForType[name]->propertyEditor->reparent(m_currentEditArea, 0, m_currentEditArea->childrenRect().topLeft());
+ m_registeredForType[name]->propertyEditor->hide();
+ }
+ return m_registeredForType[name];
+}
+
+void PropertyEditor::clearMachineCache()
+{
+ for (QMap<QString, Machine* >::iterator it = m_registeredForType.begin(); it != m_registeredForType.end(); ++it)
+ {
+ delete it.data();
+ }
+ m_registeredForType.clear();
+}
+
+void PropertyEditor::undo()
+{
+ if ((m_currentEditItem == 0) || (m_currentEditWidget == 0)
+ || (!m_currentEditWidget->isVisible()))
+ return;
+
+ m_currentEditWidget->undo();
+ m_currentEditItem->setChanged(false);
+ repaintItem(m_currentEditItem);
+}
+
+}
+
+#ifndef PURE_QT
+#include "propertyeditor.moc"
+#endif
diff --git a/lib/widgets/propeditor/propertyeditor.h b/lib/widgets/propeditor/propertyeditor.h
new file mode 100644
index 00000000..f641118c
--- /dev/null
+++ b/lib/widgets/propeditor/propertyeditor.h
@@ -0,0 +1,129 @@
+/***************************************************************************
+ * Copyright (C) 2002-2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef PROPERTYEDITOR_H
+#define PROPERTYEDITOR_H
+
+#ifndef PURE_QT
+#include <klistview.h>
+#else
+#include <qlistview.h>
+#define KListView QListView
+#define KListViewItem QListViewItem
+#endif
+
+#include "propertylist.h"
+
+class QPushButton;
+class QGridLayout;
+
+namespace PropertyLib{
+
+class PropertyItem;
+class PropertyGroupItem;
+class PropertyWidget;
+class Property;
+class MultiProperty;
+struct Machine;
+
+/** @file propertyeditor.h
+@short Contains @ref PropertyLib::PropertyEditor class.
+*/
+
+/**
+@short %Property editor.
+
+Displays a list of properties in a table form. Also performs grouping and
+creation of property widgets from the machine factory.
+@see PropertyWidget
+@see Machine
+@see PropertyMachineFactory
+*/
+class PropertyEditor: public KListView{
+ Q_OBJECT
+public:
+ /**Constructs the property editor.*/
+ PropertyEditor(QWidget *parent = 0, const char *name = 0);
+ ~PropertyEditor();
+
+ /**@return @ref Machine for given property.
+ Uses cache to store created machines.
+ Cache will be cleared only with @ref clearMachineCache.*/
+ Machine *machine(MultiProperty *property);
+
+public slots:
+ /**Shows properties from a list.*/
+ void populateProperties(PropertyList *list);
+ /**Clears property list, disconnects accessor from the editor and deletes it.*/
+ void clearProperties();
+ /**Deletes cached machines.*/
+ void clearMachineCache();
+
+signals:
+ /**Emitted when something is changed in property editor.*/
+ void changed();
+
+protected slots:
+ /**Updates property widget in the editor.*/
+ void propertyValueChanged(Property* property);
+ /**Updates property in the list when new value is selected in the editor.*/
+ void propertyChanged(MultiProperty *property, const QVariant &value);
+
+ /**Shows property editor.*/
+ void slotClicked(QListViewItem* item);
+ void updateEditorSize();
+
+ /**Undoes the last change in property editor.*/
+ void undo();
+
+protected:
+ void editItem(QListViewItem*, int);
+ void hideEditor();
+ void showEditor(PropertyItem *item);
+ void placeEditor(PropertyItem *item);
+ PropertyWidget *prepareEditor(PropertyItem *item);
+
+ void addGroup(const QString &name);
+ void addProperty(PropertyGroupItem *group, const QString &name);
+ void addProperty(const QString &name);
+ void addChildProperties(PropertyItem *parent);
+
+private:
+ PropertyList *m_list;
+ PropertyList m_detailedList;
+
+ //machines cache for property types, machines will be deleted
+ QMap<QString, Machine* > m_registeredForType;
+
+ PropertyItem *m_currentEditItem;
+ PropertyWidget *m_currentEditWidget;
+ QWidget *m_currentEditArea;
+ QGridLayout *m_currentEditLayout;
+
+ bool m_doubleClickForEdit;
+ QListViewItem* m_lastClickedItem;
+
+ QPushButton *m_undoButton;
+
+friend class PropertyItem;
+};
+
+}
+
+#endif
diff --git a/lib/widgets/propeditor/propertyeditor.pro b/lib/widgets/propeditor/propertyeditor.pro
new file mode 100644
index 00000000..125ce510
--- /dev/null
+++ b/lib/widgets/propeditor/propertyeditor.pro
@@ -0,0 +1,40 @@
+TEMPLATE = lib
+CONFIG += debug
+DEFINES += PURE_QT
+
+SOURCES += childproperty.cpp pcombobox.cpp \
+ pdummywidget.cpp ppointedit.cpp \
+ propertymachinefactory.cpp pstringlistedit.cpp \
+ multiproperty.cpp pcursoredit.cpp \
+ prectedit.cpp propertywidget.cpp \
+ psymbolcombo.cpp pcheckbox.cpp \
+ pdateedit.cpp pfontcombo.cpp \
+ property.cpp psizeedit.cpp \
+ pdatetimeedit.cpp \
+ plineedit.cpp propertyeditor.cpp \
+ psizepolicyedit.cpp pyesnobutton.cpp \
+ ppixmapedit.cpp \
+ propertylist.cpp pspinbox.cpp \
+ propertywidgetproxy.cpp plinestyleedit.cpp \
+ qeditlistbox.cpp pdoublenuminput.cpp \
+ qfloatinput.cpp pcolorbutton.cpp \
+ purledit.cpp
+
+HEADERS += childproperty.h pcombobox.h \
+ pdummywidget.h ppointedit.h \
+ propertymachinefactory.h pcursoredit.h \
+ prectedit.h propertywidget.h \
+ pdateedit.h pfontcombo.h \
+ property.h psizeedit.h \
+ pdatetimeedit.h plineedit.h \
+ propertyeditor.h psizepolicyedit.h \
+ ppixmapedit.h propertylist.h \
+ pspinbox.h propertywidgetproxy.h \
+ multiproperty.h pyesnobutton.h \
+ psymbolcombo.h pstringlistedit.h \
+ pcheckbox.h plinestyleedit.h \
+ qeditlistbox.h pdoublenuminput.h \
+ qfloatinput.h pcolorbutton.h \
+ purledit.h
+
+IMAGES += undo.xpm
diff --git a/lib/widgets/propeditor/propertylist.cpp b/lib/widgets/propeditor/propertylist.cpp
new file mode 100644
index 00000000..3ea79a87
--- /dev/null
+++ b/lib/widgets/propeditor/propertylist.cpp
@@ -0,0 +1,369 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "propertylist.h"
+
+#include "property.h"
+#include "multiproperty.h"
+
+namespace PropertyLib{
+
+PropertyList::PropertyList()
+ :QObject(0, 0), m_propertyOwner(true)
+{
+}
+
+PropertyList::PropertyList(bool propertyOwner)
+ :QObject(0, 0), m_propertyOwner(propertyOwner)
+{
+}
+
+PropertyList::~PropertyList()
+{
+ clear();
+}
+
+MultiProperty *PropertyList::operator[](const QString &name)
+{
+ if (m_list.contains(name))
+ return m_list[name];
+ else
+ return new MultiProperty(this);
+}
+
+MultiProperty *PropertyList::property( const QString &name )
+{
+ if (m_list.contains(name))
+ return m_list[name];
+ else
+ return new MultiProperty(this);
+}
+
+void PropertyList::addProperty(Property *property)
+{
+ if (property == 0)
+ return;
+ MultiProperty *mp = 0;
+ if ( m_list.contains(property->name()) )
+ {
+ mp = m_list[property->name()];
+ mp->addProperty(property);
+ }
+ else
+ {
+ mp = new MultiProperty(this, property);
+ m_list[property->name()] = mp;
+ addToGroup("", mp);
+ }
+}
+
+void PropertyList::addProperty(const QString &group, Property *property)
+{
+ if (property == 0)
+ return;
+
+ MultiProperty *mp = 0;
+ if (m_list.contains(property->name()))
+ {
+ mp = m_list[property->name()];
+ mp->addProperty(property);
+ }
+ else
+ {
+ mp = new MultiProperty(this, property);
+ m_list[property->name()] = mp;
+ addToGroup(group, mp);
+ }
+}
+
+void PropertyList::removeProperty(Property *property)
+{
+ if (property == 0)
+ return;
+
+ if (m_propertyOwner)
+ emit aboutToDeleteProperty(property);
+
+ MultiProperty *mp = m_list[property->name()];
+ QString group = m_groupOfProperty[mp];
+ removeFromGroup(mp);
+ QString pname = property->name();
+ mp->removeProperty(property);
+ if (m_propertyOwner)
+ delete property;
+ if (mp->list.count() == 0)
+ {
+// qWarning("rp: removing mp for %s itself", pname.ascii());
+ m_list.remove(pname);
+ delete mp;
+ }
+ else
+ addToGroup(group, mp);
+}
+
+void PropertyList::removeProperty(const QString &name)
+{
+ if (m_list.contains(name))
+ {
+ QString group = m_groupOfProperty[m_list[name]];
+ removeFromGroup(m_list[name]);
+ Property *property;
+ for (property = m_list[name]->list.first(); property; property = m_list[name]->list.next())
+ {
+ if (m_propertyOwner)
+ emit aboutToDeleteProperty(property);
+
+ m_list[property->name()]->removeProperty(property);
+ if (m_propertyOwner)
+ delete property;
+ }
+ if (m_list[name]->list.count() == 0)
+ {
+// qWarning("rp2: removing mp for %s itself", name.ascii());
+ delete m_list[name];
+ m_list.remove(name);
+ }
+ else
+ {
+ addToGroup(group, m_list[name]);
+ }
+ }
+}
+
+const QValueList<QPair<QString, QValueList<QString> > >& PropertyList::propertiesOfGroup() const
+{
+ return m_propertiesOfGroup;
+}
+
+const QMap<MultiProperty*, QString>& PropertyList::groupOfProperty() const
+{
+ return m_groupOfProperty;
+}
+
+void PropertyList::addToGroup(const QString &group, MultiProperty *property)
+{
+ if (!property)
+ return;
+
+ //do not add same property to the group twice
+ if (m_groupOfProperty.contains(property) && (m_groupOfProperty[property] == group))
+ return;
+
+ QPair<QString, QValueList<QString> > *groupPair = 0;
+ for(QValueList<QPair<QString, QValueList<QString> > >::iterator it = m_propertiesOfGroup.begin();
+ it != m_propertiesOfGroup.end(); ++it)
+ {
+ if ((*it).first == group)
+ {
+ groupPair = &(*it);
+ break;
+ }
+ }
+ if (groupPair == 0)
+ {
+ groupPair = new QPair<QString, QValueList<QString> >();
+ groupPair->first = group;
+ groupPair->second.append(property->name());
+ m_propertiesOfGroup.append(*groupPair);
+ m_groupOfProperty[property] = group;
+ return;
+ }
+ //check if group already contains property with the same name
+ if (!groupPair->second.contains(property->name()))
+ groupPair->second.append(property->name());
+
+ m_groupOfProperty[property] = group;
+}
+
+void PropertyList::removeFromGroup(MultiProperty *property)
+{
+ QString group = m_groupOfProperty[property];
+// qWarning("removeFromGroup group=%s", group.ascii());
+
+ for(QValueList<QPair<QString, QValueList<QString> > >::iterator it = m_propertiesOfGroup.begin();
+ it != m_propertiesOfGroup.end(); ++it)
+ {
+// qWarning("removeFromGroup checking %s", (*it).first.ascii());
+ if ((*it).first == group)
+ {
+// qWarning("removeFromGroup removing %s", property->name().ascii());
+ (*it).second.remove(property->name());
+ break;
+ }
+ }
+
+ m_groupOfProperty.remove(property);
+}
+
+void PropertyList::clear( )
+{
+ for (QMap<QString, MultiProperty*>::iterator it = m_list.begin(); it != m_list.end(); ++it)
+ removeProperty(it.key());
+}
+
+bool PropertyList::contains( const QString & name )
+{
+ if (m_list.contains(name))
+ return true;
+ return false;
+}
+
+QPtrList<Property> PropertyList::properties(const QString &name)
+{
+ if (m_list.contains(name))
+ return m_list[name]->list;
+ return QPtrList<Property>();
+}
+
+PropertyList::Iterator PropertyList::begin()
+{
+ return Iterator(this);
+}
+
+PropertyList::Iterator PropertyList::end()
+{
+ return Iterator(this, true);
+}
+
+//PropertyList::Iterator class
+
+PropertyList::Iterator::Iterator(PropertyList *list)
+ :m_list(list)
+{
+ current = m_list->m_list.begin();
+}
+
+PropertyList::Iterator::Iterator(PropertyList *list, bool // end
+ )
+ :m_list(list)
+{
+ current = m_list->m_list.end();
+}
+
+void PropertyList::Iterator::operator ++()
+{
+ next();
+}
+
+void PropertyList::Iterator::operator ++(int)
+{
+ next();
+}
+
+void PropertyList::Iterator::next()
+{
+ ++current;
+}
+
+MultiProperty *PropertyList::Iterator::operator *()
+{
+ return data();
+}
+
+QString PropertyList::Iterator::key()
+{
+ return current.key();
+}
+
+MultiProperty *PropertyList::Iterator::data()
+{
+ return current.data();
+}
+
+bool PropertyList::Iterator::operator !=(Iterator it)
+{
+ return current != it.current;
+}
+
+
+// PropertyBuffer class
+
+
+
+
+
+PropertyBuffer::PropertyBuffer( )
+ :PropertyList(false)
+{
+}
+
+void PropertyBuffer::intersect(const PropertyList *list)
+{
+ qWarning("PropertyBuffer::intersect");
+ for (QMap<QString, MultiProperty*>::iterator it = m_list.begin(); it != m_list.end(); ++it)
+ {
+// qWarning("intersect:: for mp = %s", it.data()->name().ascii());
+ if (list->m_list.contains(it.key()))
+ {
+/* qWarning("intersect:: list contains %s", it.key().ascii());
+ if ( (*(it.data()) == *(list->m_list[it.key()])))
+ qWarning("intersect:: equal properties");
+ else
+ qWarning("intersect:: not equal properties");*/
+ if ( ((*it.data()) == *(list->m_list[it.key()]))
+ && (list->m_groupOfProperty[list->m_list[it.key()]] == m_groupOfProperty[it.data()]) )
+ {
+// qWarning("intersect:: equal properties, adding");
+ it.data()->addProperty(list->m_list[it.key()]);
+ continue;
+ }
+ }
+// qWarning("intersect:: removing %s from intersection", it.key().ascii());
+ removeProperty(it.key());
+ }
+ connect(list, SIGNAL(propertyValueChanged(Property*)), this, SLOT(intersectedValueChanged(Property*)));
+}
+
+void PropertyBuffer::intersectedValueChanged(Property *property)
+{
+// qWarning("PropertyBuffer::intersectedValueChanged");
+ QString propertyName = property->name();
+ if (!contains(propertyName))
+ return;
+
+ MultiProperty mp(property);
+ if (mp == *m_list[propertyName])
+ {
+ Property *prop;
+ QPtrList<Property> props = properties(propertyName);
+ for (prop = props.first(); prop; prop = props.next())
+ emit propertyValueChanged(prop);
+ }
+}
+
+PropertyBuffer::PropertyBuffer(PropertyList *list)
+ :PropertyList(false)
+{
+ //deep copy of m_list
+ for (QMap<QString, MultiProperty*>::const_iterator it = list->m_list.begin();
+ it != list->m_list.end(); ++it)
+ {
+ MultiProperty *mp = new MultiProperty(*it.data());
+ mp->m_propertyList = this;
+ addToGroup(list->m_groupOfProperty[it.data()], mp);
+ m_list[it.key()] = mp;
+ }
+ connect(list, SIGNAL(propertyValueChanged(Property*)), this, SLOT(intersectedValueChanged(Property*)));
+}
+
+}
+
+#ifndef PURE_QT
+#include "propertylist.moc"
+#endif
diff --git a/lib/widgets/propeditor/propertylist.h b/lib/widgets/propeditor/propertylist.h
new file mode 100644
index 00000000..c07cebbd
--- /dev/null
+++ b/lib/widgets/propeditor/propertylist.h
@@ -0,0 +1,200 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef PROPERTYLIST_H
+#define PROPERTYLIST_H
+
+#include <qobject.h>
+#include <qmap.h>
+#include <qptrlist.h>
+#include <qvaluelist.h>
+#include <qpair.h>
+
+namespace PropertyLib{
+
+class Property;
+class MultiProperty;
+
+/** @file propertylist.h
+@short Contains @ref PropertyLib::PropertyList class.
+*/
+
+/**
+@short The list of properties.
+
+Every object in a program should operate with properties through
+this list in order to:
+- be informed about property changes
+- allow property lists intersections
+- display properties in the property editor widget (see @ref PropertyLib::PropertyEditor).
+.
+
+PropertyList owns properties and deletes them itself. For a list that does not own
+it's properties, look at @ref PropertyLib::PropertyBuffer class.
+
+PropertyList is also capable of grouping properties.
+You can have unsorted list of groups of properties or a plain
+alphabetically sorted list of properties or both at the same time.
+*/
+class PropertyList: public QObject
+{
+ Q_OBJECT
+
+public:
+ class Iterator {
+ public:
+ void operator ++();
+ void operator ++(int);
+
+ MultiProperty *operator *();
+
+ bool operator != (Iterator it);
+
+ QString key();
+ MultiProperty *data();
+
+ private:
+ Iterator(PropertyList *list);
+ Iterator(PropertyList *list, bool end);
+
+ void next();
+ QMap<QString, MultiProperty*>::iterator current;
+
+ PropertyList *m_list;
+ friend class PropertyList;
+ };
+
+ typedef Iterator iterator;
+
+ PropertyList();
+ virtual ~PropertyList();
+
+ /**Accesses a property by it's name. All property modifications are allowed
+ trough this method. For example, to set a value of a property, use:
+ /code
+ PropertyList list;
+ ...
+ list["My Property"]->setValue("My Value");
+ /endcode
+ @return @ref MultiProperty with given name.*/
+ virtual MultiProperty *operator[](const QString &name);
+ /**Accesses a property by it's name. All property modifications are allowed
+ trough this method. For example, to set a value of a property
+ */
+ MultiProperty *property( const QString &name );
+
+ /**Adds the property to the list to the "common" group.*/
+ virtual void addProperty(Property *property);
+ /**Adds the property to the list in group.*/
+ virtual void addProperty(const QString &group, Property *property);
+ /**Removes property from the list. Emits aboutToDeleteProperty before removing.*/
+ virtual void removeProperty(Property *property);
+ /**Removes property with the given name from the list.
+ Emits @ref aboutToDeleteProperty before removing.*/
+ virtual void removeProperty(const QString &name);
+
+ /**@return the list of grouped properties.*/
+ virtual const QValueList<QPair<QString, QValueList<QString> > >& propertiesOfGroup() const;
+ /**@return the map: property - group name.*/
+ virtual const QMap<MultiProperty*, QString>& groupOfProperty() const;
+
+ /**Clears the list of properties.*/
+ virtual void clear();
+ /**Returns true if the list of properties contains property with given name.*/
+ virtual bool contains(const QString &name);
+
+ /**The list of properties with given name.*/
+ QPtrList<Property> properties(const QString &name);
+
+ Iterator begin();
+ Iterator end();
+
+signals:
+ /**Emitted when the value of the property is changed.*/
+ void propertyValueChanged(Property* property);
+ /**Emitted when property is about to be deleted.*/
+ void aboutToDeleteProperty(Property* property);
+
+protected:
+ /**Constructs a list which owns or does not own it's properties.*/
+ PropertyList(bool propertyOwner);
+
+ /**Adds property to a group.*/
+ void addToGroup(const QString &group, MultiProperty *property);
+ /**Removes property from a group.*/
+ void removeFromGroup(MultiProperty *property);
+
+private:
+ //sorted list of properties in form name: property
+ QMap<QString, MultiProperty*> m_list;
+
+ //groups of properties:
+ // list of group name: (list of property names)
+ QValueList<QPair<QString, QValueList<QString> > > m_propertiesOfGroup;
+ // map of property: group
+ QMap<MultiProperty*, QString> m_groupOfProperty;
+
+ //indicates that this list will delete properties after removeProperty()
+ //and also in destructor
+ bool m_propertyOwner;
+
+friend class MultiProperty;
+friend class PropertyBuffer;
+friend class Iterator;
+};
+
+
+/**
+@short The list of properties which does not own them.
+
+This class acts as @ref PropertyLib::PropertyList but it does not delete properties
+in destructor (i.e. it does not own properties).
+This class should be used to store results of property intersections.
+
+Example:
+/code
+PropertyList *list = new PropertyList();
+PropertyList *list2 = new PropertyList();
+PropertyList *list3 = new PropertyList();
+...
+PropertyBuffer *buf = new PropertyBuffer(list);
+buf->intersect(list2);
+buf->intersect(list3);
+...
+/endcode
+*/
+class PropertyBuffer: public PropertyList{
+ Q_OBJECT
+public:
+ /**Constructs a buffer from given property list.*/
+ PropertyBuffer(PropertyList *list);
+ /**Constructs an empty property buffer.*/
+ PropertyBuffer();
+
+ /**Intersects with other @ref PropertyLib::PropertyList.*/
+ virtual void intersect(const PropertyList *list);
+
+protected slots:
+ void intersectedValueChanged(Property *property);
+
+};
+
+}
+
+#endif
diff --git a/lib/widgets/propeditor/propertymachinefactory.cpp b/lib/widgets/propeditor/propertymachinefactory.cpp
new file mode 100644
index 00000000..222aa930
--- /dev/null
+++ b/lib/widgets/propeditor/propertymachinefactory.cpp
@@ -0,0 +1,207 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "propertymachinefactory.h"
+
+#ifndef PURE_QT
+#include <klocale.h>
+#else
+#define i18n QObject::tr
+#endif
+
+#include <qmap.h>
+
+#include "property.h"
+#include "childproperty.h"
+#include "multiproperty.h"
+#include "plineedit.h"
+#include "pspinbox.h"
+#include "pdoublenuminput.h"
+#include "pcheckbox.h"
+#include "pstringlistedit.h"
+#include "pdummywidget.h"
+#include "pcombobox.h"
+#include "psymbolcombo.h"
+#include "pfontcombo.h"
+#include "psizeedit.h"
+#include "pdateedit.h"
+#include "pdatetimeedit.h"
+#include "ppointedit.h"
+#include "prectedit.h"
+#include "psizepolicyedit.h"
+#include "pcolorbutton.h"
+#include "pyesnobutton.h"
+#include "ppixmapedit.h"
+#include "pcursoredit.h"
+#include "plinestyleedit.h"
+#include "purledit.h"
+
+
+#ifndef PURE_QT
+#include "pfontbutton.h"
+#include "pcolorcombo.h"
+#endif
+
+namespace PropertyLib{
+
+PropertyMachineFactory *PropertyMachineFactory::m_factory = 0;
+
+PropertyMachineFactory::PropertyMachineFactory()
+{
+}
+
+PropertyMachineFactory::~PropertyMachineFactory()
+{
+}
+
+Machine *PropertyMachineFactory::machineForProperty(MultiProperty *property)
+{
+ int type = property->type();
+ QString propertyName = property->name();
+ QMap<QString, QVariant> valueList = property->valueList();
+
+ if (m_registeredForType.contains(propertyName))
+ return (*m_registeredForType[propertyName])();
+
+ switch (type)
+ {
+ case Property::String:
+ return new Machine(new PLineEdit(property));
+ case Property::Integer:
+ return new Machine(new PSpinBox(property));
+ case Property::Boolean:
+ return new Machine(new PYesNoButton(property));
+ case Property::Date:
+ return new Machine(new PDateEdit(property));
+ case Property::DateTime:
+ return new Machine(new PDateTimeEdit(property));
+ case Property::StringList:
+ return new Machine(new PStringListEdit(property));
+ case Property::Color:
+ return new Machine(new PColorButton(property));
+#ifndef PURE_QT
+ case Property::Font:
+ return new Machine(new PFontButton(property));
+#endif
+ case Property::FileURL:
+ return new Machine(new PUrlEdit(PUrlEdit::File, property));
+ case Property::DirectoryURL:
+ return new Machine(new PUrlEdit(PUrlEdit::Directory, property));
+
+ case Property::Double:
+ return new Machine(new PDoubleNumInput(property));
+ case Property::Pixmap:
+ return new Machine(new PPixmapEdit(property));
+
+ case Property::ValueFromList:
+ return new Machine(new PComboBox(property, valueList));
+ case Property::Symbol:
+ return new Machine(new PSymbolCombo(property));
+ case Property::FontName:
+ return new Machine(new PFontCombo(property));
+ case Property::LineStyle:
+ return new Machine(new PLineStyleEdit(property));
+
+ case Property::Size:
+ {
+ Machine *mach = new Machine(new PSizeEdit(property));
+ property->details.append(ChildProperty(property, Property::Integer, ChildProperty::Size_Width, i18n("Width"), i18n("Width")));
+ property->details.append(ChildProperty(property, Property::Integer, ChildProperty::Size_Height, i18n("Height"), i18n("Height")));
+ return mach;
+ }
+ case Property::Point:
+ {
+ Machine *mach = new Machine(new PPointEdit(property));
+ property->details.append(ChildProperty(property, Property::Integer, ChildProperty::Point_X, i18n("x"), i18n("x")));
+ property->details.append(ChildProperty(property, Property::Integer, ChildProperty::Point_Y, i18n("y"), i18n("y")));
+ return mach;
+ }
+ case Property::Rect:
+ {
+ Machine *mach = new Machine(new PRectEdit(property));
+ property->details.append(ChildProperty(property, Property::Integer, ChildProperty::Rect_X, i18n("x"), i18n("x")));
+ property->details.append(ChildProperty(property, Property::Integer, ChildProperty::Rect_Y, i18n("y"), i18n("y")));
+ property->details.append(ChildProperty(property, Property::Integer, ChildProperty::Rect_Width, i18n("Width"), i18n("Width")));
+ property->details.append(ChildProperty(property, Property::Integer, ChildProperty::Rect_Height, i18n("Height"), i18n("Height")));
+ return mach;
+ }
+ case Property::SizePolicy:
+ {
+ QMap<QString, QVariant> spValues;
+ spValues[i18n("Fixed")] = QSizePolicy::Fixed;
+ spValues[i18n("Minimum")] = QSizePolicy::Minimum;
+ spValues[i18n("Maximum")] = QSizePolicy::Maximum;
+ spValues[i18n("Preferred")] = QSizePolicy::Preferred;
+ spValues[i18n("Expanding")] = QSizePolicy::Expanding;
+ spValues[i18n("Minimum Expanding")] = QSizePolicy::MinimumExpanding;
+ spValues[i18n("Ignored")] = QSizePolicy::Ignored;
+
+ Machine *mach = new Machine(new PSizePolicyEdit(property, spValues));
+ property->details.append(ChildProperty(property, i18n("hSizeType"), ChildProperty::SizePolicy_HorData, spValues, i18n("Horizontal Size Type")));
+ property->details.append(ChildProperty(property, i18n("vSizeType"), ChildProperty::SizePolicy_VerData, spValues, i18n("Vertical Size Type")));
+ property->details.append(ChildProperty(property, Property::Integer, ChildProperty::SizePolicy_HorStretch, i18n("hStretch"), i18n("Horizontal Stretch")));
+ property->details.append(ChildProperty(property, Property::Integer, ChildProperty::SizePolicy_VerStretch, i18n("vStretch"), i18n("Vertical Stretch")));
+ return mach;
+ }
+ case Property::Cursor:
+ {
+ QMap<QString, QVariant> spValues;
+ spValues[i18n("Arrow")] = Qt::ArrowCursor;
+ spValues[i18n("Up Arrow")] = Qt::UpArrowCursor;
+ spValues[i18n("Cross")] = Qt::CrossCursor;
+ spValues[i18n("Waiting")] = Qt::WaitCursor;
+ spValues[i18n("iBeam")] = Qt::IbeamCursor;
+ spValues[i18n("Size Vertical")] = Qt::SizeVerCursor;
+ spValues[i18n("Size Horizontal")] = Qt::SizeHorCursor;
+ spValues[i18n("Size Slash")] = Qt::SizeBDiagCursor;
+ spValues[i18n("Size Backslash")] = Qt::SizeFDiagCursor;
+ spValues[i18n("Size All")] = Qt::SizeAllCursor;
+ spValues[i18n("Blank")] = Qt::BlankCursor;
+ spValues[i18n("Split Vertical")] = Qt::SplitVCursor;
+ spValues[i18n("Split Horizontal")] = Qt::SplitHCursor;
+ spValues[i18n("Pointing Hand")] = Qt::PointingHandCursor;
+ spValues[i18n("Forbidden")] = Qt::ForbiddenCursor;
+ spValues[i18n("What's this")] = Qt::WhatsThisCursor;
+ Machine *mach = new Machine(new PCursorEdit(property, spValues));
+ return mach;
+ }
+
+ case Property::List:
+ case Property::Map:
+ default:
+ return new Machine(new PDummyWidget(property));
+ }
+}
+
+PropertyMachineFactory *PropertyMachineFactory::getInstance()
+{
+ if (m_factory == 0)
+ m_factory = new PropertyMachineFactory();
+ return m_factory;
+}
+
+bool PropertyMachineFactory::hasDetailedEditors( int type )
+{
+ if ( (type==Property::Size) || (type==Property::Point) ||
+ (type==Property::Rect) || (type==Property::SizePolicy) )
+ return true;
+ return 0;
+}
+
+}
diff --git a/lib/widgets/propeditor/propertymachinefactory.h b/lib/widgets/propeditor/propertymachinefactory.h
new file mode 100644
index 00000000..fe776b63
--- /dev/null
+++ b/lib/widgets/propeditor/propertymachinefactory.h
@@ -0,0 +1,97 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef PROPERTYMACHINEFACTORY_H
+#define PROPERTYMACHINEFACTORY_H
+
+#include <qmap.h>
+
+#include "propertywidget.h"
+
+class QWidget;
+
+namespace PropertyLib{
+
+class Property;
+class MultiProperty;
+class ChildProperty;
+
+/** @file propertymachinefactory.h
+@short Contains @ref PropertyLib::PropertyMachineFactory class and @ref PropertyLib::Machine structure.
+*/
+
+/**
+@short Machine for a property type.
+
+Contains a pointer to a property viewer,
+property editor and a list of detailed property
+editors and viewers.
+*/
+struct Machine{
+ Machine()
+ {
+ }
+ Machine(PropertyWidget *widget)
+ {
+ propertyEditor = widget;
+ }
+ ~Machine()
+ {
+ delete propertyEditor;
+ }
+
+ /**Property viewer and editor widget.*/
+ PropertyWidget *propertyEditor;
+};
+
+/**A pointer to factory function which creates and returns machine for a property.*/
+typedef Machine *(*createMachine)();
+
+/**
+@short Factory to create property editors and property viewers.
+*/
+class PropertyMachineFactory{
+public:
+ /**Registers property editor factory function for a type.
+ This factory functions are considered before defaults
+ when @ref machineForProperty is called.*/
+ void registerEditor(int type, createMachine creator);
+
+ /**Creates and returns the editor for given property type.
+ Warning: editor and viewer widgets won't have parent widget. %Property editor
+ cares about reparenting and deletion of returned widgets in machines.*/
+ Machine *machineForProperty(MultiProperty *property);
+ bool hasDetailedEditors(int type);
+
+ /**@return a pointer to a property machine factory instance.*/
+ static PropertyMachineFactory *getInstance();
+
+ static PropertyMachineFactory *m_factory;
+
+private:
+ PropertyMachineFactory();
+ virtual ~PropertyMachineFactory();
+
+ //registered machines for property types
+ QMap<QString, createMachine > m_registeredForType;
+};
+
+}
+
+#endif
diff --git a/lib/widgets/propeditor/propertywidget.cpp b/lib/widgets/propeditor/propertywidget.cpp
new file mode 100644
index 00000000..7895acb1
--- /dev/null
+++ b/lib/widgets/propeditor/propertywidget.cpp
@@ -0,0 +1,64 @@
+/***************************************************************************
+ * Copyright (C) 2002-2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "propertywidget.h"
+
+#include <qpainter.h>
+
+namespace PropertyLib{
+
+PropertyWidget::PropertyWidget(MultiProperty *property, QWidget *parent, const char *name)
+ :QWidget(parent, name), m_property(property)
+{
+}
+
+QString PropertyWidget::propertyName() const
+{
+ return m_property->name();
+}
+
+void PropertyWidget::setProperty(MultiProperty *property)
+{
+ m_property = property;
+}
+
+void PropertyWidget::drawViewer(QPainter *p, const QColorGroup &cg, const QRect &r, const QVariant &value)
+{
+ p->setPen(Qt::NoPen);
+ p->setBrush(cg.background());
+ p->drawRect(r);
+ p->drawText(r, Qt::AlignLeft | Qt::AlignVCenter | Qt::SingleLine, value.toString());
+}
+
+void PropertyWidget::setValueList(const QMap<QString, QVariant> &// valueList
+ )
+{
+ //this does nothing
+}
+
+void PropertyWidget::undo()
+{
+ m_property->undo();
+}
+
+}
+
+#ifndef PURE_QT
+#include "propertywidget.moc"
+#endif
diff --git a/lib/widgets/propeditor/propertywidget.h b/lib/widgets/propeditor/propertywidget.h
new file mode 100644
index 00000000..3383a206
--- /dev/null
+++ b/lib/widgets/propeditor/propertywidget.h
@@ -0,0 +1,88 @@
+/***************************************************************************
+ * Copyright (C) 2002-2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef PROPERTYWIDGET_H
+#define PROPERTYWIDGET_H
+
+#include <qwidget.h>
+#include <qvariant.h>
+
+/** @file propertywidget.h
+@short Contains @ref PropertyLib::PropertyWidget class.
+*/
+
+#include "multiproperty.h"
+
+namespace PropertyLib{
+
+/**
+@short An abstract base class of property viewer and editor vidget.
+
+Subclass this class to create custom property viewer and editor widget.
+
+Descendants should implement value() and setValue() methods.
+
+Hint: in case you want to implement your property editor widget using
+existing widgets like QLineEdit, QComboBox, etc. you can't use multiple
+inheritance from two QObject descendants due to Qt library restriction.
+Therefore use line edits and combo boxes as child widgets.
+
+A set of predefined widgets for predefined property types are available
+in the library.
+*/
+class PropertyWidget: public QWidget{
+ Q_OBJECT
+public:
+ /**Constructs widget for property with name "propertyName".*/
+ PropertyWidget(MultiProperty *property, QWidget *parent = 0, const char *name = 0);
+ virtual ~PropertyWidget() {}
+
+ /**@return the value currently entered in the editor widget.*/
+ virtual QVariant value() const = 0;
+ /**Sets the value shown in the editor widget. Set emitChange to false
+ if you don't want to emit propertyChanged signal.*/
+ virtual void setValue(const QVariant &value, bool emitChange=true) = 0;
+ /**@return the name of edited property.*/
+ virtual QString propertyName() const;
+ /**Sets the name of edited property.*/
+ virtual void setProperty(MultiProperty *property);
+ /**Sets the list of possible values shown in the editor widget. This method
+ does not emit propertyChanged signal.*/
+ virtual void setValueList(const QMap<QString, QVariant> &valueList);
+
+ /**Function to draw a property viewer when the editor isn't shown.*/
+ virtual void drawViewer(QPainter *p, const QColorGroup &cg, const QRect &r, const QVariant &value);
+
+ /**Reverts the property value to previous setting.*/
+ virtual void undo();
+
+signals:
+ /**Emit this signal when property value is changed. Probably you want
+ to emit it only from @ref setValue() method.
+ @ref PropertyLib::PropertyEditor widget will connect this to the appropriate slot which
+ will make updates to the @ref PropertyLib::PropertyList that hold propeties.*/
+ void propertyChanged(MultiProperty *property, const QVariant &value);
+
+protected:
+ MultiProperty *m_property;
+};
+
+}
+
+#endif
diff --git a/lib/widgets/propeditor/propertywidgetproxy.cpp b/lib/widgets/propeditor/propertywidgetproxy.cpp
new file mode 100644
index 00000000..35fdc73b
--- /dev/null
+++ b/lib/widgets/propeditor/propertywidgetproxy.cpp
@@ -0,0 +1,106 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "propertywidgetproxy.h"
+
+#include <qlayout.h>
+
+#include "propertywidget.h"
+#include "propertymachinefactory.h"
+
+namespace PropertyLib{
+
+PropertyWidgetProxy::PropertyWidgetProxy(QWidget *parent, const char *name)
+ :QWidget(parent, name), mp(0), m_propertyType(Property::Invalid), m_editor(0)
+{
+ p = new Property();
+ m_layout = new QHBoxLayout(this, 0, 0);
+}
+
+PropertyWidgetProxy::~PropertyWidgetProxy()
+{
+ delete mp;
+ delete p;
+}
+
+void PropertyWidgetProxy::setPropertyType(int propertyType)
+{
+ m_propertyType = static_cast<PropertyType>(propertyType);
+ setWidget();
+}
+
+void PropertyWidgetProxy::setPropertyType2(PropertyType propertyType)
+{
+ m_propertyType = propertyType;
+ setWidget();
+}
+
+void PropertyWidgetProxy::setWidget()
+{
+ if (m_editor)
+ delete m_editor;
+ p->setType(m_propertyType);
+ mp = new MultiProperty(p);
+ m_editor = PropertyMachineFactory::getInstance()->machineForProperty(mp)->propertyEditor;
+ if (m_editor)
+ {
+ m_editor->reparent(this, QPoint(0,0), true);
+ m_layout->addWidget(m_editor);
+ }
+}
+
+QVariant PropertyWidgetProxy::value() const
+{
+ if (m_editor)
+ return m_editor->value();
+ else
+ return QVariant();
+}
+
+void PropertyWidgetProxy::setValue(const QVariant &value)
+{
+ if (m_editor)
+ m_editor->setValue(value, false);
+}
+
+bool PropertyWidgetProxy::setProperty( const char * name, const QVariant & value )
+{
+ if( strcmp( name, "value") == 0 )
+ {
+ setPropertyType((int) value.type() );
+ setValue( value );
+ return true;
+ }
+ else
+ return QWidget::setProperty(name, value);
+}
+
+QVariant PropertyWidgetProxy::property( const char * name ) const
+{
+ if( strcmp( name, "value") == 0 )
+ return value( );
+ else
+ return QWidget::property(name);
+}
+
+}
+
+#ifndef PURE_QT
+#include "propertywidgetproxy.moc"
+#endif
diff --git a/lib/widgets/propeditor/propertywidgetproxy.h b/lib/widgets/propeditor/propertywidgetproxy.h
new file mode 100644
index 00000000..6a88b8b1
--- /dev/null
+++ b/lib/widgets/propeditor/propertywidgetproxy.h
@@ -0,0 +1,81 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef PROPERTYWIDGETPROXY_H
+#define PROPERTYWIDGETPROXY_H
+
+#include <qwidget.h>
+#include <qvariant.h>
+
+#include "multiproperty.h"
+
+class QHBoxLayout;
+
+namespace PropertyLib{
+
+class PropertyWidget;
+
+#define PropertyType Property::PropertyType
+
+/**
+Property Widget Proxy.
+It is sometimes useful to create single property editor widgets instead of having them
+all in the property editor. Proxy creates an empty widget and shows the property editor
+depending on the property type.
+*/
+class PropertyWidgetProxy: public QWidget
+{
+Q_OBJECT
+Q_PROPERTY( int propertyType READ propertyType WRITE setPropertyType DESIGNABLE true )
+Q_PROPERTY( PropertyType propertyType2 READ propertyType2 WRITE setPropertyType2 DESIGNABLE false )
+public:
+ PropertyWidgetProxy(QWidget *parent = 0, const char *name = 0);
+ ~PropertyWidgetProxy();
+
+ /**Sets the type of a property editor to appear.*/
+ void setPropertyType(int propertyType);
+ int propertyType() const { return m_propertyType; }
+ /**Sets the type of a property editor to appear.*/
+ void setPropertyType2(PropertyType propertyType);
+ PropertyType propertyType2() const { return m_propertyType; }
+
+ QVariant value() const;
+ void setValue(const QVariant &value);
+
+ /**Sets the type of an editor basing on the @p value if the name is "value".
+ Otherwise works as QWidget::setProperty.*/
+ bool setProperty( const char *name, const QVariant &value);
+ QVariant property( const char *name) const;
+
+protected:
+ virtual void setWidget();
+
+private:
+ Property *p;
+ MultiProperty *mp;
+
+ PropertyType m_propertyType;
+ PropertyWidget *m_editor;
+
+ QHBoxLayout *m_layout;
+};
+
+}
+
+#endif
diff --git a/lib/widgets/propeditor/psizeedit.cpp b/lib/widgets/propeditor/psizeedit.cpp
new file mode 100644
index 00000000..7e322ba5
--- /dev/null
+++ b/lib/widgets/propeditor/psizeedit.cpp
@@ -0,0 +1,65 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "psizeedit.h"
+
+#include <klineedit.h>
+#include <qlayout.h>
+#include <qpainter.h>
+
+namespace PropertyLib{
+
+PSizeEdit::PSizeEdit(MultiProperty *property, QWidget *parent, const char *name)
+ :PropertyWidget(property, parent, name)
+{
+ QHBoxLayout *l = new QHBoxLayout(this, 0, 0);
+ m_edit = new KLineEdit(this);
+ m_edit->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+ l->addWidget(m_edit);
+
+ m_edit->setReadOnly(true);
+}
+
+QVariant PSizeEdit::value() const
+{
+ return m_value;
+}
+
+void PSizeEdit::drawViewer(QPainter* p, const QColorGroup& cg, const QRect& r, const QVariant& value)
+{
+ p->setPen(Qt::NoPen);
+ p->setBrush(cg.background());
+ p->drawRect(r);
+ p->drawText(r, Qt::AlignLeft | Qt::AlignVCenter | Qt::SingleLine, QString("[ %1, %2 ]").arg(value.toSize().width()).arg(value.toSize().height()));
+}
+
+void PSizeEdit::setValue(const QVariant& value, bool emitChange)
+{
+ m_value = value;
+ m_edit->setText(QString("[ %1, %2 ]").arg(value.toSize().width()).arg(value.toSize().height()));
+
+ if (emitChange)
+ emit propertyChanged(m_property, value);
+}
+
+}
+
+#ifndef PURE_QT
+#include "psizeedit.moc"
+#endif
diff --git a/lib/widgets/propeditor/psizeedit.h b/lib/widgets/propeditor/psizeedit.h
new file mode 100644
index 00000000..53ea5201
--- /dev/null
+++ b/lib/widgets/propeditor/psizeedit.h
@@ -0,0 +1,51 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef PSIZEEDIT_H
+#define PSIZEEDIT_H
+
+#include "propertywidget.h"
+#include "multiproperty.h"
+
+class KLineEdit;
+class QPainter;
+
+namespace PropertyLib{
+
+/**
+@short %Property editor for QSize values.
+*/
+class PSizeEdit: public PropertyWidget
+{
+ Q_OBJECT
+public:
+ PSizeEdit(MultiProperty *property, QWidget *parent = 0, const char *name = 0);
+
+ virtual QVariant value() const;
+ virtual void drawViewer(QPainter* p, const QColorGroup& cg, const QRect& r, const QVariant& value);
+ virtual void setValue(const QVariant& value, bool emitChange);
+
+private:
+ KLineEdit *m_edit;
+ QVariant m_value;
+};
+
+}
+
+#endif
diff --git a/lib/widgets/propeditor/psizepolicyedit.cpp b/lib/widgets/propeditor/psizepolicyedit.cpp
new file mode 100644
index 00000000..d903c95a
--- /dev/null
+++ b/lib/widgets/propeditor/psizepolicyedit.cpp
@@ -0,0 +1,77 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "psizepolicyedit.h"
+
+#include <klineedit.h>
+#include <qlayout.h>
+#include <qpainter.h>
+#include <qsizepolicy.h>
+
+namespace PropertyLib{
+
+PSizePolicyEdit::PSizePolicyEdit(MultiProperty* property, const QMap<QString, QVariant> &spValues, QWidget* parent, const char* name)
+ :PropertyWidget(property, parent, name), m_spValues(spValues)
+{
+ QHBoxLayout *l = new QHBoxLayout(this, 0, 0);
+ m_edit = new KLineEdit(this);
+ m_edit->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+ l->addWidget(m_edit);
+
+ m_edit->setReadOnly(true);
+}
+
+QVariant PSizePolicyEdit::value() const
+{
+ return m_value;
+}
+
+void PSizePolicyEdit::drawViewer(QPainter* p, const QColorGroup& cg, const QRect& r, const QVariant& value)
+{
+ p->setPen(Qt::NoPen);
+ p->setBrush(cg.background());
+ p->drawRect(r);
+ p->drawText(r, Qt::AlignLeft | Qt::AlignVCenter | Qt::SingleLine, QString("%1/%2/%3/%4").arg(findValueDescription(value.toSizePolicy().horData())).arg(findValueDescription(value.toSizePolicy().verData())).arg(value.toSizePolicy().horStretch()).arg(value.toSizePolicy().verStretch()));
+}
+
+void PSizePolicyEdit::setValue(const QVariant& value, bool emitChange)
+{
+ m_value = value;
+ m_edit->setText(QString("%1/%2/%3/%4").arg(findValueDescription(value.toSizePolicy().horData())).arg(findValueDescription(value.toSizePolicy().verData())).arg(value.toSizePolicy().horStretch()).arg(value.toSizePolicy().verStretch()));
+
+ if (emitChange)
+ emit propertyChanged(m_property, value);
+}
+
+QString PSizePolicyEdit::findValueDescription(QVariant val) const
+{
+// qWarning("PSizePolicyEdit::findValueDescription : %d", val.toInt());
+ for (QMap<QString, QVariant>::const_iterator it = m_spValues.begin(); it != m_spValues.end(); ++ it)
+ {
+ if (it.data() == val)
+ return it.key();
+ }
+ return "";
+}
+
+}
+
+#ifndef PURE_QT
+#include "psizepolicyedit.moc"
+#endif
diff --git a/lib/widgets/propeditor/psizepolicyedit.h b/lib/widgets/propeditor/psizepolicyedit.h
new file mode 100644
index 00000000..42651eac
--- /dev/null
+++ b/lib/widgets/propeditor/psizepolicyedit.h
@@ -0,0 +1,54 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef PSIZEPOLICYEDIT_H
+#define PSIZEPOLICYEDIT_H
+
+#include "propertywidget.h"
+
+#include <qmap.h>
+
+class KLineEdit;
+
+namespace PropertyLib{
+
+/**
+@short %Property editor for QSizePolicy values.
+*/
+class PSizePolicyEdit : public PropertyWidget
+{
+Q_OBJECT
+public:
+ PSizePolicyEdit(MultiProperty* property, const QMap<QString, QVariant> &spValues, QWidget* parent=0, const char* name=0);
+
+ virtual QVariant value() const;
+ virtual void drawViewer(QPainter* p, const QColorGroup& cg, const QRect& r, const QVariant& value);
+ virtual void setValue(const QVariant& value, bool emitChange);
+
+ QString findValueDescription(QVariant val) const;
+
+private:
+ KLineEdit *m_edit;
+ QVariant m_value;
+ QMap<QString, QVariant> m_spValues;
+};
+
+}
+
+#endif
diff --git a/lib/widgets/propeditor/pspinbox.cpp b/lib/widgets/propeditor/pspinbox.cpp
new file mode 100644
index 00000000..2e83f66c
--- /dev/null
+++ b/lib/widgets/propeditor/pspinbox.cpp
@@ -0,0 +1,73 @@
+/***************************************************************************
+ * Copyright (C) 2002-2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "pspinbox.h"
+
+#include <limits.h>
+
+#include <qspinbox.h>
+#include <qlayout.h>
+
+namespace PropertyLib{
+
+PSpinBox::PSpinBox(MultiProperty *property, QWidget *parent, const char *name)
+ :PropertyWidget(property, parent, name)
+{
+ QHBoxLayout *l = new QHBoxLayout(this, 0, 0);
+ m_edit = new QSpinBox(INT_MIN, INT_MAX, 1, this);
+ m_edit->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+ l->addWidget(m_edit);
+
+ connect(m_edit, SIGNAL(valueChanged(int)), this, SLOT(updateProperty(int)));
+}
+
+PSpinBox::PSpinBox(MultiProperty *property, int minValue, int maxValue, int step, QWidget *parent, const char *name)
+ :PropertyWidget(property, parent, name)
+{
+ QHBoxLayout *l = new QHBoxLayout(this, 0, 0);
+ m_edit = new QSpinBox(minValue, maxValue, step, this);
+ l->addWidget(m_edit);
+
+ connect(m_edit, SIGNAL(valueChanged(int)), this, SLOT(updateProperty(int)));
+}
+
+QVariant PSpinBox::value() const
+{
+ return QVariant(m_edit->cleanText().toInt());
+}
+
+void PSpinBox::setValue(const QVariant &value, bool emitChange)
+{
+ disconnect(m_edit, SIGNAL(valueChanged(int)), this, SLOT(updateProperty(int)));
+ m_edit->setValue(value.toInt());
+ connect(m_edit, SIGNAL(valueChanged(int)), this, SLOT(updateProperty(int)));
+ if (emitChange)
+ emit propertyChanged(m_property, value);
+}
+
+void PSpinBox::updateProperty(int val)
+{
+ emit propertyChanged(m_property, QVariant(val));
+}
+
+}
+
+#ifndef PURE_QT
+#include "pspinbox.moc"
+#endif
diff --git a/lib/widgets/propeditor/pspinbox.h b/lib/widgets/propeditor/pspinbox.h
new file mode 100644
index 00000000..1ca839b8
--- /dev/null
+++ b/lib/widgets/propeditor/pspinbox.h
@@ -0,0 +1,53 @@
+/***************************************************************************
+ * Copyright (C) 2002-2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef PSPINBOX_H
+#define PSPINBOX_H
+
+#include "propertywidget.h"
+
+class QSpinBox;
+
+namespace PropertyLib{
+
+/**
+@short %Property editor with integer num input box.
+*/
+class PSpinBox: public PropertyWidget{
+ Q_OBJECT
+public:
+ PSpinBox(MultiProperty *property, QWidget *parent = 0, const char *name = 0);
+ PSpinBox(MultiProperty *property, int minValue, int maxValue, int step = 1, QWidget *parent = 0, const char *name = 0);
+
+ /**@return the value currently entered in the editor widget.*/
+ virtual QVariant value() const;
+ /**Sets the value shown in the editor widget. Set emitChange to false
+ if you don't want to emit propertyChanged signal.*/
+ virtual void setValue(const QVariant &value, bool emitChange=true);
+
+private slots:
+ void updateProperty(int val);
+
+private:
+ QSpinBox *m_edit;
+};
+
+}
+
+#endif
diff --git a/lib/widgets/propeditor/pstringlistedit.cpp b/lib/widgets/propeditor/pstringlistedit.cpp
new file mode 100644
index 00000000..227050f9
--- /dev/null
+++ b/lib/widgets/propeditor/pstringlistedit.cpp
@@ -0,0 +1,121 @@
+/***************************************************************************
+ * Copyright (C) 2003-2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "pstringlistedit.h"
+
+#include <qlayout.h>
+#include <qdialog.h>
+#include <qpainter.h>
+#include <klineedit.h>
+
+#ifndef PURE_QT
+#include <keditlistbox.h>
+#include <kpushbutton.h>
+#include <kstdguiitem.h>
+#else
+#include "qeditlistbox.h"
+#include <qpushbutton.h>
+#include "compat_tools.h"
+#endif
+
+namespace PropertyLib{
+
+PStringListEdit::PStringListEdit(MultiProperty *property, QWidget *parent, const char *name)
+ :PropertyWidget(property, parent, name)
+{
+ l = new QHBoxLayout(this);
+
+ edit = new KLineEdit(this);
+ edit->setReadOnly(true);
+ edit->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+ l->addWidget(edit);
+ pbSelect = new QPushButton("...", this);
+ pbSelect->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::MinimumExpanding);
+ l->addWidget(pbSelect);
+
+ connect(pbSelect, SIGNAL(clicked()), this, SLOT(showEditor()));
+}
+
+QVariant PStringListEdit::value() const
+{
+ return QVariant(m_list);
+}
+
+void PStringListEdit::setValue(const QVariant &value, bool emitChange)
+{
+ m_list = value.toStringList();
+ edit->setText(value.toStringList().join(", "));
+ if (emitChange)
+ emit propertyChanged(m_property, value);
+}
+
+void PStringListEdit::showEditor()
+{
+ QDialog* dia = new QDialog(this, "stringlist_dialog", true);
+ QVBoxLayout *dv = new QVBoxLayout(dia, 2);
+
+#ifdef PURE_QT
+ QEditListBox *select = new QEditListBox(dia, "select_char");
+#else
+ KEditListBox *select = new KEditListBox(dia, "select_char");
+#endif
+ dv->addWidget(select);
+
+ QHBoxLayout *dh = new QHBoxLayout(dv, 6);
+#ifndef PURE_QT
+ KPushButton *pbOk = new KPushButton(KStdGuiItem::ok(), dia);
+ KPushButton *pbCancel = new KPushButton(KStdGuiItem::cancel(), dia);
+#else
+ QPushButton *pbOk = new QPushButton(i18n("Ok"), dia);
+ QPushButton *pbCancel = new QPushButton(i18n("Cancel"), dia);
+#endif
+ QSpacerItem *si = new QSpacerItem(30, 0, QSizePolicy::Expanding, QSizePolicy::Expanding);
+
+ connect(pbOk, SIGNAL(clicked()), dia, SLOT(accept()));
+ connect(pbCancel, SIGNAL(clicked()), dia, SLOT(reject()));
+
+ dh->addItem(si);
+ dh->addWidget(pbOk);
+ dh->addWidget(pbCancel);
+
+ select->insertStringList(m_list);
+
+ if (dia->exec() == QDialog::Accepted)
+ {
+ m_list = select->items();
+ edit->setText(select->items().join(", "));
+ }
+ delete dia;
+
+ emit propertyChanged(m_property, m_list);
+}
+
+void PStringListEdit::drawViewer(QPainter *p, const QColorGroup &cg, const QRect &r, const QVariant &value)
+{
+ p->setPen(Qt::NoPen);
+ p->setBrush(cg.background());
+ p->drawRect(r);
+ p->drawText(r, Qt::AlignLeft | Qt::AlignVCenter | Qt::SingleLine, value.toStringList().join(", "));
+}
+
+}
+
+#ifndef PURE_QT
+#include "pstringlistedit.moc"
+#endif
diff --git a/lib/widgets/propeditor/pstringlistedit.h b/lib/widgets/propeditor/pstringlistedit.h
new file mode 100644
index 00000000..25d6db19
--- /dev/null
+++ b/lib/widgets/propeditor/pstringlistedit.h
@@ -0,0 +1,62 @@
+/***************************************************************************
+ * Copyright (C) 2003-2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef PSTRINGLISTEDIT_H
+#define PSTRINGLISTEDIT_H
+
+#include "propertywidget.h"
+
+
+class KLineEdit;
+class QPushButton;
+class QHBoxLayout;
+
+namespace PropertyLib{
+
+/**
+@short %Property editor with string list editor.
+*/
+class PStringListEdit: public PropertyWidget
+{
+ Q_OBJECT
+public:
+ PStringListEdit(MultiProperty *property, QWidget *parent = 0, const char *name = 0);
+
+ /**@return the value currently entered in the editor widget.*/
+ virtual QVariant value() const;
+ /**Sets the value shown in the editor widget. Set emitChange to false
+ if you don't want to emit propertyChanged signal.*/
+ virtual void setValue(const QVariant &value, bool emitChange=true);
+ /**Function to draw a property viewer when the editor isn't shown.*/
+ virtual void drawViewer(QPainter *p, const QColorGroup &cg, const QRect &r, const QVariant &value);
+
+private slots:
+ void showEditor();
+
+private:
+ QPushButton *pbSelect;
+ QHBoxLayout *l;
+ KLineEdit *edit;
+
+ QStringList m_list;
+};
+
+}
+
+#endif
diff --git a/lib/widgets/propeditor/psymbolcombo.cpp b/lib/widgets/propeditor/psymbolcombo.cpp
new file mode 100644
index 00000000..70dd7ba9
--- /dev/null
+++ b/lib/widgets/propeditor/psymbolcombo.cpp
@@ -0,0 +1,131 @@
+/***************************************************************************
+ * Copyright (C) 2002-2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include <qlayout.h>
+#include <qpainter.h>
+#include <qpushbutton.h>
+#include <klineedit.h>
+
+#ifndef PURE_QT
+#include <kcharselect.h>
+#include <klocale.h>
+#include <kpushbutton.h>
+#include <kstdguiitem.h>
+#include <qdialog.h>
+#endif
+
+#include "psymbolcombo.h"
+
+namespace PropertyLib{
+
+PSymbolCombo::PSymbolCombo(MultiProperty *property, QWidget *parent, const char *name)
+ :PropertyWidget(property, parent, name)
+{
+ l = new QHBoxLayout(this);
+ m_edit = new KLineEdit(this);
+ m_edit->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+ m_edit->setMaxLength(1);
+ l->addWidget(m_edit);
+ m_select = new QPushButton("...", this);
+ m_select->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::MinimumExpanding);
+ l->addWidget(m_select);
+
+#ifdef PURE_QT
+ m_select->hide();
+#endif
+
+ connect(m_select, SIGNAL(clicked()), this, SLOT(selectChar()));
+ connect(m_edit, SIGNAL(textChanged(const QString&)), this, SLOT(updateProperty(const QString&)));
+}
+
+QVariant PSymbolCombo::value() const
+{
+ if (!(m_edit->text().isNull()))
+ return QVariant(QString("%1").arg(m_edit->text().at(0).unicode()));
+ else
+ return QVariant(0);
+}
+
+void PSymbolCombo::setValue(const QVariant &value, bool emitChange)
+{
+#if QT_VERSION >= 0x030100
+ if (!(value.isNull()))
+#else
+ if (value.canCast(QVariant::Int))
+#endif
+ {
+ disconnect(m_edit, SIGNAL(textChanged(const QString&)), this, SLOT(updateProperty(const QString&)));
+ m_edit->setText(QChar(value.toInt()));
+ connect(m_edit, SIGNAL(textChanged(const QString&)), this, SLOT(updateProperty(const QString&)));
+ if (emitChange)
+ emit propertyChanged(m_property, value);
+ }
+}
+
+void PSymbolCombo::selectChar()
+{
+#ifndef PURE_QT
+ QDialog* dia = new QDialog(this, "select_dialog", true);
+ QVBoxLayout *dv = new QVBoxLayout(dia, 2);
+
+ KCharSelect *select = new KCharSelect(dia, "select_char");
+ dv->addWidget(select);
+
+ QHBoxLayout *dh = new QHBoxLayout(dv, 6);
+ KPushButton *pbOk = new KPushButton(KStdGuiItem::ok(), dia);
+ KPushButton *pbCancel = new KPushButton(KStdGuiItem::cancel(), dia);
+ QSpacerItem *si = new QSpacerItem(30, 0, QSizePolicy::Expanding, QSizePolicy::Expanding);
+
+ connect(pbOk, SIGNAL(clicked()), dia, SLOT(accept()));
+ connect(pbCancel, SIGNAL(clicked()), dia, SLOT(reject()));
+
+ dh->addItem(si);
+ dh->addWidget(pbOk);
+ dh->addWidget(pbCancel);
+
+ if (!(m_edit->text().isNull()))
+ select->setChar(m_edit->text().at(0));
+
+ if (dia->exec() == QDialog::Accepted)
+ {
+ m_edit->setText(select->chr());
+ }
+ delete dia;
+#endif
+}
+
+void PSymbolCombo::updateProperty(const QString& val)
+{
+ emit propertyChanged(m_property, QVariant(QString("%1").arg(val.at(0).unicode())));
+}
+
+void PSymbolCombo::drawViewer(QPainter *p, const QColorGroup &cg, const QRect &r, const QVariant &value)
+{
+ p->setBrush(cg.background());
+ p->setPen(Qt::NoPen);
+ p->drawRect(r);
+ p->drawText(r, Qt::AlignLeft | Qt::AlignVCenter | Qt::SingleLine, QChar(value.toInt()));
+}
+
+}
+
+#ifndef PURE_QT
+#include "psymbolcombo.moc"
+#endif
diff --git a/lib/widgets/propeditor/psymbolcombo.h b/lib/widgets/propeditor/psymbolcombo.h
new file mode 100644
index 00000000..fd6e57ec
--- /dev/null
+++ b/lib/widgets/propeditor/psymbolcombo.h
@@ -0,0 +1,62 @@
+/***************************************************************************
+ * Copyright (C) 2002-2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef PSYMBOLCOMBO_H
+#define PSYMBOLCOMBO_H
+
+#include "propertywidget.h"
+
+class KLineEdit;
+class QPushButton;
+class QHBoxLayout;
+
+namespace PropertyLib{
+
+
+/**
+@short %Property editor with char selector.
+*/
+class PSymbolCombo: public PropertyWidget{
+ Q_OBJECT
+public:
+ PSymbolCombo(MultiProperty *property, QWidget *parent = 0, const char *name = 0);
+
+ /**@return the value currently entered in the editor widget.*/
+ virtual QVariant value() const;
+ /**Sets the value shown in the editor widget. Set emitChange to false
+ if you don't want to emit propertyChanged signal.*/
+ virtual void setValue(const QVariant &value, bool emitChange=true);
+ /**Function to draw a property viewer when the editor isn't shown.*/
+ virtual void drawViewer(QPainter *p, const QColorGroup &cg, const QRect &r, const QVariant &value);
+
+public slots:
+ void selectChar();
+
+private slots:
+ void updateProperty(const QString &val);
+
+private:
+ KLineEdit *m_edit;
+ QPushButton *m_select;
+ QHBoxLayout *l;
+};
+
+}
+
+#endif
diff --git a/lib/widgets/propeditor/purledit.cpp b/lib/widgets/propeditor/purledit.cpp
new file mode 100644
index 00000000..9d90273a
--- /dev/null
+++ b/lib/widgets/propeditor/purledit.cpp
@@ -0,0 +1,97 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "purledit.h"
+
+#ifndef PURE_QT
+#include <kurlrequester.h>
+#else
+#include <qpushbutton.h>
+#include <qlineedit.h>
+#endif
+#include <qfiledialog.h>
+#include <qlayout.h>
+
+namespace PropertyLib{
+
+PUrlEdit::PUrlEdit(Mode mode, MultiProperty* property, QWidget* parent, const char* name)
+ :PropertyWidget(property, parent, name)
+{
+ QHBoxLayout *l = new QHBoxLayout(this, 0, 0);
+#ifndef PURE_QT
+ m_edit = new KURLRequester(this);
+ l->addWidget(m_edit);
+ m_edit->setMode((KFile::Mode)mode);
+ connect(m_edit, SIGNAL(textChanged(const QString&)), this, SLOT(updateProperty(const QString&)));
+#else
+ m_edit = new KLineEdit(this);
+ m_select = new QPushButton("...",this);
+ l->addWidget(m_edit);
+ l->addWidget(m_select);
+ m_mode = mode;
+ connect( m_select, SIGNAL(clicked()),this,SLOT(select()));
+#endif
+ m_edit->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+}
+
+QVariant PUrlEdit::value() const
+{
+#ifndef PURE_QT
+ return QVariant(m_edit->url());
+#else
+ return QVariant(m_url);
+#endif
+}
+
+void PUrlEdit::setValue(const QVariant& value, bool emitChange)
+{
+#ifndef PURE_QT
+ disconnect(m_edit, SIGNAL(textChanged(const QString&)), this, SLOT(updateProperty(const QString&)));
+ m_edit->setURL(value.toString());
+ connect(m_edit, SIGNAL(textChanged(const QString&)), this, SLOT(updateProperty(const QString&)));
+#else
+ m_edit->setText(value.toString());
+#endif
+ if (emitChange)
+ emit propertyChanged(m_property, value);
+}
+
+void PUrlEdit::updateProperty(const QString &val)
+{
+ emit propertyChanged(m_property, QVariant(val));
+}
+
+void PUrlEdit::select()
+{
+#ifdef PURE_QT
+ QString path = m_url;
+ if( m_mode == Directory )
+ m_url = QFileDialog::getExistingDirectory( m_url,this);
+ else
+ m_url = QFileDialog::getOpenFileName(m_url, QString::null, this);
+ updateProperty(m_url);
+ m_edit->setText(m_url);
+#endif
+}
+
+}
+
+#ifndef PURE_QT
+#include "purledit.moc"
+#endif
diff --git a/lib/widgets/propeditor/purledit.h b/lib/widgets/propeditor/purledit.h
new file mode 100644
index 00000000..5da0108d
--- /dev/null
+++ b/lib/widgets/propeditor/purledit.h
@@ -0,0 +1,70 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef PURLEDIT_H
+#define PURLEDIT_H
+
+#include "propertywidget.h"
+
+#ifndef PURE_QT
+#include <kfile.h>
+class KURLRequester;
+#else
+#include <klineedit.h>
+class QPushButton;
+#endif
+
+
+namespace PropertyLib{
+
+/**
+@short %Property editor with an url editor to choose the location of file or directory.
+*/
+class PUrlEdit : public PropertyWidget
+{
+Q_OBJECT
+public:
+#ifndef PURE_QT
+ enum Mode {File = KFile::File,Directory = KFile::Directory};
+#else
+ enum Mode {File,Directory};
+#endif
+
+ PUrlEdit(Mode mode, MultiProperty* property, QWidget* parent=0, const char* name=0);
+
+ virtual QVariant value() const;
+ virtual void setValue(const QVariant& value, bool emitChange);
+
+private slots:
+ void updateProperty(const QString &val);
+ void select();
+private:
+#ifndef PURE_QT
+ KURLRequester *m_edit;
+#else
+ KLineEdit *m_edit;
+ QPushButton *m_select;
+ QString m_url;
+ Mode m_mode;
+#endif
+};
+
+}
+
+#endif
diff --git a/lib/widgets/propeditor/pyesnobutton.cpp b/lib/widgets/propeditor/pyesnobutton.cpp
new file mode 100644
index 00000000..c27f4a60
--- /dev/null
+++ b/lib/widgets/propeditor/pyesnobutton.cpp
@@ -0,0 +1,76 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "pyesnobutton.h"
+
+#include <qlayout.h>
+#include <qpainter.h>
+#include <qpushbutton.h>
+
+#ifndef PURE_QT
+#include <klocale.h>
+#else
+#include "compat_tools.h"
+#endif
+
+namespace PropertyLib{
+
+PYesNoButton::PYesNoButton(MultiProperty* property, QWidget* parent, const char* name)
+ :PropertyWidget(property, parent, name)
+{
+ QHBoxLayout *l = new QHBoxLayout(this, 0, 0);
+ m_edit = new QPushButton(this);
+ m_edit->setToggleButton(true);
+ m_edit->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+ l->addWidget(m_edit);
+
+ connect(m_edit, SIGNAL(toggled(bool)), this, SLOT(updateProperty(bool)));
+}
+
+QVariant PYesNoButton::value() const
+{
+ return QVariant(m_edit->isOn());
+}
+
+void PYesNoButton::drawViewer(QPainter* p, const QColorGroup& cg, const QRect& r, const QVariant& value)
+{
+ PropertyWidget::drawViewer(p, cg, r, value.toBool() ? i18n("Yes") : i18n("No"));
+}
+
+void PYesNoButton::setValue(const QVariant& value, bool emitChange)
+{
+ disconnect(m_edit, SIGNAL(toggled(bool)), this, SLOT(updateProperty(bool)));
+ m_edit->setDown(value.toBool());
+ value.toBool() ? m_edit->setText(i18n("Yes")) : m_edit->setText(i18n("No"));
+ connect(m_edit, SIGNAL(toggled(bool)), this, SLOT(updateProperty(bool)));
+ if (emitChange)
+ emit propertyChanged(m_property, value);
+}
+
+void PYesNoButton::updateProperty(bool toggled)
+{
+ toggled ? m_edit->setText(i18n("Yes")) : m_edit->setText(i18n("No"));
+ emit propertyChanged(m_property, value());
+}
+
+}
+
+#ifndef PURE_QT
+#include "pyesnobutton.moc"
+#endif
diff --git a/lib/widgets/propeditor/pyesnobutton.h b/lib/widgets/propeditor/pyesnobutton.h
new file mode 100644
index 00000000..f0596a8f
--- /dev/null
+++ b/lib/widgets/propeditor/pyesnobutton.h
@@ -0,0 +1,51 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Alexander Dymo *
+ * cloudtemple@mskat.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef PYESNOBUTTON_H
+#define PYESNOBUTTON_H
+
+#include <propertywidget.h>
+
+class QPushButton;
+
+namespace PropertyLib{
+
+/**
+@short %Property editor with yes-no button to edit boolean values.
+*/
+class PYesNoButton : public PropertyWidget
+{
+ Q_OBJECT
+public:
+ PYesNoButton(MultiProperty* property, QWidget* parent = 0, const char* name = 0);
+
+ virtual QVariant value() const;
+ virtual void drawViewer(QPainter* p, const QColorGroup& cg, const QRect& r, const QVariant& value);
+ virtual void setValue(const QVariant& value, bool emitChange);
+
+protected slots:
+ void updateProperty(bool toggled);
+
+private:
+ QPushButton *m_edit;
+};
+
+}
+
+#endif
diff --git a/lib/widgets/propeditor/qeditlistbox.cpp b/lib/widgets/propeditor/qeditlistbox.cpp
new file mode 100644
index 00000000..e9b17d54
--- /dev/null
+++ b/lib/widgets/propeditor/qeditlistbox.cpp
@@ -0,0 +1,401 @@
+/* This file is part of the KDE libraries
+ Copyright (C) 2000 David Faure <faure@kde.org>, Alexander Neundorf <neundorf@kde.org>
+ 2000, 2002 Carsten Pfeiffer <pfeiffer@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+#include "qeditlistbox.h"
+
+#include "compat_tools.h"
+
+#include <klineedit.h>
+
+#include <qpushbutton.h>
+#include <qlayout.h>
+#include <qgroupbox.h>
+#include <qlistbox.h>
+#include <qwhatsthis.h>
+#include <qlabel.h>
+#include <qcombobox.h>
+#include <qapplication.h>
+#include <qstringlist.h>
+
+#include <assert.h>
+
+//same as kdialog.cpp ones
+#define MarginSize 11
+#define SpazingSize 6
+
+class QEditListBoxPrivate
+{
+public:
+ bool m_checkAtEntering;
+ int buttons;
+};
+
+QEditListBox::QEditListBox(QWidget *parent, const char *name,
+ bool checkAtEntering, int buttons )
+ :QGroupBox(parent, name )
+{
+ init( checkAtEntering, buttons );
+}
+
+QEditListBox::QEditListBox(const QString& title, QWidget *parent,
+ const char *name, bool checkAtEntering, int buttons)
+ :QGroupBox(title, parent, name )
+{
+ init( checkAtEntering, buttons );
+}
+
+QEditListBox::QEditListBox(const QString& title, const CustomEditor& custom,
+ QWidget *parent, const char *name,
+ bool checkAtEntering, int buttons)
+ :QGroupBox(title, parent, name )
+{
+ m_lineEdit = custom.lineEdit();
+ init( checkAtEntering, buttons, custom.representationWidget() );
+}
+
+QEditListBox::~QEditListBox()
+{
+ delete d;
+ d=0;
+}
+
+void QEditListBox::init( bool checkAtEntering, int buttons,
+ QWidget *representationWidget )
+{
+ d=new QEditListBoxPrivate;
+ d->m_checkAtEntering=checkAtEntering;
+ d->buttons = buttons;
+
+ int lostButtons = 0;
+ if ( (buttons & Add) == 0 )
+ lostButtons++;
+ if ( (buttons & Remove) == 0 )
+ lostButtons++;
+ if ( (buttons & UpDown) == 0 )
+ lostButtons += 2;
+
+
+ servNewButton = servRemoveButton = servUpButton = servDownButton = 0L;
+ setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,
+ QSizePolicy::MinimumExpanding));
+
+ QWidget * gb = this;
+ QGridLayout * grid = new QGridLayout(gb, 7 - lostButtons, 2,
+ MarginSize,
+ SpazingSize);
+ grid->addRowSpacing(0, fontMetrics().lineSpacing());
+ for ( int i = 1; i < 7 - lostButtons; i++ )
+ grid->setRowStretch(i, 1);
+
+ grid->setMargin(15);
+
+ if ( representationWidget )
+ representationWidget->reparent( gb, QPoint(0,0) );
+ else
+ m_lineEdit=new KLineEdit(gb);
+
+ m_listBox = new QListBox(gb);
+
+ QWidget *editingWidget = representationWidget ?
+ representationWidget : m_lineEdit;
+ grid->addMultiCellWidget(editingWidget,1,1,0,1);
+ grid->addMultiCellWidget(m_listBox, 2, 6 - lostButtons, 0, 0);
+ int row = 2;
+ if ( buttons & Add ) {
+ servNewButton = new QPushButton(i18n("&Add"), gb);
+ servNewButton->setEnabled(false);
+ connect(servNewButton, SIGNAL(clicked()), SLOT(addItem()));
+
+ grid->addWidget(servNewButton, row++, 1);
+ }
+
+ if ( buttons & Remove ) {
+ servRemoveButton = new QPushButton(i18n("&Remove"), gb);
+ servRemoveButton->setEnabled(false);
+ connect(servRemoveButton, SIGNAL(clicked()), SLOT(removeItem()));
+
+ grid->addWidget(servRemoveButton, row++, 1);
+ }
+
+ if ( buttons & UpDown ) {
+ servUpButton = new QPushButton(i18n("Move &Up"), gb);
+ servUpButton->setEnabled(false);
+ connect(servUpButton, SIGNAL(clicked()), SLOT(moveItemUp()));
+
+ servDownButton = new QPushButton(i18n("Move &Down"), gb);
+ servDownButton->setEnabled(false);
+ connect(servDownButton, SIGNAL(clicked()), SLOT(moveItemDown()));
+
+ grid->addWidget(servUpButton, row++, 1);
+ grid->addWidget(servDownButton, row++, 1);
+ }
+
+ connect(m_lineEdit,SIGNAL(textChanged(const QString&)),this,SLOT(typedSomething(const QString&)));
+
+ connect(m_lineEdit,SIGNAL(returnPressed()),this,SLOT(addItem()));
+ connect(m_listBox, SIGNAL(highlighted(int)), SLOT(enableMoveButtons(int)));
+
+ // maybe supplied lineedit has some text already
+ typedSomething( m_lineEdit->text() );
+}
+
+void QEditListBox::typedSomething(const QString& text)
+{
+ if(currentItem() >= 0) {
+ if(currentText() != m_lineEdit->text())
+ {
+ // IMHO changeItem() shouldn't do anything with the value
+ // of currentItem() ... like changing it or emitting signals ...
+ // but TT disagree with me on this one (it's been that way since ages ... grrr)
+ bool block = m_listBox->signalsBlocked();
+ m_listBox->blockSignals( true );
+ m_listBox->changeItem(text, currentItem());
+ m_listBox->blockSignals( block );
+ emit changed();
+ }
+ }
+
+ if ( !servNewButton )
+ return;
+
+ if (!d->m_checkAtEntering)
+ servNewButton->setEnabled(!text.isEmpty());
+ else
+ {
+ if (text.isEmpty())
+ {
+ servNewButton->setEnabled(false);
+ }
+ else
+ {
+ StringComparisonMode mode = (StringComparisonMode) (ExactMatch | CaseSensitive );
+ bool enable = (m_listBox->findItem( text, mode ) == 0L);
+ servNewButton->setEnabled( enable );
+ }
+ }
+}
+
+void QEditListBox::moveItemUp()
+{
+ if (!m_listBox->isEnabled())
+ {
+ qDebug("beep");
+ return;
+ }
+
+ unsigned int selIndex = m_listBox->currentItem();
+ if (selIndex == 0)
+ {
+ qDebug("beep");
+ return;
+ }
+
+ QListBoxItem *selItem = m_listBox->item(selIndex);
+ m_listBox->takeItem(selItem);
+ m_listBox->insertItem(selItem, selIndex-1);
+ m_listBox->setCurrentItem(selIndex - 1);
+
+ emit changed();
+}
+
+void QEditListBox::moveItemDown()
+{
+ if (!m_listBox->isEnabled())
+ {
+ qDebug("beep");
+ return;
+ }
+
+ unsigned int selIndex = m_listBox->currentItem();
+ if (selIndex == m_listBox->count() - 1)
+ {
+ qDebug("beep");
+ return;
+ }
+
+ QListBoxItem *selItem = m_listBox->item(selIndex);
+ m_listBox->takeItem(selItem);
+ m_listBox->insertItem(selItem, selIndex+1);
+ m_listBox->setCurrentItem(selIndex + 1);
+
+ emit changed();
+}
+
+void QEditListBox::addItem()
+{
+ // when m_checkAtEntering is true, the add-button is disabled, but this
+ // slot can still be called through Key_Return/Key_Enter. So we guard
+ // against this.
+ if ( !servNewButton || !servNewButton->isEnabled() )
+ return;
+
+ const QString& currentTextLE=m_lineEdit->text();
+ bool alreadyInList(false);
+ //if we didn't check for dupes at the inserting we have to do it now
+ if (!d->m_checkAtEntering)
+ {
+ // first check current item instead of dumb iterating the entire list
+ if ( m_listBox->currentText() == currentTextLE )
+ alreadyInList = true;
+ else
+ {
+ StringComparisonMode mode = (StringComparisonMode) (ExactMatch | CaseSensitive );
+ alreadyInList =(m_listBox->findItem(currentTextLE, mode) != 0);
+ }
+ }
+
+ if ( servNewButton )
+ servNewButton->setEnabled(false);
+
+ bool block = m_lineEdit->signalsBlocked();
+ m_lineEdit->blockSignals(true);
+ m_lineEdit->clear();
+ m_lineEdit->blockSignals(block);
+
+ m_listBox->setSelected(currentItem(), false);
+
+ if (!alreadyInList)
+ {
+ block = m_listBox->signalsBlocked();
+ m_listBox->blockSignals( true );
+ m_listBox->insertItem(currentTextLE);
+ m_listBox->blockSignals( block );
+ emit changed();
+ emit added( currentTextLE );
+ }
+}
+
+int QEditListBox::currentItem() const
+{
+ int nr = m_listBox->currentItem();
+ if(nr >= 0 && !m_listBox->item(nr)->isSelected()) return -1;
+ return nr;
+}
+
+void QEditListBox::removeItem()
+{
+ int selected = m_listBox->currentItem();
+
+ if ( selected >= 0 )
+ {
+ QString removedText = m_listBox->currentText();
+
+ m_listBox->removeItem( selected );
+ if ( count() > 0 )
+ m_listBox->setSelected( QMIN( selected, count() - 1 ), true );
+
+ emit changed();
+ emit removed( removedText );
+ }
+
+ if ( servRemoveButton && m_listBox->currentItem() == -1 )
+ servRemoveButton->setEnabled(false);
+}
+
+void QEditListBox::enableMoveButtons(int index)
+{
+ // Update the lineEdit when we select a different line.
+ if(currentText() != m_lineEdit->text())
+ m_lineEdit->setText(currentText());
+
+ bool moveEnabled = servUpButton && servDownButton;
+
+ if (moveEnabled )
+ {
+ if (m_listBox->count() <= 1)
+ {
+ servUpButton->setEnabled(false);
+ servDownButton->setEnabled(false);
+ }
+ else if ((uint) index == (m_listBox->count() - 1))
+ {
+ servUpButton->setEnabled(true);
+ servDownButton->setEnabled(false);
+ }
+ else if (index == 0)
+ {
+ servUpButton->setEnabled(false);
+ servDownButton->setEnabled(true);
+ }
+ else
+ {
+ servUpButton->setEnabled(true);
+ servDownButton->setEnabled(true);
+ }
+ }
+
+ if ( servRemoveButton )
+ servRemoveButton->setEnabled(true);
+}
+
+void QEditListBox::clear()
+{
+ m_lineEdit->clear();
+ m_listBox->clear();
+ emit changed();
+}
+
+void QEditListBox::insertStringList(const QStringList& list, int index)
+{
+ m_listBox->insertStringList(list,index);
+}
+
+void QEditListBox::insertStrList(const QStrList* list, int index)
+{
+ m_listBox->insertStrList(list,index);
+}
+
+void QEditListBox::insertStrList(const QStrList& list, int index)
+{
+ m_listBox->insertStrList(list,index);
+}
+
+void QEditListBox::insertStrList(const char ** list, int numStrings, int index)
+{
+ m_listBox->insertStrList(list,numStrings,index);
+}
+
+QStringList QEditListBox::items() const
+{
+ QStringList list;
+ for ( uint i = 0; i < m_listBox->count(); i++ )
+ list.append( m_listBox->text( i ));
+
+ return list;
+}
+
+void QEditListBox::setItems(const QStringList& items)
+{
+ m_listBox->clear();
+ m_listBox->insertStringList(items, 0);
+}
+
+void QEditListBox::virtual_hook( int, void* )
+{ /*BASE::virtual_hook( id, data );*/ }
+
+
+///////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////
+
+QEditListBox::CustomEditor::CustomEditor( QComboBox *combo )
+{
+ m_representationWidget = combo;
+ m_lineEdit = dynamic_cast<KLineEdit*>( combo->lineEdit() );
+ assert( m_lineEdit );
+}
diff --git a/lib/widgets/propeditor/qeditlistbox.h b/lib/widgets/propeditor/qeditlistbox.h
new file mode 100644
index 00000000..0b95a919
--- /dev/null
+++ b/lib/widgets/propeditor/qeditlistbox.h
@@ -0,0 +1,255 @@
+/* This file is part of the KDE libraries
+ Copyright (C) 2000 David Faure <faure@kde.org>, Alexander Neundorf <neundorf@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef QEDITLISTBOX_H
+#define QEDITLISTBOX_H
+
+#include <qgroupbox.h>
+#include <qlistbox.h>
+
+class KLineEdit;
+class QComboBox;
+class QPushButton;
+
+/**
+ * An editable listbox
+ *
+ * This class provides a editable listbox ;-), this means
+ * a listbox which is accompanied by a line edit to enter new
+ * items into the listbox and pushbuttons to add and remove
+ * items from the listbox and two buttons to move items up and down.
+ *
+ * \image html keditlistbox.png "KDE Edit List Box Widget"
+ *
+ */
+
+
+class QEditListBoxPrivate;
+
+class QEditListBox : public QGroupBox
+{
+ Q_OBJECT
+
+ Q_PROPERTY( QStringList items READ items WRITE setItems )
+
+public:
+ // @since 3.1
+ class CustomEditor
+ {
+ public:
+ CustomEditor()
+ : m_representationWidget( 0L ),
+ m_lineEdit( 0L ) {}
+ CustomEditor( QWidget *repWidget, KLineEdit *edit )
+ : m_representationWidget( repWidget ),
+ m_lineEdit( edit ) {}
+ CustomEditor( QComboBox *combo );
+
+ void setRepresentationWidget( QWidget *repWidget ) {
+ m_representationWidget = repWidget;
+ }
+ void setLineEdit( KLineEdit *edit ) {
+ m_lineEdit = edit;
+ }
+
+ virtual QWidget *representationWidget() const {
+ return m_representationWidget;
+ }
+ virtual KLineEdit *lineEdit() const {
+ return m_lineEdit;
+ }
+
+ protected:
+ QWidget *m_representationWidget;
+ KLineEdit *m_lineEdit;
+ };
+
+ public:
+
+ /**
+ * Enumeration of the buttons, the listbox offers. Specify them in the
+ * constructor in the buttons parameter.
+ */
+ enum Button { Add = 1, Remove = 2, UpDown = 4, All = Add|Remove|UpDown };
+
+ /**
+ * Create an editable listbox.
+ *
+ * If @p checkAtEntering is true, after every character you type
+ * in the line edit QEditListBox will enable or disable
+ * the Add-button, depending whether the current content of the
+ * line edit is already in the listbox. Maybe this can become a
+ * performance hit with large lists on slow machines.
+ * If @p checkAtEntering is false,
+ * it will be checked if you press the Add-button. It is not
+ * possible to enter items twice into the listbox.
+ */
+ QEditListBox(QWidget *parent = 0, const char *name = 0,
+ bool checkAtEntering=false, int buttons = All );
+ /**
+ * Create an editable listbox.
+ *
+ * The same as the other constructor, additionally it takes
+ * @p title, which will be the title of the frame around the listbox.
+ */
+ QEditListBox(const QString& title, QWidget *parent = 0,
+ const char *name = 0, bool checkAtEntering=false,
+ int buttons = All );
+
+ /**
+ * Another constructor, which allows to use a custom editing widget
+ * instead of the standard QLineEdit widget. E.g. you can use a
+ * KURLRequester or a QComboBox as input widget. The custom
+ * editor must consist of a lineedit and optionally another widget that
+ * is used as representation. A QComboBox or a KURLRequester have a
+ * QLineEdit as child-widget for example, so the QComboBox is used as
+ * the representation widget.
+ *
+ * @see KURLRequester::customEditor()
+ * @since 3.1
+ */
+ QEditListBox( const QString& title,
+ const CustomEditor &customEditor,
+ QWidget *parent = 0, const char *name = 0,
+ bool checkAtEntering = false, int buttons = All );
+
+ virtual ~QEditListBox();
+
+ /**
+ * Return a pointer to the embedded QListBox.
+ */
+ QListBox* listBox() const { return m_listBox; }
+ /**
+ * Return a pointer to the embedded KLineEdit.
+ */
+ KLineEdit* lineEdit() const { return m_lineEdit; }
+ /**
+ * Return a pointer to the Add button
+ */
+ QPushButton* addButton() const { return servNewButton; }
+ /**
+ * Return a pointer to the Remove button
+ */
+ QPushButton* removeButton() const { return servRemoveButton; }
+ /**
+ * Return a pointer to the Up button
+ */
+ QPushButton* upButton() const { return servUpButton; }
+ /**
+ * Return a pointer to the Down button
+ */
+ QPushButton* downButton() const { return servDownButton; }
+
+ /**
+ * See QListBox::count()
+ */
+ int count() const { return int(m_listBox->count()); }
+ /**
+ * See QListBox::insertStringList()
+ */
+ void insertStringList(const QStringList& list, int index=-1);
+ /**
+ * See QListBox::insertStringList()
+ */
+ void insertStrList(const QStrList* list, int index=-1);
+ /**
+ * See QListBox::insertStrList()
+ */
+ void insertStrList(const QStrList& list, int index=-1);
+ /**
+ * See QListBox::insertStrList()
+ */
+ void insertStrList(const char ** list, int numStrings=-1, int index=-1);
+ /**
+ * See QListBox::insertItem()
+ */
+ void insertItem(const QString& text, int index=-1) {m_listBox->insertItem(text,index);}
+ /**
+ * Clears both the listbox and the line edit.
+ */
+ void clear();
+ /**
+ * See QListBox::text()
+ */
+ QString text(int index) const { return m_listBox->text(index); }
+ /**
+ * See QListBox::currentItem()
+ */
+ int currentItem() const;
+ /**
+ * See QListBox::currentText()
+ */
+ QString currentText() const { return m_listBox->currentText(); }
+
+ /**
+ * @returns a stringlist of all items in the listbox
+ */
+ QStringList items() const;
+
+ /**
+ * Clears the listbox and sets the contents to @p items
+ *
+ * @since 3.4
+ */
+ void setItems(const QStringList& items);
+
+ signals:
+ void changed();
+
+ /**
+ * This signal is emitted when the user adds a new string to the list,
+ * the parameter is the added string.
+ * @since 3.2
+ */
+ void added( const QString & text );
+
+ /**
+ * This signal is emitted when the user removes a string from the list,
+ * the parameter is the removed string.
+ * @since 3.2
+ */
+ void removed( const QString & text );
+
+ protected slots:
+ //the names should be self-explaining
+ void moveItemUp();
+ void moveItemDown();
+ void addItem();
+ void removeItem();
+ void enableMoveButtons(int index);
+ void typedSomething(const QString& text);
+
+ private:
+ QListBox *m_listBox;
+ QPushButton *servUpButton, *servDownButton;
+ QPushButton *servNewButton, *servRemoveButton;
+ KLineEdit *m_lineEdit;
+
+ //this is called in both ctors, to avoid code duplication
+ void init( bool checkAtEntering, int buttons,
+ QWidget *representationWidget = 0L );
+
+ protected:
+ virtual void virtual_hook( int id, void* data );
+ private:
+ //our lovely private d-pointer
+ QEditListBoxPrivate *d;
+};
+
+#endif
diff --git a/lib/widgets/propeditor/qfloatinput.cpp b/lib/widgets/propeditor/qfloatinput.cpp
new file mode 100644
index 00000000..ea3b17f1
--- /dev/null
+++ b/lib/widgets/propeditor/qfloatinput.cpp
@@ -0,0 +1,51 @@
+/*
+ * qfloatinput.cpp
+ *
+ * Copyright (C) 2004 David Faure <faure@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307 USA
+ */
+#include "qfloatinput.h"
+
+#include <math.h>
+
+QFloatInput::QFloatInput( int min, int max, float step, int digits,
+ QWidget *parent, const char *name )
+ : QSpinBox( (int) (min*pow(digits,10)),
+ (int) (max*pow(digits,10)),
+ (int) (step*pow(digits,10)), parent, name ),
+ m_digits( digits )
+{
+ setValue( (int) (min*pow(digits,10)) );
+ delete validator();
+ QDoubleValidator* validator =
+ new QDoubleValidator( min, max, m_digits, this );
+ setValidator( validator );
+}
+
+QString QFloatInput::mapValueToText( int value )
+{
+ QString format = QString("%.%1f").arg( m_digits );
+ return QString().sprintf(format.latin1(),
+ (value/(float)pow(m_digits,10)) );
+}
+
+int QFloatInput::mapTextToValue( bool* ok )
+{
+ return int(cleanText().toFloat(ok)*pow(m_digits,10));
+}
+
+
diff --git a/lib/widgets/propeditor/qfloatinput.h b/lib/widgets/propeditor/qfloatinput.h
new file mode 100644
index 00000000..72977dd5
--- /dev/null
+++ b/lib/widgets/propeditor/qfloatinput.h
@@ -0,0 +1,48 @@
+/**
+ * qfloatinput.h
+ *
+ * Copyright (C) 2004 David Faure <faure@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307 USA
+ */
+#ifndef QFLOATINPUT_H
+#define QFLOATINPUT_H
+
+#include <qapplication.h>
+#include <qspinbox.h>
+#include <qvalidator.h>
+
+class QFloatInput : public QSpinBox
+{
+public:
+ QFloatInput( int min, int max, float step, int digits,
+ QWidget *parent, const char *name = 0 );
+
+ virtual QString mapValueToText( int value );
+
+ virtual int mapTextToValue( bool* ok );
+
+ int digits() const
+ {
+ return m_digits;
+ }
+
+private:
+ int m_digits;
+};
+
+
+#endif
diff --git a/lib/widgets/propeditor/test.cpp b/lib/widgets/propeditor/test.cpp
new file mode 100644
index 00000000..db49addc
--- /dev/null
+++ b/lib/widgets/propeditor/test.cpp
@@ -0,0 +1,86 @@
+/***************************************************************************
+ * Copyright (C) 2004 by SourceXtreme, Inc *
+ * oss@sourcextreme.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include <qapplication.h>
+
+#include "propertyeditor.h"
+#include "propertylist.h"
+#include "multiproperty.h"
+
+using namespace PropertyLib;
+
+int main( int argc, char **argv )
+{
+ QApplication app( argc, argv );
+
+ PropertyEditor *editor = new PropertyEditor( 0 );
+
+ PropertyList *currentList = new PropertyList();
+
+ currentList->addProperty(
+ new Property(Property::String, "Sample string",
+ "Sample description", "value" ) );
+ currentList->addProperty(
+ new Property(Property::Color, "Color",
+ "Sample color description", Qt::red ) );
+ currentList->addProperty(
+ new Property( Property::Pixmap, "Pixmap",
+ "sample pixmap description" ) );
+ currentList->addProperty(
+ new Property( Property::Rect, "Rectangle",
+ "sample rectangle", QRect( 10, 11, 30, 40 ) ) );
+ currentList->addProperty(
+ new Property( Property::Point, "Point",
+ "sample point", QPoint( 20, 30 ) ) );
+ currentList->addProperty(
+ new Property( Property::Boolean, "Boolean",
+ "sample bool", false ) );
+ currentList->addProperty(
+ new Property( Property::Integer, "Integer",
+ "sample integer", 7 ) );
+
+ currentList->addProperty(
+ new Property( Property::Double, "Double",
+ "sample double", 7.0 ) );
+
+ QStringList things;
+ things += "Thing 1";
+ things += "Thing 2";
+
+ currentList->addProperty(
+ new Property( Property::StringList, "StringList",
+ "sample stringlist", things ) );
+
+
+ currentList->addProperty(
+ new Property( Property::DirectoryURL, "Directory",
+ "sample dir", "C:/" ) );
+
+ currentList->addProperty(
+ new Property( Property::FileURL, "File",
+ "sample file", "C:/" ) );
+
+ editor->populateProperties( currentList );
+
+ app.setMainWidget( editor );
+ editor->show();
+
+ return app.exec();
+}
+
diff --git a/lib/widgets/propeditor/test.pro b/lib/widgets/propeditor/test.pro
new file mode 100755
index 00000000..c5b53846
--- /dev/null
+++ b/lib/widgets/propeditor/test.pro
@@ -0,0 +1,40 @@
+TEMPLATE = app
+CONFIG += release
+DEFINES += PURE_QT
+
+SOURCES += childproperty.cpp pcombobox.cpp \
+ pdummywidget.cpp ppointedit.cpp \
+ propertymachinefactory.cpp pstringlistedit.cpp \
+ multiproperty.cpp pcursoredit.cpp \
+ prectedit.cpp propertywidget.cpp \
+ psymbolcombo.cpp pcheckbox.cpp \
+ pdateedit.cpp pfontcombo.cpp \
+ property.cpp psizeedit.cpp \
+ pdatetimeedit.cpp \
+ plineedit.cpp propertyeditor.cpp \
+ psizepolicyedit.cpp pyesnobutton.cpp \
+ ppixmapedit.cpp \
+ propertylist.cpp pspinbox.cpp \
+ propertywidgetproxy.cpp plinestyleedit.cpp \
+ qeditlistbox.cpp pcolorbutton.cpp \
+ pdoublenuminput.cpp qfloatinput.cpp \
+ purledit.cpp test.cpp
+
+HEADERS += childproperty.h pcombobox.h \
+ pdummywidget.h ppointedit.h \
+ propertymachinefactory.h pcursoredit.h \
+ prectedit.h propertywidget.h \
+ pdateedit.h pfontcombo.h \
+ property.h psizeedit.h \
+ pdatetimeedit.h plineedit.h \
+ propertyeditor.h psizepolicyedit.h \
+ ppixmapedit.h propertylist.h \
+ pspinbox.h propertywidgetproxy.h \
+ multiproperty.h pyesnobutton.h \
+ psymbolcombo.h pstringlistedit.h \
+ pcheckbox.h plinestyleedit.h \
+ qeditlistbox.h pcolorbutton.h \
+ pdoublenuminput.h qfloatinput.h \
+ compat_tools.h purledit.h
+
+IMAGES += undo.xpm
diff --git a/lib/widgets/propeditor/undo.xpm b/lib/widgets/propeditor/undo.xpm
new file mode 100644
index 00000000..42cbaed0
--- /dev/null
+++ b/lib/widgets/propeditor/undo.xpm
@@ -0,0 +1,44 @@
+/* XPM */
+static char *undo[] = {
+/* columns rows colors chars-per-pixel */
+"16 15 23 1",
+" c #000100010001",
+". c #0170016F0162",
+"X c #02B802E802C8",
+"o c #037D026B0273",
+"O c #048802AC02C1",
+"+ c #055D031C0338",
+"@ c #08D206B006B1",
+"# c #14B10C350C95",
+"$ c #20CA134E13E8",
+"% c #216B13B71451",
+"& c #230A14A51546",
+"* c #2EDD2EF02D48",
+"= c #3F0D25332654",
+"- c #4EA039B73A18",
+"; c #542530E9329F",
+": c #4FBD4FDA4D09",
+"> c #4FDD506B4D88",
+", c #558351244ECB",
+"< c #7CAF498E4BCC",
+"1 c #7CF25FC15FA7",
+"2 c #CB51C348BD5B",
+"3 c #CF18CD55C654",
+"4 c None",
+/* pixels */
+"4444444444444444",
+"4444444444444444",
+"4444444444444444",
+"44444 444444444",
+"44444 444444444",
+"4444 ,-@@ 44444",
+"444 *321;& 44444",
+"4444 ,>X%<#44444",
+"44444 4 &= 4444",
+"44444 44 O 4444",
+"444444444 4444",
+"444444444 44444",
+"4444444444444444",
+"4444444444444444",
+"4444444444444444"
+};