Skip to content

Commit

Permalink
Fixes for world model (#1031)
Browse files Browse the repository at this point in the history
  • Loading branch information
IKhonakhbeeva authored Aug 2, 2020
1 parent e3bdb27 commit 98cc668
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,8 @@ void TwoDModelWidget::loadWorldModelWithoutRobot()
auto currentRobot = generateWorldModelXml().firstChildElement("root")
.firstChildElement("robots").firstChildElement("robot");

saveRobot.replaceChild(saveRobot.firstChildElement("sensors"), currentRobot.firstChildElement("sensors"));
saveRobot.replaceChild(saveRobot.firstChildElement("wheels"), currentRobot.firstChildElement("wheels"));
saveRobot.replaceChild(currentRobot.firstChildElement("sensors"), saveRobot.firstChildElement("sensors"));
saveRobot.replaceChild(currentRobot.firstChildElement("wheels"), saveRobot.firstChildElement("wheels"));
saveRobot.setAttribute("id", currentRobot.attribute("id"));

auto command = new commands::LoadWorldCommand(*this, save);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ void SubprogramsImporterExporterPlugin::importToProject() const
for (const auto &diagram : openedDiagrams) {
mMainWindowInterpretersInterface->activateItemOrDiagram(diagram);
}
mLogicalModel->mutableLogicalRepoApi().clearMetaInformation();
for (const auto &metaKey : oldMeta.keys()) {
mLogicalModel->mutableLogicalRepoApi().setMetaInformation(metaKey, oldMeta[metaKey]);
}
Expand Down Expand Up @@ -269,6 +270,7 @@ void SubprogramsImporterExporterPlugin::importFromCollectionTriggered() const
for (const auto &diagram : openedDiagrams) {
mMainWindowInterpretersInterface->activateItemOrDiagram(diagram);
}
mLogicalModel->mutableLogicalRepoApi().clearMetaInformation();
for (const auto &metaKey : oldMeta.keys()) {
mLogicalModel->mutableLogicalRepoApi().setMetaInformation(metaKey, oldMeta[metaKey]);
}
Expand Down
3 changes: 3 additions & 0 deletions qrrepo/logicalRepoApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,8 @@ class LogicalRepoApi : public CommonRepoApi

/// Stores the meta-information for current stored binded to the given key.
virtual void setMetaInformation(const QString &key, const QVariant &info) = 0;

/// Clear the meta-information.
virtual void clearMetaInformation() = 0;
};
}
5 changes: 5 additions & 0 deletions qrrepo/private/repoApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,3 +639,8 @@ void RepoApi::setMetaInformation(const QString &key, const QVariant &info)
{
mRepository->setMetaInformation(key, info);
}

void RepoApi::clearMetaInformation()
{
mRepository->clearMetaInformation();
}
5 changes: 5 additions & 0 deletions qrrepo/private/repository.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,3 +629,8 @@ void Repository::setMetaInformation(const QString &key, const QVariant &info)
{
mMetaInfo[key] = info;
}

void Repository::clearMetaInformation()
{
mMetaInfo.clear();
}
3 changes: 3 additions & 0 deletions qrrepo/private/repository.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ class Repository
/// Stores the meta-information for current stored binded to the given key.
void setMetaInformation(const QString &key, const QVariant &info);

/// Clear the meta-information.
void clearMetaInformation();

private:
void init();

Expand Down
1 change: 1 addition & 0 deletions qrrepo/repoApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ class QRREPO_EXPORT RepoApi : public GraphicalRepoApi, public LogicalRepoApi, pu
QStringList metaInformationKeys() const override;
QVariant metaInformation(const QString &key) const override;
void setMetaInformation(const QString &key, const QVariant &info) override;
void clearMetaInformation() override;

private:
RepoApi(const RepoApi &other); // Copying is not allowed.
Expand Down
2 changes: 1 addition & 1 deletion qrtranslations/ru/plugins/robots/twoDModel_ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@
<message>
<location line="+44"/>
<source>Robot track:</source>
<translation>Колейность робота:</translation>
<translation>Колея робота:</translation>
</message>
</context>
<context>
Expand Down
6 changes: 3 additions & 3 deletions qrtranslations/ru/plugins/subprogramsImporterExporter_ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
<translation>В проекте нет подпрограмм.</translation>
</message>
<message>
<location line="+78"/>
<location line="+79"/>
<source>There are not subprograms in your project</source>
<translation>В проекте нет подпрограмм</translation>
</message>
Expand All @@ -101,12 +101,12 @@
<translation>В коллекции нет подпрограмм для робота %1</translation>
</message>
<message>
<location line="-97"/>
<location line="-98"/>
<source>Select subprograms file</source>
<translation>Выберите файл с подпрограммами</translation>
</message>
<message>
<location line="+143"/>
<location line="+145"/>
<source>Clear the collection</source>
<translation type="unfinished"></translation>
</message>
Expand Down

0 comments on commit 98cc668

Please sign in to comment.