QmlDesigner: Add hints for visibility in library and navigator

Change-Id: If5d3a4c34a0010cc5a826296aa428a5915142659
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Thomas Hartmann
2019-04-29 12:09:12 +02:00
parent ee68989e2a
commit 63a646af9b
5 changed files with 31 additions and 6 deletions

View File

@@ -30,6 +30,7 @@
#include "itemlibrarysection.h"
#include <model.h>
#include <nodehints.h>
#include <nodemetainfo.h>
#include <utils/algorithm.h>
@@ -184,8 +185,10 @@ void ItemLibraryModel::update(ItemLibraryInfo *itemLibraryInfo, Model *model)
qDebug() << Utils::transform(metaInfo.superClasses(), &NodeMetaInfo::typeName);
}
bool forceVisiblity = valid && NodeHints::fromItemLibraryEntry(entry).visibleInLibrary();
if (valid
&& isItem //We can change if the navigator does support pure QObjects
&& (isItem || forceVisiblity) //We can change if the navigator does support pure QObjects
&& (entry.requiredImport().isEmpty()
|| model->hasImport(entryToImport(entry), true, true))) {
QString itemSectionName = entry.category();

View File

@@ -252,7 +252,7 @@ QList<ModelNode> filteredList(const NodeListProperty &property, bool filter)
return property.toModelNodeList();
return Utils::filtered(property.toModelNodeList(), [] (const ModelNode &arg) {
return QmlItemNode::isValidQmlItemNode(arg);
return QmlItemNode::isValidQmlItemNode(arg) || NodeHints::fromModelNode(arg).visibleInNavigator();
});
}

View File

@@ -48,6 +48,7 @@
#include <utils/utilsicons.h>
#include <QHeaderView>
#include <QTimer>
static inline void setScenePos(const QmlDesigner::ModelNode &modelNode,const QPointF &pos)
@@ -147,15 +148,21 @@ void NavigatorView::modelAttached(Model *model)
{
AbstractView::modelAttached(model);
m_currentModelInterface->setFilter(
DesignerSettings::getValue(DesignerSettingsKey::NAVIGATOR_SHOW_ONLY_VISIBLE_ITEMS).toBool());
QTreeView *treeView = treeWidget();
treeView->expandAll();
treeView->header()->setSectionResizeMode(0, QHeaderView::Stretch);
treeView->header()->resizeSection(1,26);
treeView->setIndentation(20);
m_currentModelInterface->setFilter(false);
QTimer::singleShot(0, this, [this, treeView]() {
m_currentModelInterface->setFilter(
DesignerSettings::getValue(DesignerSettingsKey::NAVIGATOR_SHOW_ONLY_VISIBLE_ITEMS).toBool());
treeView->expandAll();
});
#ifdef _LOCK_ITEMS_
treeView->header()->resizeSection(2,20);
#endif

View File

@@ -65,6 +65,8 @@ public:
bool canBeReparentedTo(const ModelNode &potenialParent);
QString indexPropertyForStackedContainer() const;
bool takesOverRenderingOfChildren() const;
bool visibleInNavigator() const;
bool visibleInLibrary() const;
QHash<QString, QString> hints() const;
static NodeHints fromModelNode(const ModelNode &modelNode);

View File

@@ -201,6 +201,19 @@ bool NodeHints::takesOverRenderingOfChildren() const
return evaluateBooleanExpression("takesOverRenderingOfChildren", false);
}
bool NodeHints::visibleInNavigator() const
{
if (!isValid())
return false;
return evaluateBooleanExpression("visibleInNavigator", false);
}
bool NodeHints::visibleInLibrary() const
{
return evaluateBooleanExpression("visibleInLibrary", true);
}
QHash<QString, QString> NodeHints::hints() const
{
return m_hints;