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

OutputDataItem is serialized into project directory.

parent 4149c21e
No related branches found
No related tags found
No related merge requests found
......@@ -10,12 +10,14 @@
JobItem::JobItem(QString name)
: m_name(name)
, m_status(Idle)
: m_status(Idle)
, m_progress(0)
{
OutputDataItem *dataItem = new OutputDataItem();
m_data_items.append(dataItem);
setName(name);
connect(dataItem, SIGNAL(modified()), this, SLOT(onDataItemModified()));
m_status_list << "" << "running" << "completed" << "canceled";
}
......@@ -34,6 +36,21 @@ void JobItem::clear()
}
void JobItem::setName(QString name)
{
m_name = name;
// setting names for OutputDataItem's
int n_data(0);
foreach(OutputDataItem *dataItem, m_data_items) {
QString dataFileName = QString("data_%1_%2.txt").arg(m_name, QString::number(n_data));
dataItem->setName(dataFileName);
++n_data;
}
emit modified(this);
}
QString JobItem::getStatusString() const
{
return m_status_list.at(int(m_status));
......
......@@ -56,7 +56,7 @@ signals:
void modified(JobItem *);
public slots:
void setName(QString name) { m_name = name; emit modified(this); }
void setName(QString name);
void setBeginTime(QString begin_time) { m_begin_time = begin_time; emit modified(this);}
void setEndTime(QString end_time) { m_end_time = end_time; emit modified(this);}
void setComments(QString comments) { m_comments = comments; emit modified(this);}
......
......@@ -373,4 +373,3 @@ void JobQueueModel::removeJob(const QModelIndex &index)
m_queue_data->removeJob(identifier);
}
......@@ -4,6 +4,7 @@
#include <QObject>
#include <QString>
#include "OutputData.h"
#include "OutputDataIOFactory.h"
class QXmlStreamWriter;
class QXmlStreamReader;
......
#include "projectdocument.h"
#include "JobQueueModel.h"
#include "JobItem.h"
#include "OutputDataItem.h"
#include <QFile>
#include <QTextStream>
#include <QFileInfo>
......@@ -90,6 +92,8 @@ bool ProjectDocument::save()
writeTo(&file);
file.close();
saveOutputData();
m_modified = false;
emit modified();
......@@ -114,6 +118,8 @@ bool ProjectDocument::load()
bool success_read = readFrom(&file);
file.close();
loadOutputData();
return success_read;
}
......@@ -201,3 +207,42 @@ QString ProjectDocument::getProjectDir()
return result;
}
//! saves OutputData into project directory
void ProjectDocument::saveOutputData()
{
Q_ASSERT(m_jobQueueModel);
for(int i=0; i<m_jobQueueModel->rowCount(); ++i) {
JobItem *jobItem = m_jobQueueModel->getJobItemForIndex(m_jobQueueModel->index(i,0));
OutputDataItem *dataItem = jobItem->getOutputDataItem();
if(dataItem) {
QString filename = getProjectDir() + "/" + dataItem->getName();
const OutputData<double> *data = dataItem->getOutputData();
if(data) {
OutputDataIOFactory::writeIntensityData(*data, filename.toStdString());
}
}
}
}
//! load OutputData from project directory
void ProjectDocument::loadOutputData()
{
for(int i=0; i<m_jobQueueModel->rowCount(); ++i) {
JobItem *jobItem = m_jobQueueModel->getJobItemForIndex(m_jobQueueModel->index(i,0));
OutputDataItem *dataItem = jobItem->getOutputDataItem();
if(dataItem) {
QString filename = getProjectDir() + "/" + dataItem->getName();
QFileInfo info(filename);
if(info.exists()) {
jobItem->getOutputDataItem()->setOutputData(OutputDataIOFactory::readIntensityData(filename.toStdString()));
}
}
}
}
......@@ -7,6 +7,7 @@
class JobQueueModel;
class QIODevice;
class QModelIndex;
class JobItem;
namespace ProjectDocumentXML
......@@ -63,6 +64,11 @@ private:
bool writeTo(QIODevice *device);
bool readFrom(QIODevice *device);
void saveOutputData();
void loadOutputData();
//QString getOutputDataFileName(JobItem *item);
QString m_project_path;
QString m_project_name;
JobQueueModel *m_jobQueueModel;
......
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