Commit 1553eb04 authored by Tim Jenssen's avatar Tim Jenssen

QmlDesigner: use default values at isSubclassOf

Change-Id: Ia31d698635a9b29a023f4d919f3741ac912923b7
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@theqtcompany.com>
parent cc1c2b79
......@@ -300,7 +300,7 @@ bool singleSelectionAndInQtQuickLayout(const SelectionContext &context)
if (!metaInfo.isValid())
return false;
return metaInfo.isSubclassOf("QtQuick.Layouts.Layout", -1, -1);
return metaInfo.isSubclassOf("QtQuick.Layouts.Layout");
}
bool isLayout(const SelectionContext &context)
......@@ -321,7 +321,7 @@ bool isLayout(const SelectionContext &context)
if (!metaInfo.isValid())
return false;
return metaInfo.isSubclassOf("QtQuick.Layouts.Layout", -1, -1);
return metaInfo.isSubclassOf("QtQuick.Layouts.Layout");
}
bool isPositioner(const SelectionContext &context)
......@@ -342,8 +342,8 @@ bool isPositioner(const SelectionContext &context)
if (!metaInfo.isValid())
return false;
return metaInfo.isSubclassOf("<cpp>.QDeclarativeBasePositioner", -1, -1)
|| metaInfo.isSubclassOf("QtQuick.Positioner", -1, -1);
return metaInfo.isSubclassOf("<cpp>.QDeclarativeBasePositioner")
|| metaInfo.isSubclassOf("QtQuick.Positioner");
}
bool layoutOptionVisible(const SelectionContext &context)
......
......@@ -88,7 +88,7 @@ void ContentNotEditableIndicator::updateItems(const QList<FormEditorItem *> &ite
void ContentNotEditableIndicator::addAddiationEntries(const QList<FormEditorItem *> &itemList)
{
foreach (FormEditorItem *formEditorItem, itemList) {
if (formEditorItem->qmlItemNode().modelNode().metaInfo().isSubclassOf("QtQuick.Loader", -1, -1)) {
if (formEditorItem->qmlItemNode().modelNode().metaInfo().isSubclassOf("QtQuick.Loader")) {
if (!m_entryList.contains(EntryPair(formEditorItem, 0))) {
QGraphicsRectItem *indicatorShape = new QGraphicsRectItem(m_layerItem);
......
......@@ -148,7 +148,7 @@ void ItemLibraryModel::update(ItemLibraryInfo *itemLibraryInfo, Model *model)
foreach (ItemLibraryEntry entry, itemLibraryInfo->entries()) {
NodeMetaInfo metaInfo = model->metaInfo(entry.typeName(), -1, -1);
NodeMetaInfo metaInfo = model->metaInfo(entry.typeName());
bool valid = metaInfo.isValid() && metaInfo.majorVersion() == entry.majorVersion();
if (valid
......
......@@ -693,7 +693,7 @@ void NavigatorTreeModel::moveNodesInteractive(NodeAbstractProperty &parentProper
if (modelNode.isValid()
&& modelNode != parentProperty.parentModelNode()
&& !modelNode.isAncestorOf(parentProperty.parentModelNode())
&& (modelNode.metaInfo().isSubclassOf(propertyQmlType, -1, -1) || propertyQmlType == "alias")) {
&& (modelNode.metaInfo().isSubclassOf(propertyQmlType) || propertyQmlType == "alias")) {
//### todo: allowing alias is just a heuristic
//once the MetaInfo is part of instances we can do this right
......
......@@ -77,7 +77,7 @@ void StatesEditorView::removeState(int nodeId)
try {
if (nodeId > 0 && hasModelNodeForInternalId(nodeId)) {
ModelNode stateNode(modelNodeForInternalId(nodeId));
Q_ASSERT(stateNode.metaInfo().isSubclassOf("QtQuick.State", -1, -1));
Q_ASSERT(stateNode.metaInfo().isSubclassOf("QtQuick.State"));
NodeListProperty parentProperty = stateNode.parentProperty().toNodeListProperty();
if (parentProperty.count() <= 1) {
......@@ -188,7 +188,7 @@ void StatesEditorView::duplicateCurrentState()
void StatesEditorView::checkForWindow()
{
if (m_statesEditorWidget)
m_statesEditorWidget->showAddNewStatesButton(!rootModelNode().metaInfo().isSubclassOf("QtQuick.Window.Window", -1, -1));
m_statesEditorWidget->showAddNewStatesButton(!rootModelNode().metaInfo().isSubclassOf("QtQuick.Window.Window"));
}
void StatesEditorView::setCurrentState(const QmlModelState &state)
......
......@@ -44,14 +44,14 @@ namespace QmlDesigner {
bool isTabView(const ModelNode &modelNode)
{
return modelNode.metaInfo().isSubclassOf("QtQuick.Controls.TabView", -1, -1);
return modelNode.metaInfo().isSubclassOf("QtQuick.Controls.TabView");
}
bool isTabAndParentIsTabView(const ModelNode &modelNode)
{
return modelNode.metaInfo().isSubclassOf("QtQuick.Controls.Tab", -1, -1)
return modelNode.metaInfo().isSubclassOf("QtQuick.Controls.Tab")
&& modelNode.hasParentProperty()
&& modelNode.parentProperty().parentModelNode().metaInfo().isSubclassOf("QtQuick.Controls.TabView", -1, -1);
&& modelNode.parentProperty().parentModelNode().metaInfo().isSubclassOf("QtQuick.Controls.TabView");
}
AddTabDesignerAction::AddTabDesignerAction()
......@@ -97,7 +97,7 @@ bool AddTabDesignerAction::isEnabled(const SelectionContext &selectionContext) c
static ModelNode findTabViewModelNode(const ModelNode &currentModelNode)
{
if (currentModelNode.metaInfo().isSubclassOf("QtQuick.Controls.TabView", -1, -1))
if (currentModelNode.metaInfo().isSubclassOf("QtQuick.Controls.TabView"))
return currentModelNode;
else
return findTabViewModelNode(currentModelNode.parentProperty().parentModelNode());
......
......@@ -83,7 +83,7 @@ void EnterTabDesignerAction::updateContext()
if (action()->isEnabled()) {
const ModelNode selectedModelNode = selectionContext().currentSingleSelectedNode();
if (selectedModelNode.metaInfo().isValid()
&& selectedModelNode.metaInfo().isSubclassOf("QtQuick.Controls.TabView", -1, -1)) {
&& selectedModelNode.metaInfo().isSubclassOf("QtQuick.Controls.TabView")) {
const NodeAbstractProperty defaultProperty = selectedModelNode.defaultNodeAbstractProperty();
foreach (const QmlDesigner::ModelNode &childModelNode, defaultProperty.directSubNodes()) {
......@@ -117,7 +117,7 @@ bool EnterTabDesignerAction::isEnabled(const SelectionContext &selectionContext)
void EnterTabDesignerAction::createActionForTab(const ModelNode &modelNode)
{
if (modelNode.metaInfo().isValid()
&& modelNode.metaInfo().isSubclassOf("QtQuick.Controls.Tab", -1, -1)) {
&& modelNode.metaInfo().isSubclassOf("QtQuick.Controls.Tab")) {
QmlDesigner::QmlItemNode itemNode(modelNode);
......
......@@ -60,11 +60,11 @@ void TabViewIndexModel::setupModel()
m_tabViewIndexModel.clear();
if (m_modelNode.isValid()
&& m_modelNode.metaInfo().isValid()
&& m_modelNode.metaInfo().isSubclassOf("QtQuick.Controls.TabView", -1, -1)) {
&& m_modelNode.metaInfo().isSubclassOf("QtQuick.Controls.TabView")) {
foreach (const QmlDesigner::ModelNode &childModelNode, m_modelNode.defaultNodeAbstractProperty().directSubNodes()) {
if (childModelNode.metaInfo().isValid()
&& childModelNode.metaInfo().isSubclassOf("QtQuick.Controls.Tab", -1, -1)) {
&& childModelNode.metaInfo().isSubclassOf("QtQuick.Controls.Tab")) {
QmlDesigner::QmlItemNode itemNode(childModelNode);
if (itemNode.isValid()) {
m_tabViewIndexModel.append(itemNode.instanceValue("title").toString());
......
......@@ -96,7 +96,7 @@ public:
bool hasCustomParser() const;
bool availableInVersion(int majorVersion, int minorVersion) const;
bool isSubclassOf(const TypeName &type, int majorVersion, int minorVersio) const;
bool isSubclassOf(const TypeName &type, int majorVersion = -1, int minorVersion = -1) const;
bool isGraphicalItem() const;
bool isLayoutable() const;
......
......@@ -783,7 +783,7 @@ CreateSceneCommand NodeInstanceView::createCreateSceneCommand()
InstanceContainer::NodeSourceType nodeSourceType = static_cast<InstanceContainer::NodeSourceType>(instance.modelNode().nodeSourceType());
InstanceContainer::NodeMetaType nodeMetaType = InstanceContainer::ObjectMetaType;
if (instance.modelNode().metaInfo().isSubclassOf("QtQuick.Item", -1, -1))
if (instance.modelNode().metaInfo().isSubclassOf("QtQuick.Item"))
nodeMetaType = InstanceContainer::ItemMetaType;
InstanceContainer container(instance.instanceId(),
......@@ -885,7 +885,7 @@ CreateInstancesCommand NodeInstanceView::createCreateInstancesCommand(const QLis
InstanceContainer::NodeSourceType nodeSourceType = static_cast<InstanceContainer::NodeSourceType>(instance.modelNode().nodeSourceType());
InstanceContainer::NodeMetaType nodeMetaType = InstanceContainer::ObjectMetaType;
if (instance.modelNode().metaInfo().isSubclassOf("QtQuick.Item", -1, -1))
if (instance.modelNode().metaInfo().isSubclassOf("QtQuick.Item"))
nodeMetaType = InstanceContainer::ItemMetaType;
InstanceContainer container(instance.instanceId(), instance.modelNode().type(), instance.modelNode().majorVersion(), instance.modelNode().minorVersion(),
......
......@@ -1519,7 +1519,7 @@ bool NodeMetaInfo::isSubclassOf(const TypeName &type, int majorVersion, int mino
bool NodeMetaInfo::isGraphicalItem() const
{
return isSubclassOf("QtQuick.Item", -1, -1) || isSubclassOf("QtQuick.Window.Window", -1, -1);
return isSubclassOf("QtQuick.Item") || isSubclassOf("QtQuick.Window.Window");
}
void NodeMetaInfo::clearCache()
......@@ -1529,25 +1529,25 @@ void NodeMetaInfo::clearCache()
bool NodeMetaInfo::isLayoutable() const
{
if (isSubclassOf("<cpp>.QDeclarativeBasePositioner", -1, -1))
if (isSubclassOf("<cpp>.QDeclarativeBasePositioner"))
return true; //QtQuick 1
return isSubclassOf("QtQuick.Positioner", -1, -1)
|| isSubclassOf("QtQuick.Layouts.Layout", -1, -1)
|| isSubclassOf("QtQuick.Controls.SplitView", -1, -1);
return isSubclassOf("QtQuick.Positioner")
|| isSubclassOf("QtQuick.Layouts.Layout")
|| isSubclassOf("QtQuick.Controls.SplitView");
}
bool NodeMetaInfo::isView() const
{
return isValid() &&
(isSubclassOf("QtQuick.ListView", -1, -1) ||
isSubclassOf("QtQuick.GridView", -1, -1) ||
isSubclassOf("QtQuick.PathView", -1, -1));
(isSubclassOf("QtQuick.ListView") ||
isSubclassOf("QtQuick.GridView") ||
isSubclassOf("QtQuick.PathView"));
}
bool NodeMetaInfo::isTabView() const
{
return isSubclassOf("QtQuick.Controls.TabView", -1, -1);
return isSubclassOf("QtQuick.Controls.TabView");
}
} // namespace QmlDesigner
......@@ -1056,7 +1056,7 @@ bool ModelNode::isComponent() const
return true;
}
if (metaInfo().isSubclassOf("QtQuick.Loader", -1 , -1)) {
if (metaInfo().isSubclassOf("QtQuick.Loader")) {
if (hasNodeListProperty("component")) {
......
......@@ -51,7 +51,7 @@ bool QmlPropertyChanges::isValid() const
bool QmlPropertyChanges::isValidQmlPropertyChanges(const ModelNode &modelNode)
{
return isValidQmlModelNodeFacade(modelNode) && modelNode.metaInfo().isSubclassOf("QtQuick.PropertyChanges", -1, -1);
return isValidQmlModelNodeFacade(modelNode) && modelNode.metaInfo().isSubclassOf("QtQuick.PropertyChanges");
}
bool QmlModelStateOperation::isValid() const
......@@ -62,8 +62,8 @@ bool QmlModelStateOperation::isValid() const
bool QmlModelStateOperation::isValidQmlModelStateOperation(const ModelNode &modelNode)
{
return isValidQmlModelNodeFacade(modelNode)
&& (modelNode.metaInfo().isSubclassOf("<cpp>.QDeclarative1StateOperation", -1, -1)
|| modelNode.metaInfo().isSubclassOf("<cpp>.QQuickStateOperation", -1, -1));
&& (modelNode.metaInfo().isSubclassOf("<cpp>.QDeclarative1StateOperation")
|| modelNode.metaInfo().isSubclassOf("<cpp>.QQuickStateOperation"));
}
void QmlPropertyChanges::removeProperty(const PropertyName &name)
......
......@@ -47,10 +47,10 @@ namespace QmlDesigner {
bool QmlItemNode::isItemOrWindow(const ModelNode &modelNode)
{
if (modelNode.metaInfo().isSubclassOf("QtQuick.Item", -1, -1))
if (modelNode.metaInfo().isSubclassOf("QtQuick.Item"))
return true;
if (modelNode.metaInfo().isSubclassOf("QtQuick.Window.Window", -1, -1) && modelNode.isRootNode())
if (modelNode.metaInfo().isSubclassOf("QtQuick.Window.Window") && modelNode.isRootNode())
return true;
return false;
......@@ -364,7 +364,7 @@ bool QmlItemNode::instanceHasRotationTransform() const
bool itemIsMovable(const ModelNode &modelNode)
{
if (modelNode.metaInfo().isSubclassOf("QtQuick.Controls.Tab", -1, -1))
if (modelNode.metaInfo().isSubclassOf("QtQuick.Controls.Tab"))
return false;
if (modelNode.hasParentProperty()) {
......@@ -599,7 +599,7 @@ bool QmlItemNode::isInLayout() const
ModelNode parent = modelNode().parentProperty().parentModelNode();
if (parent.isValid() && parent.metaInfo().isValid())
return parent.metaInfo().isSubclassOf("QtQuick.Layouts.Layout", -1, -1);
return parent.metaInfo().isSubclassOf("QtQuick.Layouts.Layout");
}
return false;
......
......@@ -224,7 +224,7 @@ bool QmlModelState::isValidQmlModelState(const ModelNode &modelNode)
{
return isValidQmlModelNodeFacade(modelNode)
&& modelNode.metaInfo().isValid()
&& (modelNode.metaInfo().isSubclassOf("QtQuick.State", -1, -1) || isBaseState(modelNode));
&& (modelNode.metaInfo().isSubclassOf("QtQuick.State") || isBaseState(modelNode));
}
/**
......
......@@ -294,7 +294,7 @@ static bool isConnectionsType(const QmlDesigner::TypeName &type)
static bool propertyIsComponentType(const QmlDesigner::NodeAbstractProperty &property, const QmlDesigner::TypeName &type, QmlDesigner::Model *model)
{
if (model->metaInfo(type, -1, -1).isSubclassOf("QtQuick.Component", -1, -1) && !isComponentType(type))
if (model->metaInfo(type).isSubclassOf("QtQuick.Component") && !isComponentType(type))
return false; //If the type is already a subclass of Component keep it
return property.parentModelNode().isValid() &&
......
......@@ -240,7 +240,7 @@ static bool isLoaderWithSourceComponent(const ModelNode &modelNode)
{
if (modelNode.isValid()
&& modelNode.metaInfo().isValid()
&& modelNode.metaInfo().isSubclassOf("QtQuick.Loader", -1, -1)) {
&& modelNode.metaInfo().isSubclassOf("QtQuick.Loader")) {
if (modelNode.hasNodeProperty("sourceComponent"))
return true;
......@@ -256,7 +256,7 @@ static bool hasSourceWithFileComponent(const ModelNode &modelNode)
{
if (modelNode.isValid()
&& modelNode.metaInfo().isValid()
&& modelNode.metaInfo().isSubclassOf("QtQuick.Loader", -1, -1)
&& modelNode.metaInfo().isSubclassOf("QtQuick.Loader")
&& modelNode.hasVariantProperty("source"))
return true;
......
......@@ -78,7 +78,7 @@ static int pathRankForModelNode(const ModelNode &modelNode) {
if (modelNode.metaInfo().hasProperty("path")) {
if (modelNode.hasNodeProperty("path")) {
ModelNode pathNode = modelNode.nodeProperty("path").modelNode();
if (pathNode.metaInfo().isSubclassOf("QtQuick.Path", -1, -1) && pathNode.hasNodeListProperty("pathElements")) {
if (pathNode.metaInfo().isSubclassOf("QtQuick.Path") && pathNode.hasNodeListProperty("pathElements")) {
QList<ModelNode> pathElements = pathNode.nodeListProperty("pathElements").toModelNodeList();
if (pathElements.isEmpty())
return 0;
......
......@@ -47,7 +47,7 @@ static bool isInEditedPath(const NodeAbstractProperty &propertyParent, const Mod
if (editingPathViewModelNode.isValid()) {
if (editingPathViewModelNode.hasNodeProperty("path")) {
ModelNode pathModelNode = editingPathViewModelNode.nodeProperty("path").modelNode();
if (pathModelNode.metaInfo().isSubclassOf("QtQuick.Path", -1, -1)) {
if (pathModelNode.metaInfo().isSubclassOf("QtQuick.Path")) {
if (propertyParent.name() == "pathElements" && propertyParent.parentModelNode() == pathModelNode)
return true;
}
......
......@@ -65,8 +65,8 @@ void TextEditItem::setFormEditorItem(FormEditorItem *formEditorItem)
NodeMetaInfo metaInfo = m_formEditorItem->qmlItemNode().modelNode().metaInfo();
if (metaInfo.isValid() &&
(metaInfo.isSubclassOf("QtQuick.TextEdit", -1, -1)
|| metaInfo.isSubclassOf("QtQuick.Controls.TextArea", -1, -1))) {
(metaInfo.isSubclassOf("QtQuick.TextEdit")
|| metaInfo.isSubclassOf("QtQuick.Controls.TextArea"))) {
QSize maximumSize = rect.size().toSize();
activateTextEdit(maximumSize);
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment