diff --git a/src/worker.cpp b/src/worker.cpp index cc8e001..ec9fe7c 100644 --- a/src/worker.cpp +++ b/src/worker.cpp @@ -5,7 +5,7 @@ Worker::Worker(QObject *parent) : QObject(parent), protocolADC_(NULL), protocolGPS_(NULL) { // Set all params to initial values - finish(); + setInitial(); } void Worker::reset(ProtocolCreator *protADC, ProtocolCreator *protGPS) { @@ -120,6 +120,13 @@ void Worker::onCheckedGPS(bool success) { } } +void Worker::setInitial() +{ + autostart = false; + prepared = false; + started = false; +} + void Worker::setPrepared(PrepareResult res) { prepared = (res == PrepareSuccess); emit prepareFinished(res); @@ -184,9 +191,7 @@ void Worker::finish() { if (protocolADC_ != protocolGPS_) { finalizeProtocol(protocolGPS_); } - autostart = false; - prepared = false; - started = false; + setInitial(); emit finished(); } diff --git a/src/worker.h b/src/worker.h index e7ccbad..ebda65b 100644 --- a/src/worker.h +++ b/src/worker.h @@ -167,6 +167,18 @@ private slots: void onCheckedADC(bool); void onCheckedGPS(bool); private: + /*! Initializes all fields */ + void setInitial(); + /*! + * \brief Clever setter for \a prepared + * \param res the result of preparing (\see PrepareResult) + * + * Does three things: + * + * 1. Sets \a prepared to either true or false + * 2. Emits Worker::prepareFinished() passing \a res to it + * 3. If \a autostart enabled, starts worker + */ void setPrepared(PrepareResult res); void assignProtocol(Protocol *& lvalue, ProtocolCreator * rvalue);