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
94a4a429
Commit
94a4a429
authored
6 years ago
by
Yurov, Dmitry
Browse files
Options
Downloads
Patches
Plain Diff
Made DataItem derived from SaveLoadInterface
Redmine: #2177
parent
5e8cf35f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
GUI/coregui/Models/DataItem.cpp
+29
-3
29 additions, 3 deletions
GUI/coregui/Models/DataItem.cpp
GUI/coregui/Models/DataItem.h
+8
-3
8 additions, 3 deletions
GUI/coregui/Models/DataItem.h
with
37 additions
and
6 deletions
GUI/coregui/Models/DataItem.cpp
+
29
−
3
View file @
94a4a429
...
@@ -37,10 +37,9 @@ void DataItem::setRawDataVector(std::vector<double> data)
...
@@ -37,10 +37,9 @@ void DataItem::setRawDataVector(std::vector<double> data)
emitDataChanged
();
emitDataChanged
();
}
}
QString
DataItem
::
fileName
(
const
QString
&
projectDir
)
const
QString
DataItem
::
fileName
()
const
{
{
QString
filename
=
getItemValue
(
DataItem
::
P_FILE_NAME
).
toString
();
return
getItemValue
(
DataItem
::
P_FILE_NAME
).
toString
();
return
projectDir
.
isEmpty
()
?
filename
:
projectDir
+
QStringLiteral
(
"/"
)
+
filename
;
}
}
QDateTime
DataItem
::
lastModified
()
const
QDateTime
DataItem
::
lastModified
()
const
...
@@ -48,6 +47,33 @@ QDateTime DataItem::lastModified() const
...
@@ -48,6 +47,33 @@ QDateTime DataItem::lastModified() const
return
m_last_modified
;
return
m_last_modified
;
}
}
bool
DataItem
::
containsNonXMLData
()
const
{
return
static_cast
<
bool
>
(
m_data
);
}
bool
DataItem
::
load
(
const
QString
&
projectDir
)
{
QString
filename
=
fileName
(
projectDir
);
auto
data
=
IntensityDataIOFactory
::
readOutputData
(
filename
.
toStdString
());
if
(
!
data
)
return
false
;
setOutputData
(
data
);
return
true
;
}
bool
DataItem
::
save
(
const
QString
&
projectDir
)
{
if
(
!
containsNonXMLData
())
return
false
;
std
::
unique_lock
<
std
::
mutex
>
lock
(
m_update_data_mutex
);
std
::
unique_ptr
<
OutputData
<
double
>>
clone
(
getOutputData
()
->
clone
());
lock
.
unlock
();
IntensityDataIOFactory
::
writeOutputData
(
*
clone
,
fileName
(
projectDir
).
toStdString
());
return
true
;
}
void
DataItem
::
setLastModified
(
const
QDateTime
&
dtime
)
void
DataItem
::
setLastModified
(
const
QDateTime
&
dtime
)
{
{
m_last_modified
=
dtime
;
m_last_modified
=
dtime
;
...
...
This diff is collapsed.
Click to expand it.
GUI/coregui/Models/DataItem.h
+
8
−
3
View file @
94a4a429
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
#ifndef DATAITEM_H
#ifndef DATAITEM_H
#define DATAITEM_H
#define DATAITEM_H
#include
"SaveLoadInterface.h"
#include
"SessionItem.h"
#include
"SessionItem.h"
#include
"OutputData.h"
#include
"OutputData.h"
#include
<QDateTime>
#include
<QDateTime>
...
@@ -24,7 +25,7 @@ class InstrumentItem;
...
@@ -24,7 +25,7 @@ class InstrumentItem;
//! Provides common functionality for IntensityDataItem and SpecularDataItem
//! Provides common functionality for IntensityDataItem and SpecularDataItem
class
BA_CORE_API_
DataItem
:
public
SessionItem
class
BA_CORE_API_
DataItem
:
public
SessionItem
,
public
SaveLoadInterface
{
{
public:
public:
static
const
QString
P_FILE_NAME
;
static
const
QString
P_FILE_NAME
;
...
@@ -39,9 +40,13 @@ public:
...
@@ -39,9 +40,13 @@ public:
//! no dimension checks are applied.
//! no dimension checks are applied.
void
setRawDataVector
(
std
::
vector
<
double
>
data
);
void
setRawDataVector
(
std
::
vector
<
double
>
data
);
QString
fileName
(
const
QString
&
projectDir
=
QString
())
const
;
using
SaveLoadInterface
::
fileName
;
QString
fileName
()
const
override
;
QDateTime
lastModified
()
const
override
;
bool
containsNonXMLData
()
const
override
;
bool
load
(
const
QString
&
projectDir
)
override
;
bool
save
(
const
QString
&
projectDir
)
override
;
QDateTime
lastModified
()
const
;
void
setLastModified
(
const
QDateTime
&
dtime
);
void
setLastModified
(
const
QDateTime
&
dtime
);
QString
selectedAxesUnits
()
const
;
QString
selectedAxesUnits
()
const
;
...
...
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