Skip to content
Snippets Groups Projects
Commit 85d7babc authored by Pospelov, Gennady's avatar Pospelov, Gennady
Browse files

LastModified time introduced for IntensityDataItem

parent 90a6ecbe
No related branches found
No related tags found
No related merge requests found
......@@ -78,6 +78,19 @@ IntensityDataItem::IntensityDataItem() : SessionItem(Constants::IntensityDataTyp
setDefaultTag(T_MASKS);
registerTag(T_PROJECTIONS, 0, -1, QStringList() << Constants::ProjectionContainerType);
mapper()->setOnPropertyChange([this](const QString& name)
{
if(name == P_FILE_NAME)
setLastModified(QDateTime::currentDateTime());
});
mapper()->setOnValueChange([this]()
{
// OutputData was modified
setLastModified(QDateTime::currentDateTime());
});
}
void IntensityDataItem::setOutputData(OutputData<double>* data)
......@@ -395,3 +408,13 @@ ProjectionContainerItem* IntensityDataItem::projectionContainerItem()
{
return dynamic_cast<ProjectionContainerItem*>(getItem(IntensityDataItem::T_PROJECTIONS));
}
QDateTime IntensityDataItem::lastModified() const
{
return m_last_modified;
}
void IntensityDataItem::setLastModified(const QDateTime &dtime)
{
m_last_modified = dtime;
}
......@@ -19,6 +19,7 @@
#include "SessionItem.h"
#include "OutputData.h"
#include <QDateTime>
class BasicAxisItem;
class MaskContainerItem;
......@@ -99,6 +100,9 @@ public:
MaskContainerItem* maskContainerItem();
ProjectionContainerItem* projectionContainerItem();
QDateTime lastModified() const;
void setLastModified(const QDateTime& dtime);
public slots:
void setLowerX(double xmin);
void setUpperX(double xmax);
......@@ -118,6 +122,7 @@ private:
void updateAxesLabels();
std::unique_ptr<OutputData<double>> m_data; //!< simulation results
QDateTime m_last_modified;
};
#endif // INTENSITYDATAITEM_H
......
......@@ -26,6 +26,7 @@
#include "TestProjectDocument.h"
#include "TestAutosave.h"
#include "TestOutputDataIOService.h"
#include "TestIntensityDataItem.h"
int main(int argc, char** argv) {
QCoreApplication app(argc, argv);
......@@ -58,6 +59,7 @@ int main(int argc, char** argv) {
TestProjectDocument testProjectDocument;
TestAutosave testAutosave;
TestOutputDataIOService testIO;
TestIntensityDataItem testIntensityData;
bool status(false);
......@@ -88,6 +90,7 @@ int main(int argc, char** argv) {
status |= QTest::qExec(&testProjectDocument, argc, argv);
status |= QTest::qExec(&testAutosave, argc, argv);
status |= QTest::qExec(&testIO, argc, argv);
status |= QTest::qExec(&testIntensityData, argc, argv);
return status;
}
#include <QtTest>
#include "SessionModel.h"
#include "IntensityDataItem.h"
#include <QDebug>
class TestIntensityDataItem : public QObject
{
Q_OBJECT
private slots:
void test_lastModified();
};
inline void TestIntensityDataItem::test_lastModified()
{
SessionModel model("TempModel");
IntensityDataItem* item = dynamic_cast<IntensityDataItem*>(
model.insertNewItem(Constants::IntensityDataType));
QDateTime time = QDateTime::currentDateTime();
item->setLastModified(time);
QVERIFY(time == item->lastModified());
const int nap_time(10);
QTest::qSleep(nap_time);
// changing item (file name)
item->setItemValue(IntensityDataItem::P_FILE_NAME, "name.txt");
QDateTime time2 = item->lastModified();
QVERIFY(time.msecsTo(time2) >= nap_time);
QTest::qSleep(nap_time);
// changing item (OutputData)
item->emitDataChanged();
QDateTime time3 = item->lastModified();
QVERIFY(time2.msecsTo(time3) >= nap_time);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment