forked from qt-creator/qt-creator
ModelEditor: Minor refactoring of ComponentViewController
Change-Id: I6c54c694e77b377b9c0d0d2a4abe41d6976ede09 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -344,7 +344,7 @@ void ComponentViewController::doCreateComponentModel(const QString &filePath, qm
|
|||||||
case CppTools::ProjectFile::CXXHeader:
|
case CppTools::ProjectFile::CXXHeader:
|
||||||
case CppTools::ProjectFile::ObjCHeader:
|
case CppTools::ProjectFile::ObjCHeader:
|
||||||
case CppTools::ProjectFile::ObjCXXHeader:
|
case CppTools::ProjectFile::ObjCXXHeader:
|
||||||
isSource = scanHeaders && !isProxyHeader(file);
|
isSource = scanHeaders && !d->pxnodeUtilities->isProxyHeader(file);
|
||||||
break;
|
break;
|
||||||
case CppTools::ProjectFile::Unclassified:
|
case CppTools::ProjectFile::Unclassified:
|
||||||
case CppTools::ProjectFile::Unsupported:
|
case CppTools::ProjectFile::Unsupported:
|
||||||
@@ -374,20 +374,5 @@ void ComponentViewController::doCreateComponentModel(const QString &filePath, qm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ComponentViewController::isProxyHeader(const QString &file) const
|
|
||||||
{
|
|
||||||
CppTools::CppModelManager *cppModelManager = CppTools::CppModelManager::instance();
|
|
||||||
CPlusPlus::Snapshot snapshot = cppModelManager->snapshot();
|
|
||||||
|
|
||||||
CPlusPlus::Document::Ptr document = snapshot.document(file);
|
|
||||||
if (document) {
|
|
||||||
QList<CPlusPlus::Document::Include> includes = document->resolvedIncludes();
|
|
||||||
if (includes.count() != 1)
|
|
||||||
return false;
|
|
||||||
return QFileInfo(includes.at(0).resolvedFileName()).fileName() == QFileInfo(file).fileName();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace ModelEditor
|
} // namespace ModelEditor
|
||||||
|
@@ -64,7 +64,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
void doCreateComponentModel(const QString &filePath, qmt::MDiagram *diagram,
|
void doCreateComponentModel(const QString &filePath, qmt::MDiagram *diagram,
|
||||||
const QString &anchorFolder, bool scanHeaders);
|
const QString &anchorFolder, bool scanHeaders);
|
||||||
bool isProxyHeader(const QString &file) const;
|
|
||||||
|
|
||||||
ComponentViewControllerPrivate *d;
|
ComponentViewControllerPrivate *d;
|
||||||
};
|
};
|
||||||
|
@@ -30,6 +30,9 @@
|
|||||||
#include "qmt/tasks/diagramscenecontroller.h"
|
#include "qmt/tasks/diagramscenecontroller.h"
|
||||||
#include "qmt/model_controller/modelcontroller.h"
|
#include "qmt/model_controller/modelcontroller.h"
|
||||||
|
|
||||||
|
#include <cpptools/cppmodelmanager.h>
|
||||||
|
#include <cplusplus/CppDocument.h>
|
||||||
|
|
||||||
#include <projectexplorer/projectnodes.h>
|
#include <projectexplorer/projectnodes.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
@@ -234,5 +237,20 @@ qmt::MObject *PxNodeUtilities::findSameObject(const QStringList &relativeElement
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PxNodeUtilities::isProxyHeader(const QString &file) const
|
||||||
|
{
|
||||||
|
CppTools::CppModelManager *cppModelManager = CppTools::CppModelManager::instance();
|
||||||
|
CPlusPlus::Snapshot snapshot = cppModelManager->snapshot();
|
||||||
|
|
||||||
|
CPlusPlus::Document::Ptr document = snapshot.document(file);
|
||||||
|
if (document) {
|
||||||
|
QList<CPlusPlus::Document::Include> includes = document->resolvedIncludes();
|
||||||
|
if (includes.count() != 1)
|
||||||
|
return false;
|
||||||
|
return QFileInfo(includes.at(0).resolvedFileName()).fileName() == QFileInfo(file).fileName();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace ModelEditor
|
} // namespace ModelEditor
|
||||||
|
@@ -56,6 +56,7 @@ public:
|
|||||||
const QStringList &relativeElements);
|
const QStringList &relativeElements);
|
||||||
qmt::MObject *findSameObject(const QStringList &relativeElements,
|
qmt::MObject *findSameObject(const QStringList &relativeElements,
|
||||||
const qmt::MObject *object);
|
const qmt::MObject *object);
|
||||||
|
bool isProxyHeader(const QString &file) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PxNodeUtilitiesPrivate *d;
|
PxNodeUtilitiesPrivate *d;
|
||||||
|
Reference in New Issue
Block a user