diff --git a/src/libcalamares/Job.cpp b/src/libcalamares/Job.cpp index beb5bbad3..8d122d393 100644 --- a/src/libcalamares/Job.cpp +++ b/src/libcalamares/Job.cpp @@ -26,4 +26,7 @@ Job::Job( QObject* parent ) { } +Job::~Job() +{} + } // namespace Calamares diff --git a/src/libcalamares/Job.h b/src/libcalamares/Job.h index adfc6c950..eb08dff3b 100644 --- a/src/libcalamares/Job.h +++ b/src/libcalamares/Job.h @@ -20,6 +20,7 @@ #define CALAMARES_JOB_H #include "DllMacro.h" +#include "Typedefs.h" #include @@ -29,7 +30,21 @@ class DLLEXPORT Job : public QObject { Q_OBJECT public: + enum State + { + Pending = 0, + Running, + Finished + }; + explicit Job( QObject* parent = nullptr ); + virtual ~Job(); + + virtual QString prettyName() = 0; + virtual void exec() = 0; +signals: + void running( const Calamares::job_ptr& ); + void finished( const Calamares::job_ptr& ); }; } // namespace Calamares diff --git a/src/libcalamares/JobQueue.cpp b/src/libcalamares/JobQueue.cpp index 2f4bf0f6e..0b960b4e1 100644 --- a/src/libcalamares/JobQueue.cpp +++ b/src/libcalamares/JobQueue.cpp @@ -20,6 +20,14 @@ namespace Calamares { +JobQueue* JobQueue::s_instance = nullptr; + +JobQueue* +JobQueue::instance() +{ + return s_instance; +} + JobQueue::JobQueue( QObject* parent ) : QObject( parent ) { diff --git a/src/libcalamares/JobQueue.h b/src/libcalamares/JobQueue.h index 716bebb2c..e1145bfbc 100644 --- a/src/libcalamares/JobQueue.h +++ b/src/libcalamares/JobQueue.h @@ -20,6 +20,7 @@ #define CALAMARES_JOBQUEUE_H #include "DllMacro.h" +#include "Typedefs.h" #include @@ -31,6 +32,18 @@ class DLLEXPORT JobQueue : public QObject Q_OBJECT public: explicit JobQueue( QObject* parent = nullptr ); + + static JobQueue* instance(); + + void enqueue( const Calamares::job_ptr& job ); + void enqueue( const QList< Calamares::job_ptr >& jobs ); + +signals: + void jobRunning( const Calamares::job_ptr& ); + void jobFinished( const Calamares::job_ptr& ); + +private: + static JobQueue* s_instance; }; } diff --git a/src/libcalamares/Typedefs.h b/src/libcalamares/Typedefs.h new file mode 100644 index 000000000..03f603e91 --- /dev/null +++ b/src/libcalamares/Typedefs.h @@ -0,0 +1,32 @@ +/* === This file is part of Calamares - === + * + * Copyright 2014, Teo Mrnjavac + * + * Calamares is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calamares is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calamares. If not, see . + */ + +#ifndef TYPEDEFS_H +#define TYPEDEFS_H + +#include + +namespace Calamares +{ +class Job; + +typedef QSharedPointer< Job > job_ptr; + +} //ns + +#endif // TYPEDEFS_H