First commit

This commit is contained in:
Abhijit Kundu
2014-12-01 13:41:34 -05:00
commit 2b9f84b72b
147 changed files with 35700 additions and 0 deletions

116
src/CMakeLists.txt Normal file
View File

@@ -0,0 +1,116 @@
# Tell CMake to run moc when necessary:
#set(CMAKE_AUTOMOC ON)
# As moc files are generated in the binary dir, tell CMake
# to always look for includes there:
set(CMAKE_INCLUDE_CURRENT_DIR ON)
SET(KIT_SRCS
qtbuttonpropertybrowser.cpp
qtbuttonpropertybrowser.h
qteditorfactory.cpp
qteditorfactory.h
qtgroupboxpropertybrowser.cpp
qtgroupboxpropertybrowser.h
qtpropertybrowser.cpp
qtpropertybrowser.h
qtpropertybrowserutils.cpp
qtpropertybrowserutils_p.h
qtpropertymanager.cpp
qtpropertymanager.h
qttreepropertybrowser.cpp
qttreepropertybrowser.h
qtvariantproperty.cpp
qtvariantproperty.h
)
SET(KIT_MOC_SRCS
qtpropertybrowserutils_p.h
)
SET(KIT_UI_FORMS
)
SET(KIT_resources
qtpropertybrowser.qrc
)
if(QT5_FOUND)
QT5_WRAP_UI(KIT_UI_CPP ${KIT_UI_FORMS})
QT5_WRAP_CPP(KIT_MOC_CPP ${KIT_MOC_SRCS})
QT5_ADD_RESOURCES(KIT_QRC_SRCS ${KIT_resources})
ELSE()
QT4_WRAP_UI(KIT_UI_CPP ${KIT_UI_FORMS})
QT4_WRAP_CPP(KIT_MOC_CPP ${KIT_MOC_SRCS})
QT4_ADD_RESOURCES(KIT_QRC_SRCS ${KIT_resources})
ENDIF()
SET(libname ${PROJECT_NAME})
ADD_LIBRARY(${libname} STATIC
${KIT_SRCS}
${KIT_UI_CPP}
${KIT_MOC_CPP}
${KIT_QRC_SRCS}
)
target_include_directories(${libname} PRIVATE ${QT_INCLUDE_DIRS})
target_compile_definitions(${libname} PRIVATE ${QT_COMPILE_DEFS})
set_target_properties(${libname} PROPERTIES POSITION_INDEPENDENT_CODE ON)
SET(${PROJECT_NAME}_LINK_LIBRARIES ${QT_LIBRARIES})
TARGET_LINK_LIBRARIES(
${libname}
${${PROJECT_NAME}_LINK_LIBRARIES}
)
# List of header that should go though moc
SET(KIT_HEADERS_MOC_SRCS
qtbuttonpropertybrowser.h
qteditorfactory.h
qtgroupboxpropertybrowser.h
qtpropertybrowser.h
qtpropertybrowserutils_p.h
qtpropertymanager.h
qttreepropertybrowser.h
qtvariantproperty.h
)
SET(KIT_MOC_CPP)
FOREACH(file ${KIT_HEADERS_MOC_SRCS})
get_filename_component(filename_we ${file} NAME_WE)
SET(output_file moc_${filename_we}.cpp)
IF(QT5_FOUND)
QT5_GENERATE_MOC(${file} ${output_file})
ELSE()
QT4_GENERATE_MOC(${file} ${output_file})
ENDIF()
LIST(APPEND KIT_MOC_CPP ${output_file})
ENDFOREACH()
# List of cpp files that should go though moc
SET(KIT_CPP_MOC_SRCS
qteditorfactory.cpp
qtpropertymanager.cpp
qttreepropertybrowser.cpp
)
FOREACH(file ${KIT_CPP_MOC_SRCS})
get_filename_component(filename_we ${file} NAME_WE)
SET(output_file ${filename_we}.moc)
if(QT5_FOUND)
QT5_GENERATE_MOC(${file} ${output_file})
ELSE()
QT4_GENERATE_MOC(${file} ${output_file})
ENDIF()
LIST(APPEND KIT_MOC_CPP ${output_file})
ENDFOREACH()
add_custom_target(${libname}GenerateMoc
DEPENDS ${KIT_MOC_CPP}
)
add_dependencies(${libname} ${libname}GenerateMoc)

View File

@@ -0,0 +1 @@
#include "qtpropertybrowser.h"

View File

@@ -0,0 +1 @@
#include "qtpropertybrowser.h"

View File

@@ -0,0 +1 @@
#include "qtpropertybrowser.h"

View File

@@ -0,0 +1 @@
#include "qtpropertymanager.h"

1
src/QtBrowserItem Normal file
View File

@@ -0,0 +1 @@
#include "qtpropertybrowser.h"

View File

@@ -0,0 +1 @@
#include "qtbuttonpropertybrowser.h"

1
src/QtCharEditorFactory Normal file
View File

@@ -0,0 +1 @@
#include "qteditorfactory.h"

View File

@@ -0,0 +1 @@
#include "qtpropertymanager.h"

1
src/QtCheckBoxFactory Normal file
View File

@@ -0,0 +1 @@
#include "qteditorfactory.h"

1
src/QtColorEditorFactory Normal file
View File

@@ -0,0 +1 @@
#include "qteditorfactory.h"

View File

@@ -0,0 +1 @@
#include "qtpropertymanager.h"

View File

@@ -0,0 +1 @@
#include "qteditorfactory.h"

View File

@@ -0,0 +1 @@
#include "qtpropertymanager.h"

1
src/QtDateEditFactory Normal file
View File

@@ -0,0 +1 @@
#include "qteditorfactory.h"

View File

@@ -0,0 +1 @@
#include "qtpropertymanager.h"

View File

@@ -0,0 +1 @@
#include "qteditorfactory.h"

View File

@@ -0,0 +1 @@
#include "qtpropertymanager.h"

View File

@@ -0,0 +1 @@
#include "qtpropertymanager.h"

View File

@@ -0,0 +1 @@
#include "qteditorfactory.h"

1
src/QtEnumEditorFactory Normal file
View File

@@ -0,0 +1 @@
#include "qteditorfactory.h"

View File

@@ -0,0 +1 @@
#include "qtpropertymanager.h"

View File

@@ -0,0 +1 @@
#include "qtpropertymanager.h"

1
src/QtFontEditorFactory Normal file
View File

@@ -0,0 +1 @@
#include "qteditorfactory.h"

View File

@@ -0,0 +1 @@
#include "qtpropertymanager.h"

View File

@@ -0,0 +1 @@
#include "qtgroupboxpropertybrowser.h"

View File

@@ -0,0 +1 @@
#include "qtpropertymanager.h"

1
src/QtIntPropertyManager Normal file
View File

@@ -0,0 +1 @@
#include "qtpropertymanager.h"

View File

@@ -0,0 +1 @@
#include "qteditorfactory.h"

View File

@@ -0,0 +1 @@
#include "qtpropertymanager.h"

1
src/QtLineEditFactory Normal file
View File

@@ -0,0 +1 @@
#include "qteditorfactory.h"

View File

@@ -0,0 +1 @@
#include "qtpropertymanager.h"

View File

@@ -0,0 +1 @@
#include "qtpropertymanager.h"

View File

@@ -0,0 +1 @@
#include "qtpropertymanager.h"

1
src/QtProperty Normal file
View File

@@ -0,0 +1 @@
#include "qtpropertybrowser.h"

View File

@@ -0,0 +1 @@
#include "qtpropertymanager.h"

View File

@@ -0,0 +1 @@
#include "qtpropertymanager.h"

1
src/QtScrollBarFactory Normal file
View File

@@ -0,0 +1 @@
#include "qteditorfactory.h"

View File

@@ -0,0 +1 @@
#include "qtpropertymanager.h"

View File

@@ -0,0 +1 @@
#include "qtpropertymanager.h"

View File

@@ -0,0 +1 @@
#include "qtpropertymanager.h"

1
src/QtSliderFactory Normal file
View File

@@ -0,0 +1 @@
#include "qteditorfactory.h"

1
src/QtSpinBoxFactory Normal file
View File

@@ -0,0 +1 @@
#include "qteditorfactory.h"

View File

@@ -0,0 +1 @@
#include "qtpropertymanager.h"

1
src/QtTimeEditFactory Normal file
View File

@@ -0,0 +1 @@
#include "qteditorfactory.h"

View File

@@ -0,0 +1 @@
#include "qtpropertymanager.h"

View File

@@ -0,0 +1 @@
#include "qttreepropertybrowser.h"

View File

@@ -0,0 +1 @@
#include "qtvariantproperty.h"

1
src/QtVariantProperty Normal file
View File

@@ -0,0 +1 @@
#include "qtvariantproperty.h"

View File

@@ -0,0 +1 @@
#include "qtvariantproperty.h"

BIN
src/images/cursor-arrow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 B

BIN
src/images/cursor-busy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 B

BIN
src/images/cursor-cross.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 B

BIN
src/images/cursor-hand.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 B

BIN
src/images/cursor-ibeam.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 B

BIN
src/images/cursor-sizeb.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 B

BIN
src/images/cursor-sizef.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 B

BIN
src/images/cursor-sizeh.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 B

BIN
src/images/cursor-sizev.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 B

BIN
src/images/cursor-wait.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 B

View File

@@ -0,0 +1,629 @@
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of a Qt Solutions component.
**
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
** the names of its contributors may be used to endorse or promote
** products derived from this software without specific prior written
** permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
****************************************************************************/
#include "qtbuttonpropertybrowser.h"
#include <QtCore/QSet>
#include <QtCore/QTimer>
#include <QtCore/QMap>
#include <QGridLayout>
#include <QLabel>
#include <QToolButton>
#include <QStyle>
#if QT_VERSION >= 0x040400
QT_BEGIN_NAMESPACE
#endif
class QtButtonPropertyBrowserPrivate
{
QtButtonPropertyBrowser *q_ptr;
Q_DECLARE_PUBLIC(QtButtonPropertyBrowser)
public:
void init(QWidget *parent);
void propertyInserted(QtBrowserItem *index, QtBrowserItem *afterIndex);
void propertyRemoved(QtBrowserItem *index);
void propertyChanged(QtBrowserItem *index);
QWidget *createEditor(QtProperty *property, QWidget *parent) const
{ return q_ptr->createEditor(property, parent); }
void slotEditorDestroyed();
void slotUpdate();
void slotToggled(bool checked);
struct WidgetItem
{
WidgetItem() : widget(0), label(0), widgetLabel(0),
button(0), container(0), layout(0), /*line(0), */parent(0), expanded(false) { }
QWidget *widget; // can be null
QLabel *label; // main label with property name
QLabel *widgetLabel; // label substitute showing the current value if there is no widget
QToolButton *button; // expandable button for items with children
QWidget *container; // container which is expanded when the button is clicked
QGridLayout *layout; // layout in container
WidgetItem *parent;
QList<WidgetItem *> children;
bool expanded;
};
private:
void updateLater();
void updateItem(WidgetItem *item);
void insertRow(QGridLayout *layout, int row) const;
void removeRow(QGridLayout *layout, int row) const;
int gridRow(WidgetItem *item) const;
int gridSpan(WidgetItem *item) const;
void setExpanded(WidgetItem *item, bool expanded);
QToolButton *createButton(QWidget *panret = 0) const;
QMap<QtBrowserItem *, WidgetItem *> m_indexToItem;
QMap<WidgetItem *, QtBrowserItem *> m_itemToIndex;
QMap<QWidget *, WidgetItem *> m_widgetToItem;
QMap<QObject *, WidgetItem *> m_buttonToItem;
QGridLayout *m_mainLayout;
QList<WidgetItem *> m_children;
QList<WidgetItem *> m_recreateQueue;
};
QToolButton *QtButtonPropertyBrowserPrivate::createButton(QWidget *parent) const
{
QToolButton *button = new QToolButton(parent);
button->setCheckable(true);
button->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed));
button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
button->setArrowType(Qt::DownArrow);
button->setIconSize(QSize(3, 16));
/*
QIcon icon;
icon.addPixmap(q_ptr->style()->standardPixmap(QStyle::SP_ArrowDown), QIcon::Normal, QIcon::Off);
icon.addPixmap(q_ptr->style()->standardPixmap(QStyle::SP_ArrowUp), QIcon::Normal, QIcon::On);
button->setIcon(icon);
*/
return button;
}
int QtButtonPropertyBrowserPrivate::gridRow(WidgetItem *item) const
{
QList<WidgetItem *> siblings;
if (item->parent)
siblings = item->parent->children;
else
siblings = m_children;
int row = 0;
QListIterator<WidgetItem *> it(siblings);
while (it.hasNext()) {
WidgetItem *sibling = it.next();
if (sibling == item)
return row;
row += gridSpan(sibling);
}
return -1;
}
int QtButtonPropertyBrowserPrivate::gridSpan(WidgetItem *item) const
{
if (item->container && item->expanded)
return 2;
return 1;
}
void QtButtonPropertyBrowserPrivate::init(QWidget *parent)
{
m_mainLayout = new QGridLayout();
parent->setLayout(m_mainLayout);
QLayoutItem *item = new QSpacerItem(0, 0,
QSizePolicy::Fixed, QSizePolicy::Expanding);
m_mainLayout->addItem(item, 0, 0);
}
void QtButtonPropertyBrowserPrivate::slotEditorDestroyed()
{
QWidget *editor = qobject_cast<QWidget *>(q_ptr->sender());
if (!editor)
return;
if (!m_widgetToItem.contains(editor))
return;
m_widgetToItem[editor]->widget = 0;
m_widgetToItem.remove(editor);
}
void QtButtonPropertyBrowserPrivate::slotUpdate()
{
QListIterator<WidgetItem *> itItem(m_recreateQueue);
while (itItem.hasNext()) {
WidgetItem *item = itItem.next();
WidgetItem *parent = item->parent;
QWidget *w = 0;
QGridLayout *l = 0;
const int oldRow = gridRow(item);
if (parent) {
w = parent->container;
l = parent->layout;
} else {
w = q_ptr;
l = m_mainLayout;
}
int span = 1;
if (!item->widget && !item->widgetLabel)
span = 2;
item->label = new QLabel(w);
item->label->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
l->addWidget(item->label, oldRow, 0, 1, span);
updateItem(item);
}
m_recreateQueue.clear();
}
void QtButtonPropertyBrowserPrivate::setExpanded(WidgetItem *item, bool expanded)
{
if (item->expanded == expanded)
return;
if (!item->container)
return;
item->expanded = expanded;
const int row = gridRow(item);
WidgetItem *parent = item->parent;
QGridLayout *l = 0;
if (parent)
l = parent->layout;
else
l = m_mainLayout;
if (expanded) {
insertRow(l, row + 1);
l->addWidget(item->container, row + 1, 0, 1, 2);
item->container->show();
} else {
l->removeWidget(item->container);
item->container->hide();
removeRow(l, row + 1);
}
item->button->setChecked(expanded);
item->button->setArrowType(expanded ? Qt::UpArrow : Qt::DownArrow);
}
void QtButtonPropertyBrowserPrivate::slotToggled(bool checked)
{
WidgetItem *item = m_buttonToItem.value(q_ptr->sender());
if (!item)
return;
setExpanded(item, checked);
if (checked)
emit q_ptr->expanded(m_itemToIndex.value(item));
else
emit q_ptr->collapsed(m_itemToIndex.value(item));
}
void QtButtonPropertyBrowserPrivate::updateLater()
{
QTimer::singleShot(0, q_ptr, SLOT(slotUpdate()));
}
void QtButtonPropertyBrowserPrivate::propertyInserted(QtBrowserItem *index, QtBrowserItem *afterIndex)
{
WidgetItem *afterItem = m_indexToItem.value(afterIndex);
WidgetItem *parentItem = m_indexToItem.value(index->parent());
WidgetItem *newItem = new WidgetItem();
newItem->parent = parentItem;
QGridLayout *layout = 0;
QWidget *parentWidget = 0;
int row = -1;
if (!afterItem) {
row = 0;
if (parentItem)
parentItem->children.insert(0, newItem);
else
m_children.insert(0, newItem);
} else {
row = gridRow(afterItem) + gridSpan(afterItem);
if (parentItem)
parentItem->children.insert(parentItem->children.indexOf(afterItem) + 1, newItem);
else
m_children.insert(m_children.indexOf(afterItem) + 1, newItem);
}
if (!parentItem) {
layout = m_mainLayout;
parentWidget = q_ptr;
} else {
if (!parentItem->container) {
m_recreateQueue.removeAll(parentItem);
WidgetItem *grandParent = parentItem->parent;
QWidget *w = 0;
QGridLayout *l = 0;
const int oldRow = gridRow(parentItem);
if (grandParent) {
w = grandParent->container;
l = grandParent->layout;
} else {
w = q_ptr;
l = m_mainLayout;
}
QFrame *container = new QFrame();
container->setFrameShape(QFrame::Panel);
container->setFrameShadow(QFrame::Raised);
parentItem->container = container;
parentItem->button = createButton();
m_buttonToItem[parentItem->button] = parentItem;
q_ptr->connect(parentItem->button, SIGNAL(toggled(bool)), q_ptr, SLOT(slotToggled(bool)));
parentItem->layout = new QGridLayout();
container->setLayout(parentItem->layout);
if (parentItem->label) {
l->removeWidget(parentItem->label);
delete parentItem->label;
parentItem->label = 0;
}
int span = 1;
if (!parentItem->widget && !parentItem->widgetLabel)
span = 2;
l->addWidget(parentItem->button, oldRow, 0, 1, span);
updateItem(parentItem);
}
layout = parentItem->layout;
parentWidget = parentItem->container;
}
newItem->label = new QLabel(parentWidget);
newItem->label->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
newItem->widget = createEditor(index->property(), parentWidget);
if (newItem->widget) {
QObject::connect(newItem->widget, SIGNAL(destroyed()), q_ptr, SLOT(slotEditorDestroyed()));
m_widgetToItem[newItem->widget] = newItem;
} else if (index->property()->hasValue()) {
newItem->widgetLabel = new QLabel(parentWidget);
newItem->widgetLabel->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed));
}
insertRow(layout, row);
int span = 1;
if (newItem->widget)
layout->addWidget(newItem->widget, row, 1);
else if (newItem->widgetLabel)
layout->addWidget(newItem->widgetLabel, row, 1);
else
span = 2;
layout->addWidget(newItem->label, row, 0, span, 1);
m_itemToIndex[newItem] = index;
m_indexToItem[index] = newItem;
updateItem(newItem);
}
void QtButtonPropertyBrowserPrivate::propertyRemoved(QtBrowserItem *index)
{
WidgetItem *item = m_indexToItem.value(index);
m_indexToItem.remove(index);
m_itemToIndex.remove(item);
WidgetItem *parentItem = item->parent;
const int row = gridRow(item);
if (parentItem)
parentItem->children.removeAt(parentItem->children.indexOf(item));
else
m_children.removeAt(m_children.indexOf(item));
const int colSpan = gridSpan(item);
m_buttonToItem.remove(item->button);
if (item->widget)
delete item->widget;
if (item->label)
delete item->label;
if (item->widgetLabel)
delete item->widgetLabel;
if (item->button)
delete item->button;
if (item->container)
delete item->container;
if (!parentItem) {
removeRow(m_mainLayout, row);
if (colSpan > 1)
removeRow(m_mainLayout, row);
} else if (parentItem->children.count() != 0) {
removeRow(parentItem->layout, row);
if (colSpan > 1)
removeRow(parentItem->layout, row);
} else {
const WidgetItem *grandParent = parentItem->parent;
QGridLayout *l = 0;
if (grandParent) {
l = grandParent->layout;
} else {
l = m_mainLayout;
}
const int parentRow = gridRow(parentItem);
const int parentSpan = gridSpan(parentItem);
l->removeWidget(parentItem->button);
l->removeWidget(parentItem->container);
delete parentItem->button;
delete parentItem->container;
parentItem->button = 0;
parentItem->container = 0;
parentItem->layout = 0;
if (!m_recreateQueue.contains(parentItem))
m_recreateQueue.append(parentItem);
if (parentSpan > 1)
removeRow(l, parentRow + 1);
updateLater();
}
m_recreateQueue.removeAll(item);
delete item;
}
void QtButtonPropertyBrowserPrivate::insertRow(QGridLayout *layout, int row) const
{
QMap<QLayoutItem *, QRect> itemToPos;
int idx = 0;
while (idx < layout->count()) {
int r, c, rs, cs;
layout->getItemPosition(idx, &r, &c, &rs, &cs);
if (r >= row) {
itemToPos[layout->takeAt(idx)] = QRect(r + 1, c, rs, cs);
} else {
idx++;
}
}
const QMap<QLayoutItem *, QRect>::ConstIterator icend = itemToPos.constEnd();
for(QMap<QLayoutItem *, QRect>::ConstIterator it = itemToPos.constBegin(); it != icend; ++it) {
const QRect r = it.value();
layout->addItem(it.key(), r.x(), r.y(), r.width(), r.height());
}
}
void QtButtonPropertyBrowserPrivate::removeRow(QGridLayout *layout, int row) const
{
QMap<QLayoutItem *, QRect> itemToPos;
int idx = 0;
while (idx < layout->count()) {
int r, c, rs, cs;
layout->getItemPosition(idx, &r, &c, &rs, &cs);
if (r > row) {
itemToPos[layout->takeAt(idx)] = QRect(r - 1, c, rs, cs);
} else {
idx++;
}
}
const QMap<QLayoutItem *, QRect>::ConstIterator icend = itemToPos.constEnd();
for(QMap<QLayoutItem *, QRect>::ConstIterator it = itemToPos.constBegin(); it != icend; ++it) {
const QRect r = it.value();
layout->addItem(it.key(), r.x(), r.y(), r.width(), r.height());
}
}
void QtButtonPropertyBrowserPrivate::propertyChanged(QtBrowserItem *index)
{
WidgetItem *item = m_indexToItem.value(index);
updateItem(item);
}
void QtButtonPropertyBrowserPrivate::updateItem(WidgetItem *item)
{
QtProperty *property = m_itemToIndex[item]->property();
if (item->button) {
QFont font = item->button->font();
font.setUnderline(property->isModified());
item->button->setFont(font);
item->button->setText(property->propertyName());
item->button->setToolTip(property->toolTip());
item->button->setStatusTip(property->statusTip());
item->button->setWhatsThis(property->whatsThis());
item->button->setEnabled(property->isEnabled());
}
if (item->label) {
QFont font = item->label->font();
font.setUnderline(property->isModified());
item->label->setFont(font);
item->label->setText(property->propertyName());
item->label->setToolTip(property->toolTip());
item->label->setStatusTip(property->statusTip());
item->label->setWhatsThis(property->whatsThis());
item->label->setEnabled(property->isEnabled());
}
if (item->widgetLabel) {
QFont font = item->widgetLabel->font();
font.setUnderline(false);
item->widgetLabel->setFont(font);
item->widgetLabel->setText(property->valueText());
item->widgetLabel->setToolTip(property->valueText());
item->widgetLabel->setEnabled(property->isEnabled());
}
if (item->widget) {
QFont font = item->widget->font();
font.setUnderline(false);
item->widget->setFont(font);
item->widget->setEnabled(property->isEnabled());
item->widget->setToolTip(property->valueText());
}
}
/*!
\class QtButtonPropertyBrowser
\brief The QtButtonPropertyBrowser class provides a drop down QToolButton
based property browser.
A property browser is a widget that enables the user to edit a
given set of properties. Each property is represented by a label
specifying the property's name, and an editing widget (e.g. a line
edit or a combobox) holding its value. A property can have zero or
more subproperties.
QtButtonPropertyBrowser provides drop down button for all nested
properties, i.e. subproperties are enclosed by a container associated with
the drop down button. The parent property's name is displayed as button text. For example:
\image qtbuttonpropertybrowser.png
Use the QtAbstractPropertyBrowser API to add, insert and remove
properties from an instance of the QtButtonPropertyBrowser
class. The properties themselves are created and managed by
implementations of the QtAbstractPropertyManager class.
\sa QtTreePropertyBrowser, QtAbstractPropertyBrowser
*/
/*!
\fn void QtButtonPropertyBrowser::collapsed(QtBrowserItem *item)
This signal is emitted when the \a item is collapsed.
\sa expanded(), setExpanded()
*/
/*!
\fn void QtButtonPropertyBrowser::expanded(QtBrowserItem *item)
This signal is emitted when the \a item is expanded.
\sa collapsed(), setExpanded()
*/
/*!
Creates a property browser with the given \a parent.
*/
QtButtonPropertyBrowser::QtButtonPropertyBrowser(QWidget *parent)
: QtAbstractPropertyBrowser(parent)
{
d_ptr = new QtButtonPropertyBrowserPrivate;
d_ptr->q_ptr = this;
d_ptr->init(this);
}
/*!
Destroys this property browser.
Note that the properties that were inserted into this browser are
\e not destroyed since they may still be used in other
browsers. The properties are owned by the manager that created
them.
\sa QtProperty, QtAbstractPropertyManager
*/
QtButtonPropertyBrowser::~QtButtonPropertyBrowser()
{
const QMap<QtButtonPropertyBrowserPrivate::WidgetItem *, QtBrowserItem *>::ConstIterator icend = d_ptr->m_itemToIndex.constEnd();
for (QMap<QtButtonPropertyBrowserPrivate::WidgetItem *, QtBrowserItem *>::ConstIterator it = d_ptr->m_itemToIndex.constBegin(); it != icend; ++it)
delete it.key();
delete d_ptr;
}
/*!
\reimp
*/
void QtButtonPropertyBrowser::itemInserted(QtBrowserItem *item, QtBrowserItem *afterItem)
{
d_ptr->propertyInserted(item, afterItem);
}
/*!
\reimp
*/
void QtButtonPropertyBrowser::itemRemoved(QtBrowserItem *item)
{
d_ptr->propertyRemoved(item);
}
/*!
\reimp
*/
void QtButtonPropertyBrowser::itemChanged(QtBrowserItem *item)
{
d_ptr->propertyChanged(item);
}
/*!
Sets the \a item to either collapse or expanded, depending on the value of \a expanded.
\sa isExpanded(), expanded(), collapsed()
*/
void QtButtonPropertyBrowser::setExpanded(QtBrowserItem *item, bool expanded)
{
QtButtonPropertyBrowserPrivate::WidgetItem *itm = d_ptr->m_indexToItem.value(item);
if (itm)
d_ptr->setExpanded(itm, expanded);
}
/*!
Returns true if the \a item is expanded; otherwise returns false.
\sa setExpanded()
*/
bool QtButtonPropertyBrowser::isExpanded(QtBrowserItem *item) const
{
QtButtonPropertyBrowserPrivate::WidgetItem *itm = d_ptr->m_indexToItem.value(item);
if (itm)
return itm->expanded;
return false;
}
#if QT_VERSION >= 0x040400
QT_END_NAMESPACE
#endif
#include "moc_qtbuttonpropertybrowser.cpp"

View File

@@ -0,0 +1,88 @@
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of a Qt Solutions component.
**
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
** the names of its contributors may be used to endorse or promote
** products derived from this software without specific prior written
** permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
****************************************************************************/
#ifndef QTBUTTONPROPERTYBROWSER_H
#define QTBUTTONPROPERTYBROWSER_H
#include "qtpropertybrowser.h"
#if QT_VERSION >= 0x040400
QT_BEGIN_NAMESPACE
#endif
class QtButtonPropertyBrowserPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtButtonPropertyBrowser : public QtAbstractPropertyBrowser
{
Q_OBJECT
public:
QtButtonPropertyBrowser(QWidget *parent = 0);
~QtButtonPropertyBrowser();
void setExpanded(QtBrowserItem *item, bool expanded);
bool isExpanded(QtBrowserItem *item) const;
Q_SIGNALS:
void collapsed(QtBrowserItem *item);
void expanded(QtBrowserItem *item);
protected:
virtual void itemInserted(QtBrowserItem *item, QtBrowserItem *afterItem);
virtual void itemRemoved(QtBrowserItem *item);
virtual void itemChanged(QtBrowserItem *item);
private:
QtButtonPropertyBrowserPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtButtonPropertyBrowser)
Q_DISABLE_COPY(QtButtonPropertyBrowser)
Q_PRIVATE_SLOT(d_func(), void slotUpdate())
Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed())
Q_PRIVATE_SLOT(d_func(), void slotToggled(bool))
};
#if QT_VERSION >= 0x040400
QT_END_NAMESPACE
#endif
#endif

2579
src/qteditorfactory.cpp Normal file

File diff suppressed because it is too large Load Diff

400
src/qteditorfactory.h Normal file
View File

@@ -0,0 +1,400 @@
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of a Qt Solutions component.
**
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
** the names of its contributors may be used to endorse or promote
** products derived from this software without specific prior written
** permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
****************************************************************************/
#ifndef QTEDITORFACTORY_H
#define QTEDITORFACTORY_H
#include "qtpropertymanager.h"
#if QT_VERSION >= 0x040400
QT_BEGIN_NAMESPACE
#endif
class QtSpinBoxFactoryPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtSpinBoxFactory : public QtAbstractEditorFactory<QtIntPropertyManager>
{
Q_OBJECT
public:
QtSpinBoxFactory(QObject *parent = 0);
~QtSpinBoxFactory();
protected:
void connectPropertyManager(QtIntPropertyManager *manager);
QWidget *createEditor(QtIntPropertyManager *manager, QtProperty *property,
QWidget *parent);
void disconnectPropertyManager(QtIntPropertyManager *manager);
private:
QtSpinBoxFactoryPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtSpinBoxFactory)
Q_DISABLE_COPY(QtSpinBoxFactory)
Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, int))
Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, int, int))
Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, int))
Q_PRIVATE_SLOT(d_func(), void slotSetValue(int))
Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
};
class QtSliderFactoryPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtSliderFactory : public QtAbstractEditorFactory<QtIntPropertyManager>
{
Q_OBJECT
public:
QtSliderFactory(QObject *parent = 0);
~QtSliderFactory();
protected:
void connectPropertyManager(QtIntPropertyManager *manager);
QWidget *createEditor(QtIntPropertyManager *manager, QtProperty *property,
QWidget *parent);
void disconnectPropertyManager(QtIntPropertyManager *manager);
private:
QtSliderFactoryPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtSliderFactory)
Q_DISABLE_COPY(QtSliderFactory)
Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, int))
Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, int, int))
Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, int))
Q_PRIVATE_SLOT(d_func(), void slotSetValue(int))
Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
};
class QtScrollBarFactoryPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtScrollBarFactory : public QtAbstractEditorFactory<QtIntPropertyManager>
{
Q_OBJECT
public:
QtScrollBarFactory(QObject *parent = 0);
~QtScrollBarFactory();
protected:
void connectPropertyManager(QtIntPropertyManager *manager);
QWidget *createEditor(QtIntPropertyManager *manager, QtProperty *property,
QWidget *parent);
void disconnectPropertyManager(QtIntPropertyManager *manager);
private:
QtScrollBarFactoryPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtScrollBarFactory)
Q_DISABLE_COPY(QtScrollBarFactory)
Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, int))
Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, int, int))
Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, int))
Q_PRIVATE_SLOT(d_func(), void slotSetValue(int))
Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
};
class QtCheckBoxFactoryPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtCheckBoxFactory : public QtAbstractEditorFactory<QtBoolPropertyManager>
{
Q_OBJECT
public:
QtCheckBoxFactory(QObject *parent = 0);
~QtCheckBoxFactory();
protected:
void connectPropertyManager(QtBoolPropertyManager *manager);
QWidget *createEditor(QtBoolPropertyManager *manager, QtProperty *property,
QWidget *parent);
void disconnectPropertyManager(QtBoolPropertyManager *manager);
private:
QtCheckBoxFactoryPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtCheckBoxFactory)
Q_DISABLE_COPY(QtCheckBoxFactory)
Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, bool))
Q_PRIVATE_SLOT(d_func(), void slotSetValue(bool))
Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
};
class QtDoubleSpinBoxFactoryPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtDoubleSpinBoxFactory : public QtAbstractEditorFactory<QtDoublePropertyManager>
{
Q_OBJECT
public:
QtDoubleSpinBoxFactory(QObject *parent = 0);
~QtDoubleSpinBoxFactory();
protected:
void connectPropertyManager(QtDoublePropertyManager *manager);
QWidget *createEditor(QtDoublePropertyManager *manager, QtProperty *property,
QWidget *parent);
void disconnectPropertyManager(QtDoublePropertyManager *manager);
private:
QtDoubleSpinBoxFactoryPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtDoubleSpinBoxFactory)
Q_DISABLE_COPY(QtDoubleSpinBoxFactory)
Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, double))
Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, double, double))
Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, double))
Q_PRIVATE_SLOT(d_func(), void slotDecimalsChanged(QtProperty *, int))
Q_PRIVATE_SLOT(d_func(), void slotSetValue(double))
Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
};
class QtLineEditFactoryPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtLineEditFactory : public QtAbstractEditorFactory<QtStringPropertyManager>
{
Q_OBJECT
public:
QtLineEditFactory(QObject *parent = 0);
~QtLineEditFactory();
protected:
void connectPropertyManager(QtStringPropertyManager *manager);
QWidget *createEditor(QtStringPropertyManager *manager, QtProperty *property,
QWidget *parent);
void disconnectPropertyManager(QtStringPropertyManager *manager);
private:
QtLineEditFactoryPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtLineEditFactory)
Q_DISABLE_COPY(QtLineEditFactory)
Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, const QString &))
Q_PRIVATE_SLOT(d_func(), void slotRegExpChanged(QtProperty *, const QRegExp &))
Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QString &))
Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
};
class QtDateEditFactoryPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtDateEditFactory : public QtAbstractEditorFactory<QtDatePropertyManager>
{
Q_OBJECT
public:
QtDateEditFactory(QObject *parent = 0);
~QtDateEditFactory();
protected:
void connectPropertyManager(QtDatePropertyManager *manager);
QWidget *createEditor(QtDatePropertyManager *manager, QtProperty *property,
QWidget *parent);
void disconnectPropertyManager(QtDatePropertyManager *manager);
private:
QtDateEditFactoryPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtDateEditFactory)
Q_DISABLE_COPY(QtDateEditFactory)
Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, const QDate &))
Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *,
const QDate &, const QDate &))
Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QDate &))
Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
};
class QtTimeEditFactoryPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtTimeEditFactory : public QtAbstractEditorFactory<QtTimePropertyManager>
{
Q_OBJECT
public:
QtTimeEditFactory(QObject *parent = 0);
~QtTimeEditFactory();
protected:
void connectPropertyManager(QtTimePropertyManager *manager);
QWidget *createEditor(QtTimePropertyManager *manager, QtProperty *property,
QWidget *parent);
void disconnectPropertyManager(QtTimePropertyManager *manager);
private:
QtTimeEditFactoryPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtTimeEditFactory)
Q_DISABLE_COPY(QtTimeEditFactory)
Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, const QTime &))
Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QTime &))
Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
};
class QtDateTimeEditFactoryPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtDateTimeEditFactory : public QtAbstractEditorFactory<QtDateTimePropertyManager>
{
Q_OBJECT
public:
QtDateTimeEditFactory(QObject *parent = 0);
~QtDateTimeEditFactory();
protected:
void connectPropertyManager(QtDateTimePropertyManager *manager);
QWidget *createEditor(QtDateTimePropertyManager *manager, QtProperty *property,
QWidget *parent);
void disconnectPropertyManager(QtDateTimePropertyManager *manager);
private:
QtDateTimeEditFactoryPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtDateTimeEditFactory)
Q_DISABLE_COPY(QtDateTimeEditFactory)
Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, const QDateTime &))
Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QDateTime &))
Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
};
class QtKeySequenceEditorFactoryPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtKeySequenceEditorFactory : public QtAbstractEditorFactory<QtKeySequencePropertyManager>
{
Q_OBJECT
public:
QtKeySequenceEditorFactory(QObject *parent = 0);
~QtKeySequenceEditorFactory();
protected:
void connectPropertyManager(QtKeySequencePropertyManager *manager);
QWidget *createEditor(QtKeySequencePropertyManager *manager, QtProperty *property,
QWidget *parent);
void disconnectPropertyManager(QtKeySequencePropertyManager *manager);
private:
QtKeySequenceEditorFactoryPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtKeySequenceEditorFactory)
Q_DISABLE_COPY(QtKeySequenceEditorFactory)
Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, const QKeySequence &))
Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QKeySequence &))
Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
};
class QtCharEditorFactoryPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtCharEditorFactory : public QtAbstractEditorFactory<QtCharPropertyManager>
{
Q_OBJECT
public:
QtCharEditorFactory(QObject *parent = 0);
~QtCharEditorFactory();
protected:
void connectPropertyManager(QtCharPropertyManager *manager);
QWidget *createEditor(QtCharPropertyManager *manager, QtProperty *property,
QWidget *parent);
void disconnectPropertyManager(QtCharPropertyManager *manager);
private:
QtCharEditorFactoryPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtCharEditorFactory)
Q_DISABLE_COPY(QtCharEditorFactory)
Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, const QChar &))
Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QChar &))
Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
};
class QtEnumEditorFactoryPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtEnumEditorFactory : public QtAbstractEditorFactory<QtEnumPropertyManager>
{
Q_OBJECT
public:
QtEnumEditorFactory(QObject *parent = 0);
~QtEnumEditorFactory();
protected:
void connectPropertyManager(QtEnumPropertyManager *manager);
QWidget *createEditor(QtEnumPropertyManager *manager, QtProperty *property,
QWidget *parent);
void disconnectPropertyManager(QtEnumPropertyManager *manager);
private:
QtEnumEditorFactoryPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtEnumEditorFactory)
Q_DISABLE_COPY(QtEnumEditorFactory)
Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, int))
Q_PRIVATE_SLOT(d_func(), void slotEnumNamesChanged(QtProperty *,
const QStringList &))
Q_PRIVATE_SLOT(d_func(), void slotEnumIconsChanged(QtProperty *,
const QMap<int, QIcon> &))
Q_PRIVATE_SLOT(d_func(), void slotSetValue(int))
Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
};
class QtCursorEditorFactoryPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtCursorEditorFactory : public QtAbstractEditorFactory<QtCursorPropertyManager>
{
Q_OBJECT
public:
QtCursorEditorFactory(QObject *parent = 0);
~QtCursorEditorFactory();
protected:
void connectPropertyManager(QtCursorPropertyManager *manager);
QWidget *createEditor(QtCursorPropertyManager *manager, QtProperty *property,
QWidget *parent);
void disconnectPropertyManager(QtCursorPropertyManager *manager);
private:
QtCursorEditorFactoryPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtCursorEditorFactory)
Q_DISABLE_COPY(QtCursorEditorFactory)
Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, const QCursor &))
Q_PRIVATE_SLOT(d_func(), void slotEnumChanged(QtProperty *, int))
Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
};
class QtColorEditorFactoryPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtColorEditorFactory : public QtAbstractEditorFactory<QtColorPropertyManager>
{
Q_OBJECT
public:
QtColorEditorFactory(QObject *parent = 0);
~QtColorEditorFactory();
protected:
void connectPropertyManager(QtColorPropertyManager *manager);
QWidget *createEditor(QtColorPropertyManager *manager, QtProperty *property,
QWidget *parent);
void disconnectPropertyManager(QtColorPropertyManager *manager);
private:
QtColorEditorFactoryPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtColorEditorFactory)
Q_DISABLE_COPY(QtColorEditorFactory)
Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, const QColor &))
Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QColor &))
};
class QtFontEditorFactoryPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtFontEditorFactory : public QtAbstractEditorFactory<QtFontPropertyManager>
{
Q_OBJECT
public:
QtFontEditorFactory(QObject *parent = 0);
~QtFontEditorFactory();
protected:
void connectPropertyManager(QtFontPropertyManager *manager);
QWidget *createEditor(QtFontPropertyManager *manager, QtProperty *property,
QWidget *parent);
void disconnectPropertyManager(QtFontPropertyManager *manager);
private:
QtFontEditorFactoryPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtFontEditorFactory)
Q_DISABLE_COPY(QtFontEditorFactory)
Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, const QFont &))
Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QFont &))
};
#if QT_VERSION >= 0x040400
QT_END_NAMESPACE
#endif
#endif

View File

@@ -0,0 +1,536 @@
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of a Qt Solutions component.
**
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
** the names of its contributors may be used to endorse or promote
** products derived from this software without specific prior written
** permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
****************************************************************************/
#include "qtgroupboxpropertybrowser.h"
#include <QtCore/QSet>
#include <QGridLayout>
#include <QLabel>
#include <QGroupBox>
#include <QtCore/QTimer>
#include <QtCore/QMap>
#if QT_VERSION >= 0x040400
QT_BEGIN_NAMESPACE
#endif
class QtGroupBoxPropertyBrowserPrivate
{
QtGroupBoxPropertyBrowser *q_ptr;
Q_DECLARE_PUBLIC(QtGroupBoxPropertyBrowser)
public:
void init(QWidget *parent);
void propertyInserted(QtBrowserItem *index, QtBrowserItem *afterIndex);
void propertyRemoved(QtBrowserItem *index);
void propertyChanged(QtBrowserItem *index);
QWidget *createEditor(QtProperty *property, QWidget *parent) const
{ return q_ptr->createEditor(property, parent); }
void slotEditorDestroyed();
void slotUpdate();
struct WidgetItem
{
WidgetItem() : widget(0), label(0), widgetLabel(0),
groupBox(0), layout(0), line(0), parent(0) { }
QWidget *widget; // can be null
QLabel *label;
QLabel *widgetLabel;
QGroupBox *groupBox;
QGridLayout *layout;
QFrame *line;
WidgetItem *parent;
QList<WidgetItem *> children;
};
private:
void updateLater();
void updateItem(WidgetItem *item);
void insertRow(QGridLayout *layout, int row) const;
void removeRow(QGridLayout *layout, int row) const;
bool hasHeader(WidgetItem *item) const;
QMap<QtBrowserItem *, WidgetItem *> m_indexToItem;
QMap<WidgetItem *, QtBrowserItem *> m_itemToIndex;
QMap<QWidget *, WidgetItem *> m_widgetToItem;
QGridLayout *m_mainLayout;
QList<WidgetItem *> m_children;
QList<WidgetItem *> m_recreateQueue;
};
void QtGroupBoxPropertyBrowserPrivate::init(QWidget *parent)
{
m_mainLayout = new QGridLayout();
parent->setLayout(m_mainLayout);
QLayoutItem *item = new QSpacerItem(0, 0,
QSizePolicy::Fixed, QSizePolicy::Expanding);
m_mainLayout->addItem(item, 0, 0);
}
void QtGroupBoxPropertyBrowserPrivate::slotEditorDestroyed()
{
QWidget *editor = qobject_cast<QWidget *>(q_ptr->sender());
if (!editor)
return;
if (!m_widgetToItem.contains(editor))
return;
m_widgetToItem[editor]->widget = 0;
m_widgetToItem.remove(editor);
}
void QtGroupBoxPropertyBrowserPrivate::slotUpdate()
{
QListIterator<WidgetItem *> itItem(m_recreateQueue);
while (itItem.hasNext()) {
WidgetItem *item = itItem.next();
WidgetItem *par = item->parent;
QWidget *w = 0;
QGridLayout *l = 0;
int oldRow = -1;
if (!par) {
w = q_ptr;
l = m_mainLayout;
oldRow = m_children.indexOf(item);
} else {
w = par->groupBox;
l = par->layout;
oldRow = par->children.indexOf(item);
if (hasHeader(par))
oldRow += 2;
}
if (item->widget) {
item->widget->setParent(w);
} else if (item->widgetLabel) {
item->widgetLabel->setParent(w);
} else {
item->widgetLabel = new QLabel(w);
item->widgetLabel->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed));
item->widgetLabel->setTextFormat(Qt::PlainText);
}
int span = 1;
if (item->widget)
l->addWidget(item->widget, oldRow, 1, 1, 1);
else if (item->widgetLabel)
l->addWidget(item->widgetLabel, oldRow, 1, 1, 1);
else
span = 2;
item->label = new QLabel(w);
item->label->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
l->addWidget(item->label, oldRow, 0, 1, span);
updateItem(item);
}
m_recreateQueue.clear();
}
void QtGroupBoxPropertyBrowserPrivate::updateLater()
{
QTimer::singleShot(0, q_ptr, SLOT(slotUpdate()));
}
void QtGroupBoxPropertyBrowserPrivate::propertyInserted(QtBrowserItem *index, QtBrowserItem *afterIndex)
{
WidgetItem *afterItem = m_indexToItem.value(afterIndex);
WidgetItem *parentItem = m_indexToItem.value(index->parent());
WidgetItem *newItem = new WidgetItem();
newItem->parent = parentItem;
QGridLayout *layout = 0;
QWidget *parentWidget = 0;
int row = -1;
if (!afterItem) {
row = 0;
if (parentItem)
parentItem->children.insert(0, newItem);
else
m_children.insert(0, newItem);
} else {
if (parentItem) {
row = parentItem->children.indexOf(afterItem) + 1;
parentItem->children.insert(row, newItem);
} else {
row = m_children.indexOf(afterItem) + 1;
m_children.insert(row, newItem);
}
}
if (parentItem && hasHeader(parentItem))
row += 2;
if (!parentItem) {
layout = m_mainLayout;
parentWidget = q_ptr;;
} else {
if (!parentItem->groupBox) {
m_recreateQueue.removeAll(parentItem);
WidgetItem *par = parentItem->parent;
QWidget *w = 0;
QGridLayout *l = 0;
int oldRow = -1;
if (!par) {
w = q_ptr;
l = m_mainLayout;
oldRow = m_children.indexOf(parentItem);
} else {
w = par->groupBox;
l = par->layout;
oldRow = par->children.indexOf(parentItem);
if (hasHeader(par))
oldRow += 2;
}
parentItem->groupBox = new QGroupBox(w);
parentItem->layout = new QGridLayout();
parentItem->groupBox->setLayout(parentItem->layout);
if (parentItem->label) {
l->removeWidget(parentItem->label);
delete parentItem->label;
parentItem->label = 0;
}
if (parentItem->widget) {
l->removeWidget(parentItem->widget);
parentItem->widget->setParent(parentItem->groupBox);
parentItem->layout->addWidget(parentItem->widget, 0, 0, 1, 2);
parentItem->line = new QFrame(parentItem->groupBox);
} else if (parentItem->widgetLabel) {
l->removeWidget(parentItem->widgetLabel);
delete parentItem->widgetLabel;
parentItem->widgetLabel = 0;
}
if (parentItem->line) {
parentItem->line->setFrameShape(QFrame::HLine);
parentItem->line->setFrameShadow(QFrame::Sunken);
parentItem->layout->addWidget(parentItem->line, 1, 0, 1, 2);
}
l->addWidget(parentItem->groupBox, oldRow, 0, 1, 2);
updateItem(parentItem);
}
layout = parentItem->layout;
parentWidget = parentItem->groupBox;
}
newItem->label = new QLabel(parentWidget);
newItem->label->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
newItem->widget = createEditor(index->property(), parentWidget);
if (!newItem->widget) {
newItem->widgetLabel = new QLabel(parentWidget);
newItem->widgetLabel->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed));
newItem->widgetLabel->setTextFormat(Qt::PlainText);
} else {
QObject::connect(newItem->widget, SIGNAL(destroyed()), q_ptr, SLOT(slotEditorDestroyed()));
m_widgetToItem[newItem->widget] = newItem;
}
insertRow(layout, row);
int span = 1;
if (newItem->widget)
layout->addWidget(newItem->widget, row, 1);
else if (newItem->widgetLabel)
layout->addWidget(newItem->widgetLabel, row, 1);
else
span = 2;
layout->addWidget(newItem->label, row, 0, 1, span);
m_itemToIndex[newItem] = index;
m_indexToItem[index] = newItem;
updateItem(newItem);
}
void QtGroupBoxPropertyBrowserPrivate::propertyRemoved(QtBrowserItem *index)
{
WidgetItem *item = m_indexToItem.value(index);
m_indexToItem.remove(index);
m_itemToIndex.remove(item);
WidgetItem *parentItem = item->parent;
int row = -1;
if (parentItem) {
row = parentItem->children.indexOf(item);
parentItem->children.removeAt(row);
if (hasHeader(parentItem))
row += 2;
} else {
row = m_children.indexOf(item);
m_children.removeAt(row);
}
if (item->widget)
delete item->widget;
if (item->label)
delete item->label;
if (item->widgetLabel)
delete item->widgetLabel;
if (item->groupBox)
delete item->groupBox;
if (!parentItem) {
removeRow(m_mainLayout, row);
} else if (parentItem->children.count() != 0) {
removeRow(parentItem->layout, row);
} else {
WidgetItem *par = parentItem->parent;
QWidget *w = 0;
QGridLayout *l = 0;
int oldRow = -1;
if (!par) {
w = q_ptr;
l = m_mainLayout;
oldRow = m_children.indexOf(parentItem);
} else {
w = par->groupBox;
l = par->layout;
oldRow = par->children.indexOf(parentItem);
if (hasHeader(par))
oldRow += 2;
}
if (parentItem->widget) {
parentItem->widget->hide();
parentItem->widget->setParent(0);
} else if (parentItem->widgetLabel) {
parentItem->widgetLabel->hide();
parentItem->widgetLabel->setParent(0);
} else {
//parentItem->widgetLabel = new QLabel(w);
}
l->removeWidget(parentItem->groupBox);
delete parentItem->groupBox;
parentItem->groupBox = 0;
parentItem->line = 0;
parentItem->layout = 0;
if (!m_recreateQueue.contains(parentItem))
m_recreateQueue.append(parentItem);
updateLater();
}
m_recreateQueue.removeAll(item);
delete item;
}
void QtGroupBoxPropertyBrowserPrivate::insertRow(QGridLayout *layout, int row) const
{
QMap<QLayoutItem *, QRect> itemToPos;
int idx = 0;
while (idx < layout->count()) {
int r, c, rs, cs;
layout->getItemPosition(idx, &r, &c, &rs, &cs);
if (r >= row) {
itemToPos[layout->takeAt(idx)] = QRect(r + 1, c, rs, cs);
} else {
idx++;
}
}
const QMap<QLayoutItem *, QRect>::ConstIterator icend = itemToPos.constEnd();
for (QMap<QLayoutItem *, QRect>::ConstIterator it = itemToPos.constBegin(); it != icend; ++it) {
const QRect r = it.value();
layout->addItem(it.key(), r.x(), r.y(), r.width(), r.height());
}
}
void QtGroupBoxPropertyBrowserPrivate::removeRow(QGridLayout *layout, int row) const
{
QMap<QLayoutItem *, QRect> itemToPos;
int idx = 0;
while (idx < layout->count()) {
int r, c, rs, cs;
layout->getItemPosition(idx, &r, &c, &rs, &cs);
if (r > row) {
itemToPos[layout->takeAt(idx)] = QRect(r - 1, c, rs, cs);
} else {
idx++;
}
}
const QMap<QLayoutItem *, QRect>::ConstIterator icend = itemToPos.constEnd();
for (QMap<QLayoutItem *, QRect>::ConstIterator it = itemToPos.constBegin(); it != icend; ++it) {
const QRect r = it.value();
layout->addItem(it.key(), r.x(), r.y(), r.width(), r.height());
}
}
bool QtGroupBoxPropertyBrowserPrivate::hasHeader(WidgetItem *item) const
{
if (item->widget)
return true;
return false;
}
void QtGroupBoxPropertyBrowserPrivate::propertyChanged(QtBrowserItem *index)
{
WidgetItem *item = m_indexToItem.value(index);
updateItem(item);
}
void QtGroupBoxPropertyBrowserPrivate::updateItem(WidgetItem *item)
{
QtProperty *property = m_itemToIndex[item]->property();
if (item->groupBox) {
QFont font = item->groupBox->font();
font.setUnderline(property->isModified());
item->groupBox->setFont(font);
item->groupBox->setTitle(property->propertyName());
item->groupBox->setToolTip(property->toolTip());
item->groupBox->setStatusTip(property->statusTip());
item->groupBox->setWhatsThis(property->whatsThis());
item->groupBox->setEnabled(property->isEnabled());
}
if (item->label) {
QFont font = item->label->font();
font.setUnderline(property->isModified());
item->label->setFont(font);
item->label->setText(property->propertyName());
item->label->setToolTip(property->toolTip());
item->label->setStatusTip(property->statusTip());
item->label->setWhatsThis(property->whatsThis());
item->label->setEnabled(property->isEnabled());
}
if (item->widgetLabel) {
QFont font = item->widgetLabel->font();
font.setUnderline(false);
item->widgetLabel->setFont(font);
item->widgetLabel->setText(property->valueText());
item->widgetLabel->setToolTip(property->valueText());
item->widgetLabel->setEnabled(property->isEnabled());
}
if (item->widget) {
QFont font = item->widget->font();
font.setUnderline(false);
item->widget->setFont(font);
item->widget->setEnabled(property->isEnabled());
item->widget->setToolTip(property->valueText());
}
//item->setIcon(1, property->valueIcon());
}
/*!
\class QtGroupBoxPropertyBrowser
\brief The QtGroupBoxPropertyBrowser class provides a QGroupBox
based property browser.
A property browser is a widget that enables the user to edit a
given set of properties. Each property is represented by a label
specifying the property's name, and an editing widget (e.g. a line
edit or a combobox) holding its value. A property can have zero or
more subproperties.
QtGroupBoxPropertyBrowser provides group boxes for all nested
properties, i.e. subproperties are enclosed by a group box with
the parent property's name as its title. For example:
\image qtgroupboxpropertybrowser.png
Use the QtAbstractPropertyBrowser API to add, insert and remove
properties from an instance of the QtGroupBoxPropertyBrowser
class. The properties themselves are created and managed by
implementations of the QtAbstractPropertyManager class.
\sa QtTreePropertyBrowser, QtAbstractPropertyBrowser
*/
/*!
Creates a property browser with the given \a parent.
*/
QtGroupBoxPropertyBrowser::QtGroupBoxPropertyBrowser(QWidget *parent)
: QtAbstractPropertyBrowser(parent)
{
d_ptr = new QtGroupBoxPropertyBrowserPrivate;
d_ptr->q_ptr = this;
d_ptr->init(this);
}
/*!
Destroys this property browser.
Note that the properties that were inserted into this browser are
\e not destroyed since they may still be used in other
browsers. The properties are owned by the manager that created
them.
\sa QtProperty, QtAbstractPropertyManager
*/
QtGroupBoxPropertyBrowser::~QtGroupBoxPropertyBrowser()
{
const QMap<QtGroupBoxPropertyBrowserPrivate::WidgetItem *, QtBrowserItem *>::ConstIterator icend = d_ptr->m_itemToIndex.constEnd();
for (QMap<QtGroupBoxPropertyBrowserPrivate::WidgetItem *, QtBrowserItem *>::ConstIterator it = d_ptr->m_itemToIndex.constBegin(); it != icend; ++it)
delete it.key();
delete d_ptr;
}
/*!
\reimp
*/
void QtGroupBoxPropertyBrowser::itemInserted(QtBrowserItem *item, QtBrowserItem *afterItem)
{
d_ptr->propertyInserted(item, afterItem);
}
/*!
\reimp
*/
void QtGroupBoxPropertyBrowser::itemRemoved(QtBrowserItem *item)
{
d_ptr->propertyRemoved(item);
}
/*!
\reimp
*/
void QtGroupBoxPropertyBrowser::itemChanged(QtBrowserItem *item)
{
d_ptr->propertyChanged(item);
}
#if QT_VERSION >= 0x040400
QT_END_NAMESPACE
#endif
#include "moc_qtgroupboxpropertybrowser.cpp"

View File

@@ -0,0 +1,79 @@
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of a Qt Solutions component.
**
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
** the names of its contributors may be used to endorse or promote
** products derived from this software without specific prior written
** permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
****************************************************************************/
#ifndef QTGROUPBOXPROPERTYBROWSER_H
#define QTGROUPBOXPROPERTYBROWSER_H
#include "qtpropertybrowser.h"
#if QT_VERSION >= 0x040400
QT_BEGIN_NAMESPACE
#endif
class QtGroupBoxPropertyBrowserPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtGroupBoxPropertyBrowser : public QtAbstractPropertyBrowser
{
Q_OBJECT
public:
QtGroupBoxPropertyBrowser(QWidget *parent = 0);
~QtGroupBoxPropertyBrowser();
protected:
virtual void itemInserted(QtBrowserItem *item, QtBrowserItem *afterItem);
virtual void itemRemoved(QtBrowserItem *item);
virtual void itemChanged(QtBrowserItem *item);
private:
QtGroupBoxPropertyBrowserPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtGroupBoxPropertyBrowser)
Q_DISABLE_COPY(QtGroupBoxPropertyBrowser)
Q_PRIVATE_SLOT(d_func(), void slotUpdate())
Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed())
};
#if QT_VERSION >= 0x040400
QT_END_NAMESPACE
#endif
#endif

2048
src/qtpropertybrowser.cpp Normal file

File diff suppressed because it is too large Load Diff

335
src/qtpropertybrowser.h Normal file
View File

@@ -0,0 +1,335 @@
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of a Qt Solutions component.
**
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
** the names of its contributors may be used to endorse or promote
** products derived from this software without specific prior written
** permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
****************************************************************************/
#ifndef QTPROPERTYBROWSER_H
#define QTPROPERTYBROWSER_H
#include <QWidget>
#include <QtCore/QSet>
#if QT_VERSION >= 0x040400
QT_BEGIN_NAMESPACE
#endif
#if defined(Q_WS_WIN)
# if !defined(QT_QTPROPERTYBROWSER_EXPORT) && !defined(QT_QTPROPERTYBROWSER_IMPORT)
# define QT_QTPROPERTYBROWSER_EXPORT
# elif defined(QT_QTPROPERTYBROWSER_IMPORT)
# if defined(QT_QTPROPERTYBROWSER_EXPORT)
# undef QT_QTPROPERTYBROWSER_EXPORT
# endif
# define QT_QTPROPERTYBROWSER_EXPORT __declspec(dllimport)
# elif defined(QT_QTPROPERTYBROWSER_EXPORT)
# undef QT_QTPROPERTYBROWSER_EXPORT
# define QT_QTPROPERTYBROWSER_EXPORT __declspec(dllexport)
# endif
#else
# define QT_QTPROPERTYBROWSER_EXPORT
#endif
class QtAbstractPropertyManager;
class QtPropertyPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtProperty
{
public:
virtual ~QtProperty();
QList<QtProperty *> subProperties() const;
QtAbstractPropertyManager *propertyManager() const;
QString toolTip() const;
QString statusTip() const;
QString whatsThis() const;
QString propertyName() const;
QString propertyId() const;
bool isEnabled() const;
bool isModified() const;
bool hasValue() const;
QIcon valueIcon() const;
QString valueText() const;
virtual bool compare(QtProperty* otherProperty)const;
void setToolTip(const QString &text);
void setStatusTip(const QString &text);
void setWhatsThis(const QString &text);
void setPropertyName(const QString &text);
void setPropertyId(const QString &text);
void setEnabled(bool enable);
void setModified(bool modified);
bool isSubProperty()const;
void addSubProperty(QtProperty *property);
void insertSubProperty(QtProperty *property, QtProperty *afterProperty);
void removeSubProperty(QtProperty *property);
protected:
explicit QtProperty(QtAbstractPropertyManager *manager);
void propertyChanged();
private:
friend class QtAbstractPropertyManager;
QtPropertyPrivate *d_ptr;
};
class QtAbstractPropertyManagerPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtAbstractPropertyManager : public QObject
{
Q_OBJECT
public:
explicit QtAbstractPropertyManager(QObject *parent = 0);
~QtAbstractPropertyManager();
QSet<QtProperty *> properties() const;
void clear() const;
QtProperty *addProperty(const QString &name = QString());
QtProperty *qtProperty(const QString &id)const;
Q_SIGNALS:
void propertyInserted(QtProperty *property,
QtProperty *parent, QtProperty *after);
void propertyChanged(QtProperty *property);
void propertyRemoved(QtProperty *property, QtProperty *parent);
void propertyDestroyed(QtProperty *property);
protected:
virtual bool hasValue(const QtProperty *property) const;
virtual QIcon valueIcon(const QtProperty *property) const;
virtual QString valueText(const QtProperty *property) const;
virtual void initializeProperty(QtProperty *property) = 0;
virtual void uninitializeProperty(QtProperty *property);
virtual QtProperty *createProperty();
private:
friend class QtProperty;
QtAbstractPropertyManagerPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtAbstractPropertyManager)
Q_DISABLE_COPY(QtAbstractPropertyManager)
};
class QT_QTPROPERTYBROWSER_EXPORT QtAbstractEditorFactoryBase : public QObject
{
Q_OBJECT
public:
virtual QWidget *createEditor(QtProperty *property, QWidget *parent) = 0;
protected:
explicit QtAbstractEditorFactoryBase(QObject *parent = 0)
: QObject(parent) {}
virtual void breakConnection(QtAbstractPropertyManager *manager) = 0;
protected Q_SLOTS:
virtual void managerDestroyed(QObject *manager) = 0;
friend class QtAbstractPropertyBrowser;
};
template <class PropertyManager>
class QtAbstractEditorFactory : public QtAbstractEditorFactoryBase
{
public:
explicit QtAbstractEditorFactory(QObject *parent) : QtAbstractEditorFactoryBase(parent) {}
QWidget *createEditor(QtProperty *property, QWidget *parent)
{
QSetIterator<PropertyManager *> it(m_managers);
while (it.hasNext()) {
PropertyManager *manager = it.next();
if (manager == property->propertyManager()) {
return createEditor(manager, property, parent);
}
}
return 0;
}
void addPropertyManager(PropertyManager *manager)
{
if (m_managers.contains(manager))
return;
m_managers.insert(manager);
connectPropertyManager(manager);
connect(manager, SIGNAL(destroyed(QObject *)),
this, SLOT(managerDestroyed(QObject *)));
}
void removePropertyManager(PropertyManager *manager)
{
if (!m_managers.contains(manager))
return;
disconnect(manager, SIGNAL(destroyed(QObject *)),
this, SLOT(managerDestroyed(QObject *)));
disconnectPropertyManager(manager);
m_managers.remove(manager);
}
QSet<PropertyManager *> propertyManagers() const
{
return m_managers;
}
PropertyManager *propertyManager(QtProperty *property) const
{
QtAbstractPropertyManager *manager = property->propertyManager();
QSetIterator<PropertyManager *> itManager(m_managers);
while (itManager.hasNext()) {
PropertyManager *m = itManager.next();
if (m == manager) {
return m;
}
}
return 0;
}
protected:
virtual void connectPropertyManager(PropertyManager *manager) = 0;
virtual QWidget *createEditor(PropertyManager *manager, QtProperty *property,
QWidget *parent) = 0;
virtual void disconnectPropertyManager(PropertyManager *manager) = 0;
void managerDestroyed(QObject *manager)
{
QSetIterator<PropertyManager *> it(m_managers);
while (it.hasNext()) {
PropertyManager *m = it.next();
if (m == manager) {
m_managers.remove(m);
return;
}
}
}
private:
void breakConnection(QtAbstractPropertyManager *manager)
{
QSetIterator<PropertyManager *> it(m_managers);
while (it.hasNext()) {
PropertyManager *m = it.next();
if (m == manager) {
removePropertyManager(m);
return;
}
}
}
private:
QSet<PropertyManager *> m_managers;
friend class QtAbstractPropertyEditor;
};
class QtAbstractPropertyBrowser;
class QtBrowserItemPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtBrowserItem
{
public:
QtProperty *property() const;
QtBrowserItem *parent() const;
QList<QtBrowserItem *> children() const;
QtAbstractPropertyBrowser *browser() const;
private:
explicit QtBrowserItem(QtAbstractPropertyBrowser *browser, QtProperty *property, QtBrowserItem *parent);
~QtBrowserItem();
QtBrowserItemPrivate *d_ptr;
friend class QtAbstractPropertyBrowserPrivate;
};
class QtAbstractPropertyBrowserPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtAbstractPropertyBrowser : public QWidget
{
Q_OBJECT
public:
explicit QtAbstractPropertyBrowser(QWidget *parent = 0);
~QtAbstractPropertyBrowser();
QList<QtProperty *> properties() const;
QList<QtBrowserItem *> items(QtProperty *property) const;
QtBrowserItem *topLevelItem(QtProperty *property) const;
QList<QtBrowserItem *> topLevelItems() const;
void clear();
template <class PropertyManager>
void setFactoryForManager(PropertyManager *manager,
QtAbstractEditorFactory<PropertyManager> *factory) {
QtAbstractPropertyManager *abstractManager = manager;
QtAbstractEditorFactoryBase *abstractFactory = factory;
if (addFactory(abstractManager, abstractFactory))
factory->addPropertyManager(manager);
}
void unsetFactoryForManager(QtAbstractPropertyManager *manager);
QtBrowserItem *currentItem() const;
void setCurrentItem(QtBrowserItem *);
Q_SIGNALS:
void currentItemChanged(QtBrowserItem *);
public Q_SLOTS:
QtBrowserItem *addProperty(QtProperty *property);
QtBrowserItem *insertProperty(QtProperty *property, QtProperty *afterProperty);
void removeProperty(QtProperty *property);
protected:
virtual void itemInserted(QtBrowserItem *item, QtBrowserItem *afterItem) = 0;
virtual void itemRemoved(QtBrowserItem *item) = 0;
// can be tooltip, statustip, whatsthis, name, icon, text.
virtual void itemChanged(QtBrowserItem *item) = 0;
virtual QWidget *createEditor(QtProperty *property, QWidget *parent);
private:
bool addFactory(QtAbstractPropertyManager *abstractManager,
QtAbstractEditorFactoryBase *abstractFactory);
QtAbstractPropertyBrowserPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtAbstractPropertyBrowser)
Q_DISABLE_COPY(QtAbstractPropertyBrowser)
Q_PRIVATE_SLOT(d_func(), void slotPropertyInserted(QtProperty *,
QtProperty *, QtProperty *))
Q_PRIVATE_SLOT(d_func(), void slotPropertyRemoved(QtProperty *,
QtProperty *))
Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *))
Q_PRIVATE_SLOT(d_func(), void slotPropertyDataChanged(QtProperty *))
};
#if QT_VERSION >= 0x040400
QT_END_NAMESPACE
#endif
#endif // QTPROPERTYBROWSER_H

30
src/qtpropertybrowser.pri Normal file
View File

@@ -0,0 +1,30 @@
include(../common.pri)
INCLUDEPATH += $$PWD
DEPENDPATH += $$PWD
qtpropertybrowser-uselib:!qtpropertybrowser-buildlib {
LIBS += -L$$QTPROPERTYBROWSER_LIBDIR -l$$QTPROPERTYBROWSER_LIBNAME
} else {
SOURCES += $$PWD/qtpropertybrowser.cpp \
$$PWD/qtpropertymanager.cpp \
$$PWD/qteditorfactory.cpp \
$$PWD/qtvariantproperty.cpp \
$$PWD/qttreepropertybrowser.cpp \
$$PWD/qtbuttonpropertybrowser.cpp \
$$PWD/qtgroupboxpropertybrowser.cpp \
$$PWD/qtpropertybrowserutils.cpp
HEADERS += $$PWD/qtpropertybrowser.h \
$$PWD/qtpropertymanager.h \
$$PWD/qteditorfactory.h \
$$PWD/qtvariantproperty.h \
$$PWD/qttreepropertybrowser.h \
$$PWD/qtbuttonpropertybrowser.h \
$$PWD/qtgroupboxpropertybrowser.h \
$$PWD/qtpropertybrowserutils_p.h
RESOURCES += $$PWD/qtpropertybrowser.qrc
}
win32 {
contains(TEMPLATE, lib):contains(CONFIG, shared):DEFINES += QT_QTPROPERTYBROWSER_EXPORT
else:qtpropertybrowser-uselib:DEFINES += QT_QTPROPERTYBROWSER_IMPORT
}

23
src/qtpropertybrowser.qrc Normal file
View File

@@ -0,0 +1,23 @@
<RCC version="1.0">
<qresource prefix="/trolltech/qtpropertybrowser">
<file>images/cursor-arrow.png</file>
<file>images/cursor-busy.png</file>
<file>images/cursor-closedhand.png</file>
<file>images/cursor-cross.png</file>
<file>images/cursor-forbidden.png</file>
<file>images/cursor-hand.png</file>
<file>images/cursor-hsplit.png</file>
<file>images/cursor-ibeam.png</file>
<file>images/cursor-openhand.png</file>
<file>images/cursor-sizeall.png</file>
<file>images/cursor-sizeb.png</file>
<file>images/cursor-sizef.png</file>
<file>images/cursor-sizeh.png</file>
<file>images/cursor-sizev.png</file>
<file>images/cursor-uparrow.png</file>
<file>images/cursor-vsplit.png</file>
<file>images/cursor-wait.png</file>
<file>images/cursor-whatsthis.png</file>
</qresource>
</RCC>

View File

@@ -0,0 +1,432 @@
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of a Qt Solutions component.
**
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
** the names of its contributors may be used to endorse or promote
** products derived from this software without specific prior written
** permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
****************************************************************************/
#include "qtpropertybrowserutils_p.h"
#include <QApplication>
#include <QPainter>
#include <QHBoxLayout>
#include <QMouseEvent>
#include <QCheckBox>
#include <QLineEdit>
#include <QMenu>
#include <QStyleOption>
#if QT_VERSION >= 0x040400
QT_BEGIN_NAMESPACE
#endif
QtCursorDatabase::QtCursorDatabase()
{
appendCursor(Qt::ArrowCursor, QApplication::translate("QtCursorDatabase", "Arrow", 0), QIcon(QLatin1String(":/trolltech/qtpropertybrowser/images/cursor-arrow.png")));
appendCursor(Qt::UpArrowCursor, QApplication::translate("QtCursorDatabase", "Up Arrow", 0), QIcon(QLatin1String(":/trolltech/qtpropertybrowser/images/cursor-uparrow.png")));
appendCursor(Qt::CrossCursor, QApplication::translate("QtCursorDatabase", "Cross", 0), QIcon(QLatin1String(":/trolltech/qtpropertybrowser/images/cursor-cross.png")));
appendCursor(Qt::WaitCursor, QApplication::translate("QtCursorDatabase", "Wait", 0), QIcon(QLatin1String(":/trolltech/qtpropertybrowser/images/cursor-wait.png")));
appendCursor(Qt::IBeamCursor, QApplication::translate("QtCursorDatabase", "IBeam", 0), QIcon(QLatin1String(":/trolltech/qtpropertybrowser/images/cursor-ibeam.png")));
appendCursor(Qt::SizeVerCursor, QApplication::translate("QtCursorDatabase", "Size Vertical", 0), QIcon(QLatin1String(":/trolltech/qtpropertybrowser/images/cursor-sizev.png")));
appendCursor(Qt::SizeHorCursor, QApplication::translate("QtCursorDatabase", "Size Horizontal", 0), QIcon(QLatin1String(":/trolltech/qtpropertybrowser/images/cursor-sizeh.png")));
appendCursor(Qt::SizeFDiagCursor, QApplication::translate("QtCursorDatabase", "Size Backslash", 0), QIcon(QLatin1String(":/trolltech/qtpropertybrowser/images/cursor-sizef.png")));
appendCursor(Qt::SizeBDiagCursor, QApplication::translate("QtCursorDatabase", "Size Slash", 0), QIcon(QLatin1String(":/trolltech/qtpropertybrowser/images/cursor-sizeb.png")));
appendCursor(Qt::SizeAllCursor, QApplication::translate("QtCursorDatabase", "Size All", 0), QIcon(QLatin1String(":/trolltech/qtpropertybrowser/images/cursor-sizeall.png")));
appendCursor(Qt::BlankCursor, QApplication::translate("QtCursorDatabase", "Blank", 0), QIcon());
appendCursor(Qt::SplitVCursor, QApplication::translate("QtCursorDatabase", "Split Vertical", 0), QIcon(QLatin1String(":/trolltech/qtpropertybrowser/images/cursor-vsplit.png")));
appendCursor(Qt::SplitHCursor, QApplication::translate("QtCursorDatabase", "Split Horizontal", 0), QIcon(QLatin1String(":/trolltech/qtpropertybrowser/images/cursor-hsplit.png")));
appendCursor(Qt::PointingHandCursor, QApplication::translate("QtCursorDatabase", "Pointing Hand", 0), QIcon(QLatin1String(":/trolltech/qtpropertybrowser/images/cursor-hand.png")));
appendCursor(Qt::ForbiddenCursor, QApplication::translate("QtCursorDatabase", "Forbidden", 0), QIcon(QLatin1String(":/trolltech/qtpropertybrowser/images/cursor-forbidden.png")));
appendCursor(Qt::OpenHandCursor, QApplication::translate("QtCursorDatabase", "Open Hand", 0), QIcon(QLatin1String(":/trolltech/qtpropertybrowser/images/cursor-openhand.png")));
appendCursor(Qt::ClosedHandCursor, QApplication::translate("QtCursorDatabase", "Closed Hand", 0), QIcon(QLatin1String(":/trolltech/qtpropertybrowser/images/cursor-closedhand.png")));
appendCursor(Qt::WhatsThisCursor, QApplication::translate("QtCursorDatabase", "What's This", 0), QIcon(QLatin1String(":/trolltech/qtpropertybrowser/images/cursor-whatsthis.png")));
appendCursor(Qt::BusyCursor, QApplication::translate("QtCursorDatabase", "Busy", 0), QIcon(QLatin1String(":/trolltech/qtpropertybrowser/images/cursor-busy.png")));
}
void QtCursorDatabase::appendCursor(Qt::CursorShape shape, const QString &name, const QIcon &icon)
{
if (m_cursorShapeToValue.contains(shape))
return;
int value = m_cursorNames.count();
m_cursorNames.append(name);
m_cursorIcons[value] = icon;
m_valueToCursorShape[value] = shape;
m_cursorShapeToValue[shape] = value;
}
QStringList QtCursorDatabase::cursorShapeNames() const
{
return m_cursorNames;
}
QMap<int, QIcon> QtCursorDatabase::cursorShapeIcons() const
{
return m_cursorIcons;
}
QString QtCursorDatabase::cursorToShapeName(const QCursor &cursor) const
{
int val = cursorToValue(cursor);
if (val >= 0)
return m_cursorNames.at(val);
return QString();
}
QIcon QtCursorDatabase::cursorToShapeIcon(const QCursor &cursor) const
{
int val = cursorToValue(cursor);
return m_cursorIcons.value(val);
}
int QtCursorDatabase::cursorToValue(const QCursor &cursor) const
{
#ifndef QT_NO_CURSOR
Qt::CursorShape shape = cursor.shape();
if (m_cursorShapeToValue.contains(shape))
return m_cursorShapeToValue[shape];
#endif
return -1;
}
#ifndef QT_NO_CURSOR
QCursor QtCursorDatabase::valueToCursor(int value) const
{
if (m_valueToCursorShape.contains(value))
return QCursor(m_valueToCursorShape[value]);
return QCursor();
}
#endif
QPixmap QtPropertyBrowserUtils::brushValuePixmap(const QBrush &b)
{
QImage img(16, 16, QImage::Format_ARGB32_Premultiplied);
img.fill(0);
QPainter painter(&img);
painter.setCompositionMode(QPainter::CompositionMode_Source);
painter.fillRect(0, 0, img.width(), img.height(), b);
QColor color = b.color();
if (color.alpha() != 255) { // indicate alpha by an inset
QBrush opaqueBrush = b;
color.setAlpha(255);
opaqueBrush.setColor(color);
painter.fillRect(img.width() / 4, img.height() / 4,
img.width() / 2, img.height() / 2, opaqueBrush);
}
painter.end();
return QPixmap::fromImage(img);
}
QIcon QtPropertyBrowserUtils::brushValueIcon(const QBrush &b)
{
return QIcon(brushValuePixmap(b));
}
QString QtPropertyBrowserUtils::colorValueText(const QColor &c)
{
return QApplication::translate("QtPropertyBrowserUtils", "[%1, %2, %3] (%4)", 0)
.arg(QString::number(c.red()))
.arg(QString::number(c.green()))
.arg(QString::number(c.blue()))
.arg(QString::number(c.alpha()));
}
QPixmap QtPropertyBrowserUtils::fontValuePixmap(const QFont &font)
{
QFont f = font;
QImage img(16, 16, QImage::Format_ARGB32_Premultiplied);
img.fill(0);
QPainter p(&img);
p.setRenderHint(QPainter::TextAntialiasing, true);
p.setRenderHint(QPainter::Antialiasing, true);
f.setPointSize(13);
p.setFont(f);
QTextOption t;
t.setAlignment(Qt::AlignCenter);
p.drawText(QRect(0, 0, 16, 16), QString(QLatin1Char('A')), t);
return QPixmap::fromImage(img);
}
QIcon QtPropertyBrowserUtils::fontValueIcon(const QFont &f)
{
return QIcon(fontValuePixmap(f));
}
QString QtPropertyBrowserUtils::fontValueText(const QFont &f)
{
return QApplication::translate("QtPropertyBrowserUtils", "[%1, %2]", 0)
.arg(f.family())
.arg(f.pointSize());
}
QtBoolEdit::QtBoolEdit(QWidget *parent) :
QWidget(parent),
m_checkBox(new QCheckBox(this)),
m_textVisible(true)
{
QHBoxLayout *lt = new QHBoxLayout;
if (QApplication::layoutDirection() == Qt::LeftToRight)
lt->setContentsMargins(4, 0, 0, 0);
else
lt->setContentsMargins(0, 0, 4, 0);
lt->addWidget(m_checkBox);
setLayout(lt);
connect(m_checkBox, SIGNAL(toggled(bool)), this, SIGNAL(toggled(bool)));
setFocusProxy(m_checkBox);
m_checkBox->setText(tr("True"));
}
void QtBoolEdit::setTextVisible(bool textVisible)
{
if (m_textVisible == textVisible)
return;
m_textVisible = textVisible;
if (m_textVisible)
m_checkBox->setText(isChecked() ? tr("True") : tr("False"));
else
m_checkBox->setText(QString());
}
Qt::CheckState QtBoolEdit::checkState() const
{
return m_checkBox->checkState();
}
void QtBoolEdit::setCheckState(Qt::CheckState state)
{
m_checkBox->setCheckState(state);
}
bool QtBoolEdit::isChecked() const
{
return m_checkBox->isChecked();
}
void QtBoolEdit::setChecked(bool c)
{
m_checkBox->setChecked(c);
if (!m_textVisible)
return;
m_checkBox->setText(isChecked() ? tr("True") : tr("False"));
}
bool QtBoolEdit::blockCheckBoxSignals(bool block)
{
return m_checkBox->blockSignals(block);
}
void QtBoolEdit::mousePressEvent(QMouseEvent *event)
{
if (event->buttons() == Qt::LeftButton) {
m_checkBox->click();
event->accept();
} else {
QWidget::mousePressEvent(event);
}
}
void QtBoolEdit::paintEvent(QPaintEvent *)
{
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}
QtKeySequenceEdit::QtKeySequenceEdit(QWidget *parent)
: QWidget(parent), m_num(0), m_lineEdit(new QLineEdit(this))
{
QHBoxLayout *layout = new QHBoxLayout(this);
layout->addWidget(m_lineEdit);
layout->setMargin(0);
m_lineEdit->installEventFilter(this);
m_lineEdit->setReadOnly(true);
m_lineEdit->setFocusProxy(this);
setFocusPolicy(m_lineEdit->focusPolicy());
setAttribute(Qt::WA_InputMethodEnabled);
}
bool QtKeySequenceEdit::eventFilter(QObject *o, QEvent *e)
{
if (o == m_lineEdit && e->type() == QEvent::ContextMenu) {
QContextMenuEvent *c = static_cast<QContextMenuEvent *>(e);
QMenu *menu = m_lineEdit->createStandardContextMenu();
const QList<QAction *> actions = menu->actions();
QListIterator<QAction *> itAction(actions);
while (itAction.hasNext()) {
QAction *action = itAction.next();
action->setShortcut(QKeySequence());
QString actionString = action->text();
const int pos = actionString.lastIndexOf(QLatin1Char('\t'));
if (pos > 0)
actionString.remove(pos, actionString.length() - pos);
action->setText(actionString);
}
QAction *actionBefore = 0;
if (actions.count() > 0)
actionBefore = actions[0];
QAction *clearAction = new QAction(tr("Clear Shortcut"), menu);
menu->insertAction(actionBefore, clearAction);
menu->insertSeparator(actionBefore);
clearAction->setEnabled(!m_keySequence.isEmpty());
connect(clearAction, SIGNAL(triggered()), this, SLOT(slotClearShortcut()));
menu->exec(c->globalPos());
delete menu;
e->accept();
return true;
}
return QWidget::eventFilter(o, e);
}
void QtKeySequenceEdit::slotClearShortcut()
{
if (m_keySequence.isEmpty())
return;
setKeySequence(QKeySequence());
emit keySequenceChanged(m_keySequence);
}
void QtKeySequenceEdit::handleKeyEvent(QKeyEvent *e)
{
int nextKey = e->key();
if (nextKey == Qt::Key_Control || nextKey == Qt::Key_Shift ||
nextKey == Qt::Key_Meta || nextKey == Qt::Key_Alt ||
nextKey == Qt::Key_Super_L || nextKey == Qt::Key_AltGr)
return;
nextKey |= translateModifiers(e->modifiers(), e->text());
int k0 = m_keySequence[0];
int k1 = m_keySequence[1];
int k2 = m_keySequence[2];
int k3 = m_keySequence[3];
switch (m_num) {
case 0: k0 = nextKey; k1 = 0; k2 = 0; k3 = 0; break;
case 1: k1 = nextKey; k2 = 0; k3 = 0; break;
case 2: k2 = nextKey; k3 = 0; break;
case 3: k3 = nextKey; break;
default: break;
}
++m_num;
if (m_num > 3)
m_num = 0;
m_keySequence = QKeySequence(k0, k1, k2, k3);
m_lineEdit->setText(m_keySequence.toString(QKeySequence::NativeText));
e->accept();
emit keySequenceChanged(m_keySequence);
}
void QtKeySequenceEdit::setKeySequence(const QKeySequence &sequence)
{
if (sequence == m_keySequence)
return;
m_num = 0;
m_keySequence = sequence;
m_lineEdit->setText(m_keySequence.toString(QKeySequence::NativeText));
}
QKeySequence QtKeySequenceEdit::keySequence() const
{
return m_keySequence;
}
int QtKeySequenceEdit::translateModifiers(Qt::KeyboardModifiers state, const QString &text) const
{
int result = 0;
if ((state & Qt::ShiftModifier) && (text.size() == 0 || !text.at(0).isPrint() || text.at(0).isLetter() || text.at(0).isSpace()))
result |= Qt::SHIFT;
if (state & Qt::ControlModifier)
result |= Qt::CTRL;
if (state & Qt::MetaModifier)
result |= Qt::META;
if (state & Qt::AltModifier)
result |= Qt::ALT;
return result;
}
void QtKeySequenceEdit::focusInEvent(QFocusEvent *e)
{
m_lineEdit->event(e);
m_lineEdit->selectAll();
QWidget::focusInEvent(e);
}
void QtKeySequenceEdit::focusOutEvent(QFocusEvent *e)
{
m_num = 0;
m_lineEdit->event(e);
QWidget::focusOutEvent(e);
}
void QtKeySequenceEdit::keyPressEvent(QKeyEvent *e)
{
handleKeyEvent(e);
e->accept();
}
void QtKeySequenceEdit::keyReleaseEvent(QKeyEvent *e)
{
m_lineEdit->event(e);
}
void QtKeySequenceEdit::paintEvent(QPaintEvent *)
{
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}
bool QtKeySequenceEdit::event(QEvent *e)
{
if (e->type() == QEvent::Shortcut ||
e->type() == QEvent::ShortcutOverride ||
e->type() == QEvent::KeyRelease) {
e->accept();
return true;
}
return QWidget::event(e);
}
#if QT_VERSION >= 0x040400
QT_END_NAMESPACE
#endif

View File

@@ -0,0 +1,162 @@
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of a Qt Solutions component.
**
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
** the names of its contributors may be used to endorse or promote
** products derived from this software without specific prior written
** permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
****************************************************************************/
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists for the convenience
// of Qt Designer. This header
// file may change from version to version without notice, or even be removed.
//
// We mean it.
//
#ifndef QTPROPERTYBROWSERUTILS_H
#define QTPROPERTYBROWSERUTILS_H
#include <QtCore/QMap>
#include <QtGui/QIcon>
#include <QWidget>
#include <QtCore/QStringList>
#if QT_VERSION >= 0x040400
QT_BEGIN_NAMESPACE
#endif
class QMouseEvent;
class QCheckBox;
class QLineEdit;
class QtCursorDatabase
{
public:
QtCursorDatabase();
QStringList cursorShapeNames() const;
QMap<int, QIcon> cursorShapeIcons() const;
QString cursorToShapeName(const QCursor &cursor) const;
QIcon cursorToShapeIcon(const QCursor &cursor) const;
int cursorToValue(const QCursor &cursor) const;
#ifndef QT_NO_CURSOR
QCursor valueToCursor(int value) const;
#endif
private:
void appendCursor(Qt::CursorShape shape, const QString &name, const QIcon &icon);
QStringList m_cursorNames;
QMap<int, QIcon> m_cursorIcons;
QMap<int, Qt::CursorShape> m_valueToCursorShape;
QMap<Qt::CursorShape, int> m_cursorShapeToValue;
};
class QtPropertyBrowserUtils
{
public:
static QPixmap brushValuePixmap(const QBrush &b);
static QIcon brushValueIcon(const QBrush &b);
static QString colorValueText(const QColor &c);
static QPixmap fontValuePixmap(const QFont &f);
static QIcon fontValueIcon(const QFont &f);
static QString fontValueText(const QFont &f);
};
class QtBoolEdit : public QWidget {
Q_OBJECT
public:
QtBoolEdit(QWidget *parent = 0);
bool textVisible() const { return m_textVisible; }
void setTextVisible(bool textVisible);
Qt::CheckState checkState() const;
void setCheckState(Qt::CheckState state);
bool isChecked() const;
void setChecked(bool c);
bool blockCheckBoxSignals(bool block);
Q_SIGNALS:
void toggled(bool);
protected:
void mousePressEvent(QMouseEvent * event);
void paintEvent(QPaintEvent *);
private:
QCheckBox *m_checkBox;
bool m_textVisible;
};
class QtKeySequenceEdit : public QWidget
{
Q_OBJECT
public:
QtKeySequenceEdit(QWidget *parent = 0);
QKeySequence keySequence() const;
bool eventFilter(QObject *o, QEvent *e);
public Q_SLOTS:
void setKeySequence(const QKeySequence &sequence);
Q_SIGNALS:
void keySequenceChanged(const QKeySequence &sequence);
protected:
void focusInEvent(QFocusEvent *e);
void focusOutEvent(QFocusEvent *e);
void keyPressEvent(QKeyEvent *e);
void keyReleaseEvent(QKeyEvent *e);
void paintEvent(QPaintEvent *);
bool event(QEvent *e);
private slots:
void slotClearShortcut();
private:
void handleKeyEvent(QKeyEvent *e);
int translateModifiers(Qt::KeyboardModifiers state, const QString &text) const;
int m_num;
QKeySequence m_keySequence;
QLineEdit *m_lineEdit;
};
#if QT_VERSION >= 0x040400
QT_END_NAMESPACE
#endif
#endif

6425
src/qtpropertymanager.cpp Normal file

File diff suppressed because it is too large Load Diff

749
src/qtpropertymanager.h Normal file
View File

@@ -0,0 +1,749 @@
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of a Qt Solutions component.
**
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
** the names of its contributors may be used to endorse or promote
** products derived from this software without specific prior written
** permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
****************************************************************************/
#ifndef QTPROPERTYMANAGER_H
#define QTPROPERTYMANAGER_H
#include "qtpropertybrowser.h"
#if QT_VERSION >= 0x040400
QT_BEGIN_NAMESPACE
#endif
class QDate;
class QTime;
class QDateTime;
class QLocale;
class QT_QTPROPERTYBROWSER_EXPORT QtGroupPropertyManager : public QtAbstractPropertyManager
{
Q_OBJECT
public:
QtGroupPropertyManager(QObject *parent = 0);
~QtGroupPropertyManager();
protected:
virtual bool hasValue(const QtProperty *property) const;
virtual void initializeProperty(QtProperty *property);
virtual void uninitializeProperty(QtProperty *property);
};
class QtIntPropertyManagerPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtIntPropertyManager : public QtAbstractPropertyManager
{
Q_OBJECT
public:
QtIntPropertyManager(QObject *parent = 0);
~QtIntPropertyManager();
int value(const QtProperty *property) const;
int minimum(const QtProperty *property) const;
int maximum(const QtProperty *property) const;
int singleStep(const QtProperty *property) const;
public Q_SLOTS:
void setValue(QtProperty *property, int val);
void setMinimum(QtProperty *property, int minVal);
void setMaximum(QtProperty *property, int maxVal);
void setRange(QtProperty *property, int minVal, int maxVal);
void setSingleStep(QtProperty *property, int step);
Q_SIGNALS:
void valueChanged(QtProperty *property, int val);
void rangeChanged(QtProperty *property, int minVal, int maxVal);
void singleStepChanged(QtProperty *property, int step);
protected:
QString valueText(const QtProperty *property) const;
virtual void initializeProperty(QtProperty *property);
virtual void uninitializeProperty(QtProperty *property);
private:
QtIntPropertyManagerPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtIntPropertyManager)
Q_DISABLE_COPY(QtIntPropertyManager)
};
class QtBoolPropertyManagerPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtBoolPropertyManager : public QtAbstractPropertyManager
{
Q_OBJECT
public:
QtBoolPropertyManager(QObject *parent = 0);
~QtBoolPropertyManager();
bool value(const QtProperty *property) const;
public Q_SLOTS:
void setValue(QtProperty *property, bool val);
Q_SIGNALS:
void valueChanged(QtProperty *property, bool val);
protected:
QString valueText(const QtProperty *property) const;
QIcon valueIcon(const QtProperty *property) const;
virtual void initializeProperty(QtProperty *property);
virtual void uninitializeProperty(QtProperty *property);
private:
QtBoolPropertyManagerPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtBoolPropertyManager)
Q_DISABLE_COPY(QtBoolPropertyManager)
};
class QtDoublePropertyManagerPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtDoublePropertyManager : public QtAbstractPropertyManager
{
Q_OBJECT
public:
QtDoublePropertyManager(QObject *parent = 0);
~QtDoublePropertyManager();
double value(const QtProperty *property) const;
double minimum(const QtProperty *property) const;
double maximum(const QtProperty *property) const;
double singleStep(const QtProperty *property) const;
int decimals(const QtProperty *property) const;
public Q_SLOTS:
void setValue(QtProperty *property, double val);
void setMinimum(QtProperty *property, double minVal);
void setMaximum(QtProperty *property, double maxVal);
void setRange(QtProperty *property, double minVal, double maxVal);
void setSingleStep(QtProperty *property, double step);
void setDecimals(QtProperty *property, int prec);
Q_SIGNALS:
void valueChanged(QtProperty *property, double val);
void rangeChanged(QtProperty *property, double minVal, double maxVal);
void singleStepChanged(QtProperty *property, double step);
void decimalsChanged(QtProperty *property, int prec);
protected:
QString valueText(const QtProperty *property) const;
virtual void initializeProperty(QtProperty *property);
virtual void uninitializeProperty(QtProperty *property);
private:
QtDoublePropertyManagerPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtDoublePropertyManager)
Q_DISABLE_COPY(QtDoublePropertyManager)
};
class QtStringPropertyManagerPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtStringPropertyManager : public QtAbstractPropertyManager
{
Q_OBJECT
public:
QtStringPropertyManager(QObject *parent = 0);
~QtStringPropertyManager();
QString value(const QtProperty *property) const;
QRegExp regExp(const QtProperty *property) const;
public Q_SLOTS:
void setValue(QtProperty *property, const QString &val);
void setRegExp(QtProperty *property, const QRegExp &regExp);
Q_SIGNALS:
void valueChanged(QtProperty *property, const QString &val);
void regExpChanged(QtProperty *property, const QRegExp &regExp);
protected:
QString valueText(const QtProperty *property) const;
virtual void initializeProperty(QtProperty *property);
virtual void uninitializeProperty(QtProperty *property);
private:
QtStringPropertyManagerPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtStringPropertyManager)
Q_DISABLE_COPY(QtStringPropertyManager)
};
class QtDatePropertyManagerPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtDatePropertyManager : public QtAbstractPropertyManager
{
Q_OBJECT
public:
QtDatePropertyManager(QObject *parent = 0);
~QtDatePropertyManager();
QDate value(const QtProperty *property) const;
QDate minimum(const QtProperty *property) const;
QDate maximum(const QtProperty *property) const;
public Q_SLOTS:
void setValue(QtProperty *property, const QDate &val);
void setMinimum(QtProperty *property, const QDate &minVal);
void setMaximum(QtProperty *property, const QDate &maxVal);
void setRange(QtProperty *property, const QDate &minVal, const QDate &maxVal);
Q_SIGNALS:
void valueChanged(QtProperty *property, const QDate &val);
void rangeChanged(QtProperty *property, const QDate &minVal, const QDate &maxVal);
protected:
QString valueText(const QtProperty *property) const;
virtual void initializeProperty(QtProperty *property);
virtual void uninitializeProperty(QtProperty *property);
private:
QtDatePropertyManagerPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtDatePropertyManager)
Q_DISABLE_COPY(QtDatePropertyManager)
};
class QtTimePropertyManagerPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtTimePropertyManager : public QtAbstractPropertyManager
{
Q_OBJECT
public:
QtTimePropertyManager(QObject *parent = 0);
~QtTimePropertyManager();
QTime value(const QtProperty *property) const;
public Q_SLOTS:
void setValue(QtProperty *property, const QTime &val);
Q_SIGNALS:
void valueChanged(QtProperty *property, const QTime &val);
protected:
QString valueText(const QtProperty *property) const;
virtual void initializeProperty(QtProperty *property);
virtual void uninitializeProperty(QtProperty *property);
private:
QtTimePropertyManagerPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtTimePropertyManager)
Q_DISABLE_COPY(QtTimePropertyManager)
};
class QtDateTimePropertyManagerPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtDateTimePropertyManager : public QtAbstractPropertyManager
{
Q_OBJECT
public:
QtDateTimePropertyManager(QObject *parent = 0);
~QtDateTimePropertyManager();
QDateTime value(const QtProperty *property) const;
public Q_SLOTS:
void setValue(QtProperty *property, const QDateTime &val);
Q_SIGNALS:
void valueChanged(QtProperty *property, const QDateTime &val);
protected:
QString valueText(const QtProperty *property) const;
virtual void initializeProperty(QtProperty *property);
virtual void uninitializeProperty(QtProperty *property);
private:
QtDateTimePropertyManagerPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtDateTimePropertyManager)
Q_DISABLE_COPY(QtDateTimePropertyManager)
};
class QtKeySequencePropertyManagerPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtKeySequencePropertyManager : public QtAbstractPropertyManager
{
Q_OBJECT
public:
QtKeySequencePropertyManager(QObject *parent = 0);
~QtKeySequencePropertyManager();
QKeySequence value(const QtProperty *property) const;
public Q_SLOTS:
void setValue(QtProperty *property, const QKeySequence &val);
Q_SIGNALS:
void valueChanged(QtProperty *property, const QKeySequence &val);
protected:
QString valueText(const QtProperty *property) const;
virtual void initializeProperty(QtProperty *property);
virtual void uninitializeProperty(QtProperty *property);
private:
QtKeySequencePropertyManagerPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtKeySequencePropertyManager)
Q_DISABLE_COPY(QtKeySequencePropertyManager)
};
class QtCharPropertyManagerPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtCharPropertyManager : public QtAbstractPropertyManager
{
Q_OBJECT
public:
QtCharPropertyManager(QObject *parent = 0);
~QtCharPropertyManager();
QChar value(const QtProperty *property) const;
public Q_SLOTS:
void setValue(QtProperty *property, const QChar &val);
Q_SIGNALS:
void valueChanged(QtProperty *property, const QChar &val);
protected:
QString valueText(const QtProperty *property) const;
virtual void initializeProperty(QtProperty *property);
virtual void uninitializeProperty(QtProperty *property);
private:
QtCharPropertyManagerPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtCharPropertyManager)
Q_DISABLE_COPY(QtCharPropertyManager)
};
class QtEnumPropertyManager;
class QtLocalePropertyManagerPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtLocalePropertyManager : public QtAbstractPropertyManager
{
Q_OBJECT
public:
QtLocalePropertyManager(QObject *parent = 0);
~QtLocalePropertyManager();
QtEnumPropertyManager *subEnumPropertyManager() const;
QLocale value(const QtProperty *property) const;
public Q_SLOTS:
void setValue(QtProperty *property, const QLocale &val);
Q_SIGNALS:
void valueChanged(QtProperty *property, const QLocale &val);
protected:
QString valueText(const QtProperty *property) const;
virtual void initializeProperty(QtProperty *property);
virtual void uninitializeProperty(QtProperty *property);
private:
QtLocalePropertyManagerPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtLocalePropertyManager)
Q_DISABLE_COPY(QtLocalePropertyManager)
Q_PRIVATE_SLOT(d_func(), void slotEnumChanged(QtProperty *, int))
Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *))
};
class QtPointPropertyManagerPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtPointPropertyManager : public QtAbstractPropertyManager
{
Q_OBJECT
public:
QtPointPropertyManager(QObject *parent = 0);
~QtPointPropertyManager();
QtIntPropertyManager *subIntPropertyManager() const;
QPoint value(const QtProperty *property) const;
public Q_SLOTS:
void setValue(QtProperty *property, const QPoint &val);
Q_SIGNALS:
void valueChanged(QtProperty *property, const QPoint &val);
protected:
QString valueText(const QtProperty *property) const;
virtual void initializeProperty(QtProperty *property);
virtual void uninitializeProperty(QtProperty *property);
private:
QtPointPropertyManagerPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtPointPropertyManager)
Q_DISABLE_COPY(QtPointPropertyManager)
Q_PRIVATE_SLOT(d_func(), void slotIntChanged(QtProperty *, int))
Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *))
};
class QtPointFPropertyManagerPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtPointFPropertyManager : public QtAbstractPropertyManager
{
Q_OBJECT
public:
QtPointFPropertyManager(QObject *parent = 0);
~QtPointFPropertyManager();
QtDoublePropertyManager *subDoublePropertyManager() const;
QPointF value(const QtProperty *property) const;
int decimals(const QtProperty *property) const;
public Q_SLOTS:
void setValue(QtProperty *property, const QPointF &val);
void setDecimals(QtProperty *property, int prec);
Q_SIGNALS:
void valueChanged(QtProperty *property, const QPointF &val);
void decimalsChanged(QtProperty *property, int prec);
protected:
QString valueText(const QtProperty *property) const;
virtual void initializeProperty(QtProperty *property);
virtual void uninitializeProperty(QtProperty *property);
private:
QtPointFPropertyManagerPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtPointFPropertyManager)
Q_DISABLE_COPY(QtPointFPropertyManager)
Q_PRIVATE_SLOT(d_func(), void slotDoubleChanged(QtProperty *, double))
Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *))
};
class QtSizePropertyManagerPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtSizePropertyManager : public QtAbstractPropertyManager
{
Q_OBJECT
public:
QtSizePropertyManager(QObject *parent = 0);
~QtSizePropertyManager();
QtIntPropertyManager *subIntPropertyManager() const;
QSize value(const QtProperty *property) const;
QSize minimum(const QtProperty *property) const;
QSize maximum(const QtProperty *property) const;
public Q_SLOTS:
void setValue(QtProperty *property, const QSize &val);
void setMinimum(QtProperty *property, const QSize &minVal);
void setMaximum(QtProperty *property, const QSize &maxVal);
void setRange(QtProperty *property, const QSize &minVal, const QSize &maxVal);
Q_SIGNALS:
void valueChanged(QtProperty *property, const QSize &val);
void rangeChanged(QtProperty *property, const QSize &minVal, const QSize &maxVal);
protected:
QString valueText(const QtProperty *property) const;
virtual void initializeProperty(QtProperty *property);
virtual void uninitializeProperty(QtProperty *property);
private:
QtSizePropertyManagerPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtSizePropertyManager)
Q_DISABLE_COPY(QtSizePropertyManager)
Q_PRIVATE_SLOT(d_func(), void slotIntChanged(QtProperty *, int))
Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *))
};
class QtSizeFPropertyManagerPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtSizeFPropertyManager : public QtAbstractPropertyManager
{
Q_OBJECT
public:
QtSizeFPropertyManager(QObject *parent = 0);
~QtSizeFPropertyManager();
QtDoublePropertyManager *subDoublePropertyManager() const;
QSizeF value(const QtProperty *property) const;
QSizeF minimum(const QtProperty *property) const;
QSizeF maximum(const QtProperty *property) const;
int decimals(const QtProperty *property) const;
public Q_SLOTS:
void setValue(QtProperty *property, const QSizeF &val);
void setMinimum(QtProperty *property, const QSizeF &minVal);
void setMaximum(QtProperty *property, const QSizeF &maxVal);
void setRange(QtProperty *property, const QSizeF &minVal, const QSizeF &maxVal);
void setDecimals(QtProperty *property, int prec);
Q_SIGNALS:
void valueChanged(QtProperty *property, const QSizeF &val);
void rangeChanged(QtProperty *property, const QSizeF &minVal, const QSizeF &maxVal);
void decimalsChanged(QtProperty *property, int prec);
protected:
QString valueText(const QtProperty *property) const;
virtual void initializeProperty(QtProperty *property);
virtual void uninitializeProperty(QtProperty *property);
private:
QtSizeFPropertyManagerPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtSizeFPropertyManager)
Q_DISABLE_COPY(QtSizeFPropertyManager)
Q_PRIVATE_SLOT(d_func(), void slotDoubleChanged(QtProperty *, double))
Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *))
};
class QtRectPropertyManagerPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtRectPropertyManager : public QtAbstractPropertyManager
{
Q_OBJECT
public:
QtRectPropertyManager(QObject *parent = 0);
~QtRectPropertyManager();
QtIntPropertyManager *subIntPropertyManager() const;
QRect value(const QtProperty *property) const;
QRect constraint(const QtProperty *property) const;
public Q_SLOTS:
void setValue(QtProperty *property, const QRect &val);
void setConstraint(QtProperty *property, const QRect &constraint);
Q_SIGNALS:
void valueChanged(QtProperty *property, const QRect &val);
void constraintChanged(QtProperty *property, const QRect &constraint);
protected:
QString valueText(const QtProperty *property) const;
virtual void initializeProperty(QtProperty *property);
virtual void uninitializeProperty(QtProperty *property);
private:
QtRectPropertyManagerPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtRectPropertyManager)
Q_DISABLE_COPY(QtRectPropertyManager)
Q_PRIVATE_SLOT(d_func(), void slotIntChanged(QtProperty *, int))
Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *))
};
class QtRectFPropertyManagerPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtRectFPropertyManager : public QtAbstractPropertyManager
{
Q_OBJECT
public:
QtRectFPropertyManager(QObject *parent = 0);
~QtRectFPropertyManager();
QtDoublePropertyManager *subDoublePropertyManager() const;
QRectF value(const QtProperty *property) const;
QRectF constraint(const QtProperty *property) const;
int decimals(const QtProperty *property) const;
public Q_SLOTS:
void setValue(QtProperty *property, const QRectF &val);
void setConstraint(QtProperty *property, const QRectF &constraint);
void setDecimals(QtProperty *property, int prec);
Q_SIGNALS:
void valueChanged(QtProperty *property, const QRectF &val);
void constraintChanged(QtProperty *property, const QRectF &constraint);
void decimalsChanged(QtProperty *property, int prec);
protected:
QString valueText(const QtProperty *property) const;
virtual void initializeProperty(QtProperty *property);
virtual void uninitializeProperty(QtProperty *property);
private:
QtRectFPropertyManagerPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtRectFPropertyManager)
Q_DISABLE_COPY(QtRectFPropertyManager)
Q_PRIVATE_SLOT(d_func(), void slotDoubleChanged(QtProperty *, double))
Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *))
};
class QtEnumPropertyManagerPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtEnumPropertyManager : public QtAbstractPropertyManager
{
Q_OBJECT
public:
QtEnumPropertyManager(QObject *parent = 0);
~QtEnumPropertyManager();
int value(const QtProperty *property) const;
QStringList enumNames(const QtProperty *property) const;
QMap<int, QIcon> enumIcons(const QtProperty *property) const;
public Q_SLOTS:
void setValue(QtProperty *property, int val);
void setEnumNames(QtProperty *property, const QStringList &names);
void setEnumIcons(QtProperty *property, const QMap<int, QIcon> &icons);
Q_SIGNALS:
void valueChanged(QtProperty *property, int val);
void enumNamesChanged(QtProperty *property, const QStringList &names);
void enumIconsChanged(QtProperty *property, const QMap<int, QIcon> &icons);
protected:
QString valueText(const QtProperty *property) const;
QIcon valueIcon(const QtProperty *property) const;
virtual void initializeProperty(QtProperty *property);
virtual void uninitializeProperty(QtProperty *property);
private:
QtEnumPropertyManagerPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtEnumPropertyManager)
Q_DISABLE_COPY(QtEnumPropertyManager)
};
class QtFlagPropertyManagerPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtFlagPropertyManager : public QtAbstractPropertyManager
{
Q_OBJECT
public:
QtFlagPropertyManager(QObject *parent = 0);
~QtFlagPropertyManager();
QtBoolPropertyManager *subBoolPropertyManager() const;
int value(const QtProperty *property) const;
QStringList flagNames(const QtProperty *property) const;
public Q_SLOTS:
void setValue(QtProperty *property, int val);
void setFlagNames(QtProperty *property, const QStringList &names);
Q_SIGNALS:
void valueChanged(QtProperty *property, int val);
void flagNamesChanged(QtProperty *property, const QStringList &names);
protected:
QString valueText(const QtProperty *property) const;
virtual void initializeProperty(QtProperty *property);
virtual void uninitializeProperty(QtProperty *property);
private:
QtFlagPropertyManagerPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtFlagPropertyManager)
Q_DISABLE_COPY(QtFlagPropertyManager)
Q_PRIVATE_SLOT(d_func(), void slotBoolChanged(QtProperty *, bool))
Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *))
};
class QtSizePolicyPropertyManagerPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtSizePolicyPropertyManager : public QtAbstractPropertyManager
{
Q_OBJECT
public:
QtSizePolicyPropertyManager(QObject *parent = 0);
~QtSizePolicyPropertyManager();
QtIntPropertyManager *subIntPropertyManager() const;
QtEnumPropertyManager *subEnumPropertyManager() const;
QSizePolicy value(const QtProperty *property) const;
public Q_SLOTS:
void setValue(QtProperty *property, const QSizePolicy &val);
Q_SIGNALS:
void valueChanged(QtProperty *property, const QSizePolicy &val);
protected:
QString valueText(const QtProperty *property) const;
virtual void initializeProperty(QtProperty *property);
virtual void uninitializeProperty(QtProperty *property);
private:
QtSizePolicyPropertyManagerPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtSizePolicyPropertyManager)
Q_DISABLE_COPY(QtSizePolicyPropertyManager)
Q_PRIVATE_SLOT(d_func(), void slotIntChanged(QtProperty *, int))
Q_PRIVATE_SLOT(d_func(), void slotEnumChanged(QtProperty *, int))
Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *))
};
class QtFontPropertyManagerPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtFontPropertyManager : public QtAbstractPropertyManager
{
Q_OBJECT
public:
QtFontPropertyManager(QObject *parent = 0);
~QtFontPropertyManager();
QtIntPropertyManager *subIntPropertyManager() const;
QtEnumPropertyManager *subEnumPropertyManager() const;
QtBoolPropertyManager *subBoolPropertyManager() const;
QFont value(const QtProperty *property) const;
public Q_SLOTS:
void setValue(QtProperty *property, const QFont &val);
Q_SIGNALS:
void valueChanged(QtProperty *property, const QFont &val);
protected:
QString valueText(const QtProperty *property) const;
QIcon valueIcon(const QtProperty *property) const;
virtual void initializeProperty(QtProperty *property);
virtual void uninitializeProperty(QtProperty *property);
private:
QtFontPropertyManagerPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtFontPropertyManager)
Q_DISABLE_COPY(QtFontPropertyManager)
Q_PRIVATE_SLOT(d_func(), void slotIntChanged(QtProperty *, int))
Q_PRIVATE_SLOT(d_func(), void slotEnumChanged(QtProperty *, int))
Q_PRIVATE_SLOT(d_func(), void slotBoolChanged(QtProperty *, bool))
Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *))
Q_PRIVATE_SLOT(d_func(), void slotFontDatabaseChanged())
Q_PRIVATE_SLOT(d_func(), void slotFontDatabaseDelayedChange())
};
class QtColorPropertyManagerPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtColorPropertyManager : public QtAbstractPropertyManager
{
Q_OBJECT
public:
QtColorPropertyManager(QObject *parent = 0);
~QtColorPropertyManager();
QtIntPropertyManager *subIntPropertyManager() const;
QColor value(const QtProperty *property) const;
public Q_SLOTS:
void setValue(QtProperty *property, const QColor &val);
Q_SIGNALS:
void valueChanged(QtProperty *property, const QColor &val);
protected:
QString valueText(const QtProperty *property) const;
QIcon valueIcon(const QtProperty *property) const;
virtual void initializeProperty(QtProperty *property);
virtual void uninitializeProperty(QtProperty *property);
private:
QtColorPropertyManagerPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtColorPropertyManager)
Q_DISABLE_COPY(QtColorPropertyManager)
Q_PRIVATE_SLOT(d_func(), void slotIntChanged(QtProperty *, int))
Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *))
};
class QtCursorPropertyManagerPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtCursorPropertyManager : public QtAbstractPropertyManager
{
Q_OBJECT
public:
QtCursorPropertyManager(QObject *parent = 0);
~QtCursorPropertyManager();
#ifndef QT_NO_CURSOR
QCursor value(const QtProperty *property) const;
#endif
public Q_SLOTS:
void setValue(QtProperty *property, const QCursor &val);
Q_SIGNALS:
void valueChanged(QtProperty *property, const QCursor &val);
protected:
QString valueText(const QtProperty *property) const;
QIcon valueIcon(const QtProperty *property) const;
virtual void initializeProperty(QtProperty *property);
virtual void uninitializeProperty(QtProperty *property);
private:
QtCursorPropertyManagerPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtCursorPropertyManager)
Q_DISABLE_COPY(QtCursorPropertyManager)
};
#if QT_VERSION >= 0x040400
QT_END_NAMESPACE
#endif
#endif

File diff suppressed because it is too large Load Diff

137
src/qttreepropertybrowser.h Normal file
View File

@@ -0,0 +1,137 @@
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of a Qt Solutions component.
**
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
** the names of its contributors may be used to endorse or promote
** products derived from this software without specific prior written
** permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
****************************************************************************/
#ifndef QTTREEPROPERTYBROWSER_H
#define QTTREEPROPERTYBROWSER_H
#include "qtpropertybrowser.h"
#if QT_VERSION >= 0x040400
QT_BEGIN_NAMESPACE
#endif
class QTreeWidgetItem;
class QtTreePropertyBrowserPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtTreePropertyBrowser : public QtAbstractPropertyBrowser
{
Q_OBJECT
Q_ENUMS(ResizeMode)
Q_PROPERTY(int indentation READ indentation WRITE setIndentation)
Q_PROPERTY(bool rootIsDecorated READ rootIsDecorated WRITE setRootIsDecorated)
Q_PROPERTY(bool alternatingRowColors READ alternatingRowColors WRITE setAlternatingRowColors)
Q_PROPERTY(bool headerVisible READ isHeaderVisible WRITE setHeaderVisible)
Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode)
Q_PROPERTY(int splitterPosition READ splitterPosition WRITE setSplitterPosition)
Q_PROPERTY(bool propertiesWithoutValueMarked READ propertiesWithoutValueMarked WRITE setPropertiesWithoutValueMarked)
public:
enum ResizeMode
{
Interactive,
Stretch,
Fixed,
ResizeToContents
};
QtTreePropertyBrowser(QWidget *parent = 0);
~QtTreePropertyBrowser();
int indentation() const;
void setIndentation(int i);
bool rootIsDecorated() const;
void setRootIsDecorated(bool show);
bool alternatingRowColors() const;
void setAlternatingRowColors(bool enable);
bool isHeaderVisible() const;
void setHeaderVisible(bool visible);
ResizeMode resizeMode() const;
void setResizeMode(ResizeMode mode);
int splitterPosition() const;
void setSplitterPosition(int position);
void setExpanded(QtBrowserItem *item, bool expanded);
bool isExpanded(QtBrowserItem *item) const;
bool isItemVisible(QtBrowserItem *item) const;
void setItemVisible(QtBrowserItem *item, bool visible);
void setBackgroundColor(QtBrowserItem *item, const QColor &color);
QColor backgroundColor(QtBrowserItem *item) const;
QColor calculatedBackgroundColor(QtBrowserItem *item) const;
void setPropertiesWithoutValueMarked(bool mark);
bool propertiesWithoutValueMarked() const;
void editItem(QtBrowserItem *item);
Q_SIGNALS:
void collapsed(QtBrowserItem *item);
void expanded(QtBrowserItem *item);
protected:
virtual void itemInserted(QtBrowserItem *item, QtBrowserItem *afterItem);
virtual void itemRemoved(QtBrowserItem *item);
virtual void itemChanged(QtBrowserItem *item);
private:
QtTreePropertyBrowserPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtTreePropertyBrowser)
Q_DISABLE_COPY(QtTreePropertyBrowser)
Q_PRIVATE_SLOT(d_func(), void slotCollapsed(const QModelIndex &))
Q_PRIVATE_SLOT(d_func(), void slotExpanded(const QModelIndex &))
Q_PRIVATE_SLOT(d_func(), void slotCurrentBrowserItemChanged(QtBrowserItem *))
Q_PRIVATE_SLOT(d_func(), void slotCurrentTreeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *))
};
#if QT_VERSION >= 0x040400
QT_END_NAMESPACE
#endif
#endif

2358
src/qtvariantproperty.cpp Normal file

File diff suppressed because it is too large Load Diff

190
src/qtvariantproperty.h Normal file
View File

@@ -0,0 +1,190 @@
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of a Qt Solutions component.
**
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
** the names of its contributors may be used to endorse or promote
** products derived from this software without specific prior written
** permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
****************************************************************************/
#ifndef QTVARIANTPROPERTY_H
#define QTVARIANTPROPERTY_H
#include "qtpropertybrowser.h"
#include <QtCore/QVariant>
#include <QtGui/QIcon>
#if QT_VERSION >= 0x040400
QT_BEGIN_NAMESPACE
#endif
typedef QMap<int, QIcon> QtIconMap;
class QtVariantPropertyManager;
class QtVariantPropertyPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtVariantProperty : public QtProperty
{
public:
~QtVariantProperty();
QVariant value() const;
QVariant attributeValue(const QString &attribute) const;
int valueType() const;
int propertyType() const;
virtual bool compare(QtProperty* otherProperty)const;
void setValue(const QVariant &value);
void setAttribute(const QString &attribute, const QVariant &value);
protected:
QtVariantProperty(QtVariantPropertyManager *manager);
private:
friend class QtVariantPropertyManager;
QtVariantPropertyPrivate *d_ptr;
};
class QtVariantPropertyManagerPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtVariantPropertyManager : public QtAbstractPropertyManager
{
Q_OBJECT
public:
QtVariantPropertyManager(QObject *parent = 0);
~QtVariantPropertyManager();
virtual QtVariantProperty *addProperty(int propertyType, const QString &name = QString());
void setProperties(QSet<QtProperty *> properties);
int propertyType(const QtProperty *property) const;
int valueType(const QtProperty *property) const;
QtVariantProperty *variantProperty(const QtProperty *property) const;
virtual bool isPropertyTypeSupported(int propertyType) const;
virtual int valueType(int propertyType) const;
virtual QStringList attributes(int propertyType) const;
virtual int attributeType(int propertyType, const QString &attribute) const;
virtual QVariant value(const QtProperty *property) const;
virtual QVariant attributeValue(const QtProperty *property, const QString &attribute) const;
static int enumTypeId();
static int flagTypeId();
static int groupTypeId();
static int iconMapTypeId();
public Q_SLOTS:
virtual void setValue(QtProperty *property, const QVariant &val);
virtual void setAttribute(QtProperty *property,
const QString &attribute, const QVariant &value);
Q_SIGNALS:
void valueChanged(QtProperty *property, const QVariant &val);
void attributeChanged(QtProperty *property,
const QString &attribute, const QVariant &val);
protected:
virtual bool hasValue(const QtProperty *property) const;
QString valueText(const QtProperty *property) const;
QIcon valueIcon(const QtProperty *property) const;
virtual void initializeProperty(QtProperty *property);
virtual void uninitializeProperty(QtProperty *property);
virtual QtProperty *createProperty();
private:
QtVariantPropertyManagerPrivate *d_ptr;
Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, int))
Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, int, int))
Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, int))
Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, double))
Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, double, double))
Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, double))
Q_PRIVATE_SLOT(d_func(), void slotDecimalsChanged(QtProperty *, int))
Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, bool))
Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QString &))
Q_PRIVATE_SLOT(d_func(), void slotRegExpChanged(QtProperty *, const QRegExp &))
Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QDate &))
Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, const QDate &, const QDate &))
Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QTime &))
Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QDateTime &))
Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QKeySequence &))
Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QChar &))
Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QLocale &))
Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QPoint &))
Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QPointF &))
Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QSize &))
Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, const QSize &, const QSize &))
Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QSizeF &))
Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, const QSizeF &, const QSizeF &))
Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QRect &))
Q_PRIVATE_SLOT(d_func(), void slotConstraintChanged(QtProperty *, const QRect &))
Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QRectF &))
Q_PRIVATE_SLOT(d_func(), void slotConstraintChanged(QtProperty *, const QRectF &))
Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QColor &))
Q_PRIVATE_SLOT(d_func(), void slotEnumNamesChanged(QtProperty *, const QStringList &))
Q_PRIVATE_SLOT(d_func(), void slotEnumIconsChanged(QtProperty *, const QMap<int, QIcon> &))
Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QSizePolicy &))
Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QFont &))
Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QCursor &))
Q_PRIVATE_SLOT(d_func(), void slotFlagNamesChanged(QtProperty *, const QStringList &))
Q_PRIVATE_SLOT(d_func(), void slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *))
Q_PRIVATE_SLOT(d_func(), void slotPropertyRemoved(QtProperty *, QtProperty *))
Q_DECLARE_PRIVATE(QtVariantPropertyManager)
Q_DISABLE_COPY(QtVariantPropertyManager)
};
class QtVariantEditorFactoryPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtVariantEditorFactory : public QtAbstractEditorFactory<QtVariantPropertyManager>
{
Q_OBJECT
public:
QtVariantEditorFactory(QObject *parent = 0);
~QtVariantEditorFactory();
protected:
void connectPropertyManager(QtVariantPropertyManager *manager);
QWidget *createEditor(QtVariantPropertyManager *manager, QtProperty *property,
QWidget *parent);
QWidget *createEditor(QtProperty *property, QWidget *parent);
void disconnectPropertyManager(QtVariantPropertyManager *manager);
private:
QtVariantEditorFactoryPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtVariantEditorFactory)
Q_DISABLE_COPY(QtVariantEditorFactory)
};
#if QT_VERSION >= 0x040400
QT_END_NAMESPACE
#endif
Q_DECLARE_METATYPE(QIcon)
Q_DECLARE_METATYPE(QtIconMap)
#endif