forked from qt-creator/qt-creator
Changed the import notifications to distinguish between adds/removes.
This commit is contained in:
@@ -120,7 +120,8 @@ public:
|
||||
|
||||
virtual void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex) = 0;
|
||||
|
||||
virtual void importsChanged();
|
||||
virtual void importAdded(const Import &import);
|
||||
virtual void importRemoved(const Import &import);
|
||||
|
||||
virtual void auxiliaryDataChanged(const ModelNode &node, const QString &name, const QVariant &data);
|
||||
|
||||
|
||||
@@ -71,7 +71,8 @@ public:
|
||||
|
||||
void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex);
|
||||
|
||||
void importsChanged();
|
||||
void importAdded(const Import &import);
|
||||
void importRemoved(const Import &import);
|
||||
|
||||
void auxiliaryDataChanged(const ModelNode &node, const QString &name, const QVariant &data);
|
||||
|
||||
@@ -218,12 +219,21 @@ void ForwardView<ViewType>::nodeOrderChanged(const NodeListProperty &listPropert
|
||||
}
|
||||
|
||||
template <class ViewType>
|
||||
void ForwardView<ViewType>::importsChanged()
|
||||
void ForwardView<ViewType>::importAdded(const Import &import)
|
||||
{
|
||||
AbstractView::importsChanged();
|
||||
AbstractView::importAdded(import);
|
||||
|
||||
foreach (const ViewTypePointer &view, m_targetViewList)
|
||||
view->importsChanged();
|
||||
view->importAdded(import);
|
||||
}
|
||||
|
||||
template <class ViewType>
|
||||
void ForwardView<ViewType>::importRemoved(const Import &import)
|
||||
{
|
||||
AbstractView::importRemoved(import);
|
||||
|
||||
foreach (const ViewTypePointer &view, m_targetViewList)
|
||||
view->importRemoved(import);
|
||||
}
|
||||
|
||||
template <class ViewType>
|
||||
|
||||
@@ -125,6 +125,9 @@ public:
|
||||
void nodeTypeChanged(const ModelNode &node,const QString &type, int majorVersion, int minorVersion);
|
||||
void customNotification(const AbstractView *view, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data);
|
||||
|
||||
void importAdded(const Import &import);
|
||||
void importRemoved(const Import &import);
|
||||
|
||||
void fileUrlChanged(const QUrl &oldUrl, const QUrl &newUrl);
|
||||
|
||||
void selectedNodesChanged(const QList<ModelNode> &selectedNodeList, const QList<ModelNode> &lastSelectedNodeList);
|
||||
|
||||
@@ -203,10 +203,18 @@ void AbstractView::fileUrlChanged(const QUrl &/*oldUrl*/, const QUrl &/*newUrl*/
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn AbstractView::importsChanged()
|
||||
\brief Called when the imports for the model change.
|
||||
\fn AbstractView::importAdded(const Import &import)
|
||||
\brief Called when an import has been added to the model
|
||||
*/
|
||||
void AbstractView::importsChanged()
|
||||
void AbstractView::importAdded(const Import &/*import*/)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn AbstractView::importRemoved(const Import &import)
|
||||
\brief Called when an import has been removed from the model
|
||||
*/
|
||||
void AbstractView::importRemoved(const Import &/*import*/)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -117,26 +117,13 @@ Model *ModelPrivate::create(QString type, int major, int minor)
|
||||
return model;
|
||||
}
|
||||
|
||||
void ModelPrivate::setImports(const QSet<Import> &imports)
|
||||
{
|
||||
QList<Import> added = QSet<Import>(imports).subtract(m_imports).toList();
|
||||
QList<Import> removed = QSet<Import>(m_imports).subtract(imports).toList();
|
||||
|
||||
if (added.isEmpty() && removed.isEmpty())
|
||||
return;
|
||||
|
||||
m_imports = imports;
|
||||
|
||||
notifyImportsChanged();
|
||||
}
|
||||
|
||||
void ModelPrivate::addImport(const Import &import)
|
||||
{
|
||||
if (m_imports.contains(import))
|
||||
return;
|
||||
|
||||
m_imports.insert(import);
|
||||
notifyImportsChanged();
|
||||
notifyImportAdded(import);
|
||||
}
|
||||
|
||||
void ModelPrivate::removeImport(const Import &import)
|
||||
@@ -144,13 +131,19 @@ void ModelPrivate::removeImport(const Import &import)
|
||||
if (!m_imports.remove(import))
|
||||
return;
|
||||
|
||||
notifyImportsChanged();
|
||||
notifyImportRemoved(import);
|
||||
}
|
||||
|
||||
void ModelPrivate::notifyImportsChanged() const
|
||||
void ModelPrivate::notifyImportAdded(const Import &import) const
|
||||
{
|
||||
foreach (const QWeakPointer<AbstractView> &view, m_viewList)
|
||||
view->importsChanged();
|
||||
view->importAdded(import);
|
||||
}
|
||||
|
||||
void ModelPrivate::notifyImportRemoved(const Import &import) const
|
||||
{
|
||||
foreach (const QWeakPointer<AbstractView> &view, m_viewList)
|
||||
view->importRemoved(import);
|
||||
}
|
||||
|
||||
QUrl ModelPrivate::fileUrl() const
|
||||
|
||||
@@ -155,10 +155,10 @@ public:
|
||||
|
||||
// Imports:
|
||||
QSet<Import> imports() const { return m_imports; }
|
||||
void setImports(const QSet<Import> &imports);
|
||||
void addImport(const Import &import);
|
||||
void removeImport(const Import &import);
|
||||
void notifyImportsChanged() const;
|
||||
void notifyImportAdded(const Import &import) const;
|
||||
void notifyImportRemoved(const Import &import) const;
|
||||
|
||||
|
||||
//node state property manipulation
|
||||
|
||||
@@ -261,6 +261,30 @@ void RewriterView::nodeReparented(const ModelNode &node, const NodeAbstractPrope
|
||||
applyChanges();
|
||||
}
|
||||
|
||||
void RewriterView::importAdded(const Import &import)
|
||||
{
|
||||
Q_ASSERT(textModifier());
|
||||
if (textToModelMerger()->isActive())
|
||||
return;
|
||||
|
||||
modelToTextMerger()->addImport(import);
|
||||
|
||||
if (!isModificationGroupActive())
|
||||
applyChanges();
|
||||
}
|
||||
|
||||
void RewriterView::importRemoved(const Import &import)
|
||||
{
|
||||
Q_ASSERT(textModifier());
|
||||
if (textToModelMerger()->isActive())
|
||||
return;
|
||||
|
||||
modelToTextMerger()->removeImport(import);
|
||||
|
||||
if (!isModificationGroupActive())
|
||||
applyChanges();
|
||||
}
|
||||
|
||||
void RewriterView::fileUrlChanged(const QUrl &/*oldUrl*/, const QUrl &/*newUrl*/)
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user