diff --git a/Core/Tools/inc/StochasticDoubleGate.h b/Core/Tools/inc/StochasticDoubleGate.h index ad22a4201b81f76544d415f7e18433ce7a462361..2508ffae7865b3194767b463c75b8280858ddbd4 100644 --- a/Core/Tools/inc/StochasticDoubleGate.h +++ b/Core/Tools/inc/StochasticDoubleGate.h @@ -56,7 +56,7 @@ inline void StochasticDoubleGate::setToRandom() } inline StochasticDoubleGate::StochasticDoubleGate(double min, double max) -: StochasticParameter<double>((m_min+m_max)/2.0) +: StochasticParameter<double>((min+max)/2.0) , m_min(min) , m_max(max) { diff --git a/GUI/coregui/Models/JobItem.cpp b/GUI/coregui/Models/JobItem.cpp index 12882295642cb64cc520743a6cab872e8afc9660..6f6c1d94a1b8a7ab552ef8e2556445b437404c9f 100644 --- a/GUI/coregui/Models/JobItem.cpp +++ b/GUI/coregui/Models/JobItem.cpp @@ -1,48 +1,103 @@ #include "JobItem.h" -#include <QTimer> +#include "JobQueueModel.h" +#include "JobRunner.h" +#include "OutputDataItem.h" +#include "GUIHelpers.h" +#include <QXmlStreamWriter> #include <QDebug> +#include <QTimer> +#include <QThread> -JobItem::JobItem() - : m_progress(0) +JobItem::JobItem(QString name) + : m_name(name) + , m_status(Idle) + , m_progress(0) { - + m_data_items.append(new OutputDataItem()); + m_status_list << "" << "running" << "completed" << "canceled"; } JobItem::~JobItem() { - qDebug() << "JobItem::~JobItem()"; + clear(); } -void JobItem::run() +void JobItem::clear() { - qDebug() << "JobItem::run() 1.1"; - loopFunctionWithDelay(); - qDebug() << "JobItem::run() 1.2 emiting finished"; + qDeleteAll(m_data_items); + m_data_items.clear(); } +QString JobItem::getStatusString() const +{ + return m_status_list.at(int(m_status)); +} + -void JobItem::loopFunctionWithDelay() +void JobItem::writeTo(QXmlStreamWriter *writer) { - qDebug() << "JobItem::loopFunctionWithDelay()" << m_progress; - if(m_progress < 100) { - m_progress++; - emit progressUpdate(m_progress); - QTimer::singleShot(500, this, SLOT(loopFunctionWithDelay())); + Q_ASSERT(writer); + writer->writeStartElement(JobQueueXML::JobTag); + writer->writeAttribute(JobQueueXML::JobNameAttribute, getName()); + writer->writeAttribute(JobQueueXML::JobStatusAttribute, QString::number((int)getStatus())); + writer->writeAttribute(JobQueueXML::JobBeginTimeAttribute, getBeginTime()); + writer->writeAttribute(JobQueueXML::JobEndTimeAttribute, getEndTime()); + writer->writeAttribute(JobQueueXML::JobCommentsAttribute, getComments()); + foreach(OutputDataItem *item, m_data_items) { + item->writeTo(writer); } + writer->writeEndElement(); // JobTag +} + - if(m_progress == 100) { - emit progressUpdate(m_progress); - emit finished(); +void JobItem::readFrom(QXmlStreamReader *reader) +{ + Q_ASSERT(reader); + clear(); + + qDebug() << "JobQueueItem::readFrom() -> " << reader->name(); + if(reader->name() != JobQueueXML::JobTag) { + throw GUIHelpers::Error("JobQueueItem::readFrom() -> Format error in p1"); } -} + setName(reader->attributes() + .value(JobQueueXML::JobNameAttribute).toString()); + setBeginTime(reader->attributes() + .value(JobQueueXML::JobBeginTimeAttribute).toString()); + + setEndTime(reader->attributes() + .value(JobQueueXML::JobEndTimeAttribute).toString()); + + setComments(reader->attributes() + .value(JobQueueXML::JobCommentsAttribute).toString()); + + JobStatus status = (JobStatus) (reader->attributes() + .value(JobQueueXML::JobStatusAttribute).toInt()); + setStatus(status); + + + while (!reader->atEnd()) { + reader->readNext(); + if (reader->isStartElement()) { + + if (reader->name() == JobQueueXML::OutputDataTag) { + qDebug() << "XXX output data"; + OutputDataItem *item = new OutputDataItem(); + item->readFrom(reader); + m_data_items.append(item); + } + } else if (reader->isEndElement()) { + if (reader->name() == JobQueueXML::JobTag) { + break; // end of xml of current Job + } + } + } -void JobItem::terminate() -{ - m_progress = 1000; } + + diff --git a/GUI/coregui/Models/JobItem.h b/GUI/coregui/Models/JobItem.h index 83e706b39c3993f0086880bfa45d126e9835f41a..1d5ef6aa6485679a697c617eb1d13a5f83205b03 100644 --- a/GUI/coregui/Models/JobItem.h +++ b/GUI/coregui/Models/JobItem.h @@ -1,34 +1,80 @@ #ifndef JOBITEM_H #define JOBITEM_H -#include <QObject> +#include <QList> +#include <QVariant> +#include <QString> +#include <QStringList> +class QXmlStreamWriter; +class QXmlStreamReader; +class OutputDataItem; + + +//! Class to hold all job settings +//! +//! See also JobQueueItem which is stored in a list by JobQueueModel and serve +//! as an adapter for given JobItem. class JobItem : public QObject { Q_OBJECT + public: + enum JobStatus + { + Idle, + Running, + Completed, + Canceled + }; - JobItem(); + JobItem(QString name); virtual ~JobItem(); -public slots: - void run(); - void terminate(); + QString getName() const { return m_name; } + + QString getBeginTime() const { return m_begin_time; } + + QString getEndTime() const { return m_end_time; } + + QString getComments() const { return m_comments; } -private slots: - void loopFunctionWithDelay(); + JobStatus getStatus() const { return m_status; } + + QString getStatusString() const; + + int getProgress() const { return m_progress; } + + void writeTo(QXmlStreamWriter *writer); + void readFrom(QXmlStreamReader *reader); + + bool isRunning() const { return m_status == Running; } signals: - void finished(); - void progressUpdate(int); + void modified(JobItem *); + +public slots: + void setName(QString name) { m_name = name; emit modified(this); } + 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);} + void setStatus(JobStatus status) { m_status = status; emit modified(this);} + void setProgress(int progress) { m_progress = progress; emit modified(this); } private: + void clear(); + QString m_name; + QString m_begin_time; + QString m_end_time; + QString m_comments; + JobStatus m_status; int m_progress; + QList<OutputDataItem *> m_data_items; + QStringList m_status_list; }; -#endif - +#endif // JOBITEM_H diff --git a/GUI/coregui/Models/JobQueueData.cpp b/GUI/coregui/Models/JobQueueData.cpp index cb41d938b85325538bbf794d8404dcccb14857aa..6449048e728099915af97bd824785bfb4dec40a7 100644 --- a/GUI/coregui/Models/JobQueueData.cpp +++ b/GUI/coregui/Models/JobQueueData.cpp @@ -1,2 +1,265 @@ #include "JobQueueData.h" +#include "JobQueueItem.h" +#include "JobItem.h" +#include "JobRunner.h" +#include "GUIHelpers.h" +#include <QUuid> +#include <QThread> +#include <QDateTime> +#include <QDebug> + + +int JobQueueData::m_job_index = 0; + +//! Creates JobQueueItem and corresponding JobItem. +//! Created JobItem will be registered using unique identifier +JobQueueItem *JobQueueData::createJobQueueItem(Simulation *simulation) +{ + (void)simulation; + JobQueueItem *result = new JobQueueItem(generateJobIdentifier()); + m_job_items[result->getIdentifier()] = new JobItem(generateJobName()); + return result; +} + + +//! returns existing JobItem for given identifier +const JobItem *JobQueueData::getJobItem(QString identifier) const +{ + QMap<QString, JobItem *>::const_iterator it = m_job_items.find(identifier); + if(it != m_job_items.end()) { + return it.value(); + } + throw GUIHelpers::Error("JobQueueData::getJobItem() -> Error! Can't find item."); + return 0; +} + +//! returns existing JobItem for given identifier (const version) +JobItem *JobQueueData::getJobItem(QString identifier) +{ + return const_cast<JobItem *>(static_cast<const JobQueueData &>(*this).getJobItem(identifier)); +} + + +//! returns the thread (if exists) for given identifier +QThread *JobQueueData::getThread(QString identifier) +{ + QMap<QString, QThread *>::const_iterator it = m_threads.find(identifier); + if(it != m_threads.end()) { + return it.value(); + } + return 0; +} + + +//! returns job runner (if exists) for given identifier +JobRunner *JobQueueData::getRunner(QString identifier) +{ + QMap<QString, JobRunner *>::const_iterator it = m_runners.find(identifier); + if(it != m_runners.end()) { + return it.value(); + } + return 0; +} + +//! returns identifier for given JobIteM +QString JobQueueData::getIdentifierForJobItem(const JobItem *item) +{ + for(QMap<QString, JobItem *>::iterator it=m_job_items.begin(); it!=m_job_items.end(); ++it) { + if(it.value() == item) return it.key(); + } + throw GUIHelpers::Error("JobQueueData::getIdentifierForJobItem() -> Error! Can't find item."); +} + + +//! submit job and run it in a thread +void JobQueueData::runJob(QString identifier) +{ + if(getThread(identifier)) { + qDebug() << "JobQueueData::runInThread() -> Thread is already running"; + return; + } + + JobRunner *runner = new JobRunner(identifier); + m_runners[identifier] = runner; + + QThread *thread = new QThread(); + runner->moveToThread(thread); + m_threads[identifier] = thread; + + // thread will start the runner + connect(thread, SIGNAL(started()), runner, SLOT(start())); + + // after runner is finished it will tell to the thread to quit + //connect(runner, SIGNAL(finished()), thread, SLOT(quit())); + + // finished thread will be removed from the list + connect(thread, SIGNAL(finished()), this, SLOT(onFinishedThread())); + + // connecting the runner to started/progress slots + connect(runner, SIGNAL(started()), this, SLOT(onStartedJob())); + connect(runner, SIGNAL(progressUpdate()), this, SLOT(onProgressUpdate())); + + // finished job will do all cleanup + connect(runner, SIGNAL(finished()), this, SLOT(onFinishedJob())); + + qDebug() << "JobQueueData::runInThread() starting thread"; + thread->start(); +} + + +//! cancels running job +void JobQueueData::cancelJob(QString identifier) +{ + qDebug() << "JobQueueData::cancelJob()"; + if(QThread *thread = getThread(identifier)) { + thread->quit(); + JobItem *jobItem = getJobItem(identifier); + jobItem->setStatus(JobItem::Canceled); + jobItem->setEndTime(QDateTime::currentDateTime().toString("yyyy.MM.dd hh:mm:ss")); + jobItem->setProgress(0); + JobRunner *runner = getRunner(identifier); + runner->disconnect(); + assignForDeletion(runner); + updateGlobalProgress(); + return; + } + qDebug() << "JobQueueData::cancelJob() -> No thread is running"; +} + + +//! remove job from list +void JobQueueData::removeJob(QString identifier) +{ + qDebug() << "JobQueueData::removeJob"; + cancelJob(identifier); + for(QMap<QString, JobItem *>::iterator it=m_job_items.begin(); it!=m_job_items.end(); ++it) { + if(it.key() == identifier) { + delete it.value(); + m_job_items.erase(it); + return; + } + } +} + + +void JobQueueData::onStartedJob() +{ + qDebug() << "JobQueueData::onStartedJob()"; + JobRunner *runner = qobject_cast<JobRunner *>(sender()); + Q_ASSERT(runner); + JobItem *jobItem = getJobItem(runner->getIdentifier()); + jobItem->setProgress(0); + jobItem->setStatus(JobItem::Running); + QString begin_time = QDateTime::currentDateTime().toString("yyyy.MM.dd hh:mm:ss"); + jobItem->setBeginTime(begin_time); + jobItem->setEndTime(""); +} + + +void JobQueueData::onFinishedJob() +{ + qDebug() << "JobQueueData::onFinishedJob()"; + JobRunner *runner = qobject_cast<JobRunner *>(sender()); + Q_ASSERT(runner); + JobItem *jobItem = getJobItem(runner->getIdentifier()); + jobItem->setStatus(JobItem::Completed); + QString end_time = QDateTime::currentDateTime().toString("yyyy.MM.dd hh:mm:ss"); + jobItem->setEndTime(end_time); + + // I tell to the thread to exit here (instead of connecting JobRunner::finished to the QThread::quit because of strange behaviour) + getThread(runner->getIdentifier())->quit(); + + assignForDeletion(runner); +} + + +void JobQueueData::onFinishedThread() +{ + qDebug() << "JobQueueData::onFinishedThread()"; + QThread *thread = qobject_cast<QThread *>(sender()); + assignForDeletion(thread); +} + + +void JobQueueData::onProgressUpdate() +{ + qDebug() << "JobQueueData::ProgressUpdate()"; + JobRunner *runner = qobject_cast<JobRunner *>(sender()); + Q_ASSERT(runner); + JobItem *jobItem = getJobItem(runner->getIdentifier()); + jobItem->setProgress(runner->getProgress()); + updateGlobalProgress(); +} + + +void JobQueueData::updateGlobalProgress() +{ + int global_progress(0); + int nRunningJobs(0); + for(QMap<QString, JobItem *>::iterator it = m_job_items.begin(); it!= m_job_items.end(); ++it) { + JobItem *jobItem = it.value(); + if(jobItem->isRunning()) { + global_progress += jobItem->getProgress(); + nRunningJobs++; + } + } + if(nRunningJobs) { + global_progress /= nRunningJobs; + } else { + global_progress=-1; + } + emit globalProgress(global_progress); +} + + +void JobQueueData::onCancelAllJobs() +{ + QStringList keys = m_threads.keys(); + foreach(QString key, keys) { + cancelJob(key); + } +} + +//! Removes QThread from the map of known threads, assigns it for deletion. +void JobQueueData::assignForDeletion(QThread *thread) +{ + Q_ASSERT(thread); + for(QMap<QString, QThread *>::iterator it=m_threads.begin(); it!=m_threads.end(); ++it) { + if(it.value() == thread) { + thread->deleteLater(); + m_threads.erase(it); + return; + } + } + throw GUIHelpers::Error("JobQueueData::assignForDeletion() -> Error! Can't find thread."); +} + + +//! Removes JobRunner from the map of known runners, assigns it for deletion. +void JobQueueData::assignForDeletion(JobRunner *runner) +{ + Q_ASSERT(runner); + for(QMap<QString, JobRunner *>::iterator it=m_runners.begin(); it!=m_runners.end(); ++it) { + if(it.value() == runner) { + runner->deleteLater(); + m_runners.erase(it); + return; + } + } + throw GUIHelpers::Error("JobQueueData::assignForDeletion() -> Error! Can't find the runner."); +} + + +//! generates job name +QString JobQueueData::generateJobName() +{ + return QString("job")+QString::number(++m_job_index); +} + + +//! generate unique job identifier +QString JobQueueData::generateJobIdentifier() +{ + return QUuid::createUuid().toString(); +} diff --git a/GUI/coregui/Models/JobQueueData.h b/GUI/coregui/Models/JobQueueData.h index 2a77afab28627133f003b162610eb43ad7f6daa9..4a7b13f2a837060e78fb8886c698bbb4e76c4b28 100644 --- a/GUI/coregui/Models/JobQueueData.h +++ b/GUI/coregui/Models/JobQueueData.h @@ -1,11 +1,62 @@ #ifndef JOBQUEUEDATA_H #define JOBQUEUEDATA_H +#include <QObject> +#include <QString> +#include <QMap> +class JobItem; +class JobQueueItem; +class Simulation; +class JobRunner; +class QThread; -class JobQueueData + +//! Holds correspondance of job identifiers and JobItem's, QThread's, JobRunner's +//! Contains all submit/cancel logic +class JobQueueData : public QObject { + Q_OBJECT +public: + + JobQueueItem *createJobQueueItem(Simulation *simulation = 0); + + const JobItem *getJobItem(QString identifier) const; + JobItem *getJobItem(QString identifier); + + QThread *getThread(QString identifier); + + JobRunner *getRunner(QString identifier); + + QString getIdentifierForJobItem(const JobItem *); + +signals: + void globalProgress(int); + +public slots: + void onStartedJob(); + void onProgressUpdate(); + void onFinishedJob(); + void onFinishedThread(); + void onCancelAllJobs(); + + void runJob(QString identifier); + void cancelJob(QString identifier); + void removeJob(QString identifier); + +private: + void assignForDeletion(QThread *thread); + void assignForDeletion(JobRunner *runner); + void updateGlobalProgress(); + + QString generateJobName(); + QString generateJobIdentifier(); + + QMap<QString, JobItem *> m_job_items; //!< correspondance of JobIdentifier and JobItem's + QMap<QString, QThread *> m_threads; //! correspondance of JobIdentifier and running threads + QMap<QString, JobRunner *> m_runners; //! correspondance of JobIdentifier and JobRunner's + static int m_job_index; }; diff --git a/GUI/coregui/Models/JobQueueItem.cpp b/GUI/coregui/Models/JobQueueItem.cpp index 71871f524973e08e86e3553110bdbfff7f170ded..0aa36dcb2491f52981fb922f14b1159320b81519 100644 --- a/GUI/coregui/Models/JobQueueItem.cpp +++ b/GUI/coregui/Models/JobQueueItem.cpp @@ -1,146 +1,16 @@ #include "JobQueueItem.h" -#include "JobQueueModel.h" -#include "JobItem.h" -#include "OutputDataItem.h" -#include "GUIHelpers.h" -#include <QXmlStreamWriter> -#include <QDebug> -#include <QTimer> -#include <QThread> - -JobQueueItem::JobQueueItem(QString name) - : m_name(name) - , m_progress(0) -{ - m_data_items.append(new OutputDataItem()); - -// mp_job_watcher = new QFutureWatcher<void>; -// connect(mp_job_watcher, SIGNAL(finished()), this, SLOT(onJobFinished())); - -// m_jobItem = new JobItem(); - -} - - -JobQueueItem::~JobQueueItem() -{ - clear(); -} - - - -//void JobQueueItem::run() -//{ -// qDebug() << "JobQueueItem::run(): preparing to run a thread"; -// JobItem *jobItem = new JobItem(); -// QThread *thread = new QThread(); -// jobItem->moveToThread(thread); - -// // thread will start jobItem::run -// connect(thread, SIGNAL(started()), jobItem, SLOT(run())); - -// // thread will quit after JobItem is done -// connect(jobItem, SIGNAL(finished()), thread, SLOT(quit())); -// connect(jobItem, SIGNAL(finished()), this, SLOT(onJobFinished())); - -// // objects will be deleted after JobItem is done -// connect(jobItem, SIGNAL(finished()), jobItem, SLOT(deleteLater())); -// connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); - -// qDebug() << "JobQueueItem::run(): starting thread"; -// thread->start(); -// qDebug() << "JobQueueItem::run(): thread is started"; - -//} - - -void JobQueueItem::onJobFinished() -{ - qDebug() << "JobQueueItem::onJobFinished()"; -} -//void JobQueueItem::loopFunctionWithDelay() +//JobQueueItem::JobQueueItem(QString name, QString identifier) +// : m_name(name) +// , m_identifier(identifier) //{ -// qDebug() << "JobQueueItem::loopFunctionWithDelay()" << m_counterForDelayedLoop; -// if(m_counterForDelayedLoop < 100) { -// m_counterForDelayedLoop++; -// qDebug() << "XXX1"; -// QTimer::singleShot(5000, this, SLOT(loopFunctionWithDelay())); -// qDebug() << "XXX2"; -// } //} -// -------------------- - - -void JobQueueItem::clear() -{ - qDeleteAll(m_data_items); - m_data_items.clear(); -} - - -void JobQueueItem::writeTo(QXmlStreamWriter *writer) -{ - Q_ASSERT(writer); - writer->writeStartElement(JobQueueXML::JobTag); - writer->writeAttribute(JobQueueXML::JobNameAttribute, getName()); - writer->writeAttribute(JobQueueXML::JobStatusAttribute, getStatus()); - writer->writeAttribute(JobQueueXML::JobBeginTimeAttribute, getBeginTime()); - writer->writeAttribute(JobQueueXML::JobEndTimeAttribute, getEndTime()); - writer->writeAttribute(JobQueueXML::JobCommentsAttribute, getComments()); - foreach(OutputDataItem *item, m_data_items) { - item->writeTo(writer); - } - writer->writeEndElement(); // JobTag -} - -void JobQueueItem::readFrom(QXmlStreamReader *reader) +JobQueueItem::JobQueueItem(QString identifier) + : m_identifier(identifier) { - Q_ASSERT(reader); - clear(); - - qDebug() << "JobQueueItem::readFrom() -> " << reader->name(); - if(reader->name() != JobQueueXML::JobTag) { - throw GUIHelpers::Error("JobQueueItem::readFrom() -> Format error in p1"); - } - - setName(reader->attributes() - .value(JobQueueXML::JobNameAttribute).toString()); - - setBeginTime(reader->attributes() - .value(JobQueueXML::JobBeginTimeAttribute).toString()); - - setEndTime(reader->attributes() - .value(JobQueueXML::JobEndTimeAttribute).toString()); - - setComments(reader->attributes() - .value(JobQueueXML::JobCommentsAttribute).toString()); - - setStatus(reader->attributes() - .value(JobQueueXML::JobStatusAttribute).toString()); - - - while (!reader->atEnd()) { - reader->readNext(); - if (reader->isStartElement()) { - - if (reader->name() == JobQueueXML::OutputDataTag) { - qDebug() << "XXX output data"; - OutputDataItem *item = new OutputDataItem(); - item->readFrom(reader); - m_data_items.append(item); - } - } else if (reader->isEndElement()) { - if (reader->name() == JobQueueXML::JobTag) { - break; // end of xml of current Job - } - } - } } - - diff --git a/GUI/coregui/Models/JobQueueItem.h b/GUI/coregui/Models/JobQueueItem.h index 2a803e44611e1eda79a40a973d22cb765cdae8e5..57fc765b731e2cb0281a36c8662a6e9e467d9a7d 100644 --- a/GUI/coregui/Models/JobQueueItem.h +++ b/GUI/coregui/Models/JobQueueItem.h @@ -1,73 +1,28 @@ #ifndef JOBQUEUEITEM_H #define JOBQUEUEITEM_H -#include <QList> -#include <QVariant> #include <QString> -#include <QFutureWatcher> -class QXmlStreamWriter; -class QXmlStreamReader; -class OutputDataItem; - -class JobQueueItem : public QObject +//! Simple JobQueueItem with name and jobId which is handled by JobQueueModel +//! +//! See also JobItem which contains real information about the job. +class JobQueueItem { - Q_OBJECT - public: - JobQueueItem(QString name); - virtual ~JobQueueItem(); - - QString getName() const { return m_name; } - void setName(QString name) { m_name = name; } - - QString getBeginTime() const { return m_begin_time; } - void setBeginTime(QString begin_time) { m_begin_time = begin_time; } - - QString getEndTime() const { return m_end_time; } - void setEndTime(QString end_time) { m_end_time = end_time; } - - QString getComments() const { return m_comments; } - void setComments(QString comments) { m_comments = comments; } - - QString getStatus() const { return m_status; } - void setStatus(QString status) { m_status = status; } - - int getProgress() const { return m_progress; } + //JobQueueItem(QString name, QString identifier); + JobQueueItem(QString identifier); - void writeTo(QXmlStreamWriter *writer); - void readFrom(QXmlStreamReader *reader); +// QString getName() const { return m_name; } +// void setName(QString name) { m_name = name; } - void clear(); - -// void run(); - -// QFutureWatcher<void> *getJobWatcher() { return mp_job_watcher; } - -public slots: - void onJobFinished(); - void setProgress(int progress) { m_progress = progress; emit modified(this); } - -// void loopFunctionWithDelay(); - -signals: - void modified(JobQueueItem *item); + QString getIdentifier() const { return m_identifier; } + void setIdentifier(QString identifier) { m_identifier = identifier; } private: - QString m_name; - QString m_begin_time; - QString m_end_time; - QString m_comments; - QString m_status; - int m_progress; - - QList<OutputDataItem *> m_data_items; - -// int m_counterForDelayedLoop ; -// QFutureWatcher<void> *mp_job_watcher; +// QString m_name; + QString m_identifier; }; - #endif diff --git a/GUI/coregui/Models/JobQueueModel.cpp b/GUI/coregui/Models/JobQueueModel.cpp index ae5e84635551c5b66468ee0ff34174e28b463337..8211a5d86ea0bf16529f16bf3d9ef27073894e29 100644 --- a/GUI/coregui/Models/JobQueueModel.cpp +++ b/GUI/coregui/Models/JobQueueModel.cpp @@ -1,6 +1,7 @@ #include "JobQueueModel.h" -#include "JobQueueItem.h" #include "JobItem.h" +#include "JobQueueItem.h" +#include "JobRunner.h" #include "mainwindow_constants.h" #include "Exceptions.h" #include "GUIHelpers.h" @@ -13,10 +14,12 @@ #include <QtCore/QXmlStreamReader> #include <QtCore/QXmlStreamWriter> #include <QItemSelection> +#include <QUuid> JobQueueModel::JobQueueModel(QObject *parent) : QAbstractListModel(parent) + , m_queue_data(new JobQueueData) , m_name("DefaultName") { @@ -27,6 +30,7 @@ JobQueueModel::JobQueueModel(QObject *parent) JobQueueModel::~JobQueueModel() { qDeleteAll(m_jobs); + delete m_queue_data; } @@ -45,7 +49,8 @@ QVariant JobQueueModel::data(const QModelIndex &index, int role) const return QVariant(); if (role == Qt::DisplayRole) { - return m_jobs.at(index.row())->getName(); + return getJobItemForIndex(index)->getName(); + //return m_jobs.at(index.row())->getName(); } return QVariant(); } @@ -56,7 +61,8 @@ Qt::ItemFlags JobQueueModel::flags(const QModelIndex &index) const // qDebug() << "JobQueueModel::flags" << index; Qt::ItemFlags defaultFlags = QAbstractListModel::flags(index); if(index.isValid()) - return Qt::ItemIsDragEnabled | Qt::ItemIsEditable | defaultFlags; + return Qt::ItemIsDragEnabled | defaultFlags; + //return Qt::ItemIsDragEnabled | Qt::ItemIsEditable | defaultFlags; else return Qt::ItemIsDropEnabled | defaultFlags; } @@ -65,7 +71,8 @@ Qt::ItemFlags JobQueueModel::flags(const QModelIndex &index) const bool JobQueueModel::setData(const QModelIndex &index, const QVariant &value, int role) { if (index.isValid() && role == Qt::EditRole) { - m_jobs.at(index.row())->setName(value.toString()); + getJobItemForIndex(index)->setName(value.toString()); + //m_jobs.at(index.row())->setName(value.toString()); return true; } return false; @@ -86,25 +93,29 @@ bool JobQueueModel::setData(const QModelIndex &index, const QVariant &value, int //} -void JobQueueModel::addJob(JobQueueItem *item) +void JobQueueModel::addJob(Simulation *simulation) { int position = m_jobs.size(); beginInsertRows(QModelIndex(), position, position); - m_jobs.append(item); + JobQueueItem *queue_item = m_queue_data->createJobQueueItem(simulation); + m_jobs.append(queue_item); endInsertRows(); -} + JobItem *item = m_queue_data->getJobItem(queue_item->getIdentifier()); + connect(item, SIGNAL(modified(JobItem*)), this, SLOT(onJobItemIsModified(JobItem*))); +} bool JobQueueModel::removeRows(int position, int rows, const QModelIndex &/* parent */) { - qDebug() << "JobQueueModel::removeRows"; beginRemoveRows(QModelIndex(), position, position+rows-1); - for (int row = 0; row < rows; ++row) { + QModelIndex item_index = index(position+row,0); + qDebug() << "removing" << item_index; + //emit selectionChanged(0); + m_queue_data->removeJob(getIdentifier(item_index)); m_jobs.removeAt(position); } - endRemoveRows(); return true; } @@ -118,27 +129,16 @@ QStringList JobQueueModel::mimeTypes() const QMimeData *JobQueueModel::mimeData(const QModelIndexList &indices) const { - qDebug() << "----"; - qDebug() << "JobQueueModel::mimeData()" << indices.count() << indices; if (indices.count() != 1) return 0; - JobQueueItem *jobItem = m_jobs.at(indices.at(0).row()); - Q_ASSERT(jobItem); + JobQueueItem *item = m_jobs.at(indices.at(0).row()); + Q_ASSERT(item); QMimeData *mimeData = new QMimeData(); QByteArray encodedData; - QXmlStreamWriter writer(&encodedData); - - jobItem->writeTo(&writer); - -// QString buff; -// QXmlStreamWriter writer2(&buff); -// jobItem->writeTo(&writer2); -// qDebug() << buff; - - const int MaxCompression = 9; - mimeData->setData(Constants::MIME_JOBQUEUE, qCompress(encodedData, MaxCompression)); - + QDataStream dataStream(&encodedData, QIODevice::WriteOnly); + dataStream << item->getIdentifier(); + mimeData->setData(Constants::MIME_JOBQUEUE, encodedData); return mimeData; } @@ -146,7 +146,6 @@ QMimeData *JobQueueModel::mimeData(const QModelIndexList &indices) const bool JobQueueModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) { - qDebug() << "JobQueueModel::dropMimeData() 1.1" << row << column << action; if (action == Qt::IgnoreAction) return true; @@ -164,25 +163,16 @@ bool JobQueueModel::dropMimeData(const QMimeData *data, Qt::DropAction action, else beginRow = rowCount(QModelIndex()); - qDebug() << "JobQueueModel::dropMimeData() 1.2 beginRow" << beginRow; - - QByteArray encodedData = qUncompress(data->data(Constants::MIME_JOBQUEUE)); - QXmlStreamReader reader(encodedData); - - while (!reader.atEnd()) { - reader.readNext(); - if (reader.isStartElement()) { - if (reader.name() == JobQueueXML::JobTag) { - beginInsertRows(QModelIndex(), beginRow, beginRow); + QByteArray encodedData = data->data(Constants::MIME_JOBQUEUE); + QDataStream dataStream(&encodedData, QIODevice::ReadOnly); - JobQueueItem *item = new JobQueueItem(""); - item->readFrom(&reader); - m_jobs.insert(beginRow, item); - endInsertRows(); + QString identifier; + dataStream >> identifier; + JobQueueItem *item = new JobQueueItem(identifier); - } - } - } + beginInsertRows(QModelIndex(), beginRow, beginRow); + m_jobs.insert(beginRow, item); + endInsertRows(); return true; } @@ -222,14 +212,14 @@ void JobQueueModel::writeTo(QXmlStreamWriter *writer) { Q_ASSERT(writer); - writer->writeStartElement(JobQueueXML::ModelTag); - writer->writeAttribute(JobQueueXML::ModelNameAttribute, getName()); +// writer->writeStartElement(JobQueueXML::ModelTag); +// writer->writeAttribute(JobQueueXML::ModelNameAttribute, getName()); - foreach(JobQueueItem *item, m_jobs) { - item->writeTo(writer); - } +// foreach(JobItem *item, m_jobs) { +// item->writeTo(writer); +// } - writer->writeEndElement(); // ModelTag +// writer->writeEndElement(); // ModelTag } @@ -256,28 +246,28 @@ void JobQueueModel::readFrom(QXmlStreamReader *reader) { Q_ASSERT(reader); - clear(); - while (!reader->atEnd()) { - reader->readNext(); - if (reader->isStartElement()) { - - if (reader->name() == JobQueueXML::ModelTag) { - beginResetModel(); - const QString name = reader->attributes() - .value(JobQueueXML::ModelNameAttribute).toString(); - qDebug() << "JobQueueModel::readFrom " << name; - setName(name); - } else if(reader->name() == JobQueueXML::JobTag) { - JobQueueItem *job = new JobQueueItem(""); - job->readFrom(reader); - addJob(job); - } - } else if (reader->isEndElement()) { - if (reader->name() == JobQueueXML::ModelTag) { - endResetModel(); - } - } - } +// clear(); +// while (!reader->atEnd()) { +// reader->readNext(); +// if (reader->isStartElement()) { + +// if (reader->name() == JobQueueXML::ModelTag) { +// beginResetModel(); +// const QString name = reader->attributes() +// .value(JobQueueXML::ModelNameAttribute).toString(); +// qDebug() << "JobQueueModel::readFrom " << name; +// setName(name); +// } else if(reader->name() == JobQueueXML::JobTag) { +// JobItem *job = new JobItem(""); +// job->readFrom(reader); +// addJob(job); +// } +// } else if (reader->isEndElement()) { +// if (reader->name() == JobQueueXML::ModelTag) { +// endResetModel(); +// } +// } +// } } @@ -285,97 +275,60 @@ void JobQueueModel::onSelectionChanged( const QItemSelection &selected, const QI { qDebug() << "JobQueueModel::onSelectionChanged" << selected; if(!selected.empty() and !selected.first().indexes().empty()) { - int row = selected.first().indexes().at(0).row(); - JobQueueItem *item = m_jobs.at(row); - emit selectionChanged(item); + QModelIndex index = selected.first().indexes().at(0); + emit selectionChanged(getJobItemForIndex(index)); } - -// if(!selected.empty() ) { -// emit selectionChanged(selected.first()); -// } } -//! returns model index of given JobQueueItem -QModelIndex JobQueueModel::indexOfItem(JobQueueItem *item) const +//! Method should be called to inform given model about changes in JobItem +void JobQueueModel::onJobItemIsModified(JobItem *modified_item) { - if(m_jobs.contains(item)) { - return index(m_jobs.indexOf(item), 0); + QString identifier = m_queue_data->getIdentifierForJobItem(modified_item); + foreach(JobQueueItem *queue_item, m_jobs) { + if(queue_item->getIdentifier() == identifier) { + QModelIndex item_index = index(m_jobs.indexOf(queue_item), 0); + dataChanged(item_index, item_index); + } } - throw GUIHelpers::Error("JobQueueModel::indexOfItem() -> Can't find index for item"); } -//! Method should be called to inform given model about changes in JobQueueItem -void JobQueueModel::jobQueueItemIsChanged(JobQueueItem *changed_item) +//! returns JobIdentifier for given model index +QString JobQueueModel::getIdentifier(const QModelIndex &index) const { - QModelIndex item_index = indexOfItem(changed_item); - qDebug() << "JobQueueModel::jobQueueItemIsChanged" << item_index; - dataChanged(item_index, item_index); + if(!index.isValid() || index.row() < 0 || index.row() >= rowCount()) + throw GUIHelpers::Error("JobQueueModel::getIdentifier() -> Wrong index"); + + return m_jobs.at(index.row())->getIdentifier(); } -//! returns JobQueueItem for given index -JobQueueItem *JobQueueModel::getJobQueueItemForIndex(const QModelIndex &index) +//! returns JobItem for given index (const version) +const JobItem *JobQueueModel::getJobItemForIndex(const QModelIndex &index) const { - if(!index.isValid()) - throw GUIHelpers::Error("JobQueueModel::getJobQueueItemForIndex() -> Can't find item for index"); - if(index.row() >=0 && index.row() < rowCount()) - return m_jobs.at(index.row()); - throw GUIHelpers::Error("JobQueueModel::getJobQueueItemForIndex() -> Can't find item for index p2"); + return m_queue_data->getJobItem(getIdentifier(index)); } -const JobQueueItem *JobQueueModel::getJobQueueItemForIndex(const QModelIndex &index) const + +//! returns JobItem for given index +JobItem *JobQueueModel::getJobItemForIndex(const QModelIndex &index) { - if(!index.isValid()) - throw GUIHelpers::Error("JobQueueModel::getJobQueueItemForIndex() -> Can't find item for index"); - if(index.row() >=0 && index.row() < rowCount()) - return m_jobs.at(index.row()); - throw GUIHelpers::Error("JobQueueModel::getJobQueueItemForIndex() -> Can't find item for index p2"); + return const_cast<JobItem *>(static_cast<const JobQueueModel &>(*this).getJobItemForIndex(index)); } -void JobQueueModel::runInThread(JobQueueItem *job) +//! runs corresponding job in a thread +void JobQueueModel::runJob(const QModelIndex &index) { - qDebug() << "JobQueueItem::run(): preparing to run a thread" << job->getName(); - JobItem *jobItem = new JobItem(); - QThread *thread = new QThread(); - jobItem->moveToThread(thread); - - // thread will start jobItem::run - connect(thread, SIGNAL(started()), jobItem, SLOT(run())); - - // thread will quit after JobItem is done - connect(jobItem, SIGNAL(finished()), thread, SLOT(quit())); - ////connect(jobItem, SIGNAL(finished()), this, SLOT(onJobFinished())); - connect(jobItem, SIGNAL(progressUpdate(int)), job, SLOT(setProgress(int))); - connect(job, SIGNAL(modified(JobQueueItem*)), this, SLOT(jobQueueItemIsChanged(JobQueueItem*))); - - // objects will be deleted after JobItem is done - connect(jobItem, SIGNAL(finished()), jobItem, SLOT(deleteLater())); - connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); - - m_JobQueueItemToThread[job] = thread; - m_ThreadToJobQueueItem[thread] = job; - - qDebug() << "JobQueueItem::run(): starting thread"; - thread->start(); - qDebug() << "JobQueueItem::run(): thread is started"; + m_queue_data->runJob(getIdentifier(index)); } - -void JobQueueModel::onCancelJob(const QModelIndex &index) +//! cancel corresponding job if it is running +void JobQueueModel::cancelJob(const QModelIndex &index) { - qDebug() << "JobQueueModel::onCancelJob" << index; - JobQueueItem *job = getJobQueueItemForIndex(index); - qDebug() << "JobQueueModel::onCancelJob" << job; - QThread *thread = m_JobQueueItemToThread[job]; - qDebug() << "AAA" << thread->isRunning(); - if(thread) { - thread->quit(); - //thread->wait(); - } + m_queue_data->cancelJob(getIdentifier(index)); } diff --git a/GUI/coregui/Models/JobQueueModel.h b/GUI/coregui/Models/JobQueueModel.h index f5cadc7e8afa6e97d8370dec4317fd91e50e7c8b..203c15d885bc75a78f2f932f790440176bb59700 100644 --- a/GUI/coregui/Models/JobQueueModel.h +++ b/GUI/coregui/Models/JobQueueModel.h @@ -1,18 +1,21 @@ #ifndef JOBQUEUEMODEL_H #define JOBQUEUEMODEL_H +#include "JobQueueData.h" #include <QAbstractListModel> #include <QList> #include <QModelIndex> #include <QMap> - +class JobItem; class JobQueueItem; +class Simulation; class QXmlStreamWriter; class QXmlStreamReader; class QItemSelection; class QThread; + namespace JobQueueXML { const QString ModelTag("JobQueueModel"); @@ -36,6 +39,8 @@ namespace JobQueueXML } +//! The model for all jobs in a queue. Contains JobQueueItem in a list. +//! Provides interface to access real JobItem objects. class JobQueueModel : public QAbstractListModel { Q_OBJECT @@ -46,7 +51,6 @@ public: int rowCount(const QModelIndex &parent = QModelIndex()) const; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; Qt::ItemFlags flags(const QModelIndex &index) const; - bool setData(const QModelIndex &index, const QVariant &value, int role); // bool insertRows(int position, int rows, const QModelIndex &parent); @@ -54,16 +58,12 @@ public: Qt::DropActions supportedDragActions() const { return Qt::MoveAction; } Qt::DropActions supportedDropActions() const { return Qt::MoveAction; } - QStringList mimeTypes() const; - QMimeData *mimeData(const QModelIndexList &indexes) const; - bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent); - - void addJob(JobQueueItem *item); + void addJob(Simulation *simulation); void clear(); @@ -76,29 +76,26 @@ public: QString getName() const { return m_name; } void setName(QString name) { m_name = name; } - JobQueueItem *getJobQueueItemForIndex(const QModelIndex &index); - const JobQueueItem *getJobQueueItemForIndex(const QModelIndex &index) const; + QString getIdentifier(const QModelIndex &index) const; + const JobItem *getJobItemForIndex(const QModelIndex &index) const; + JobItem *getJobItemForIndex(const QModelIndex &index); - void runInThread(JobQueueItem *job); + JobQueueData *getJobQueueData() { return m_queue_data; } + +signals: + void selectionChanged(JobItem *item); public slots: - void jobQueueItemIsChanged(JobQueueItem *item); + void onJobItemIsModified(JobItem *); void onSelectionChanged( const QItemSelection&, const QItemSelection& ); - - void onCancelJob(const QModelIndex &index); - -signals: - void selectionChanged(JobQueueItem *item); + void runJob(const QModelIndex &index); + void cancelJob(const QModelIndex &index); private: - QModelIndex indexOfItem(JobQueueItem *item) const; - + JobQueueData *m_queue_data; QString m_name; QList <JobQueueItem *> m_jobs; - - QMap<JobQueueItem *, QThread *> m_JobQueueItemToThread; - QMap<QThread *, JobQueueItem *> m_ThreadToJobQueueItem; }; diff --git a/GUI/coregui/Models/JobRunner.cpp b/GUI/coregui/Models/JobRunner.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1ab00d5a543e4f87205a7aa8027966ce7829301a --- /dev/null +++ b/GUI/coregui/Models/JobRunner.cpp @@ -0,0 +1,53 @@ +#include "JobRunner.h" +#include "Simulation.h" +#include <QTimer> +#include <QDebug> + + +JobRunner::JobRunner(QString identifier) + : m_identifier(identifier) + , m_progress(0) +{ + +} + + +JobRunner::~JobRunner() +{ + qDebug() << "JobRunner::~JobRunner()"; +} + + +void JobRunner::start() +{ + qDebug() << "JobRunner::start() 1.1"; + emit started(); + loopFunctionWithDelay(); +} + + + +void JobRunner::loopFunctionWithDelay() +{ + qDebug() << "JobItem::loopFunctionWithDelay()" << m_progress; + if(m_progress < 100) { + m_progress = m_progress+4; + emit progressUpdate(); + QTimer::singleShot(500, this, SLOT(loopFunctionWithDelay())); + } + + if(m_progress >= 100) { + qDebug() << "JobRunner::loopFunctionWithDelay() 1.1"; + emit progressUpdate(); + qDebug() << "JobRunner::loopFunctionWithDelay() 1.2"; + emit finished(); + qDebug() << "JobRunner::loopFunctionWithDelay() 1.3"; + } +} + + + +void JobRunner::terminate() +{ + m_progress = 1000; +} diff --git a/GUI/coregui/Models/JobRunner.h b/GUI/coregui/Models/JobRunner.h new file mode 100644 index 0000000000000000000000000000000000000000..98155da5009c662de1c02d384c118468648d1226 --- /dev/null +++ b/GUI/coregui/Models/JobRunner.h @@ -0,0 +1,42 @@ +#ifndef JOBRUNNER_H +#define JOBRUNNER_H + +#include <QObject> +#include <QString> + +//! Class for running the simulation in a thread +class JobRunner : public QObject +{ + Q_OBJECT +public: + + JobRunner(QString identifier); + virtual ~JobRunner(); + + QString getIdentifier() const { return m_identifier; } + void setIdentifier(QString identifier) { m_identifier = identifier; } + + int getProgress() const { return m_progress; } + +signals: + void started(); + void finished(); + void progressUpdate(); + +public slots: + void start(); + void terminate(); + +private slots: + void loopFunctionWithDelay(); + +private: + QString m_identifier; + int m_progress; + +}; + + + +#endif // JOBRUNNER_H + diff --git a/GUI/coregui/Views/Components/JobQueueWidgets/JobListViewDelegate.cpp b/GUI/coregui/Views/Components/JobQueueWidgets/JobListViewDelegate.cpp index a576cd065ae1b87c2802d0f3b42167218391465e..b036024439190170073375ee3d35c131e70e7722 100644 --- a/GUI/coregui/Views/Components/JobQueueWidgets/JobListViewDelegate.cpp +++ b/GUI/coregui/Views/Components/JobQueueWidgets/JobListViewDelegate.cpp @@ -1,6 +1,6 @@ #include "JobListViewDelegate.h" #include "JobQueueModel.h" -#include "JobQueueItem.h" +#include "JobItem.h" #include "progressbar.h" #include <QDebug> #include <QPainter> @@ -20,21 +20,13 @@ JobListViewDelegate::JobListViewDelegate(QWidget *parent) void JobListViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const { - - qDebug() << "JobListViewDelegate::paint() " << index; -// QItemDelegate::paint(painter, option, index); - - // Set up a QStyleOptionProgressBar to precisely mimic the - // environment of a progress bar. - - if (option.state & QStyle::State_Selected) painter->fillRect(option.rect, option.palette.highlight()); const JobQueueModel* model = static_cast<const JobQueueModel*>(index.model()); Q_ASSERT(model); - const JobQueueItem *item = model->getJobQueueItemForIndex(index); + const JobItem *item = model->getJobItemForIndex(index); Q_ASSERT(item); painter->save(); @@ -46,8 +38,6 @@ void JobListViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o textRect.setHeight( 30); painter->drawText(textRect,text); - QRect barRect(option.rect); - QStyleOptionProgressBar progressBarOption; progressBarOption.state = QStyle::State_Enabled; progressBarOption.direction = QApplication::layoutDirection(); @@ -61,16 +51,17 @@ void JobListViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o // Set the progress and text values of the style option. int progress = item->getProgress(); progressBarOption.progress = progress < 0 ? 0 : progress; -// progressBarOption.text = QString().sprintf("%d%%", progressBarOption.progress); QApplication::style()->drawControl(QStyle::CE_ProgressBar, &progressBarOption, painter); - QStyleOptionButton button; - button.rect = getButtonRect(option.rect); - button.state = m_buttonState | QStyle::State_Enabled; - button.icon = QIcon(":/images/darkclosebutton.png"); - button.iconSize = QSize(12,12); + if(item->isRunning()) { + QStyleOptionButton button; + button.rect = getButtonRect(option.rect); + button.state = m_buttonState | QStyle::State_Enabled; + button.icon = QIcon(":/images/darkclosebutton.png"); + button.iconSize = QSize(12,12); - QApplication::style()->drawControl (QStyle::CE_PushButton, &button, painter); + QApplication::style()->drawControl (QStyle::CE_PushButton, &button, painter); + } painter->restore(); } @@ -84,11 +75,20 @@ bool JobListViewDelegate::editorEvent(QEvent *event, if( event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonRelease ) { } else { - m_buttonState = QStyle::State_Raised; - return QItemDelegate::editorEvent(event, model, option, index); + m_buttonState = QStyle::State_Raised; + return QItemDelegate::editorEvent(event, model, option, index); return true; } + + const JobQueueModel* jqmodel = static_cast<const JobQueueModel*>(index.model()); + Q_ASSERT(model); + + const JobItem *item = jqmodel->getJobItemForIndex(index); + Q_ASSERT(item); + + if(!item->isRunning()) return false; + QRect buttonRect = getButtonRect(option.rect); QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event); diff --git a/GUI/coregui/Views/Components/JobQueueWidgets/JobListWidget.cpp b/GUI/coregui/Views/Components/JobQueueWidgets/JobListWidget.cpp index 41caa0d676e5461d7f1543146b4d63f3a096bd11..da53846efca1da10007ad29d73a0d153862f6de4 100644 --- a/GUI/coregui/Views/Components/JobQueueWidgets/JobListWidget.cpp +++ b/GUI/coregui/Views/Components/JobQueueWidgets/JobListWidget.cpp @@ -1,13 +1,13 @@ #include "JobListWidget.h" #include "JobQueueModel.h" -#include "JobQueueItem.h" +#include "JobItem.h" #include "JobListViewDelegate.h" -#include "progressbar.h" #include "styledbar.h" #include <QPushButton> #include <QListView> #include <QVBoxLayout> #include <QDebug> +#include <QAction> JobListWidget::JobListWidget(QWidget *parent) @@ -26,6 +26,7 @@ JobListWidget::JobListWidget(QWidget *parent) m_listView->setAcceptDrops(true); m_listView->setDefaultDropAction(Qt::MoveAction); m_listView->setItemDelegate(m_listViewDelegate); + m_listView->setContextMenuPolicy(Qt::ActionsContextMenu); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->setMargin(0); @@ -47,13 +48,6 @@ JobListWidget::JobListWidget(QWidget *parent) vlayout->addLayout(buttonsLayout); vlayout->addWidget(m_listView); - Manhattan::ProgressBar *progressBar = new Manhattan::ProgressBar(this); - progressBar->setRange(0,100); - progressBar->setValue(50); - vlayout->addWidget(progressBar); - - - //mainLayout->addWidget(m_listView); mainLayout->addLayout(vlayout); setLayout(mainLayout); @@ -62,36 +56,25 @@ JobListWidget::JobListWidget(QWidget *parent) connect(m_submitButton, SIGNAL(clicked()), this, SLOT(submit())); connect(m_runButton, SIGNAL(clicked()), this, SLOT(run())); - //connecting delegate's signal to this class's slot -// connect(m_listViewDelegate, SIGNAL(cancelButtonClicked(QModelIndex)), -// this, SLOT(onCancelJob(QModelIndex))); - - - + setupContextMenu(); } -void JobListWidget::onCancelJob(const QModelIndex &index) -{ - emit cancelJob(index); -} - - - void JobListWidget::setModel(JobQueueModel *model) { Q_ASSERT(model); if(model != m_jobQueueModel) { m_jobQueueModel = model; m_listView->setModel(model); + connect(m_listView->selectionModel(), SIGNAL( selectionChanged(const QItemSelection&, const QItemSelection&) ), m_jobQueueModel, SLOT( onSelectionChanged(const QItemSelection&, const QItemSelection&) ) ); - connect(m_listViewDelegate, SIGNAL(cancelButtonClicked(QModelIndex)), - m_jobQueueModel, SLOT(onCancelJob(QModelIndex))); + connect(m_listViewDelegate, SIGNAL(cancelButtonClicked(QModelIndex)), + m_jobQueueModel, SLOT(cancelJob(QModelIndex))); } } @@ -108,26 +91,36 @@ void JobListWidget::save() void JobListWidget::submit() { - Q_ASSERT(m_jobQueueModel); - qDebug() << "JobListWidget::submit() -> "; - static int i=4; - m_jobQueueModel->addJob(new JobQueueItem(QString("job")+QString::number(i++))); - + m_jobQueueModel->addJob(0); } void JobListWidget::run() { - Q_ASSERT(m_jobQueueModel); - qDebug() << "JobListWidget::run()"; - QModelIndexList indexList = m_listView->selectionModel()->selectedIndexes(); - qDebug() <<indexList; - if(!indexList.empty()) { - JobQueueItem *job = m_jobQueueModel->getJobQueueItemForIndex(indexList.front()); - qDebug() << "JobListWidget::run()" << job->getName(); -// job->run(); - m_jobQueueModel->runInThread(job); + m_jobQueueModel->runJob(indexList.front()); } } + + +//! setup context menu for listView +void JobListWidget::setupContextMenu() +{ + QAction *removeJobAction = new QAction(tr("Remove Job"), this); + connect(removeJobAction, SIGNAL(triggered()), this, SLOT(removeJob())); + m_listView->addAction(removeJobAction); + +} + + +//! remove job from the list +void JobListWidget::removeJob() +{ + qDebug() << "JobListWidget::removeJob() "; + QModelIndex index = m_listView->selectionModel()->currentIndex(); + m_jobQueueModel->removeRows(index.row(), 1, QModelIndex()); +} + + + diff --git a/GUI/coregui/Views/Components/JobQueueWidgets/JobListWidget.h b/GUI/coregui/Views/Components/JobQueueWidgets/JobListWidget.h index 42294b177d6b2d92103b8befca0e2da681d3bcb9..7f7eadd86e0b666d59cbb6ab0eef0d6ef644122e 100644 --- a/GUI/coregui/Views/Components/JobQueueWidgets/JobListWidget.h +++ b/GUI/coregui/Views/Components/JobQueueWidgets/JobListWidget.h @@ -22,25 +22,22 @@ public: void setModel(JobQueueModel *model); // QSize sizeHint() const { return QSize(128, 128); } -signals: - void cancelJob(const QModelIndex &); - -public slots: - void onCancelJob(const QModelIndex &); private slots: void save(); void submit(); void run(); + void removeJob(); private: + void setupContextMenu(); + JobQueueModel *m_jobQueueModel; JobListViewDelegate *m_listViewDelegate; QListView *m_listView; QPushButton *m_submitButton; QPushButton *m_runButton; QPushButton *m_saveButton; - }; diff --git a/GUI/coregui/Views/Components/JobQueueWidgets/JobPropertiesWidget.cpp b/GUI/coregui/Views/Components/JobQueueWidgets/JobPropertiesWidget.cpp index c36217469ada7939c1746d05940e818bd21db7d1..8332ab661cbb02be5cd22a48d5fc5d9cb4534e60 100644 --- a/GUI/coregui/Views/Components/JobQueueWidgets/JobPropertiesWidget.cpp +++ b/GUI/coregui/Views/Components/JobQueueWidgets/JobPropertiesWidget.cpp @@ -1,6 +1,6 @@ #include "JobPropertiesWidget.h" #include "JobQueueModel.h" -#include "JobQueueItem.h" +#include "JobItem.h" #include "qtvariantproperty.h" #include "qttreepropertybrowser.h" #include <QVBoxLayout> @@ -47,14 +47,18 @@ void JobPropertiesWidget::setModel(JobQueueModel *model) // SLOT( itemClicked(JobQueueItem *) ) // ); connect(m_jobQueueModel, - SIGNAL( selectionChanged(JobQueueItem *) ), + SIGNAL( selectionChanged(JobItem *) ), this, - SLOT( itemClicked(JobQueueItem *) ) + SLOT( itemClicked(JobItem *) ) ); + + connect(m_jobQueueModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)) + , this, SLOT(dataChanged(QModelIndex, QModelIndex))); } } + void JobPropertiesWidget::updateExpandState() { QList<QtBrowserItem *> list = m_propertyBrowser->topLevelItems(); @@ -67,7 +71,7 @@ void JobPropertiesWidget::updateExpandState() } -void JobPropertiesWidget::itemClicked(JobQueueItem *jobItem) +void JobPropertiesWidget::itemClicked(JobItem *jobItem) { qDebug() << "JobPropertiesWidget::itemClicked" << jobItem->getName(); @@ -96,15 +100,18 @@ void JobPropertiesWidget::itemClicked(JobQueueItem *jobItem) addProperty(property, JobQueueXML::JobNameAttribute); property = m_variantManager->addProperty(QVariant::String, tr("Status")); - property->setValue(jobItem->getStatus()); + property->setValue(jobItem->getStatusString()); + property->setAttribute(QLatin1String("readOnly"), true); addProperty(property, JobQueueXML::JobStatusAttribute); property = m_variantManager->addProperty(QVariant::String, tr("Begin Time")); property->setValue(jobItem->getBeginTime()); + property->setAttribute(QLatin1String("readOnly"), true); addProperty(property, JobQueueXML::JobBeginTimeAttribute); property = m_variantManager->addProperty(QVariant::String, tr("End Time")); property->setValue(jobItem->getEndTime()); + property->setAttribute(QLatin1String("readOnly"), true); addProperty(property, JobQueueXML::JobEndTimeAttribute); } @@ -122,8 +129,6 @@ void JobPropertiesWidget::addProperty(QtVariantProperty *property, const QString void JobPropertiesWidget::valueChanged(QtProperty *property, const QVariant &value) { - qDebug() << "JobPropertiesWidget::valueChanged()"; - if (!propertyToId.contains(property)) return; @@ -134,8 +139,18 @@ void JobPropertiesWidget::valueChanged(QtProperty *property, const QVariant &val if (id == JobQueueXML::JobNameAttribute) { m_currentItem->setName(value.value<QString>()); } +} - m_jobQueueModel->jobQueueItemIsChanged(m_currentItem); +//! to update properties of currently selected item if they were changed from outside +void JobPropertiesWidget::dataChanged(const QModelIndex &index, const QModelIndex &) +{ + qDebug() << "JobPropertiesWidget::dataChanged()"; + JobItem *jobItem = m_jobQueueModel->getJobItemForIndex(index); + if(jobItem == m_currentItem) { + idToProperty[JobQueueXML::JobNameAttribute]->setValue(jobItem->getName()); + idToProperty[JobQueueXML::JobStatusAttribute]->setValue(jobItem->getStatusString()); + idToProperty[JobQueueXML::JobBeginTimeAttribute]->setValue(jobItem->getBeginTime()); + idToProperty[JobQueueXML::JobEndTimeAttribute]->setValue(jobItem->getEndTime()); + } } - diff --git a/GUI/coregui/Views/Components/JobQueueWidgets/JobPropertiesWidget.h b/GUI/coregui/Views/Components/JobQueueWidgets/JobPropertiesWidget.h index 1dc5f069de8e98257e11121fe7600515cf1c0b3f..923dee90a828ec8e59f43f55819bb153ecf48074 100644 --- a/GUI/coregui/Views/Components/JobQueueWidgets/JobPropertiesWidget.h +++ b/GUI/coregui/Views/Components/JobQueueWidgets/JobPropertiesWidget.h @@ -7,11 +7,10 @@ class QtProperty; class QtVariantProperty; class JobQueueModel; -class JobQueueItem; +class JobItem; -//! Widget to show and change properties of currently selected JobQueueItem +//! Widget to show and change properties of currently selected JobItem //! Left buttom corner of JobQueueView - class JobPropertiesWidget : public QWidget { Q_OBJECT @@ -24,7 +23,8 @@ public: QSize minimumSizeHint() const { return QSize(64, 64); } public slots: - void itemClicked(JobQueueItem *item); + void itemClicked(JobItem *item); + void dataChanged(const QModelIndex &, const QModelIndex &); private slots: void valueChanged(QtProperty *property, const QVariant &value); @@ -40,7 +40,7 @@ private: QMap<QString, QtVariantProperty *> idToProperty; QMap<QString, bool> idToExpanded; - JobQueueItem *m_currentItem; + JobItem *m_currentItem; }; diff --git a/GUI/coregui/Views/Components/JobQueueWidgets/JobSelectorWidget.cpp b/GUI/coregui/Views/Components/JobQueueWidgets/JobSelectorWidget.cpp index 9c06bb364397f93c9464034871472d53a651e676..d4f288ad135136c08be00e837d7332c0f9be178a 100644 --- a/GUI/coregui/Views/Components/JobQueueWidgets/JobSelectorWidget.cpp +++ b/GUI/coregui/Views/Components/JobQueueWidgets/JobSelectorWidget.cpp @@ -1,6 +1,6 @@ #include "JobSelectorWidget.h" #include "JobQueueModel.h" -#include "JobQueueItem.h" +#include "JobItem.h" #include "JobPropertiesWidget.h" #include "JobListWidget.h" #include "styledbar.h" diff --git a/GUI/coregui/Views/Components/JobQueueWidgets/JobSelectorWidget.h b/GUI/coregui/Views/Components/JobQueueWidgets/JobSelectorWidget.h index 4ba928fe87c325695180b375c8b0ec52f1a74fa0..4bd8ea2bb7f5d11181b49cab223fdae0f6313f03 100644 --- a/GUI/coregui/Views/Components/JobQueueWidgets/JobSelectorWidget.h +++ b/GUI/coregui/Views/Components/JobQueueWidgets/JobSelectorWidget.h @@ -20,7 +20,7 @@ public: void setModel(JobQueueModel *model); - QSize sizeHint() const { return QSize(128, 600); } + QSize sizeHint() const { return QSize(158, 600); } QSize minimumSizeHint() const { return QSize(64, 300); } private: diff --git a/GUI/coregui/Views/Components/SampleDesigner/PropertyVariantFactory.h b/GUI/coregui/Views/Components/SampleDesigner/PropertyVariantFactory.h index 034719006828659c6617baf8fe651adf772efff7..a3b2616cbf047c4378fbc6c886c92d8382456c7a 100644 --- a/GUI/coregui/Views/Components/SampleDesigner/PropertyVariantFactory.h +++ b/GUI/coregui/Views/Components/SampleDesigner/PropertyVariantFactory.h @@ -20,6 +20,7 @@ public: virtual ~PropertyVariantFactory(); protected: virtual void connectPropertyManager(QtVariantPropertyManager *manager); + using QtVariantEditorFactory::createEditor; virtual QWidget *createEditor(QtVariantPropertyManager *manager, QtProperty *property, QWidget *parent); virtual void disconnectPropertyManager(QtVariantPropertyManager *manager); diff --git a/GUI/coregui/Views/Components/widgetbox/widgetbox_dnditem.cpp b/GUI/coregui/Views/Components/widgetbox/widgetbox_dnditem.cpp index 5048f86314d3d7a45b9de93c1f10c91c2258d181..17a9f0fb1e00f4bb5e706c37eaa60b2a24d5b1a2 100644 --- a/GUI/coregui/Views/Components/widgetbox/widgetbox_dnditem.cpp +++ b/GUI/coregui/Views/Components/widgetbox/widgetbox_dnditem.cpp @@ -94,6 +94,8 @@ public: protected: + using QDesignerFormBuilder::createWidget; + using QDesignerFormBuilder::create; virtual QWidget *create(DomWidget *ui_widget, QWidget *parents); virtual QWidget *createWidget(const QString &widgetName, QWidget *parentWidget, const QString &name); virtual void createCustomWidgets(DomCustomWidgets *); diff --git a/GUI/coregui/Views/JobQueueView.cpp b/GUI/coregui/Views/JobQueueView.cpp index d33417a1f1f8d8fb48efc22cd39ecad29b86af5a..c7aa0fcc628b42039de549cf2da7ba1460010bb2 100644 --- a/GUI/coregui/Views/JobQueueView.cpp +++ b/GUI/coregui/Views/JobQueueView.cpp @@ -1,27 +1,15 @@ #include "JobQueueView.h" #include "JobQueueModel.h" -#include "JobQueueItem.h" +#include "JobItem.h" #include "JobSelectorWidget.h" #include "JobOutputDataWidget.h" - #include "minisplitter.h" - -#include <QGridLayout> -#include <QHBoxLayout> +#include "progressbar.h" #include <QVBoxLayout> -#include <QListView> -#include <QTreeView> -#include <QTableView> -#include <QPushButton> #include <QDebug> -#include <QDockWidget> #include <QSplitter> - -class QStandardItemModel; - - JobQueueView::JobQueueView(QWidget *parent) : QWidget(parent) , m_jobQueueModel(new JobQueueModel()) @@ -31,9 +19,9 @@ JobQueueView::JobQueueView(QWidget *parent) { setObjectName("JobQueueView"); - m_jobQueueModel->addJob(new JobQueueItem("job1")); - m_jobQueueModel->addJob(new JobQueueItem("job2")); - m_jobQueueModel->addJob(new JobQueueItem("job3")); + m_jobQueueModel->addJob(0); + m_jobQueueModel->addJob(0); + m_jobQueueModel->addJob(0); m_splitter->addWidget(m_jobSelector); m_splitter->addWidget(m_jobOutputData); @@ -44,13 +32,31 @@ JobQueueView::JobQueueView(QWidget *parent) mainLayout->addWidget(m_splitter); setLayout(mainLayout); + connect(m_jobQueueModel->getJobQueueData(), SIGNAL(globalProgress(int)), this, SLOT(updateGlobalProgressBar(int))); +} -// connect( -// m_jobQueueModel->selectionModel(), - -// ); +void JobQueueView::setProgressBar(Manhattan::ProgressBar *progressBar) +{ + if(m_progressBar != progressBar) { + m_progressBar = progressBar; + m_progressBar->hide(); + connect(m_progressBar, SIGNAL(clicked()), m_jobQueueModel->getJobQueueData(), SLOT(onCancelAllJobs())); + } } +void JobQueueView::updateGlobalProgressBar(int progress) +{ + if(progress<0 || progress >= 100) { + //m_progressBar->hide(); + m_progressBar->setFinished(true); + m_progressBar->hide(); + } else { + m_progressBar->show(); + m_progressBar->setFinished(false); + m_progressBar->setValue(progress); + } +} + diff --git a/GUI/coregui/Views/JobQueueView.h b/GUI/coregui/Views/JobQueueView.h index ea6304c29fc3cbefdcd2560208a2ca8e12582eeb..4abbfbb1400c7ac760439aba21ad5d0e48dce207 100644 --- a/GUI/coregui/Views/JobQueueView.h +++ b/GUI/coregui/Views/JobQueueView.h @@ -14,6 +14,11 @@ class JobQueueModel; class QDockWidget; class QSplitter; +namespace Manhattan { + class ProgressBar; +} + + class JobQueueView : public QWidget { Q_OBJECT @@ -30,33 +35,17 @@ public: JobQueueView(QWidget *parent = 0); virtual ~JobQueueView() {} -public slots: + void setProgressBar(Manhattan::ProgressBar *progressBar); -//private slots: -// void save(); +public slots: + void updateGlobalProgressBar(int); private: -// void initSubWindows(); -// QDockWidget *addDockForWidget(QWidget *widget); - JobQueueModel *m_jobQueueModel; -// QPushButton *m_button1; -// QPushButton *m_button2; -// QPushButton *m_saveButton; -// QListView *m_listView; - - -// QVector<QWidget *> m_subWindows; -// QVector<QDockWidget *> m_dockWidgets; - -// QWidget *m_subWindows[NumberOfSubWindows]; -// QDockWidget *m_dockWidgets[NumberOfSubWindows]; - QSplitter *m_splitter; JobSelectorWidget *m_jobSelector; JobOutputDataWidget *m_jobOutputData; - - + Manhattan::ProgressBar *m_progressBar; //!< general progress bar }; #endif // JOBQUEUEVIEW_H diff --git a/GUI/coregui/mainwindow/mainwindow.cpp b/GUI/coregui/mainwindow/mainwindow.cpp index 303d79b7378245133cc7168114c94d62d776df6f..93038bebefcb37cd997a0cba43b17624b30e502e 100644 --- a/GUI/coregui/mainwindow/mainwindow.cpp +++ b/GUI/coregui/mainwindow/mainwindow.cpp @@ -20,6 +20,7 @@ #include "mainwindow_constants.h" #include "hostosinfo.h" #include "projectmanager.h" +#include "progressbar.h" #include <QApplication> #include <iostream> @@ -36,6 +37,7 @@ MainWindow::MainWindow(QWidget *parent) , m_jobView(0) , m_fitView(0) , m_jobQueueView(0) + , m_progressBar(0) , m_actionManager(0) , m_projectManager(0) , m_settings(new QSettings(Constants::APPLICATION_NAME, Constants::APPLICATION_NAME, this)) @@ -78,6 +80,12 @@ MainWindow::MainWindow(QWidget *parent) m_tabWidget->insertTab(7, m_jobQueueView, QIcon(":/images/mode_fit.png"), "Queue"); m_tabWidget->setCurrentIndex(7); + + m_progressBar = new Manhattan::ProgressBar(this); + m_tabWidget->addBottomCornerWidget(m_progressBar); + m_progressBar->hide(); + m_jobQueueView->setProgressBar(m_progressBar); + setCentralWidget(m_tabWidget); m_actionManager = new ActionManager(this); diff --git a/GUI/coregui/mainwindow/mainwindow.h b/GUI/coregui/mainwindow/mainwindow.h index 9fa58a702e2f28f9e0f72e62736f7ae4fae21d68..fee6cae290d16716ec0e4b28e5b9cbce6a451107 100644 --- a/GUI/coregui/mainwindow/mainwindow.h +++ b/GUI/coregui/mainwindow/mainwindow.h @@ -5,8 +5,10 @@ #include "fancymainwindow.h" #include "mainwindow_constants.h" + namespace Manhattan { class FancyTabWidget; + class ProgressBar; } class TaskSelectorWidget; @@ -38,6 +40,9 @@ public: SimulationDataModel *getSimulationDataModel() { return mp_sim_data_model; } + Manhattan::ProgressBar *getProgressBar() { return m_progressBar; } + + public slots: void onChangeTabWidget(int index); void newProject(); @@ -62,6 +67,7 @@ private: JobView *m_jobView; FitView * m_fitView; JobQueueView * m_jobQueueView; + Manhattan::ProgressBar *m_progressBar; ActionManager *m_actionManager; //!< responsible for menus and actions ProjectManager *m_projectManager; //!< handles activity related to opening/saving projects diff --git a/GUI/externals/qtpropertybrowser/qteditorfactory.h b/GUI/externals/qtpropertybrowser/qteditorfactory.h index cbb2077d22990085b5390c0e7c2480be82cc3f5e..7a406093cee943094f28a1c503401a39ff9e4f3e 100644 --- a/GUI/externals/qtpropertybrowser/qteditorfactory.h +++ b/GUI/externals/qtpropertybrowser/qteditorfactory.h @@ -58,6 +58,7 @@ public: ~QtSpinBoxFactory(); protected: void connectPropertyManager(QtIntPropertyManager *manager); + using QtAbstractEditorFactory<QtIntPropertyManager>::createEditor; QWidget *createEditor(QtIntPropertyManager *manager, QtProperty *property, QWidget *parent); void disconnectPropertyManager(QtIntPropertyManager *manager); @@ -83,6 +84,7 @@ public: ~QtSliderFactory(); protected: void connectPropertyManager(QtIntPropertyManager *manager); + using QtAbstractEditorFactory<QtIntPropertyManager>::createEditor; QWidget *createEditor(QtIntPropertyManager *manager, QtProperty *property, QWidget *parent); void disconnectPropertyManager(QtIntPropertyManager *manager); @@ -107,6 +109,7 @@ public: ~QtScrollBarFactory(); protected: void connectPropertyManager(QtIntPropertyManager *manager); + using QtAbstractEditorFactory<QtIntPropertyManager>::createEditor; QWidget *createEditor(QtIntPropertyManager *manager, QtProperty *property, QWidget *parent); void disconnectPropertyManager(QtIntPropertyManager *manager); @@ -131,6 +134,7 @@ public: ~QtCheckBoxFactory(); protected: void connectPropertyManager(QtBoolPropertyManager *manager); + using QtAbstractEditorFactory<QtBoolPropertyManager>::createEditor; QWidget *createEditor(QtBoolPropertyManager *manager, QtProperty *property, QWidget *parent); void disconnectPropertyManager(QtBoolPropertyManager *manager); @@ -154,6 +158,7 @@ public: ~QtDoubleSpinBoxFactory(); protected: void connectPropertyManager(QtDoublePropertyManager *manager); + using QtAbstractEditorFactory<QtDoublePropertyManager>::createEditor; QWidget *createEditor(QtDoublePropertyManager *manager, QtProperty *property, QWidget *parent); void disconnectPropertyManager(QtDoublePropertyManager *manager); @@ -180,6 +185,7 @@ public: ~QtLineEditFactory(); protected: void connectPropertyManager(QtStringPropertyManager *manager); + using QtAbstractEditorFactory<QtStringPropertyManager>::createEditor; QWidget *createEditor(QtStringPropertyManager *manager, QtProperty *property, QWidget *parent); void disconnectPropertyManager(QtStringPropertyManager *manager); @@ -205,6 +211,7 @@ public: ~QtDateEditFactory(); protected: void connectPropertyManager(QtDatePropertyManager *manager); + using QtAbstractEditorFactory<QtDatePropertyManager>::createEditor; QWidget *createEditor(QtDatePropertyManager *manager, QtProperty *property, QWidget *parent); void disconnectPropertyManager(QtDatePropertyManager *manager); @@ -229,6 +236,7 @@ public: ~QtTimeEditFactory(); protected: void connectPropertyManager(QtTimePropertyManager *manager); + using QtAbstractEditorFactory<QtTimePropertyManager>::createEditor; QWidget *createEditor(QtTimePropertyManager *manager, QtProperty *property, QWidget *parent); void disconnectPropertyManager(QtTimePropertyManager *manager); @@ -251,6 +259,7 @@ public: ~QtDateTimeEditFactory(); protected: void connectPropertyManager(QtDateTimePropertyManager *manager); + using QtAbstractEditorFactory<QtDateTimePropertyManager>::createEditor; QWidget *createEditor(QtDateTimePropertyManager *manager, QtProperty *property, QWidget *parent); void disconnectPropertyManager(QtDateTimePropertyManager *manager); @@ -273,6 +282,7 @@ public: ~QtKeySequenceEditorFactory(); protected: void connectPropertyManager(QtKeySequencePropertyManager *manager); + using QtAbstractEditorFactory<QtKeySequencePropertyManager>::createEditor; QWidget *createEditor(QtKeySequencePropertyManager *manager, QtProperty *property, QWidget *parent); void disconnectPropertyManager(QtKeySequencePropertyManager *manager); @@ -295,6 +305,7 @@ public: ~QtCharEditorFactory(); protected: void connectPropertyManager(QtCharPropertyManager *manager); + using QtAbstractEditorFactory<QtCharPropertyManager>::createEditor; QWidget *createEditor(QtCharPropertyManager *manager, QtProperty *property, QWidget *parent); void disconnectPropertyManager(QtCharPropertyManager *manager); @@ -317,6 +328,7 @@ public: ~QtEnumEditorFactory(); protected: void connectPropertyManager(QtEnumPropertyManager *manager); + using QtAbstractEditorFactory<QtEnumPropertyManager>::createEditor; QWidget *createEditor(QtEnumPropertyManager *manager, QtProperty *property, QWidget *parent); void disconnectPropertyManager(QtEnumPropertyManager *manager); @@ -343,6 +355,7 @@ public: ~QtCursorEditorFactory(); protected: void connectPropertyManager(QtCursorPropertyManager *manager); + using QtAbstractEditorFactory<QtCursorPropertyManager>::createEditor; QWidget *createEditor(QtCursorPropertyManager *manager, QtProperty *property, QWidget *parent); void disconnectPropertyManager(QtCursorPropertyManager *manager); @@ -365,6 +378,7 @@ public: ~QtColorEditorFactory(); protected: void connectPropertyManager(QtColorPropertyManager *manager); + using QtAbstractEditorFactory<QtColorPropertyManager>::createEditor; QWidget *createEditor(QtColorPropertyManager *manager, QtProperty *property, QWidget *parent); void disconnectPropertyManager(QtColorPropertyManager *manager); @@ -387,6 +401,7 @@ public: ~QtFontEditorFactory(); protected: void connectPropertyManager(QtFontPropertyManager *manager); + using QtAbstractEditorFactory<QtFontPropertyManager>::createEditor; QWidget *createEditor(QtFontPropertyManager *manager, QtProperty *property, QWidget *parent); void disconnectPropertyManager(QtFontPropertyManager *manager); diff --git a/GUI/externals/qtpropertybrowser/qtpropertybrowser.h b/GUI/externals/qtpropertybrowser/qtpropertybrowser.h index 6b734f0c7d49ea021a3cd863c55c966decc8f41e..802d99763f7a6ef3f4f47e20c938664bea575ecf 100644 --- a/GUI/externals/qtpropertybrowser/qtpropertybrowser.h +++ b/GUI/externals/qtpropertybrowser/qtpropertybrowser.h @@ -168,6 +168,7 @@ class QtAbstractEditorFactory : public QtAbstractEditorFactoryBase { public: explicit QtAbstractEditorFactory(QObject *parent) : QtAbstractEditorFactoryBase(parent) {} + using QtAbstractEditorFactoryBase::createEditor; QWidget *createEditor(QtProperty *property, QWidget *parent) { QSetIterator<PropertyManager *> it(m_managers); diff --git a/GUI/externals/qtpropertybrowser/qtvariantproperty.h b/GUI/externals/qtpropertybrowser/qtvariantproperty.h index 2c09fe9eba6770d69b2614b93bfc5d63047644d0..d2cfad60b8e223e9c3aee3ba30eb05bb82a27770 100644 --- a/GUI/externals/qtpropertybrowser/qtvariantproperty.h +++ b/GUI/externals/qtpropertybrowser/qtvariantproperty.h @@ -169,6 +169,7 @@ public: QtVariantEditorFactory(QObject *parent = 0); ~QtVariantEditorFactory(); protected: + using QtAbstractEditorFactory<QtVariantPropertyManager>::createEditor; void connectPropertyManager(QtVariantPropertyManager *manager); QWidget *createEditor(QtVariantPropertyManager *manager, QtProperty *property, QWidget *parent);