QmlDesigner: Add flow mode to ItemLibrary

If in flow mode we only show FlowItems.

Change-Id: I7d41155eac8bc180c7ac1d0092b35d7fc3f9be91
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Thomas Hartmann
2020-01-29 12:28:30 +01:00
parent bff9d65729
commit 868e3133c0
5 changed files with 29 additions and 0 deletions

View File

@@ -64,6 +64,13 @@ void ItemLibraryModel::setExpanded(bool expanded, const QString &section)
collapsedStateHash.insert(section, expanded);
}
void ItemLibraryModel::setFlowMode(bool b)
{
m_flowMode = b;
bool changed;
updateVisibility(&changed);
}
ItemLibraryModel::ItemLibraryModel(QObject *parent)
: QAbstractListModel(parent)
{
@@ -187,6 +194,12 @@ void ItemLibraryModel::update(ItemLibraryInfo *itemLibraryInfo, Model *model)
bool forceVisiblity = valid && NodeHints::fromItemLibraryEntry(entry).visibleInLibrary();
if (m_flowMode) {
forceVisiblity = false;
isItem = metaInfo.isSubclassOf("FlowView.FlowItem");
}
if (valid
&& (isItem || forceVisiblity) //We can change if the navigator does support pure QObjects
&& (entry.requiredImport().isEmpty()
@@ -262,6 +275,10 @@ void ItemLibraryModel::updateVisibility(bool *changed)
bool sectionChanged = false;
bool sectionVisibility = itemLibrarySection->updateSectionVisibility(sectionSearchText,
&sectionChanged);
if (m_flowMode && itemLibrarySection->sectionName() != "My QML Components")
sectionVisibility= false;
*changed |= sectionChanged;
*changed |= itemLibrarySection->setVisible(sectionVisibility);
}