Commit f4ae2546 authored by Daniel Molkentin's avatar Daniel Molkentin Committed by Eike Ziller
Browse files

Copy dependencies specified in manifest file.



Change-Id: I7e97af90cb7cd4c93abe2330cfbd92581b2be22e
Reviewed-by: default avatarEike Ziller <eike.ziller@nokia.com>
parent a1e707f9
......@@ -294,7 +294,7 @@ Item {
script: {
delegate.state = "";
if (model.hasSourceCode)
gettingStarted.openProject(model.projectPath, model.filesToOpen, model.docUrl)
gettingStarted.openProject(model.projectPath, model.filesToOpen, model.docUrl, model.dependencies)
else
gettingStarted.openSplitHelp(model.docUrl);
}
......
......@@ -65,6 +65,7 @@ ExamplesListModel::ExamplesListModel(QObject *parent) :
roleNames[Difficulty] = "difficulty";
roleNames[Type] = "type";
roleNames[HasSourceCode] = "hasSourceCode";
roleNames[Dependencies] = "dependencies";
setRoleNames(roleNames);
connect(QtVersionManager::instance(), SIGNAL(updateExamples(QString,QString,QString)),
......@@ -73,7 +74,7 @@ ExamplesListModel::ExamplesListModel(QObject *parent) :
SLOT(helpInitialized()));
}
static inline QString fixSTringForTags(const QString &string)
static inline QString fixStringForTags(const QString &string)
{
QString returnString = string;
returnString.remove(QLatin1String("<i>"));
......@@ -104,7 +105,9 @@ QList<ExampleItem> ExamplesListModel::parseExamples(QXmlStreamReader* reader, co
} else if (reader->name() == QLatin1String("fileToOpen")) {
item.filesToOpen.append(projectsOffset + '/' + reader->readElementText(QXmlStreamReader::ErrorOnUnexpectedElement));
} else if (reader->name() == QLatin1String("description")) {
item.description = fixSTringForTags(reader->readElementText(QXmlStreamReader::ErrorOnUnexpectedElement));
item.description = fixStringForTags(reader->readElementText(QXmlStreamReader::ErrorOnUnexpectedElement));
} else if (reader->name() == QLatin1String("dependency")) {
item.dependencies.append(projectsOffset + '/' + reader->readElementText(QXmlStreamReader::ErrorOnUnexpectedElement));
} else if (reader->name() == QLatin1String("tags")) {
item.tags = reader->readElementText(QXmlStreamReader::ErrorOnUnexpectedElement).split(",");
m_tags.append(item.tags);
......@@ -144,7 +147,9 @@ QList<ExampleItem> ExamplesListModel::parseDemos(QXmlStreamReader* reader, const
} else if (reader->name() == QLatin1String("fileToOpen")) {
item.filesToOpen.append(projectsOffset + '/' + reader->readElementText(QXmlStreamReader::ErrorOnUnexpectedElement));
} else if (reader->name() == QLatin1String("description")) {
item.description = fixSTringForTags(reader->readElementText(QXmlStreamReader::ErrorOnUnexpectedElement));
item.description = fixStringForTags(reader->readElementText(QXmlStreamReader::ErrorOnUnexpectedElement));
} else if (reader->name() == QLatin1String("dependency")) {
item.dependencies.append(projectsOffset + '/' + reader->readElementText(QXmlStreamReader::ErrorOnUnexpectedElement));
} else if (reader->name() == QLatin1String("tags")) {
item.tags = reader->readElementText(QXmlStreamReader::ErrorOnUnexpectedElement).split(",");
}
......@@ -183,7 +188,9 @@ QList<ExampleItem> ExamplesListModel::parseTutorials(QXmlStreamReader* reader, c
} else if (reader->name() == QLatin1String("fileToOpen")) {
item.filesToOpen.append(projectsOffset + '/' + reader->readElementText(QXmlStreamReader::ErrorOnUnexpectedElement));
} else if (reader->name() == QLatin1String("description")) {
item.description = fixSTringForTags(reader->readElementText(QXmlStreamReader::ErrorOnUnexpectedElement));
item.description = fixStringForTags(reader->readElementText(QXmlStreamReader::ErrorOnUnexpectedElement));
} else if (reader->name() == QLatin1String("dependency")) {
item.dependencies.append(projectsOffset + '/' + reader->readElementText(QXmlStreamReader::ErrorOnUnexpectedElement));
} else if (reader->name() == QLatin1String("tags")) {
item.tags = reader->readElementText(QXmlStreamReader::ErrorOnUnexpectedElement).split(",");
}
......@@ -362,6 +369,8 @@ QVariant ExamplesListModel::data(const QModelIndex &index, int role) const
return item.tags;
case Difficulty:
return item.difficulty;
case Dependencies:
return item.dependencies;
case HasSourceCode:
return item.hasSourceCode;
case Type:
......
......@@ -42,7 +42,7 @@ namespace QtSupport {
namespace Internal {
enum ExampleRoles { Name=Qt::UserRole, ProjectPath, Description, ImageUrl,
DocUrl, FilesToOpen, Tags, Difficulty, HasSourceCode, Type };
DocUrl, FilesToOpen, Tags, Difficulty, HasSourceCode, Type, Dependencies };
enum InstructionalType { Example=0, Demo, Tutorial };
......@@ -56,6 +56,7 @@ struct ExampleItem {
QString docUrl;
QStringList filesToOpen;
QStringList tags;
QStringList dependencies;
int difficulty;
bool hasSourceCode;
};
......
......@@ -47,6 +47,7 @@
#include <QtCore/QMutexLocker>
#include <QtCore/QWeakPointer>
#include <QtCore/QWaitCondition>
#include <QtCore/QDir>
#include <QtGui/QGraphicsProxyWidget>
#include <QtGui/QScrollBar>
#include <QtGui/QSortFilterProxyModel>
......@@ -254,7 +255,7 @@ QStringList GettingStartedWelcomePage::tagList() const
return examplesModel()->tags();
}
QString GettingStartedWelcomePage::copyToAlternativeLocation(const QFileInfo& proFileInfo, QStringList &filesToOpen)
QString GettingStartedWelcomePage::copyToAlternativeLocation(const QFileInfo& proFileInfo, QStringList &filesToOpen, const QStringList& dependencies)
{
const QString projectDir = proFileInfo.canonicalPath();
QDialog d(Core::ICore::instance()->mainWindow());
......@@ -309,6 +310,15 @@ QString GettingStartedWelcomePage::copyToAlternativeLocation(const QFileInfo& pr
for (it = filesToOpen.begin(); it != filesToOpen.end(); ++it)
it->replace(projectDir, targetDir);
foreach (const QString &dependency, dependencies) {
QString dirName = QDir(dependency).dirName();
if (!Utils::FileUtils::copyRecursively(dependency, targetDir + QDir::separator()+ dirName, &error)) {
QMessageBox::warning(Core::ICore::instance()->mainWindow(), tr("Cannot Copy Project"), error);
// do not fail, just warn;
}
}
return targetDir+ '/' + proFileInfo.fileName();
} else {
QMessageBox::warning(Core::ICore::instance()->mainWindow(), tr("Cannot Copy Project"), error);
......@@ -320,7 +330,8 @@ QString GettingStartedWelcomePage::copyToAlternativeLocation(const QFileInfo& pr
}
void GettingStartedWelcomePage::openProject(const QString &projectFile, const QStringList &additionalFilesToOpen, const QUrl &help)
void GettingStartedWelcomePage::openProject(const QString &projectFile, const QStringList &additionalFilesToOpen,
const QUrl &help, const QStringList &dependencies)
{
QString proFile = projectFile;
if (proFile.isEmpty())
......@@ -330,7 +341,7 @@ void GettingStartedWelcomePage::openProject(const QString &projectFile, const QS
QFileInfo proFileInfo(proFile);
// If the Qt is a distro Qt on Linux, it will not be writable, hence compilation will fail
if (!proFileInfo.isWritable())
proFile = copyToAlternativeLocation(proFileInfo, filesToOpen);
proFile = copyToAlternativeLocation(proFileInfo, filesToOpen, dependencies);
// don't try to load help and files if loading the help request is being cancelled
QString errorMessage;
......
......@@ -68,12 +68,13 @@ signals:
public slots:
void openSplitHelp(const QUrl &help);
void openProject(const QString& projectFile, const QStringList& additionalFilesToOpen, const QUrl& help);
void openProject(const QString& projectFile, const QStringList& additionalFilesToOpen,
const QUrl& help, const QStringList &dependencies);
void updateTagsModel();
private:
ExamplesListModel *examplesModel() const;
QString copyToAlternativeLocation(const QFileInfo &fileInfo, QStringList &filesToOpen);
QString copyToAlternativeLocation(const QFileInfo &fileInfo, QStringList &filesToOpen, const QStringList &dependencies);
QDeclarativeEngine *m_engine;
bool m_showExamples;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment