diff --git a/GUI/coregui/Models/JobItem.cpp b/GUI/coregui/Models/JobItem.cpp index a49c7d1c9ca28c38e0765a5264f8354512c2bd32..46f6c22b71b4f48e4805f8027ff4092dc399742c 100644 --- a/GUI/coregui/Models/JobItem.cpp +++ b/GUI/coregui/Models/JobItem.cpp @@ -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)); diff --git a/GUI/coregui/Models/JobItem.h b/GUI/coregui/Models/JobItem.h index cd55b6bcdd2c0d4af5b1e0ccd58ea79128f107d8..8206309c48034669577dd7e5662efd69f86f4ab5 100644 --- a/GUI/coregui/Models/JobItem.h +++ b/GUI/coregui/Models/JobItem.h @@ -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);} diff --git a/GUI/coregui/Models/JobQueueModel.cpp b/GUI/coregui/Models/JobQueueModel.cpp index 5bda036cd3410280b95113a80fbae7854c6cab64..2a4b28ba57c43dd1ad4c8ac7f2f7989a0bf0cb28 100644 --- a/GUI/coregui/Models/JobQueueModel.cpp +++ b/GUI/coregui/Models/JobQueueModel.cpp @@ -373,4 +373,3 @@ void JobQueueModel::removeJob(const QModelIndex &index) m_queue_data->removeJob(identifier); } - diff --git a/GUI/coregui/Models/OutputDataItem.h b/GUI/coregui/Models/OutputDataItem.h index 2520720e1a7025a88b98931ae0339db0ebf8275c..724b5cb47e8be34a8c2657955bd78782ce9d3faa 100644 --- a/GUI/coregui/Models/OutputDataItem.h +++ b/GUI/coregui/Models/OutputDataItem.h @@ -4,6 +4,7 @@ #include <QObject> #include <QString> #include "OutputData.h" +#include "OutputDataIOFactory.h" class QXmlStreamWriter; class QXmlStreamReader; diff --git a/GUI/coregui/mainwindow/projectdocument.cpp b/GUI/coregui/mainwindow/projectdocument.cpp index 1299ebb3250d7a93a6ed33d3c1bbb09256e8432b..36678ca41d52dc674249930d9661abeb9244ffcf 100644 --- a/GUI/coregui/mainwindow/projectdocument.cpp +++ b/GUI/coregui/mainwindow/projectdocument.cpp @@ -1,5 +1,7 @@ #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())); + } + } + } +} + + + diff --git a/GUI/coregui/mainwindow/projectdocument.h b/GUI/coregui/mainwindow/projectdocument.h index 450b53fc0aa4d5f9a5080cd9554c1989b12bf454..a0ef213accc6b976c95221dcc88818e4eb78796a 100644 --- a/GUI/coregui/mainwindow/projectdocument.h +++ b/GUI/coregui/mainwindow/projectdocument.h @@ -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;