forked from qt-creator/qt-creator
Fix compilation for latest qt/master
QmlList has been replaced by QmlListProperty (33eb76f050b45718d87926). Patch provided by Aaron Kennedy. Reviewed-by: akennedy
This commit is contained in:
@@ -34,12 +34,12 @@ QT_BEGIN_NAMESPACE
|
||||
QML_DEFINE_TYPE(Bauhaus,1,0,QBoxLayout,QBoxLayoutObject);
|
||||
|
||||
QBoxLayoutObject::QBoxLayoutObject(QObject *parent)
|
||||
: QLayoutObject(parent), _widgets(this), _layout(0)
|
||||
: QLayoutObject(parent), _layout(0)
|
||||
{
|
||||
}
|
||||
|
||||
QBoxLayoutObject::QBoxLayoutObject(QBoxLayout *layout, QObject *parent)
|
||||
: QLayoutObject(parent), _widgets(this), _layout(layout)
|
||||
: QLayoutObject(parent), _layout(layout)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ class QBoxLayoutObject : public QLayoutObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QmlList<QWidget *> *children READ children)
|
||||
Q_PROPERTY(QmlListProperty<QWidget> children READ children)
|
||||
|
||||
Q_PROPERTY(int topMargin READ topMargin WRITE setTopMargin)
|
||||
Q_PROPERTY(int bottomMargin READ bottomMargin WRITE setBottomMargin)
|
||||
@@ -57,30 +57,22 @@ public:
|
||||
explicit QBoxLayoutObject(QBoxLayout *, QObject *parent=0);
|
||||
virtual QLayout *layout() const;
|
||||
|
||||
QmlList<QWidget *> *children() { return &_widgets; }
|
||||
QmlListProperty<QWidget> children() {
|
||||
return QmlListProperty<QWidget>(this, 0, children_append, 0, 0, children_clear);
|
||||
}
|
||||
|
||||
private:
|
||||
friend class WidgetList;
|
||||
void addWidget(QWidget *);
|
||||
void clearWidget();
|
||||
|
||||
//XXX need to provide real implementations once QBoxLayoutObject is finished
|
||||
class WidgetList : public QmlList<QWidget *>
|
||||
{
|
||||
public:
|
||||
WidgetList(QBoxLayoutObject *o)
|
||||
: obj(o) {}
|
||||
static void children_append(QmlListProperty<QWidget> *property, QWidget *widget) {
|
||||
static_cast<QBoxLayoutObject*>(property->object)->addWidget(widget);
|
||||
}
|
||||
|
||||
virtual void append(QWidget *w) { obj->addWidget(w); }
|
||||
virtual void clear() { obj->clearWidget(); }
|
||||
virtual int count() const { return 0; }
|
||||
virtual void removeAt(int) {}
|
||||
virtual QWidget *at(int) const { return 0; }
|
||||
virtual void insert(int, QWidget *) {}
|
||||
|
||||
private:
|
||||
QBoxLayoutObject *obj;
|
||||
};
|
||||
static void children_clear(QmlListProperty<QWidget> *property) {
|
||||
static_cast<QBoxLayoutObject*>(property->object)->clearWidget();
|
||||
}
|
||||
|
||||
void getMargins()
|
||||
{
|
||||
@@ -154,7 +146,6 @@ private:
|
||||
_layout->setSpacing(spacing);
|
||||
}
|
||||
|
||||
WidgetList _widgets;
|
||||
QBoxLayout *_layout;
|
||||
|
||||
int mTop, mLeft, mBottom, mRight;
|
||||
|
||||
@@ -51,39 +51,6 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
class QWidgetDeclarativeUI;
|
||||
|
||||
class Actions : public QmlConcreteList<Action *>
|
||||
{
|
||||
public:
|
||||
Actions(QObject *o) : widget(qobject_cast<QWidget*>(o)) {}
|
||||
virtual void append(Action *o)
|
||||
{
|
||||
QmlConcreteList<Action *>::append(o);
|
||||
o->setParent(widget);
|
||||
widget->addAction(o);
|
||||
}
|
||||
virtual void clear()
|
||||
{
|
||||
QmlConcreteList<Action *>::clear();
|
||||
|
||||
while (!widget->actions().empty())
|
||||
widget->removeAction(widget->actions().first());
|
||||
//menu->clear();
|
||||
}
|
||||
virtual void removeAt(int i)
|
||||
{
|
||||
QmlConcreteList<Action *>::removeAt(i);
|
||||
widget->removeAction(widget->actions().at(i));
|
||||
}
|
||||
virtual void insert(int i, Action *obj)
|
||||
{
|
||||
QmlConcreteList<Action *>::insert(i, obj);
|
||||
obj->setParent(widget);
|
||||
widget->addAction(obj);
|
||||
}
|
||||
private:
|
||||
QWidget *widget;
|
||||
};
|
||||
|
||||
class ResizeEventFilter : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -104,9 +71,9 @@ class QWidgetDeclarativeUI : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QmlList<QObject *> *children READ children)
|
||||
Q_PROPERTY(QmlListProperty<QObject> children READ children)
|
||||
Q_PROPERTY(QLayoutObject *layout READ layout WRITE setLayout)
|
||||
Q_PROPERTY(QmlList<Action *> *actions READ actions)
|
||||
Q_PROPERTY(QmlListProperty<Action> actions READ actions)
|
||||
Q_PROPERTY(QFont font READ font CONSTANT)
|
||||
|
||||
Q_PROPERTY(QPoint pos READ pos)
|
||||
@@ -150,7 +117,7 @@ signals:
|
||||
void opacityChanged();
|
||||
|
||||
public:
|
||||
QWidgetDeclarativeUI(QObject *other) : QObject(other), _children(other), _layout(0), _graphicsOpacityEffect(0), _actions(other) {
|
||||
QWidgetDeclarativeUI(QObject *other) : QObject(other), _layout(0), _graphicsOpacityEffect(0) {
|
||||
q = qobject_cast<QWidget*>(other);
|
||||
ResizeEventFilter *filter(new ResizeEventFilter(q));
|
||||
filter->setTarget(q);
|
||||
@@ -162,38 +129,6 @@ public:
|
||||
virtual ~QWidgetDeclarativeUI() {
|
||||
}
|
||||
|
||||
class Children : public QmlConcreteList<QObject *>
|
||||
{
|
||||
public:
|
||||
Children(QObject *widget) : q(qobject_cast<QWidget *>(widget)) {}
|
||||
virtual void append(QObject *o)
|
||||
{
|
||||
insert(-1, o);
|
||||
}
|
||||
virtual void clear()
|
||||
{
|
||||
for (int i = 0; i < count(); ++i)
|
||||
at(i)->setParent(0);
|
||||
QmlConcreteList<QObject *>::clear();
|
||||
}
|
||||
virtual void removeAt(int i)
|
||||
{
|
||||
at(i)->setParent(0);
|
||||
QmlConcreteList<QObject *>::removeAt(i);
|
||||
}
|
||||
virtual void insert(int i, QObject *o)
|
||||
{
|
||||
QmlConcreteList<QObject *>::insert(i, o);
|
||||
if (QWidget *w = qobject_cast<QWidget *>(o))
|
||||
w->setParent(static_cast<QWidget *>(q));
|
||||
else
|
||||
o->setParent(q);
|
||||
}
|
||||
|
||||
private:
|
||||
QWidget *q;
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
void setMouseOver(bool _mouseOver)
|
||||
@@ -223,7 +158,9 @@ public:
|
||||
emit mouseOverChanged();
|
||||
}
|
||||
|
||||
QmlList<QObject *> *children() { return &_children; }
|
||||
QmlListProperty<QObject> children() {
|
||||
return QmlListProperty<QObject>(this, 0, children_append, children_count, children_at, children_clear);
|
||||
}
|
||||
|
||||
QLayoutObject *layout() const { return _layout; }
|
||||
void setLayout(QLayoutObject *lo)
|
||||
@@ -440,18 +377,73 @@ public:
|
||||
|
||||
}
|
||||
|
||||
|
||||
QmlList<Action *> *actions() { return &_actions; }
|
||||
QmlListProperty<Action> actions() {
|
||||
return QmlListProperty<Action>(this, 0, actions_append, actions_count, actions_at, actions_clear);
|
||||
}
|
||||
|
||||
private:
|
||||
QWidget *q;
|
||||
Children _children;
|
||||
QLayoutObject *_layout;
|
||||
QFont _font;
|
||||
QUrl _styleSheetFile;
|
||||
QGraphicsOpacityEffect *_graphicsOpacityEffect;
|
||||
bool m_mouseOver;
|
||||
Actions _actions;
|
||||
|
||||
static void children_append(QmlListProperty<QObject> *property, QObject *o) {
|
||||
QWidgetDeclarativeUI *p = static_cast<QWidgetDeclarativeUI *>(property->object);
|
||||
QWidget *q = p->q;
|
||||
if (QWidget *w = qobject_cast<QWidget *>(o))
|
||||
w->setParent(static_cast<QWidget *>(q));
|
||||
else
|
||||
o->setParent(q);
|
||||
}
|
||||
|
||||
static int children_count(QmlListProperty<QObject> *property) {
|
||||
QWidgetDeclarativeUI *p = static_cast<QWidgetDeclarativeUI *>(property->object);
|
||||
QWidget *q = p->q;
|
||||
return q->children().count();
|
||||
}
|
||||
|
||||
static QObject * children_at(QmlListProperty<QObject> *property, int index) {
|
||||
QWidgetDeclarativeUI *p = static_cast<QWidgetDeclarativeUI *>(property->object);
|
||||
QWidget *q = p->q;
|
||||
return q->children().at(index);
|
||||
}
|
||||
|
||||
static void children_clear(QmlListProperty<QObject> *property) {
|
||||
QWidgetDeclarativeUI *p = static_cast<QWidgetDeclarativeUI *>(property->object);
|
||||
QWidget *q = p->q;
|
||||
QObjectList c = q->children();
|
||||
for (int i = 0; i < c.count(); ++i)
|
||||
c.at(i)->setParent(0);
|
||||
}
|
||||
|
||||
// ### Original had an insert, and removeAt
|
||||
static void actions_append(QmlListProperty<Action> *property, Action *o) {
|
||||
QWidgetDeclarativeUI *p = static_cast<QWidgetDeclarativeUI *>(property->object);
|
||||
QWidget *w = p->q;
|
||||
o->setParent(w);
|
||||
w->addAction(o);
|
||||
}
|
||||
|
||||
static int actions_count(QmlListProperty<Action> *property) {
|
||||
QWidgetDeclarativeUI *p = static_cast<QWidgetDeclarativeUI *>(property->object);
|
||||
QWidget *w = p->q;
|
||||
return w->actions().count();
|
||||
}
|
||||
static Action *actions_at(QmlListProperty<Action> *property, int index) {
|
||||
QWidgetDeclarativeUI *p = static_cast<QWidgetDeclarativeUI *>(property->object);
|
||||
QWidget *w = p->q;
|
||||
return qobject_cast<Action *>(w->actions().at(index));
|
||||
}
|
||||
|
||||
static void actions_clear(QmlListProperty<Action> *property) {
|
||||
QWidgetDeclarativeUI *p = static_cast<QWidgetDeclarativeUI *>(property->object);
|
||||
QWidget *w = p->q;
|
||||
|
||||
while (!w->actions().empty())
|
||||
w->removeAction(w->actions().first());
|
||||
}
|
||||
};
|
||||
|
||||
bool ResizeEventFilter::eventFilter(QObject *obj, QEvent *event)
|
||||
@@ -1113,50 +1105,28 @@ class QTabWidgetDeclarativeUI : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QmlList<QTabObject *> *tabs READ tabs)
|
||||
Q_PROPERTY(QmlListProperty<QTabObject> tabs READ tabs)
|
||||
Q_CLASSINFO("DefaultProperty", "tabs")
|
||||
public:
|
||||
QTabWidgetDeclarativeUI(QObject *other) : QObject(other), _tabs(other) {}
|
||||
QTabWidgetDeclarativeUI(QObject *other) : QObject(other) {}
|
||||
|
||||
QmlList<QTabObject *> *tabs() { return &_tabs; }
|
||||
QmlListProperty<QTabObject> tabs() {
|
||||
return QmlListProperty<QTabObject>(this, 0, tabs_append, 0, 0, tabs_clear);
|
||||
}
|
||||
|
||||
private:
|
||||
//if not for the at() function, we could use QmlList instead
|
||||
class Tabs : public QmlConcreteList<QTabObject *>
|
||||
{
|
||||
public:
|
||||
Tabs(QObject *o) : tw(o) {}
|
||||
virtual void append(QTabObject *o)
|
||||
{
|
||||
QmlConcreteList<QTabObject *>::append(o);
|
||||
//XXX can we insertTab(-1, o) instead?
|
||||
static void tabs_append(QmlListProperty<QTabObject> *property, QTabObject *o) {
|
||||
QTabWidget *tw = static_cast<QTabWidget*>(property->object->parent());
|
||||
if (!o->icon().isNull())
|
||||
static_cast<QTabWidget *>(tw)->addTab(o->content(), o->icon(), o->label());
|
||||
tw->addTab(o->content(), o->icon(), o->label());
|
||||
else
|
||||
static_cast<QTabWidget *>(tw)->addTab(o->content(), o->label());
|
||||
tw->addTab(o->content(), o->label());
|
||||
}
|
||||
virtual void clear()
|
||||
{
|
||||
QmlConcreteList<QTabObject *>::clear();
|
||||
static_cast<QTabWidget *>(tw)->clear();
|
||||
|
||||
static void tabs_clear(QmlListProperty<QTabObject> *property) {
|
||||
QTabWidget *tw = static_cast<QTabWidget*>(property->object->parent());
|
||||
tw->clear();
|
||||
}
|
||||
virtual void removeAt(int i)
|
||||
{
|
||||
QmlConcreteList<QTabObject *>::removeAt(i);
|
||||
static_cast<QTabWidget *>(tw)->removeTab(i);
|
||||
}
|
||||
virtual void insert(int i, QTabObject *obj)
|
||||
{
|
||||
QmlConcreteList<QTabObject *>::insert(i, obj);
|
||||
if (!obj->icon().isNull())
|
||||
static_cast<QTabWidget *>(tw)->insertTab(i, obj->content(), obj->icon(), obj->label());
|
||||
else
|
||||
static_cast<QTabWidget *>(tw)->insertTab(i, obj->content(), obj->label());
|
||||
}
|
||||
private:
|
||||
QObject *tw;
|
||||
};
|
||||
Tabs _tabs;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -52,7 +52,6 @@
|
||||
#include <QEvent>
|
||||
#include <QGraphicsScene>
|
||||
#include <QmlContext>
|
||||
#include <QmlList>
|
||||
#include <QmlError>
|
||||
#include <QmlBinding>
|
||||
#include <QmlMetaType>
|
||||
@@ -327,7 +326,7 @@ QPair<QString, NodeInstance> ObjectNodeInstance::anchor(const QString &/*name*/)
|
||||
|
||||
static bool isList(const QmlMetaProperty &metaProperty)
|
||||
{
|
||||
return metaProperty.propertyCategory() == QmlMetaProperty::List || metaProperty.propertyCategory() == QmlMetaProperty::QmlList;
|
||||
return metaProperty.propertyCategory() == QmlMetaProperty::List;
|
||||
}
|
||||
|
||||
static bool isObject(const QmlMetaProperty &metaProperty)
|
||||
@@ -342,15 +341,7 @@ static QVariant objectToVariant(QObject *object)
|
||||
|
||||
static void removeObjectFromList(const QmlMetaProperty &metaProperty, QObject *object, QmlEngine *engine)
|
||||
{
|
||||
QmlListAccessor listAccessor;
|
||||
listAccessor.setList(metaProperty.read(), engine);
|
||||
|
||||
for (int i = 0; i < listAccessor.count(); ++i) {
|
||||
if (QmlMetaType::toQObject(listAccessor.at(i)) == object) {
|
||||
listAccessor.removeAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// ### Very few QML lists ever responded to removes
|
||||
}
|
||||
|
||||
void ObjectNodeInstance::removeFromOldProperty(QObject *object, QObject *oldParent, const QString &oldParentProperty)
|
||||
@@ -371,9 +362,8 @@ void ObjectNodeInstance::addToNewProperty(QObject *object, QObject *newParent, c
|
||||
QmlMetaProperty metaProperty = QmlMetaProperty::createProperty(newParent, newParentProperty, context());
|
||||
|
||||
if (isList(metaProperty)) {
|
||||
QmlListAccessor listAccessor;
|
||||
listAccessor.setList(metaProperty.read(), nodeInstanceView()->engine());
|
||||
listAccessor.append(objectToVariant(object));
|
||||
QmlListReference list = qvariant_cast<QmlListReference>(metaProperty.read());
|
||||
list.append(object);
|
||||
} else if (isObject(metaProperty)) {
|
||||
metaProperty.write(objectToVariant(object));
|
||||
}
|
||||
@@ -438,14 +428,13 @@ void ObjectNodeInstance::setPropertyBinding(const QString &name, const QString &
|
||||
void ObjectNodeInstance::deleteObjectsInList(const QmlMetaProperty &metaProperty)
|
||||
{
|
||||
QObjectList objectList;
|
||||
QmlListAccessor listAccessor;
|
||||
listAccessor.setList(metaProperty.read());
|
||||
QmlListReference list = qvariant_cast<QmlListReference>(metaProperty.read());
|
||||
|
||||
for(int i = 0; i < listAccessor.count(); i++) {
|
||||
objectList += QmlMetaType::toQObject(listAccessor.at(i));
|
||||
for(int i = 0; i < list.count(); i++) {
|
||||
objectList += list.at(i);
|
||||
}
|
||||
|
||||
listAccessor.clear();
|
||||
list.clear();
|
||||
}
|
||||
|
||||
void ObjectNodeInstance::resetProperty(const QString &name)
|
||||
@@ -489,9 +478,8 @@ void ObjectNodeInstance::resetProperty(QObject *object, const QString &propertyN
|
||||
if (qmlMetaProperty.read() == resetValue(propertyName))
|
||||
return;
|
||||
qmlMetaProperty.write(resetValue(propertyName));
|
||||
} else if (QmlMetaType::isList(qmlMetaProperty.propertyType()) ||
|
||||
QmlMetaType::isQmlList(qmlMetaProperty.propertyType())) {
|
||||
QmlMetaType::clear(object->property(propertyName.toLatin1()));
|
||||
} else if (qmlMetaProperty.propertyCategory() == QmlMetaProperty::List) {
|
||||
qvariant_cast<QmlListReference>(qmlMetaProperty.read()).clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ public:
|
||||
QList<QmlFileFilterItem*> qmlFileFilters() const;
|
||||
|
||||
// content property
|
||||
QmlConcreteList<QmlProjectContentItem*> content;
|
||||
QList<QmlProjectContentItem*> content;
|
||||
};
|
||||
|
||||
QList<QmlFileFilterItem*> QmlProjectItemPrivate::qmlFileFilters() const
|
||||
@@ -45,10 +45,10 @@ QmlProjectItem::~QmlProjectItem()
|
||||
delete d_ptr;
|
||||
}
|
||||
|
||||
QmlList<QmlProjectContentItem*> *QmlProjectItem::content()
|
||||
QmlListProperty<QmlProjectContentItem> QmlProjectItem::content()
|
||||
{
|
||||
Q_D(QmlProjectItem);
|
||||
return &d->content;
|
||||
return QmlListProperty<QmlProjectContentItem>(this, d->content);
|
||||
}
|
||||
|
||||
QString QmlProjectItem::sourceDirectory() const
|
||||
|
||||
@@ -21,7 +21,7 @@ class QmlProjectItem : public QObject {
|
||||
Q_DECLARE_PRIVATE(QmlProjectItem)
|
||||
Q_DISABLE_COPY(QmlProjectItem)
|
||||
|
||||
Q_PROPERTY(QmlList<QmlProjectManager::QmlProjectContentItem*> *content READ content DESIGNABLE false)
|
||||
Q_PROPERTY(QmlListProperty<QmlProjectManager::QmlProjectContentItem> content READ content DESIGNABLE false)
|
||||
Q_PROPERTY(QString sourceDirectory READ sourceDirectory NOTIFY sourceDirectoryChanged)
|
||||
Q_PROPERTY(QStringList libraryPaths READ libraryPaths WRITE setLibraryPaths NOTIFY libraryPathsChanged)
|
||||
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
QmlProjectItem(QObject *parent = 0);
|
||||
~QmlProjectItem();
|
||||
|
||||
QmlList<QmlProjectContentItem*> *content();
|
||||
QmlListProperty<QmlProjectContentItem> content();
|
||||
|
||||
QString sourceDirectory() const;
|
||||
void setSourceDirectory(const QString &directoryPath);
|
||||
|
||||
Reference in New Issue
Block a user