Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
614776f5
Commit
614776f5
authored
2 years ago
by
Mikhail Svechnikov
Committed by
Mikhail Svechnikov
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
ProjectDocument: shorten var names
parent
4055e256
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!1191
GUI: serialization refactoring part 3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
GUI/Model/Project/ProjectDocument.cpp
+49
-49
49 additions, 49 deletions
GUI/Model/Project/ProjectDocument.cpp
with
49 additions
and
49 deletions
GUI/Model/Project/ProjectDocument.cpp
+
49
−
49
View file @
614776f5
...
...
@@ -302,37 +302,37 @@ void ProjectDocument::onModelChanged()
void
ProjectDocument
::
writeProject
(
QIODevice
*
device
)
{
QXmlStreamWriter
w
riter
(
device
);
w
riter
.
setAutoFormatting
(
true
);
w
riter
.
writeStartDocument
();
w
riter
.
writeStartElement
(
Tag
::
BornAgain
);
QXmlStreamWriter
w
(
device
);
w
.
setAutoFormatting
(
true
);
w
.
writeStartDocument
();
w
.
writeStartElement
(
Tag
::
BornAgain
);
QString
version_string
=
GUI
::
Util
::
Path
::
getBornAgainVersionString
();
w
riter
.
writeAttribute
(
XML
::
Attrib
::
BA_Version
,
version_string
);
Streamer
(
&
w
riter
).
writeVersion
(
2
);
w
.
writeAttribute
(
XML
::
Attrib
::
BA_Version
,
version_string
);
Streamer
(
&
w
).
writeVersion
(
2
);
w
riter
.
writeStartElement
(
Tag
::
DocumentInfo
);
w
riter
.
writeAttribute
(
XML
::
Attrib
::
projectName
,
projectName
());
w
riter
.
writeEndElement
();
w
.
writeStartElement
(
Tag
::
DocumentInfo
);
w
.
writeAttribute
(
XML
::
Attrib
::
projectName
,
projectName
());
w
.
writeEndElement
();
// simulation options
w
riter
.
writeStartElement
(
Tag
::
SimulationOptions
);
m_simulationOptionsItem
.
writeTo
(
&
w
riter
);
w
riter
.
writeEndElement
();
w
.
writeStartElement
(
Tag
::
SimulationOptions
);
m_simulationOptionsItem
.
writeTo
(
&
w
);
w
.
writeEndElement
();
// samples
w
riter
.
writeStartElement
(
Tag
::
SampleModel
);
m_sampleItems
.
writeTo
(
&
w
riter
);
w
riter
.
writeEndElement
();
w
.
writeStartElement
(
Tag
::
SampleModel
);
m_sampleItems
.
writeTo
(
&
w
);
w
.
writeEndElement
();
w
riter
.
writeStartElement
(
Tag
::
Instruments
);
Streamer
sInstruments
(
&
w
riter
);
w
.
writeStartElement
(
Tag
::
Instruments
);
Streamer
sInstruments
(
&
w
);
m_instruments
.
serialize
(
sInstruments
);
w
riter
.
writeEndElement
();
w
.
writeEndElement
();
m_applicationModels
.
writeTo
(
&
w
riter
);
m_applicationModels
.
writeTo
(
&
w
);
w
riter
.
writeEndElement
();
// BornAgain tag
w
riter
.
writeEndDocument
();
w
.
writeEndElement
();
// BornAgain tag
w
.
writeEndDocument
();
}
ProjectDocument
::
ReadResult
ProjectDocument
::
readProject
(
QIODevice
*
device
,
...
...
@@ -340,15 +340,15 @@ ProjectDocument::ReadResult ProjectDocument::readProject(QIODevice* device,
{
const
int
warningsBefore
=
messageService
.
warnings
().
size
();
QXmlStreamReader
reade
r
(
device
);
QXmlStreamReader
r
(
device
);
try
{
while
(
!
r
eader
.
atEnd
())
{
reade
r
.
readNext
();
if
(
r
eader
.
isStartElement
())
{
if
(
r
eader
.
name
()
==
Tag
::
BornAgain
)
{
Streamer
(
&
r
eader
).
assertVersion
(
2
);
while
(
!
r
.
atEnd
())
{
r
.
readNext
();
if
(
r
.
isStartElement
())
{
if
(
r
.
name
()
==
Tag
::
BornAgain
)
{
Streamer
(
&
r
).
assertVersion
(
2
);
m_currentVersion
=
reade
r
.
attributes
().
value
(
XML
::
Attrib
::
BA_Version
).
toString
();
r
.
attributes
().
value
(
XML
::
Attrib
::
BA_Version
).
toString
();
if
(
!
GUI
::
Util
::
Path
::
isVersionMatchMinimal
(
m_currentVersion
,
minimal_supported_version
))
{
...
...
@@ -360,48 +360,48 @@ ProjectDocument::ReadResult ProjectDocument::readProject(QIODevice* device,
return
ReadResult
::
error
;
}
while
(
r
eader
.
readNextStartElement
())
{
QString
tag
=
reade
r
.
name
().
toString
();
while
(
r
.
readNextStartElement
())
{
QString
tag
=
r
.
name
().
toString
();
if
(
tag
==
Tag
::
DocumentInfo
)
{
reade
r
.
skipCurrentElement
();
r
.
skipCurrentElement
();
// simulation options
}
else
if
(
tag
==
Tag
::
SimulationOptions
)
{
m_simulationOptionsItem
.
readFrom
(
&
r
eader
);
XML
::
gotoEndElementOfTag
(
&
r
eader
,
tag
);
m_simulationOptionsItem
.
readFrom
(
&
r
);
XML
::
gotoEndElementOfTag
(
&
r
,
tag
);
// samples
}
else
if
(
name
==
Tag
::
SampleModel
)
{
m_sampleItems
.
readFrom
(
&
r
eader
);
XML
::
gotoEndElementOfTag
(
&
r
eader
,
tag
);
}
else
if
(
tag
==
Tag
::
SampleModel
)
{
m_sampleItems
.
readFrom
(
&
r
);
XML
::
gotoEndElementOfTag
(
&
r
,
tag
);
}
else
if
(
r
eader
.
name
()
==
Tag
::
Instruments
)
{
Streamer
s
(
&
r
eader
);
}
else
if
(
r
.
name
()
==
Tag
::
Instruments
)
{
Streamer
s
(
&
r
);
m_instruments
.
serialize
(
s
);
// cleanup
if
(
r
eader
.
name
()
!=
Tag
::
Instruments
)
{
if
(
!
r
eader
.
isEndElement
())
reade
r
.
skipCurrentElement
();
reade
r
.
skipCurrentElement
();
if
(
r
.
name
()
!=
Tag
::
Instruments
)
{
if
(
!
r
.
isEndElement
())
r
.
skipCurrentElement
();
r
.
skipCurrentElement
();
}
XML
::
assertExpectedTag
(
&
r
eader
,
Tag
::
Instruments
);
ASSERT
(
r
eader
.
isEndElement
());
XML
::
assertExpectedTag
(
&
r
,
Tag
::
Instruments
);
ASSERT
(
r
.
isEndElement
());
XML
::
assertExpectedTag
(
&
r
eader
,
Tag
::
Instruments
);
XML
::
assertExpectedTag
(
&
r
,
Tag
::
Instruments
);
}
else
m_applicationModels
.
readFrom
(
&
r
eader
,
&
messageService
);
m_applicationModels
.
readFrom
(
&
r
,
&
messageService
);
}
}
}
}
}
catch
(
DeserializationException
&
ex
)
{
reade
r
.
raiseError
(
ex
.
text
());
r
.
raiseError
(
ex
.
text
());
}
if
(
r
eader
.
hasError
())
{
QString
message
=
QString
(
"Format error '%1'"
).
arg
(
r
eader
.
errorString
());
if
(
r
.
hasError
())
{
QString
message
=
QString
(
"Format error '%1'"
).
arg
(
r
.
errorString
());
messageService
.
addError
(
this
,
message
);
return
ReadResult
::
error
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment