QmlDesigner: Add static helper functions

Change-Id: If89619a7fe75b09afa53e2b33464364deccfcaee
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Thomas Hartmann
2018-02-12 16:54:52 +01:00
parent 7081ec8bec
commit ca6d4a8877
2 changed files with 35 additions and 0 deletions

View File

@@ -81,6 +81,7 @@ static inline QHash<PropertyName, QVariant> getProperties(const ModelNode &node)
propertyHash.remove("opacity");
}
}
return propertyHash;
}
@@ -326,6 +327,21 @@ Utils::FileName DocumentManager::currentFilePath()
return QmlDesignerPlugin::instance()->documentManager().currentDesignDocument()->fileName();
}
Utils::FileName DocumentManager::currentProjectDirPath()
{
QTC_ASSERT(QmlDesignerPlugin::instance(), return {});
if (!QmlDesignerPlugin::instance()->currentDesignDocument())
return {};
Utils::FileName qmlFileName = QmlDesignerPlugin::instance()->currentDesignDocument()->fileName();
ProjectExplorer::Project *project = ProjectExplorer::SessionManager::projectForFile(qmlFileName);
if (!project)
return {};
return project->projectDirectory();
}
QStringList DocumentManager::isoIconsQmakeVariableValue(const QString &proPath)
{
ProjectExplorer::Node *node = ProjectExplorer::ProjectTree::nodeForFile(Utils::FileName::fromString(proPath));
@@ -463,5 +479,22 @@ bool DocumentManager::addResourceFileToIsoProject(const QString &resourceFilePro
return true;
}
bool DocumentManager::belongsToQmakeProject()
{
QTC_ASSERT(QmlDesignerPlugin::instance(), return false);
if (!QmlDesignerPlugin::instance()->currentDesignDocument())
return false;
Utils::FileName qmlFileName = QmlDesignerPlugin::instance()->currentDesignDocument()->fileName();
ProjectExplorer::Project *project = ProjectExplorer::SessionManager::projectForFile(qmlFileName);
if (!project)
return false;
ProjectExplorer::Node *rootNode = project->rootProjectNode();
QmakeProjectManager::QmakeProFileNode *proNode = dynamic_cast<QmakeProjectManager::QmakeProFileNode*>(rootNode);
return proNode;
}
} // namespace QmlDesigner

View File

@@ -56,6 +56,7 @@ public:
static bool createFile(const QString &filePath, const QString &contents);
static void addFileToVersionControl(const QString &directoryPath, const QString &newFilePath);
static Utils::FileName currentFilePath();
static Utils::FileName currentProjectDirPath();
static QStringList isoIconsQmakeVariableValue(const QString &proPath);
static bool setIsoIconsQmakeVariableValue(const QString &proPath, const QStringList &value);
@@ -63,6 +64,7 @@ public:
QString *resourceFileProPath, const QString &isoIconsQrcFile);
static bool isoProFileSupportsAddingExistingFiles(const QString &resourceFileProPath);
static bool addResourceFileToIsoProject(const QString &resourceFileProPath, const QString &resourceFilePath);
static bool belongsToQmakeProject();
private:
QHash<Core::IEditor *,QPointer<DesignDocument> > m_designDocumentHash;