summaryrefslogtreecommitdiff
path: root/src/libs/3rdparty
diff options
context:
space:
mode:
authorJochen Becher <jochen_becher@gmx.de>2015-12-14 22:42:44 +0100
committerJochen Becher <jochen_becher@gmx.de>2016-01-04 12:18:09 +0000
commit9c6262124c0d81e2edf704fc4854e398730feb58 (patch)
treef8af591c1ae1109574cc8829d9cbcbfb89499ee1 /src/libs/3rdparty
parente9cffc1b74917ce6fc50f235cb76ab74252b04f2 (diff)
downloadqt-creator-9c6262124c0d81e2edf704fc4854e398730feb58.tar.gz
ModelEditor: Support model specific customization
If the model contains a configuration path to a configuration file (or a directory of configuration files) the configuration is loaded for that model only. The file path may be relative to the model file. No UI support for this feature yet. Change-Id: Ia3615da3e57fc4731926a5970ba1b2f741d64e21 Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
Diffstat (limited to 'src/libs/3rdparty')
-rw-r--r--src/libs/3rdparty/modeling/qmt/config/configcontroller.cpp26
-rw-r--r--src/libs/3rdparty/modeling/qmt/project/project.cpp5
-rw-r--r--src/libs/3rdparty/modeling/qmt/project/project.h3
-rw-r--r--src/libs/3rdparty/modeling/qmt/serializer/projectserializer.cpp1
4 files changed, 32 insertions, 3 deletions
diff --git a/src/libs/3rdparty/modeling/qmt/config/configcontroller.cpp b/src/libs/3rdparty/modeling/qmt/config/configcontroller.cpp
index 073a4ce917..ec7b9a5f03 100644
--- a/src/libs/3rdparty/modeling/qmt/config/configcontroller.cpp
+++ b/src/libs/3rdparty/modeling/qmt/config/configcontroller.cpp
@@ -68,15 +68,32 @@ void ConfigController::setStereotypeController(StereotypeController *stereotypeC
void ConfigController::readStereotypeDefinitions(const QString &path)
{
+ if (path.isEmpty()) {
+ // TODO add error handling
+ return;
+ }
+
StereotypeDefinitionParser parser;
connect(&parser, &StereotypeDefinitionParser::iconParsed,
this, &ConfigController::onStereotypeIconParsed);
connect(&parser, &StereotypeDefinitionParser::toolbarParsed,
this, &ConfigController::onToolbarParsed);
- QDir dir(path);
- dir.setNameFilters(QStringList() << QStringLiteral("*.def"));
- foreach (const QString &fileName, dir.entryList(QDir::Files)) {
+ QStringList fileNames;
+ QDir dir;
+ QFileInfo fileInfo(path);
+ if (fileInfo.isFile()) {
+ dir.setPath(fileInfo.path());
+ fileNames.append(fileInfo.fileName());
+ } else if (fileInfo.isDir()) {
+ dir.setPath(path);
+ dir.setNameFilters(QStringList() << QStringLiteral("*.def"));
+ fileNames = dir.entryList(QDir::Files);
+ } else {
+ // TODO add error handling
+ return;
+ }
+ foreach (const QString &fileName, fileNames) {
QFile file(QFileInfo(dir, fileName).absoluteFilePath());
if (file.open(QIODevice::ReadOnly)) {
QString text = QString::fromUtf8(file.readAll());
@@ -87,10 +104,13 @@ void ConfigController::readStereotypeDefinitions(const QString &path)
try {
parser.parse(&source);
} catch (StereotypeDefinitionParserError x) {
+ // TODO add error handling
qDebug() << x.errorMessage() << "in line" << x.sourcePos().lineNumber();
} catch (TextScannerError x) {
+ // TODO add error handling
qDebug() << x.errorMessage() << "in line" << x.sourcePos().lineNumber();
} catch (...) {
+ // TODO add error handling
}
}
}
diff --git a/src/libs/3rdparty/modeling/qmt/project/project.cpp b/src/libs/3rdparty/modeling/qmt/project/project.cpp
index d949489b4b..dcc002c753 100644
--- a/src/libs/3rdparty/modeling/qmt/project/project.cpp
+++ b/src/libs/3rdparty/modeling/qmt/project/project.cpp
@@ -60,4 +60,9 @@ void Project::setRootPackage(MPackage *rootPackage)
m_rootPackage = rootPackage;
}
+void Project::setConfigPath(const QString &configPath)
+{
+ m_configPath = configPath;
+}
+
} // namespace qmt
diff --git a/src/libs/3rdparty/modeling/qmt/project/project.h b/src/libs/3rdparty/modeling/qmt/project/project.h
index 17f5ccc6d0..f572385e65 100644
--- a/src/libs/3rdparty/modeling/qmt/project/project.h
+++ b/src/libs/3rdparty/modeling/qmt/project/project.h
@@ -52,11 +52,14 @@ public:
void setFileName(const QString &fileName);
MPackage *rootPackage() const { return m_rootPackage; }
void setRootPackage(MPackage *rootPackage);
+ QString configPath() const { return m_configPath; }
+ void setConfigPath(const QString &configPath);
private:
Uid m_uid;
QString m_fileName;
MPackage *m_rootPackage;
+ QString m_configPath;
};
} // namespace qmt
diff --git a/src/libs/3rdparty/modeling/qmt/serializer/projectserializer.cpp b/src/libs/3rdparty/modeling/qmt/serializer/projectserializer.cpp
index 7b9e69628b..09442bd21d 100644
--- a/src/libs/3rdparty/modeling/qmt/serializer/projectserializer.cpp
+++ b/src/libs/3rdparty/modeling/qmt/serializer/projectserializer.cpp
@@ -59,6 +59,7 @@ void serialize(Archive &archive, Project &project)
archive || qark::tag(QStringLiteral("project"), project)
|| qark::attr(QStringLiteral("uid"), project, &Project::uid, &Project::setUid)
|| qark::attr(QStringLiteral("root-package"), project, &Project::rootPackage, &Project::setRootPackage)
+ || qark::attr(QStringLiteral("config-path"), project, &Project::configPath, &Project::setConfigPath)
|| qark::end;
}