forked from qt-creator/qt-creator
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:
@@ -64,6 +64,13 @@ void ItemLibraryModel::setExpanded(bool expanded, const QString §ion)
|
||||
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,
|
||||
§ionChanged);
|
||||
|
||||
if (m_flowMode && itemLibrarySection->sectionName() != "My QML Components")
|
||||
sectionVisibility= false;
|
||||
|
||||
*changed |= sectionChanged;
|
||||
*changed |= itemLibrarySection->setVisible(sectionVisibility);
|
||||
}
|
||||
|
||||
@@ -73,6 +73,8 @@ public:
|
||||
|
||||
void setExpanded(bool, const QString §ion);
|
||||
|
||||
void setFlowMode(bool);
|
||||
|
||||
signals:
|
||||
void qmlModelChanged();
|
||||
void searchTextChanged();
|
||||
@@ -88,6 +90,7 @@ private: // variables
|
||||
QHash<int, QByteArray> m_roleNames;
|
||||
|
||||
QString m_searchText;
|
||||
bool m_flowMode = false;
|
||||
};
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "itemlibrarywidget.h"
|
||||
#include <import.h>
|
||||
#include <importmanagerview.h>
|
||||
#include <qmlitemnode.h>
|
||||
#include <rewriterview.h>
|
||||
|
||||
namespace QmlDesigner {
|
||||
@@ -68,6 +69,7 @@ void ItemLibraryView::modelAttached(Model *model)
|
||||
updateImports();
|
||||
model->attachView(m_importManagerView);
|
||||
m_hasErrors = !rewriterView()->errors().isEmpty();
|
||||
m_widget->setFlowMode(QmlItemNode(rootModelNode()).isFlowView());
|
||||
}
|
||||
|
||||
void ItemLibraryView::modelAboutToBeDetached(Model *model)
|
||||
|
||||
@@ -416,6 +416,11 @@ void ItemLibraryWidget::startDragAndDrop(QQuickItem *mouseArea, QVariant itemLib
|
||||
});
|
||||
}
|
||||
|
||||
void ItemLibraryWidget::setFlowMode(bool b)
|
||||
{
|
||||
m_itemLibraryModel->setFlowMode(b);
|
||||
}
|
||||
|
||||
void ItemLibraryWidget::removeImport(const QString &name)
|
||||
{
|
||||
QTC_ASSERT(m_model, return);
|
||||
|
||||
@@ -86,6 +86,8 @@ public:
|
||||
|
||||
Q_INVOKABLE void startDragAndDrop(QQuickItem *mouseArea, QVariant itemLibId);
|
||||
|
||||
void setFlowMode(bool b);
|
||||
|
||||
signals:
|
||||
void itemActivated(const QString& itemName);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user